fixed prefix scope
This commit is contained in:
@ -7,7 +7,6 @@ use Illuminate\Database\Eloquent\Model as Eloquent;
|
||||
|
||||
class Setting extends Eloquent
|
||||
{
|
||||
|
||||
protected $table = 'settings';
|
||||
|
||||
public $timestamps = false;
|
||||
@ -19,11 +18,6 @@ class Setting extends Eloquent
|
||||
*/
|
||||
protected $fillable = ['company_id', 'key', 'value'];
|
||||
|
||||
/**
|
||||
* The "booting" method of the model.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected static function boot()
|
||||
{
|
||||
parent::boot();
|
||||
@ -31,21 +25,24 @@ class Setting extends Eloquent
|
||||
static::addGlobalScope(new Company);
|
||||
}
|
||||
|
||||
public static function all($code = 'general')
|
||||
{
|
||||
return static::where('key', 'like', $code . '.%')->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Global company relation.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function company()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Common\Company');
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope to only include by prefix.
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @param $company_id
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public static function scopePrefix($query, $prefix = 'company')
|
||||
{
|
||||
return $query->where('key', 'like', $prefix . '.%');
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope to only include company data.
|
||||
*
|
||||
|
Reference in New Issue
Block a user