44 lines
914 B
PHP
44 lines
914 B
PHP
<?php
|
|
|
|
namespace App\Models\Shop;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
use Staudenmeir\EloquentHasManyDeep\HasRelationships;
|
|
use Kirschbaum\PowerJoins\PowerJoins;
|
|
|
|
use App\Traits\HasComments;
|
|
|
|
class Tariff extends Model
|
|
{
|
|
use HasComments, HasRelationships, PowerJoins;
|
|
|
|
protected $guarded = ['id'];
|
|
protected $table = 'shop_tariffs';
|
|
|
|
public function sale_channel()
|
|
{
|
|
return $this->belongsTo(SaleChannel::class);
|
|
}
|
|
|
|
public function tariff_unity()
|
|
{
|
|
return $this->belongsTo(TariffUnity::class);
|
|
}
|
|
|
|
public function price_lists()
|
|
{
|
|
return $this->hasMany(PriceList::class);
|
|
}
|
|
|
|
public function scopeBySaleChanel($query, $id)
|
|
{
|
|
return $query->where($this->table . '.sale_channel_id', $id);
|
|
}
|
|
|
|
public function scopeByStatus($query, $id)
|
|
{
|
|
return $query->where($this->table . '.status_id', $id);
|
|
}
|
|
}
|