Файл: app/Models/TaxRate.php
Строк: 29
<?php
namespace AppModels;
use IlluminateDatabaseEloquentBuilder;
use IlluminateDatabaseEloquentModel;
use IlluminateDatabaseEloquentSoftDeletes;
class TaxRate extends Model
{
use SoftDeletes;
/**
* The attributes that should be cast.
*
* @var array
*/
protected $casts = [
'regions' => 'object'
];
/**
* @param Builder $query
* @param $value
* @return Builder
*/
public function scopeSearchName(Builder $query, $value)
{
return $query->where('name', 'like', '%' . $value . '%');
}
/**
* @param Builder $query
* @param $value
* @return Builder
*/
public function scopeOfType(Builder $query, $value)
{
return $query->where('type', '=', $value);
}
/**
* @param Builder $query
* @param $value
* @return Builder
*/
public function scopeOfRegion(Builder $query, $value)
{
$query->whereNull('regions')
->when($value, function ($query) use ($value) {
$query->orWhere('regions', 'like', '%' . $value . '%');
});
return $query;
}
}