File: /var/www/vhost/disk-apps/agile-selling-wpb/app/Order.php
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use App\User;
use App\OrderState;
use App\Sucursal;
use App\Address;
use App\PaymentType;
use App\OrderType;
use App\SalesChannel;
use App\LineBusiness;
use Illuminate\Database\Eloquent\SoftDeletes;
class Order extends Model
{
use SoftDeletes;
protected $guarded = ['id','deleted_at'];
public $timestamps = false;
public function client()
{
return $this->belongsTo(User::class, 'client_id')->with("addresses")->with("boPaymentTermType")->withTrashed();
}
public function deliveryMan()
{
return $this->belongsTo(User::class, 'delivery_man_id')->with('userInfo')->withTrashed();
}
public function deliveryManAccepted()
{
return $this->belongsTo(User::class, 'accepted_delivery_man_id')->with('userInfo')->withTrashed();
}
public function deliveryManCollected()
{
return $this->belongsTo(User::class, 'collected_delivery_man_id')->with('userInfo')->withTrashed();
}
public function deliveryManDeliver()
{
return $this->belongsTo(User::class, 'deliver_delivery_man_id')->with('userInfo')->withTrashed();
}
// public function deliveryManInformation(){
// return $this->belongsTo(UserInformation::class,'delivery_man_id')->withTrashed();
// }
public function admin()
{
return $this->belongsTo(User::class, 'admin_id')->withTrashed();
}
public function orderState()
{
return $this->belongsTo(orderState::class)->select(array('id', 'name'));
}
public function sucursal()
{
return $this->belongsTo(Sucursal::class, 'sucursal_id')->withTrashed();
}
public function sucursalOrigin()
{
return $this->belongsTo(Sucursal::class, 'sucursal_origin_id')->withTrashed();
}
public function currentSucursal()
{
return $this->belongsTo(Sucursal::class, 'current_sucursal_id')->withTrashed();
}
public function comment()
{
return $this->hasMany(Comment::class);
}
public function address()
{
return $this->belongsTo(Address::class)->withTrashed();
}
public function transferences()
{
return $this->hasMany(Transfer::class);
}
public function paymentType()
{
return $this->belongsTo(PaymentType::class);
}
public function orderProducts()
{
return $this->hasMany(OrderProduct::class)->with('products','orderProductAttributes','product');
}
public function orderType()
{
return $this->belongsTo(OrderType::class);
}
public function boShippingType()
{
return $this->belongsTo(BoShippingType::class);
}
public function channel()
{
return $this->belongsTo(SalesChannel::class, 'sales_channel_id')->withTrashed();
}
public function line()
{
return $this->belongsTo(LineBusiness::class, 'line_businesses_id')->withTrashed();
}
public function point_sale()
{
return $this->belongsTo(PointSale::class);
}
public function discountOrderUser()
{
return $this->hasMany(DiscountOrderUser::class, 'order_id', 'id')->with('discount');
}
public function discountProductUsers()
{
return $this->hasMany(DiscountProductUser::class, 'order_id', 'id');
}
}