%PDF- %PDF-
Direktori : /var/www/html/hr/api/app/Models/ |
Current File : /var/www/html/hr/api/app/Models/Module.php |
<?php namespace App\Models; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Model; /** * @property integer id * @property string code * @property string name * @property boolean is_enabled */ class Module extends BaseModel { const CLIENTS_MODULE = 'clients'; const CONFIGURATIONS_MODULE = 'configurations'; const HOLIDAYS_MODULE = 'holidays'; const MAINTENANCE_PAYMENTS_MODULE = 'maintenancePayments'; const NOTIFICATIONS_MODULE = 'notifications'; const PAYMENTS_MODULE = 'payments'; const PROJECTS_MODULE = 'projects'; const PTOS_MODULE = 'ptos'; const TIMECARDS_MODULE = 'timecards'; const USERS_MODULE = 'users'; const WORKING_DAYS_MODULE = 'workingDays'; public $timestamps = false; /** * The attributes that are mass assignable. * * @var array */ protected $fillable = [ 'code', 'name', 'is_enabled', ]; /** * The attributes that should be cast to native types. * * @var array */ protected $casts = [ 'id' => 'integer', 'code' => 'string', 'name' => 'string', 'is_enabled' => 'boolean', ]; public static function getEnabled() { return self::query() ->enabled() ->get(); } /** * @param $code * @return Module|Builder|Model|object|null */ public static function getByCode($code) { return self::query() ->where('code', $code) ->first(); } public static function isModuleEnabled($code) { return self::query() ->enabled() ->where('code', $code) ->first(); } public function scopeEnabled(Builder $query) { return $query->where('is_enabled', true); } }