add shipping rules

This commit is contained in:
Ludovic CANDELLIER
2023-07-16 14:45:42 +02:00
parent 297dcc62d2
commit 39c80ce6d1
459 changed files with 6219 additions and 5416 deletions

View File

@@ -2,25 +2,24 @@
namespace App\Models\Shop;
use Illuminate\Database\Eloquent\Model;
use Staudenmeir\EloquentHasManyDeep\HasRelationships;
use Kirschbaum\PowerJoins\PowerJoins;
use App\Traits\Model\HasComments;
use Illuminate\Database\Eloquent\Model;
use Kirschbaum\PowerJoins\PowerJoins;
use Staudenmeir\EloquentHasManyDeep\HasRelationships;
class Tariff extends Model
{
use HasComments, HasRelationships, PowerJoins;
protected $guarded = ['id'];
protected $table = 'shop_tariffs';
public function offers()
{
return $this->hasMany(Offer::class);
}
public function sale_channel()
{
return $this->belongsTo(SaleChannel::class);
@@ -48,9 +47,9 @@ class Tariff extends Model
public function scopeByAutocomplete($query, $str)
{
return $query->where($this->table . '.name', 'LIKE', "%${str}%")
->orWhere($this->table . '.ref', 'LIKE', "${str}%")
->orWhere($this->table . '.code', 'LIKE', "${str}%");
return $query->where($this->table.'.name', 'LIKE', "%${str}%")
->orWhere($this->table.'.ref', 'LIKE', "${str}%")
->orWhere($this->table.'.code', 'LIKE', "${str}%");
}
public function scopeBySaleChannel($query, $id)
@@ -62,12 +61,12 @@ class Tariff extends Model
public function scopeBySaleChannelDefault($query, $id)
{
return $query->where($this->table . '.sale_channel_id', $id);
return $query->where($this->table.'.sale_channel_id', $id);
}
public function scopeByStatus($query, $id)
{
return $query->where($this->table . '.status_id', $id);
return $query->where($this->table.'.status_id', $id);
}
public function scopeByOffer($query, $id)