ProductShop.php 1.96 KB
Newer Older
Francisco Salazar committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
<?php

namespace Onestartup\Shop\Model;

use Illuminate\Database\Eloquent\Model;
use Laravel\Scout\Searchable;

class ProductShop extends Model
{
    use Searchable;
    
    protected $table = 'products_shop';
    protected $fillable = [
    	'name',
		'slug',
		'description',
		'specifications',
		'features',
		'active',
        'publication_date',
		'category_id',
        'subcategory_id',
        'category_sat_id',
        'cover',
        'extra1',
        'extra2',
        'extra3',
        'extra4',
        'extra5',
        'extra6',
        'extra7',
        'extra8',
        'extra9',
        'extra10',
    ];

    public function category()
    {
        return $this->belongsTo('Onestartup\Shop\Model\ProductCategoryShop', 'category_id');
    }

42 43 44 45 46
    public function subcategory()
    {
        return $this->belongsTo('Onestartup\Shop\Model\ProductSubCategoryShop', 'subcategory_id');
    }

Francisco Salazar committed
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
    public function user()
    {
        return $this->belongsTo('App\User', 'user_id');
    }

    public function images()
    {
        return $this->hasMany('Onestartup\Shop\Model\ProductImageShop', 'product_id');
    }

    public function infoSale()
    {
        return $this->hasOne('Onestartup\Shop\Model\ProductShopInfo', 'product_id');
    }

    public function items()
    {
        return $this->hasMany('Onestartup\Shop\Model\DetailShop', 'product_id');
    }

    public function categoria_sat()
    {
        return $this->belongsTo('Onestartup\Shop\Model\CategoriaSat', 'category_sat_id');
    }

    public function tags(){
        return $this->belongsToMany('Onestartup\Shop\Model\ProductTag', 'product_product_tags', 'product_id', 'tag_id');
    }

76
    /*public function subcategories_related(){
Francisco Salazar committed
77
        return $this->belongsToMany('Onestartup\Shop\Model\ProductSubCategoryShop', 'related_products', 'product_id', 'subcategory_id');
78
    }*/
Francisco Salazar committed
79 80 81 82 83 84

    public function details_sale()
    {
        return $this->hasMany('Onestartup\Shop\Model\DetailShop', 'product_id');
    }
}