What type of relationship is user-couriers? If you have set up one (https://laravel.com/docs/5.6/eloquent-relationships). If one-to-one, you can do: $courier_id = Auth::user()->courier->id;
Mar 1, 2018
1
Level 2
How to query from a related model with foreign key id.
I have 2 tables :
Users and Couriers
> users
id | email | password | username | You know what I mean
> couriers
id | user_id(FK) | status | no_of_parcels
I have to get the currently logged_on user which has an Id of 3 in the User model with that. if I have a user_id of 3 in the couriers table which has the id of 280
Then In My query :
$id = something like_ auth()->user()->couriers_matched_Id of the user_id which is 280
$package = Parcel::with('owner')->where([ ['courier_id','=',$id ], ['delivery_date','=',$today] ])->get();
I have to get the corresponding id depending upon the currently logged on id.
Level 43
1 like
Please or to participate in this conversation.