Just get rid of those brackets. id or location are properties that you can return, not some methods.
$userId = Auth::user()->id;
$userLocation = Auth::user()->location;
Althought I'd suggest you to always use helper function if there is one available. In this case you can use **auth()**function like this:
$userId = auth()->user()->id;
$userLocation = auth()->user()->location;
And how do I receive userId in the controller?
# requires login
Route::group(['middleware' => 'auth'], function(){
# create customer
Route::post('/createcustomer', [
'uses' => 'ChannelCustomer@createCustomer',
'as' => 'createCustomer',
'userId' => Auth::user()->id
]);
});
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community