mirror of
https://github.com/brunofontes/shareit.git
synced 2025-11-15 16:00:54 -03:00
Including authenticaed user on models: Items, Product and User
This commit is contained in:
@@ -17,4 +17,14 @@ class Product extends Model
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the products from logged in user
|
||||
*
|
||||
* @return \App\Product
|
||||
*/
|
||||
public static function fromAuthUser()
|
||||
{
|
||||
return (new static)->where('user_id', \Auth::id());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user