shareit/app/Product.php

31 lines
534 B
PHP
Raw Permalink 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
2021-05-20 23:37:35 +00:00
*
* @return \App\Product
*/
public static function fromAuthUser()
{
return (new static)->where('user_id', \Auth::id());
}
}