1class User extends Model {
2 public function products(): hasMany {
3 return $this->hasMany('App\Product');
4 }
5}
6$user = User::findOrFail($user_id);
7/* user_id is must important is hasMany Relationship */
8$user_products = $user->products()->select('product_name', 'category',
9 'user_id')->get();