| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 | 
							- <?php
 
- namespace App\Shop\Products;
 
- use App\Shop\Brands\Brand;
 
- use App\Shop\Categories\Category;
 
- use App\Shop\ProductAttributes\ProductAttribute;
 
- use App\Shop\ProductImages\ProductImage;
 
- use Gloudemans\Shoppingcart\Contracts\Buyable;
 
- use Illuminate\Database\Eloquent\Model;
 
- use Illuminate\Support\Collection;
 
- use Nicolaslopezj\Searchable\SearchableTrait;
 
- class Product extends Model implements Buyable
 
- {
 
-     use SearchableTrait;
 
-     public const MASS_UNIT = [
 
-         'OUNCES' => 'oz',
 
-         'GRAMS' => 'gms',
 
-         'POUNDS' => 'lbs'
 
-     ];
 
-     public const DISTANCE_UNIT = [
 
-         'CENTIMETER' => 'cm',
 
-         'METER' => 'mtr',
 
-         'INCH' => 'in',
 
-         'MILIMETER' => 'mm',
 
-         'FOOT' => 'ft',
 
-         'YARD' => 'yd'
 
-     ];
 
-     /**
 
-      * Searchable rules.
 
-      *
 
-      * @var array
 
-      */
 
-     protected $searchable = [
 
-         'columns' => [
 
-             'products.name' => 10,
 
-             'products.description' => 5
 
-         ]
 
-     ];
 
-     /**
 
-      * The attributes that are mass assignable.
 
-      *
 
-      * @var array
 
-      */
 
-     protected $fillable = [
 
-         'sku',
 
-         'name',
 
-         'description',
 
-         'cover',
 
-         'quantity',
 
-         'price',
 
-         'brand_id',
 
-         'status',
 
-         'weight',
 
-         'mass_unit',
 
-         'status',
 
-         'sale_price',
 
-         'length',
 
-         'width',
 
-         'height',
 
-         'distance_unit',
 
-         'slug',
 
-     ];
 
-     /**
 
-      * The attributes that should be hidden for arrays.
 
-      *
 
-      * @var array
 
-      */
 
-     protected $hidden = [];
 
-     public function categories()
 
-     {
 
-         return $this->belongsToMany(Category::class);
 
-     }
 
-     /**
 
-      * Get the identifier of the Buyable item.
 
-      *
 
-      * @param null $options
 
-      * @return int|string
 
-      */
 
-     public function getBuyableIdentifier($options = null)
 
-     {
 
-         return $this->id;
 
-     }
 
-     /**
 
-      * Get the description or title of the Buyable item.
 
-      *
 
-      * @param null $options
 
-      * @return string
 
-      */
 
-     public function getBuyableDescription($options = null)
 
-     {
 
-         return $this->name;
 
-     }
 
-     /**
 
-      * Get the price of the Buyable item.
 
-      *
 
-      * @param null $options
 
-      * @return float
 
-      */
 
-     public function getBuyablePrice($options = null)
 
-     {
 
-         return $this->price;
 
-     }
 
-     /**
 
-      * @return \Illuminate\Database\Eloquent\Relations\HasMany
 
-      */
 
-     public function images()
 
-     {
 
-         return $this->hasMany(ProductImage::class);
 
-     }
 
-     /**
 
-      * @param string $term
 
-      * @return Collection
 
-      */
 
-     public function searchProduct(string $term) : Collection
 
-     {
 
-         return self::search($term)->get();
 
-     }
 
-     /**
 
-      * @return \Illuminate\Database\Eloquent\Relations\HasMany
 
-      */
 
-     public function attributes()
 
-     {
 
-         return $this->hasMany(ProductAttribute::class);
 
-     }
 
-     /**
 
-      * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
 
-      */
 
-     public function brand()
 
-     {
 
-         return $this->belongsTo(Brand::class);
 
-     }
 
- }
 
 
  |