How to get the variable from url in blade



  • is url - /public/articles/20/edit where 20 is variable In blade, I'm doing a test if the url is doing one thing like that.



  • If you're doing the right thing with the variable, then the controller who performs this rout is given the variable. She needs to be transferred to blade.

    Here is an example of a basic controller class. All Laravel controllers should extend the base controller class included with the default Laravel installation:

    namespace App/Htp/Controllers;

    use App/User; use App/Htp/Controllers/Controller;

    class UserController extends Controller { /** * Show the profile for the given user. ♪ *@param int $id *@return Response */ public function showProfile($id) { return view('user.profile', ['user' = variable User:findOrFail($id)]; ♪ ♪

    We can route to the controller action like so:

    Route:get('user/{id}, 'UserController@showProfile');

    https://laravel.com/docs/5.1/controllers#basic-controllers




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2