Product.php 1.04 KB
Newer Older
Angel MAS committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
<?php

namespace Onestartup\Product\Model;

use Illuminate\Database\Eloquent\Model;

class Product extends Model
{
    protected $table = 'products';
    protected $fillable = [
    	'name',
		'slug',
		'description',
		'specifications',
		'features',
		'active',
Angel MAS committed
17 18
        'publication_date',
		'category_id',
19
        'subcategory_id',
Angel MAS committed
20 21 22 23 24 25 26
        'cover',
        'extra1',
        'extra2',
        'extra3',
        'extra4',
        'extra5',
        'extra6',
Angel MAS committed
27 28 29 30 31 32
        'extra7',
        'extra8',
        'extra9',
        'extra10',
        'extra11',

Angel MAS committed
33

Angel MAS committed
34 35 36 37 38 39 40
    ];

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

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

Angel MAS committed
46 47 48 49 50
    public function user()
    {
        return $this->belongsTo('App\User', 'user_id');
    }

Angel MAS committed
51 52 53 54 55
    public function images()
    {
        return $this->hasMany('Onestartup\Product\Model\ProductImage', 'product_id');
    }
}