Laravel 4: What to pass as parameters to the Url class?

前端 未结 3 1682
逝去的感伤
逝去的感伤 2020-12-28 17:28

Can somebody explain the syntax of the Laravel 4 UrlGenerator class? I can\'t find it in the documentation.

I have the following route:



        
3条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-28 18:25

    Well there is a better way of generating URLs when working with resources.

    URL::route('users.index') // Show all users links to UserController@index
    
    URL::route('users.show',$user->id) // Show user with id links to UserController@show($id)
    
    URL::route('users.create') // Show Userform links to UserController@create
    
    URL::route('users.store') // Links to UserController@store
    
    URL::route('users.edit',$user->id) // Show Editform links to UserController@edit($id)
    
    URL::route('users.update',$user->id) // Update the User with id links to UserController@update($id)
    
    URL::route('users.destroy',$user->id) // Deletes a user with the id links to UserController@destroy
    

    Hope that clears things up. Some Documentation on this can be found here http://laravel.com/docs/controllers#resource-controllers

提交回复
热议问题