I'm new to Laravel framework and now facing with a problem while trying update logged users info.
Route:
Route::post('/user/{id}', function (Request $request, $id) {
return App\Http\Controllers\UsersController::update($request, $id);
});
public static function update($request, $id)
{
$user = User::find($id);
$user->name = $request->input('name');
...
$user->save();
...
}
Error:
FatalErrorException in UsersController.php line 24: Call to undefined method Illuminate\Support\Facades\Request::input()
Add the following import at the top of your file:
use Illuminate\Http\Request;
otherwise your controller gets injected instance of Request class from global namespace that is an alias of Illuminate\Support\Facades\Request./
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With