Refactoring, change menu, add many features
This commit is contained in:
57
app/Models/Shop/Delivery.php
Normal file
57
app/Models/Shop/Delivery.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Shop;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Delivery extends Model
|
||||
{
|
||||
protected $guarded = ['id'];
|
||||
protected $table = 'shop_deliveries';
|
||||
|
||||
public function Customers()
|
||||
{
|
||||
return $this->hasMany(Customer::class);
|
||||
}
|
||||
|
||||
public function SaleChannel()
|
||||
{
|
||||
return $this->belongsTo(SaleChannel::class);
|
||||
}
|
||||
|
||||
public function scopeActive($query)
|
||||
{
|
||||
return $this->byActive(1);
|
||||
}
|
||||
|
||||
public function scopeByActive($query, $active)
|
||||
{
|
||||
return $query->where($this->table . '.active', $active);
|
||||
}
|
||||
|
||||
public function scopeByPublic($query, $is_public)
|
||||
{
|
||||
return $query->where($this->table . '.is_public', $is_public);
|
||||
}
|
||||
|
||||
public function scopeAtHouse($query)
|
||||
{
|
||||
return $query->where($this->table . '.at_house', 1);
|
||||
}
|
||||
|
||||
public function scopeInactive($query)
|
||||
{
|
||||
return $this->byActive(0);
|
||||
}
|
||||
|
||||
public function scopeManaged($query)
|
||||
{
|
||||
return $this->byPublic(0);
|
||||
}
|
||||
|
||||
public function scopePublic($query)
|
||||
{
|
||||
return $this->byPublic(1);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user