working on omis setup
This commit is contained in:
50
app/Models/Permission.php
Normal file
50
app/Models/Permission.php
Normal file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Modules\Models\User;
|
||||
use App\Modules\Models\Role;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Permission extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable= [
|
||||
'name', 'slug', 'visibility','status', 'availability','is_deleted','group_name',
|
||||
'deleted_at','created_by','last_updated_by','last_deleted_by'
|
||||
];
|
||||
|
||||
protected $appends = [
|
||||
'visibility_text', 'status_text', 'availability_text', 'thumbnail_path', 'image_path'
|
||||
];
|
||||
|
||||
function getVisibilityTextAttribute(){
|
||||
return ucwords(str_replace('_', ' ', $this->visibility));
|
||||
}
|
||||
|
||||
function getStatusTextAttribute(){
|
||||
return ucwords(str_replace('_', ' ', $this->status));
|
||||
}
|
||||
|
||||
function getAvailabilityTextAttribute(){
|
||||
return ucwords(str_replace('_', ' ', $this->availability));
|
||||
}
|
||||
|
||||
function creator(){
|
||||
return $this->belongsTo(User::class,'created_by');
|
||||
}
|
||||
|
||||
function getImagePathAttribute(){
|
||||
return $this->path.'/'. $this->image;
|
||||
}
|
||||
|
||||
function getThumbnailPathAttribute(){
|
||||
return $this->path.'/thumb/'. $this->image;
|
||||
}
|
||||
|
||||
public function roles(){
|
||||
return $this->belongsToMany(Role::class,'role_has_permissions');
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user