Files
opensem/app/Models/Shop/Tariff.php
Ludovic CANDELLIER 9cf96b7d4e fixes
2021-09-09 00:03:24 +02:00

43 lines
962 B
PHP

<?php
namespace App\Models\Shop;
use Illuminate\Database\Eloquent\Model;
use Staudenmeir\EloquentHasManyDeep\HasRelationships;
use BeyondCode\Comments\Traits\HasComments;
use Kirschbaum\PowerJoins\PowerJoins;
class Tariff extends Model
{
use HasComments, HasRelationships, PowerJoins;
protected $guarded = ['id'];
protected $table = 'shop_tariffs';
public function sale_channel()
{
return $this->belongsTo('App\Models\Shop\SaleChannel');
}
public function tariff_unity()
{
return $this->belongsTo('App\Models\Shop\TariffUnity');
}
public function price_lists()
{
return $this->hasMany('App\Models\Shop\PriceList');
}
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);
}
}