Last active
June 4, 2019 11:24
-
-
Save luckys383/90a062d86684a902af9856747048bc6c to your computer and use it in GitHub Desktop.
Laravel: Common Filters using Model Scope
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App; | |
use App\Models\AppModel; | |
class User extends AppModel | |
{ | |
protected $table = 'users'; | |
/** | |
* set fillable fields | |
*/ | |
protected $fillable = ['role_id', 'name', 'email', 'status']; | |
/** | |
* set string fields for filtering | |
* @var array | |
*/ | |
protected $likeFilterFields = ['name', 'email']; | |
/** | |
* set boolean fields for filtering | |
* @var array | |
*/ | |
protected $boolFilterFields = ['status']; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment