mirror of
				https://github.com/brunofontes/shareit.git
				synced 2025-11-04 03:31:02 -03: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());
 | 
						|
    }
 | 
						|
}
 |