| Server IP : 65.108.144.40 / Your IP : 216.73.217.165 Web Server : Apache/2.4.52 (Ubuntu) System : Linux ubuntu-8gb-hel1-1 5.15.0-173-generic #183-Ubuntu SMP Fri Mar 6 13:29:34 UTC 2026 x86_64 User : dev ( 1000) PHP Version : 8.2.30 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/html/project-slim/app/Models/ |
Upload File : |
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
class Module extends BaseModel
{
/**
* The table associated with the model.
*/
protected $table = 'repo_module';
/**
* The primary key for the model.
*/
protected $primaryKey = 'module_id';
/**
* The attributes that are mass assignable.
*/
protected $fillable = [
'module_name',
'description'
];
/**
* The attributes that should be hidden for serialization.
* Inherits from BaseModel to hide all ID fields
*/
protected $hidden = [
'id',
'module_id',
'role_id',
'user_id',
'company_id',
'report_id'
];
/**
* Get the roles that have access to this module.
*/
public function roles(): BelongsToMany
{
return $this->belongsToMany(
Role::class,
'repo_role_module',
'module_id',
'role_id',
'module_id',
'role_id'
);
}
/**
* Scope for admin modules.
*/
public function scopeAdmin($query)
{
return $query->whereIn('module_name', [
'user_listing',
'company_listing',
'analytic_reports'
]);
}
/**
* Scope for self-service modules.
*/
public function scopeSelfService($query)
{
return $query->whereIn('module_name', [
'own_profile',
'own_company',
'own_company_analytic_reports'
]);
}
/**
* Check if this is an admin module.
*/
public function isAdminModule(): bool
{
return in_array($this->module_name, [
'user_listing',
'company_listing',
'analytic_reports'
]);
}
/**
* Check if this is a self-service module.
*/
public function isSelfServiceModule(): bool
{
return in_array($this->module_name, [
'own_profile',
'own_company',
'own_company_analytic_reports'
]);
}
}