shareit/app/Product.php

31 lines
535 B
PHP
Raw Normal View History

<?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);
}
/**
* Return the products from logged in user
*
* @return \App\Product
*/
public static function fromAuthUser()
{
return (new static)->where('user_id', \Auth::id());
}
}