This commit is contained in:
f4ilji
2024-10-04 12:48:19 +05:00
parent 21a6e9073b
commit cebc584a14
303 changed files with 8224 additions and 2563 deletions
+23
View File
@@ -0,0 +1,23 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class AcceptedInvitation extends Model
{
use HasFactory;
protected $fillable = ['sender_id', 'receiver_id', 'post_limit'];
public function sender()
{
return $this->belongsTo(User::class, 'sender_id');
}
public function receiver()
{
return $this->belongsTo(User::class, 'receiver_id');
}
}
+5
View File
@@ -22,5 +22,10 @@ class AdditionalEducation extends Model
return $this->belongsTo(AdditionalEducationCategory::class, 'category_id', 'id');
}
public function seo()
{
return $this->morphOne(Seo::class, 'seoable');
}
}
@@ -20,4 +20,6 @@ class AdditionalEducationCategory extends Model
{
return $this->belongsTo(DirectionAdditionalEducation::class, 'dir_addit_educat_id', 'id');
}
}
+5
View File
@@ -15,6 +15,11 @@ class Department extends Model
'content' => 'array',
];
public function seo()
{
return $this->morphOne(Seo::class, 'seoable');
}
public function faculty()
{
return $this->belongsTo(Faculty::class);
+5
View File
@@ -15,6 +15,11 @@ class Division extends Model
'description' => 'array',
];
public function seo()
{
return $this->morphOne(Seo::class, 'seoable');
}
public function workers()
{
return $this->belongsToMany(User::class, 'division_user')->withPivot(['administrativePosition', 'sort']);
+5
View File
@@ -35,4 +35,9 @@ class EducationalProgram extends Model
{
return $this->hasMany(AdmissionPlan::class, 'educational_programs_id', 'id');
}
public function seo()
{
return $this->morphOne(Seo::class, 'seoable');
}
}
+5
View File
@@ -17,6 +17,11 @@ class Event extends Model
'content' => 'array',
];
public function seo()
{
return $this->morphOne(Seo::class, 'seoable');
}
public function category() : BelongsTo
{
return $this->belongsTo(EventCategory::class);
+5
View File
@@ -15,6 +15,11 @@ class Faculty extends Model
'content' => 'array',
];
public function seo()
{
return $this->morphOne(Seo::class, 'seoable');
}
public function departments()
{
return $this->hasMany(Department::class);
+13
View File
@@ -0,0 +1,13 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Invitation extends Model
{
use HasFactory;
protected $guarded = false;
}
+5
View File
@@ -11,6 +11,11 @@ class LibraryNews extends Model
protected $guarded = false;
public function seo()
{
return $this->morphOne(Seo::class, 'seoable');
}
protected $casts = [
'content' => 'array',
];
+5
View File
@@ -18,6 +18,11 @@ class Page extends Model
return $this->belongsTo(SubSection::class, 'sub_section_id');
}
public function seo()
{
return $this->morphOne(Seo::class, 'seoable');
}
protected $casts = [
'content' => 'array',
];
+5
View File
@@ -22,6 +22,11 @@ class Post extends Model
return $this->belongsTo(Category::class);
}
public function seo()
{
return $this->morphOne(Seo::class, 'seoable');
}
protected $casts = [
'content' => 'array',
'authors' => 'array',
+1 -1
View File
@@ -12,7 +12,7 @@ class Schedule extends Model
protected $guarded = false;
protected $casts = [
'days' => 'array',
'file' => 'array',
];
public function subSchedules()
+18
View File
@@ -0,0 +1,18 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Seo extends Model
{
use HasFactory;
protected $fillable = ['title', 'description'];
public function seoable()
{
return $this->morphTo();
}
}
+37 -2
View File
@@ -3,6 +3,10 @@
namespace App\Models;
// use Illuminate\Contracts\Auth\MustVerifyEmail;
use App\Providers\Filament\AdminPanelProvider;
use BezhanSalleh\FilamentShield\FilamentShield;
use BezhanSalleh\FilamentShield\Support\Utils;
use BezhanSalleh\FilamentShield\Traits\HasPanelShield;
use Filament\Models\Contracts\FilamentUser;
use Filament\Tables\Columns\Layout\Panel;
use Illuminate\Database\Eloquent\Factories\HasFactory;
@@ -13,7 +17,7 @@ use Spatie\Permission\Traits\HasRoles;
class User extends Authenticatable implements FilamentUser
{
use HasApiTokens, HasFactory, Notifiable, HasRoles;
use HasApiTokens, HasFactory, Notifiable, HasRoles, HasPanelShield;
/**
* The attributes that are mass assignable.
@@ -72,8 +76,39 @@ class User extends Authenticatable implements FilamentUser
return $this->belongsToMany(Faculty::class, 'workers_faculties')->withPivot(['position']);
}
// Отношение к отправленным приглашениям
public function sentInvitations()
{
return $this->hasMany(AcceptedInvitation::class, 'sender_id');
}
// Отношение к полученным приглашениям
public function receivedInvitation()
{
return $this->hasOne(AcceptedInvitation::class, 'receiver_id');
}
protected static function booted(): void
{
if (config('filament-shield.dashboard_user.enabled', false)) {
FilamentShield::createRole(name: config('filament-shield.dashboard_user.name', 'dashboard_user'));
static::created(function (User $user) {
$user->assignRole(config('filament-shield.dashboard_user.name', 'dashboard_user'));
});
static::deleting(function (User $user) {
$user->assignRole(config('filament-shield.dashboard_user.name', 'dashboard_user'));
});
}
}
public function canAccessPanel(Panel|\Filament\Panel $panel): bool
{
return true;
switch ($panel->getId()) {
case "admin":
return $this->hasRole(Utils::getSuperAdminName());
case "dashboard":
return $this->hasRole(config('filament-shield.dashboard_user.name', 'dashboard_user')) || $this->hasRole(Utils::getSuperAdminName());
default:
return false;
}
}
}
+2
View File
@@ -8,4 +8,6 @@ use Illuminate\Database\Eloquent\Model;
class VacantPosition extends Model
{
use HasFactory;
}
+5
View File
@@ -14,4 +14,9 @@ class VirtualExhibition extends Model
protected $casts = [
'content' => 'array'
];
public function seo()
{
return $this->morphOne(Seo::class, 'seoable');
}
}