[WIP] Working on orders & invoices
This commit is contained in:
@@ -7,14 +7,55 @@ use Illuminate\Database\Eloquent\Model;
|
||||
class Order extends Model
|
||||
{
|
||||
protected $guarded = ['id'];
|
||||
protected $table = 'shop_orders';
|
||||
|
||||
public function customer()
|
||||
{
|
||||
return $this->belongsTo(Customer::class);
|
||||
}
|
||||
|
||||
public function payments()
|
||||
public function address()
|
||||
{
|
||||
return $this->hasMany(OrderPayment::class);
|
||||
return $this->belongsTo(CustomerAddress::class, 'customer_address_id');
|
||||
}
|
||||
|
||||
public function delivery()
|
||||
{
|
||||
return $this->belongsTo(Delivery::class);
|
||||
}
|
||||
|
||||
public function detail()
|
||||
{
|
||||
return $this->hasMany(OrderDetail::class);
|
||||
}
|
||||
|
||||
public function invoice()
|
||||
{
|
||||
return $this->hasOne(Invoice::class);
|
||||
}
|
||||
|
||||
public function sale_channel()
|
||||
{
|
||||
return $this->belongsTo(SaleChannel::class);
|
||||
}
|
||||
|
||||
public function scopeByCustomer($query, $customer_id)
|
||||
{
|
||||
return $query->where('customer_id', $customer_id);
|
||||
}
|
||||
|
||||
public function scopeByDelivery($query, $delivery_id)
|
||||
{
|
||||
return $query->where('delivery_id', $delivery_id);
|
||||
}
|
||||
|
||||
public function scopeByStatus($query, $status)
|
||||
{
|
||||
return $query->where('status', $status);
|
||||
}
|
||||
|
||||
public function scopeByPaymentType($query, $payment_type)
|
||||
{
|
||||
return $query->where('payment_type', $payment_type);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user