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
@@ -0,0 +1,108 @@
<?php
namespace App\Containers\User\Policies;
use App\Containers\User\Models\User;
use App\Containers\User\Models\AcceptedInvitation;
use Illuminate\Auth\Access\HandlesAuthorization;
class AcceptedInvitationPolicy
{
use HandlesAuthorization;
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
{
return $user->can('view_any_accepted::invitation');
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, AcceptedInvitation $acceptedInvitation): bool
{
return $user->can('view_accepted::invitation');
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
{
return $user->can('create_accepted::invitation');
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, AcceptedInvitation $acceptedInvitation): bool
{
return $user->can('update_accepted::invitation');
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, AcceptedInvitation $acceptedInvitation): bool
{
return $user->can('delete_accepted::invitation');
}
/**
* Determine whether the user can bulk delete.
*/
public function deleteAny(User $user): bool
{
return $user->can('delete_any_accepted::invitation');
}
/**
* Determine whether the user can permanently delete.
*/
public function forceDelete(User $user, AcceptedInvitation $acceptedInvitation): bool
{
return $user->can('{{ ForceDelete }}');
}
/**
* Determine whether the user can permanently bulk delete.
*/
public function forceDeleteAny(User $user): bool
{
return $user->can('{{ ForceDeleteAny }}');
}
/**
* Determine whether the user can restore.
*/
public function restore(User $user, AcceptedInvitation $acceptedInvitation): bool
{
return $user->can('{{ Restore }}');
}
/**
* Determine whether the user can bulk restore.
*/
public function restoreAny(User $user): bool
{
return $user->can('{{ RestoreAny }}');
}
/**
* Determine whether the user can replicate.
*/
public function replicate(User $user, AcceptedInvitation $acceptedInvitation): bool
{
return $user->can('{{ Replicate }}');
}
/**
* Determine whether the user can reorder.
*/
public function reorder(User $user): bool
{
return $user->can('{{ Reorder }}');
}
}
+108
View File
@@ -0,0 +1,108 @@
<?php
namespace App\Containers\User\Policies;
use App\Containers\User\Models\User;
use App\Containers\User\Models\Role;
use Illuminate\Auth\Access\HandlesAuthorization;
class RolePolicy
{
use HandlesAuthorization;
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
{
return $user->can('view_any_shield::role');
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, Role $role): bool
{
return $user->can('view_shield::role');
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
{
return $user->can('create_shield::role');
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, Role $role): bool
{
return $user->can('update_shield::role');
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, Role $role): bool
{
return $user->can('delete_shield::role');
}
/**
* Determine whether the user can bulk delete.
*/
public function deleteAny(User $user): bool
{
return $user->can('delete_any_shield::role');
}
/**
* Determine whether the user can permanently delete.
*/
public function forceDelete(User $user, Role $role): bool
{
return $user->can('{{ ForceDelete }}');
}
/**
* Determine whether the user can permanently bulk delete.
*/
public function forceDeleteAny(User $user): bool
{
return $user->can('{{ ForceDeleteAny }}');
}
/**
* Determine whether the user can restore.
*/
public function restore(User $user, Role $role): bool
{
return $user->can('{{ Restore }}');
}
/**
* Determine whether the user can bulk restore.
*/
public function restoreAny(User $user): bool
{
return $user->can('{{ RestoreAny }}');
}
/**
* Determine whether the user can replicate.
*/
public function replicate(User $user, Role $role): bool
{
return $user->can('{{ Replicate }}');
}
/**
* Determine whether the user can reorder.
*/
public function reorder(User $user): bool
{
return $user->can('{{ Reorder }}');
}
}
@@ -0,0 +1,108 @@
<?php
namespace App\Containers\User\Policies;
use App\Containers\User\Models\User;
use App\Containers\User\Models\UserDetail;
use Illuminate\Auth\Access\HandlesAuthorization;
class UserDetailPolicy
{
use HandlesAuthorization;
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
{
return $user->can('view_any_user::detail');
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, UserDetail $userDetail): bool
{
return $user->can('view_user::detail');
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
{
return $user->can('create_user::detail');
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, UserDetail $userDetail): bool
{
return $user->can('update_user::detail');
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, UserDetail $userDetail): bool
{
return $user->can('delete_user::detail');
}
/**
* Determine whether the user can bulk delete.
*/
public function deleteAny(User $user): bool
{
return $user->can('delete_any_user::detail');
}
/**
* Determine whether the user can permanently delete.
*/
public function forceDelete(User $user, UserDetail $userDetail): bool
{
return $user->can('force_delete_user::detail');
}
/**
* Determine whether the user can permanently bulk delete.
*/
public function forceDeleteAny(User $user): bool
{
return $user->can('force_delete_any_user::detail');
}
/**
* Determine whether the user can restore.
*/
public function restore(User $user, UserDetail $userDetail): bool
{
return $user->can('restore_user::detail');
}
/**
* Determine whether the user can bulk restore.
*/
public function restoreAny(User $user): bool
{
return $user->can('restore_any_user::detail');
}
/**
* Determine whether the user can replicate.
*/
public function replicate(User $user, UserDetail $userDetail): bool
{
return $user->can('replicate_user::detail');
}
/**
* Determine whether the user can reorder.
*/
public function reorder(User $user): bool
{
return $user->can('reorder_user::detail');
}
}
+144
View File
@@ -0,0 +1,144 @@
<?php
namespace App\Containers\User\Policies;
use App\Containers\User\Models\User;
use Illuminate\Auth\Access\HandlesAuthorization;
class UserPolicy
{
use HandlesAuthorization;
/**
* Determine whether the user can view any models.
*
* @param \App\Containers\User\Models\User $user
* @return bool
*/
public function viewAny(User $user): bool
{
return $user->can('view_any_user');
}
/**
* Determine whether the user can view the model.
*
* @param \App\Containers\User\Models\User $user
* @return bool
*/
public function view(User $user): bool
{
return $user->can('view_user');
}
/**
* Determine whether the user can create models.
*
* @param \App\Containers\User\Models\User $user
* @return bool
*/
public function create(User $user): bool
{
return $user->can('create_user');
}
/**
* Determine whether the user can update the model.
*
* @param \App\Containers\User\Models\User $user
* @return bool
*/
public function update(User $user): bool
{
return $user->can('update_user');
}
/**
* Determine whether the user can delete the model.
*
* @param \App\Containers\User\Models\User $user
* @return bool
*/
public function delete(User $user): bool
{
return $user->can('delete_user');
}
/**
* Determine whether the user can bulk delete.
*
* @param \App\Containers\User\Models\User $user
* @return bool
*/
public function deleteAny(User $user): bool
{
return $user->can('delete_any_user');
}
/**
* Determine whether the user can permanently delete.
*
* @param \App\Containers\User\Models\User $user
* @return bool
*/
public function forceDelete(User $user): bool
{
return $user->can('{{ ForceDelete }}');
}
/**
* Determine whether the user can permanently bulk delete.
*
* @param \App\Containers\User\Models\User $user
* @return bool
*/
public function forceDeleteAny(User $user): bool
{
return $user->can('{{ ForceDeleteAny }}');
}
/**
* Determine whether the user can restore.
*
* @param \App\Containers\User\Models\User $user
* @return bool
*/
public function restore(User $user): bool
{
return $user->can('{{ Restore }}');
}
/**
* Determine whether the user can bulk restore.
*
* @param \App\Containers\User\Models\User $user
* @return bool
*/
public function restoreAny(User $user): bool
{
return $user->can('{{ RestoreAny }}');
}
/**
* Determine whether the user can bulk restore.
*
* @param \App\Containers\User\Models\User $user
* @return bool
*/
public function replicate(User $user): bool
{
return $user->can('{{ Replicate }}');
}
/**
* Determine whether the user can reorder.
*
* @param \App\Containers\User\Models\User $user
* @return bool
*/
public function reorder(User $user): bool
{
return $user->can('{{ Reorder }}');
}
}