👁 View: Orders.php
Path: /home/thiqat5/dex.thiqatech.com/model/Orders.php
Size: 2.01 KB · Modified: 2021-11-03 20:28:12 · Perm: 0644 · Writable
<?php

namespace App\model;

use Illuminate\Database\Eloquent\Model;

class Orders extends Model
{
    protected $table = 'orders';
    protected $hidden = ['Prodcuts','Shops','shop','customer_id','customer','Customers'];
    protected $appends = ['CustomerInfo','ShopInfo','CityInfo','cartProdcuts'];
    // public $timestamps = false;
    // 

    /*protected $fillable = [
        '',
    ];*/
    public function getCartProdcutsAttribute()
    {
        // return null ;
        $CartProducts =  Ordersprpductlist::where('Orders_id', $this->id )->get();
        return $CartProducts;
    
       
    }

   
    public  function rtvItem($shopId)
    {
        $CartProducts =  collect([]);

        $new = $this;
    $new->push($this);

        return $new;
        // $CartProducts =  Ordersprpductlist::where('Orders_id', $this->id )->get();
        // return $CartProducts;
    
       
    }
    public function getOrderProductsAttribute()
    {
        return $this->Prodcuts;
       
    }
    public function Prodcuts()
    {
        //   return $this->hasOne('App\Phone');
        return $this->belongsToMany('App\model\Products', 'ordersprpductlists', 'Orders_id', 'Products_id')
       ;// ->select(app('App\model\Products')->getTable().'.name','.price');
    } 
    
    public function Customers()
    {
        // return $this->belongsToMany('\Products', 'ordersprpductlists');
        return $this->hasOne('App\model\Customer', 'id', 'customer');
    }  
    public function getCustomerInfoAttribute( )
    {
        // return $shopId;
        return $this->Customers;
       
    }
   
    public function Shops()
    {
        // return $this->belongsToMany('\Products', 'ordersprpductlists');
        return $this->hasOne('App\model\Shop', 'id', 'shop');
    }  
    public function getShopInfoAttribute()
    {
        return $this->Shops;
       
    }
    public function getCityInfoAttribute()
    {
        $cityid = $this->city;
        $Cities =  Cities::where('id', $cityid)->first();
  
        return $Cities;
       
    }
}