<?php
namespace App\model;
use Illuminate\Database\Eloquent\Model;
class Delivery extends Model
{
//
protected $hidden = ['Orders','order_id','Drivers','driver_id','customer_id'];
protected $appends = ['DriverInfo','OrderInfo','Shops'];//'CustomerInfo'
public function getShopsAttribute()
{
// return null ;
// return $this->shopId;
// $Shop = Shop::where('id', $this->order_id )->get();
// return $Shop;
$orderShops = OrdersShop::
where('orderId', $this->order_id)->
get();
return $orderShops;
}
public function Orders()
{
// return $this->belongsToMany('\Products', 'ordersprpductlists');
return $this->hasOne('App\model\Orders', 'id', 'order_id');
}
public function getOrderInfoAttribute()
{
return $this->Orders;
if ( $this->Orders != null){
return $this->Orders->first();
}
}
public function Drivers()
{
// return $this->belongsToMany('\Products', 'ordersprpductlists');
return $this->hasOne('App\model\Customer', 'id', 'driver_id');
}
public function getDriverInfoAttribute()
{
return $this->Drivers;
}
// public function Customers()
// {
// // return $this->belongsToMany('\Products', 'ordersprpductlists');
// return $this->hasOne('App\model\Customer', 'id', 'customer_id');
// }
// public function getCustomerInfoAttribute()
// {
// return $this->Customers;
// }
}