2018-09-09 03:26:57 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App;
|
|
|
|
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
|
|
|
class Product extends Model
|
|
|
|
{
|
2018-09-16 23:32:32 +00:00
|
|
|
protected $fillable = ['user_id', 'name', 'url'];
|
2018-09-11 23:48:09 +00:00
|
|
|
|
|
|
|
public function items()
|
|
|
|
{
|
|
|
|
return $this->hasMany(Item::class);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function user()
|
|
|
|
{
|
|
|
|
return $this->belongsTo(User::class);
|
|
|
|
}
|
2018-09-19 17:58:10 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the products from logged in user
|
|
|
|
*
|
|
|
|
* @return \App\Product
|
|
|
|
*/
|
|
|
|
public static function fromAuthUser()
|
|
|
|
{
|
|
|
|
return (new static)->where('user_id', \Auth::id());
|
|
|
|
}
|
2018-09-09 03:26:57 +00:00
|
|
|
}
|