Home > other >  Laravel - admin controller can access to current model instance in form method.
Laravel - admin controller can access to current model instance in form method.

Time:05-27



Url XXX/admin/users/1/edit
Want to obtain corresponding instances of user
.
Use the App \ Models \ User;

The class UsersController extends Controller
{
.
Protected function form ()
{
$form=new form (new User);

//only for current model instance from the callback function?
$form - & gt; Saved (the function {$Form (Form)
$user=$form - & gt; The model ();
});

//isn't in the callback function returns the instance is empty
$user=$form - & gt; The model ();
}
.
}



Laravel - admin
Laravel


CodePudding user response:


Brother found the method?

CodePudding user response:


You can be in protected function form ($id) plus $id!

CodePudding user response:

How do you say, brother
  • Related