deploy commit

This commit is contained in:
2026-07-15 17:23:15 +07:00
commit b94ef4a695
148 changed files with 14831 additions and 0 deletions
+52
View File
@@ -0,0 +1,52 @@
<?php
namespace App\Policies;
use App\Models\Account;
use App\Models\User;
use Illuminate\Auth\Access\Response;
class AccountPolicy
{
public function viewAny($user)
{
return in_array($user->role, ['admin', 'patient']);
}
public function view($user, Account $account)
{
// admin boleh lihat semua, user bisa lihat diri sendiri
return $user->role==='admin' || $user->id === $account->id;
}
public function update($user, Account $account)
{
// admin boleh update semua, user bisa update diri sendiri
return $user->role==='admin' || $user->id === $account->id;
}
public function delete($user, Account $account)
{
// hanya admin
return $user->role==='admin';
}
public function create($user)
{
// pembuatan akun via API hanya lewat register
return false;
}
/**
* Determine whether the user can restore the model.
*/
public function restore(User $user, Account $account): bool
{
return false;
}
/**
* Determine whether the user can permanently delete the model.
*/
public function forceDelete(User $user, Account $account): bool
{
return false;
}
}
+51
View File
@@ -0,0 +1,51 @@
<?php
namespace App\Policies;
use App\Models\Account;
use App\Models\DoctorProfile;
use Illuminate\Auth\Access\Response;
class DoctorProfilePolicy
{
public function viewAny($user)
{
// hanya dokter & admin yg butuh list profil dokter
return in_array($user->role,['doctor','admin']);
}
public function view($user, DoctorProfile $p)
{
// dokter hanya lihat profil dirinya sendiri
return $user->role==='doctor' && $p->user_id === $user->id || $user->role==='admin';
}
public function update($user, DoctorProfile $p)
{
return $user->role==='doctor' && $p->user_id === $user->id || $user->role==='admin';
}
public function delete($user, DoctorProfile $p)
{
// biasanya nggak dihapus, tapi kalau perlu:
return $user->role==='admin';
}
public function create($user)
{
// profil dokter dibuat otomatis waktu register doctor
return false;
}
/**
* Determine whether the user can restore the model.
*/
public function restore(Account $user, DoctorProfile $doctorProfile): bool
{
return false;
}
/**
* Determine whether the user can permanently delete the model.
*/
public function forceDelete(Account $user, DoctorProfile $doctorProfile): bool
{
return false;
}
}
+79
View File
@@ -0,0 +1,79 @@
<?php
namespace App\Policies;
use App\Models\Submission;
use App\Models\Account;
use Illuminate\Auth\Access\Response;
class SubmissionPolicy
{
public function viewAny($user)
{
// pasien & dokter boleh lihat submission…
return in_array($user->role, ['patient','doctor', 'admin']);
}
public function view($user, Submission $s)
{
if($user->role==='patient'){
return $s->patient_id === $user->id;
}
if($user->role==='doctor' || $user->role==='admin'){
// dokter lihat semua (atau tambahkan filter assigned/idempot)
return true;
}
return false;
}
public function create($user)
{
return $user->role==='patient' || $user->role==='admin';
}
public function update($user, Submission $s)
{
if ($user->role === 'admin') {
return true;
}
if ($user->role === 'doctor') {
return true;
}
if ($user->role === 'patient') {
return $s->patient_id === $user->id
&& $s->status === 'pending';
}
return false;
}
public function delete($user, Submission $submission)
{
if ($user->role === 'admin') {
return true;
}
if ($user->role === 'doctor') {
return true;
}
if ($user->role === 'patient') {
return $submission->patient_id === $user->id;
}
return false;
}
/**
* Determine whether the user can restore the model.
*/
public function restore(Account $user, Submission $submission): bool
{
return false;
}
/**
* Determine whether the user can permanently delete the model.
*/
public function forceDelete(Account $user, Submission $submission): bool
{
return false;
}
}
+66
View File
@@ -0,0 +1,66 @@
<?php
namespace App\Policies;
use App\Models\User;
use App\Models\Verification;
use Illuminate\Auth\Access\Response;
class VerificationPolicy
{
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
{
return false;
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, Verification $verification): bool
{
return false;
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
{
return false;
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, Verification $verification): bool
{
return false;
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, Verification $verification): bool
{
return false;
}
/**
* Determine whether the user can restore the model.
*/
public function restore(User $user, Verification $verification): bool
{
return false;
}
/**
* Determine whether the user can permanently delete the model.
*/
public function forceDelete(User $user, Verification $verification): bool
{
return false;
}
}