mirror of
https://github.com/brunofontes/shareit.git
synced 2024-11-24 12:17:10 +00:00
31 lines
535 B
PHP
31 lines
535 B
PHP
<?php
|
|
|
|
namespace App;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class Product extends Model
|
|
{
|
|
protected $fillable = ['user_id', 'name', 'url'];
|
|
|
|
public function items()
|
|
{
|
|
return $this->hasMany(Item::class);
|
|
}
|
|
|
|
public function user()
|
|
{
|
|
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());
|
|
}
|
|
}
|