Migrate backend to Porto architecture and fix minor bugs

- Fully transitioned the backend to the Porto architectural pattern
- Improved code organization and maintainability
- Fixed minor bugs and inconsistencies
This commit is contained in:
F4ilji
2025-05-12 08:47:43 +05:00
parent 76deaf75f3
commit c01016a154
620 changed files with 16218 additions and 6073 deletions
+10
View File
@@ -0,0 +1,10 @@
<?php
namespace App\Ship\Models;
use App\Ship\Abstracts\Models\Builder as AbstractBuilder;
class Builder extends AbstractBuilder
{
}
+10
View File
@@ -0,0 +1,10 @@
<?php
namespace App\Ship\Models;
use App\Ship\Abstracts\Models\BaseModel as AbstractBaseModel;
class Model extends AbstractBaseModel
{
}
+10
View File
@@ -0,0 +1,10 @@
<?php
namespace App\Ship\Models;
use App\Ship\Abstracts\Models\MorphPivot as AbstractMorphPivot;
class MorphPivot extends AbstractMorphPivot
{
}
+10
View File
@@ -0,0 +1,10 @@
<?php
namespace App\Ship\Models;
use App\Ship\Abstracts\Models\Pivot as AbstractPivot;
class Pivot extends AbstractPivot
{
}
+15
View File
@@ -0,0 +1,15 @@
<?php
namespace App\Ship\Models;
interface Scope
{
/**
* Apply the scope to a given Eloquent query builder.
*
* @param Builder $builder
* @param Model $model
* @return void
*/
public function apply(Builder $builder, Model $model);
}
+17
View File
@@ -0,0 +1,17 @@
<?php
namespace App\Ship\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
class Seo extends Model
{
use HasFactory;
protected $fillable = ['title', 'description'];
public function seoable()
{
return $this->morphTo();
}
}
+74
View File
@@ -0,0 +1,74 @@
<?php
namespace App\Ship\Models;
use App\Containers\User\Models\User;
use App\Ship\Abstracts\Models\UserModel as AbstractUserModel;
use BezhanSalleh\FilamentShield\FilamentShield;
use BezhanSalleh\FilamentShield\Support\Utils;
use BezhanSalleh\FilamentShield\Traits\HasPanelShield;
use Filament\Tables\Columns\Layout\Panel;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Notifications\Notifiable;
use Laravel\Sanctum\HasApiTokens;
use Spatie\Permission\Traits\HasRoles;
class UserModel extends AbstractUserModel
{
use HasApiTokens, HasFactory, Notifiable, HasRoles, HasPanelShield;
protected $table = 'users';
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $fillable = [
'name',
'email',
'password',
];
/**
* The attributes that should be hidden for serialization.
*
* @var array<int, string>
*/
protected $hidden = [
'password',
'remember_token',
];
/**
* The attributes that should be cast.
*
* @var array<string, string>
*/
protected $casts = [
'email_verified_at' => 'datetime',
];
protected static function booted(): void
{
if (config('filament-shield.dashboard_user.enabled', false)) {
FilamentShield::createRole(name: config('filament-shield.dashboard_user.name', 'dashboard_user'));
FilamentShield::createRole(name: config('', 'editor'));
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 match ($panel->getId()) {
"admin" => $this->hasRole(Utils::getSuperAdminName()),
"dashboard" => $this->hasRole(config('filament-shield.dashboard_user.name', 'dashboard_user'))
|| $this->hasRole(Utils::getSuperAdminName())
|| $this->hasRole(config('filament-shield.invited_user.name', 'invited_user')),
default => false,
};
}
}