<?php

namespace Packages\Product\Models;

use Illuminate\Database\Eloquent\Model;
use App\User;
use Illuminate\Database\Eloquent\SoftDeletes;

class Product extends Model
{
    use SoftDeletes;

    protected $guarded = [];

    public function user()
    {
        return $this->belongsTo(User::class, 'creator_id', 'id');
    }

    public function category()
    {
        return $this->belongsToMany(Category::class);
    }


    public function getTypeAttribute($value)
    {

        switch ($value) {
            case 0:
                $type= 'ساده';
    break;
            case 1:
                $type= 'متغیر';
    break;
            case 2:
                $type= 'باندل';
    break;

            default:
                $type='';

        }
        return $type;
    }public function getStatusAttribute($value)
    {

        switch ($value) {
            case 0:
                $type= 'ناموجود';
            break;
            case 1:
                $type= 'موجود';
            break;

            default:
                $type='';

        }
        return $type;
    }
}
