Including authenticaed user on models: Items, Product and User

This commit is contained in:
2018-09-19 14:58:10 -03:00
parent 839d2d5773
commit 092281a228
8 changed files with 44 additions and 13 deletions

View File

@@ -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());
}
}