I have some code like this and working:
Route::get('addnew',function(){
$user = Users::where('username','=',session('username'))->first();
$data = $user->toArray();
return view('layout.addnew')->with($data);
});
Route::post('addnew', ['uses'=>'UsersController@addnew']);
With code above: session('username') not null
But, when i use this code like below:
$user = Users::where('username','=',session('username'))->first();
$data = $user->toArray();
Route::get('addnew',function() use($data){
return view('layout.addnew')->with($data);
});
Route::post('addnew', ['uses'=>'UsersController@addnew']);
With code above: session('username') null => so $data is non-object and code not working.
Somebody help me, please!
Thank you very much!
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire