<?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;
}
}