[WIP] Refactor models to better lisibility and speed
This commit is contained in:
30
app/Models/Shop/PriceGenericValue.php
Normal file
30
app/Models/Shop/PriceGenericValue.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Shop;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Znck\Eloquent\Traits\BelongsToThrough;
|
||||
|
||||
class PriceGenericValue extends Model
|
||||
{
|
||||
use BelongsToThrough;
|
||||
|
||||
protected $guarded = ['id'];
|
||||
protected $table = 'shop_price_generic_values';
|
||||
|
||||
public function price_generic()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Shop\PriceGeneric');
|
||||
}
|
||||
|
||||
public function scopeByPriceGeneric($query, $id)
|
||||
{
|
||||
return $query->where('price_generic_id', $id);
|
||||
}
|
||||
|
||||
public function scopeByQuantity($query, $quantity)
|
||||
{
|
||||
return $query->orderBy('quantity', 'desc')->where('quantity', '<', $quantity)->first();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user