JFIF  x x C         C     "        } !1AQa "q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz        w !1AQ aq"2B #3Rbr{ gilour

File "Product.php"

Full Path: /home/u703019046/domains/nawabs.com.au/public_html/app/Models/Product.php
File size: 1.99 KB
MIME-type: text/x-php
Charset: utf-8

<?php

namespace App\Models;

use Session;
use App\Models\Category;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;

class Product extends Model
{
    use HasFactory;

    protected $fillable = [
        'status'
    ];

    public function cat_name()
    {
        return $this->hasMany(category::class,'category_id','id');
    }

    public function translate_product()
    {
        return $this->belongsTo(TranslateProduct::class,'id','product_id')->where('lang_code','en');
    }

    public function product_translate_lang()
    {
        if(Session::get('front_lang')){
            $lang_code = Session::get('front_lang');
        }
        else{
            $lang_key = \App\Models\Setting::where('id', 1)->value('lang_key');
            $lang_code = $lang_key ?? 'en';
        }
        return $this->belongsTo(TranslateProduct::class,'id','product_id')->where('lang_code',$lang_code);
    }

    protected $appends = ['name','long_description','vedio_top_ber_description','vedio_buttom_description','size','specifaction'];
    protected $hidden = ['product_translate_lang'];


    public function getNameAttribute()
    {
       return $this->product_translate_lang->name;
    }
    public function getLongDescriptionAttribute()
    {
       return $this->product_translate_lang->long_description;
    }
    public function getVedioTopBerDescriptionAttribute()
    {
       return $this->product_translate_lang->vedio_top_ber_description;
    }
    public function getVedioButtomDescriptionAttribute()
    {
       return $this->product_translate_lang->vedio_buttom_description;
    }
    public function getSizeAttribute()
    {
       return $this->product_translate_lang->size;
    }
    public function getSpecifactionAttribute()
    {
       return $this->product_translate_lang->specifaction;
    }


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


}