first
This commit is contained in:
77
app/Models/Application.php
Normal file
77
app/Models/Application.php
Normal file
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Database\Factories\ApplicationFactory;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Application extends Model
|
||||
{
|
||||
/** @use HasFactory<ApplicationFactory> */
|
||||
use HasFactory, SoftDeletes;
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'approved_at' => 'datetime',
|
||||
'rejected_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
public function election(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Election::class);
|
||||
}
|
||||
|
||||
public function pusatMengundi(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(PusatMengundi::class);
|
||||
}
|
||||
|
||||
public function selectedKtmAssignment(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(StaffAssignment::class, 'selected_ktm_assignment_id');
|
||||
}
|
||||
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
public function requestedPosition(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Position::class, 'requested_position_id');
|
||||
}
|
||||
|
||||
public function approvedPosition(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Position::class, 'approved_position_id');
|
||||
}
|
||||
|
||||
public function documents(): HasMany
|
||||
{
|
||||
return $this->hasMany(ApplicationDocument::class);
|
||||
}
|
||||
|
||||
public function statusHistories(): HasMany
|
||||
{
|
||||
return $this->hasMany(ApplicationStatusHistory::class);
|
||||
}
|
||||
|
||||
public function staffAssignments(): HasMany
|
||||
{
|
||||
return $this->hasMany(StaffAssignment::class);
|
||||
}
|
||||
|
||||
public function bankVerification(): HasOne
|
||||
{
|
||||
return $this->hasOne(BankVerification::class);
|
||||
}
|
||||
}
|
||||
37
app/Models/ApplicationDocument.php
Normal file
37
app/Models/ApplicationDocument.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class ApplicationDocument extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
public const TYPE_IC_DOCUMENT = 'ic_document';
|
||||
|
||||
public const TYPE_BANK_STATEMENT = 'bank_statement';
|
||||
|
||||
/** @var list<string> */
|
||||
public const ALLOWED_FOR_ADMIN = [self::TYPE_IC_DOCUMENT, self::TYPE_BANK_STATEMENT];
|
||||
|
||||
/** @var list<string> */
|
||||
public const ALLOWED_FOR_PPM = [self::TYPE_IC_DOCUMENT, self::TYPE_BANK_STATEMENT];
|
||||
|
||||
/** @var list<string> */
|
||||
public const ALLOWED_FOR_FINANCE = [self::TYPE_BANK_STATEMENT];
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
public function application(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Application::class);
|
||||
}
|
||||
|
||||
public function uploadedBy(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'uploaded_by_user_id');
|
||||
}
|
||||
}
|
||||
28
app/Models/ApplicationStatusHistory.php
Normal file
28
app/Models/ApplicationStatusHistory.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class ApplicationStatusHistory extends Model
|
||||
{
|
||||
protected $guarded = [];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'metadata' => 'array',
|
||||
];
|
||||
}
|
||||
|
||||
public function application(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Application::class);
|
||||
}
|
||||
|
||||
public function changedBy(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'changed_by_user_id');
|
||||
}
|
||||
}
|
||||
48
app/Models/Attendance.php
Normal file
48
app/Models/Attendance.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class Attendance extends Model
|
||||
{
|
||||
protected $guarded = [];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'check_in_time' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
public function election(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Election::class);
|
||||
}
|
||||
|
||||
public function staffAssignment(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(StaffAssignment::class);
|
||||
}
|
||||
|
||||
public function pusatMengundi(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(PusatMengundi::class);
|
||||
}
|
||||
|
||||
public function saluranMengundi(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(SaluranMengundi::class);
|
||||
}
|
||||
|
||||
public function position(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Position::class);
|
||||
}
|
||||
|
||||
public function recordedBy(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'recorded_by_user_id');
|
||||
}
|
||||
}
|
||||
28
app/Models/BahagianPilihanraya.php
Normal file
28
app/Models/BahagianPilihanraya.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Database\Factories\BahagianPilihanrayaFactory;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class BahagianPilihanraya extends Model
|
||||
{
|
||||
/** @use HasFactory<BahagianPilihanrayaFactory> */
|
||||
use HasFactory, SoftDeletes;
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
public function election(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Election::class);
|
||||
}
|
||||
|
||||
public function daerahMengundis(): HasMany
|
||||
{
|
||||
return $this->hasMany(DaerahMengundi::class);
|
||||
}
|
||||
}
|
||||
28
app/Models/BankVerification.php
Normal file
28
app/Models/BankVerification.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class BankVerification extends Model
|
||||
{
|
||||
protected $guarded = [];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'verified_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
public function application(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Application::class);
|
||||
}
|
||||
|
||||
public function verifiedBy(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'verified_by_user_id');
|
||||
}
|
||||
}
|
||||
33
app/Models/DaerahMengundi.php
Normal file
33
app/Models/DaerahMengundi.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Database\Factories\DaerahMengundiFactory;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class DaerahMengundi extends Model
|
||||
{
|
||||
/** @use HasFactory<DaerahMengundiFactory> */
|
||||
use HasFactory, SoftDeletes;
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
public function election(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Election::class);
|
||||
}
|
||||
|
||||
public function bahagianPilihanraya(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(BahagianPilihanraya::class);
|
||||
}
|
||||
|
||||
public function pusatMengundis(): HasMany
|
||||
{
|
||||
return $this->hasMany(PusatMengundi::class);
|
||||
}
|
||||
}
|
||||
28
app/Models/Dun.php
Normal file
28
app/Models/Dun.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Database\Factories\DunFactory;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Dun extends Model
|
||||
{
|
||||
/** @use HasFactory<DunFactory> */
|
||||
use HasFactory, SoftDeletes;
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
public function election(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Election::class);
|
||||
}
|
||||
|
||||
public function pusatMengundis(): HasMany
|
||||
{
|
||||
return $this->hasMany(PusatMengundi::class);
|
||||
}
|
||||
}
|
||||
66
app/Models/Election.php
Normal file
66
app/Models/Election.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Database\Factories\ElectionFactory;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Election extends Model
|
||||
{
|
||||
/** @use HasFactory<ElectionFactory> */
|
||||
use HasFactory, SoftDeletes;
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'starts_at' => 'date',
|
||||
'polling_date' => 'date',
|
||||
];
|
||||
}
|
||||
|
||||
public function settings(): HasOne
|
||||
{
|
||||
return $this->hasOne(ElectionSetting::class);
|
||||
}
|
||||
|
||||
public function duns(): HasMany
|
||||
{
|
||||
return $this->hasMany(Dun::class);
|
||||
}
|
||||
|
||||
public function bahagianPilihanrayas(): HasMany
|
||||
{
|
||||
return $this->hasMany(BahagianPilihanraya::class);
|
||||
}
|
||||
|
||||
public function daerahMengundis(): HasMany
|
||||
{
|
||||
return $this->hasMany(DaerahMengundi::class);
|
||||
}
|
||||
|
||||
public function pusatMengundis(): HasMany
|
||||
{
|
||||
return $this->hasMany(PusatMengundi::class);
|
||||
}
|
||||
|
||||
public function saluranMengundis(): HasMany
|
||||
{
|
||||
return $this->hasMany(SaluranMengundi::class);
|
||||
}
|
||||
|
||||
public function applications(): HasMany
|
||||
{
|
||||
return $this->hasMany(Application::class);
|
||||
}
|
||||
|
||||
public function staffAssignments(): HasMany
|
||||
{
|
||||
return $this->hasMany(StaffAssignment::class);
|
||||
}
|
||||
}
|
||||
28
app/Models/ElectionSetting.php
Normal file
28
app/Models/ElectionSetting.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class ElectionSetting extends Model
|
||||
{
|
||||
protected $guarded = [];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'registration_start_date' => 'date',
|
||||
'registration_end_date' => 'date',
|
||||
'polling_date' => 'date',
|
||||
'is_registration_open' => 'boolean',
|
||||
'is_registration_open_override' => 'boolean',
|
||||
'is_attendance_active' => 'boolean',
|
||||
];
|
||||
}
|
||||
|
||||
public function election(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Election::class);
|
||||
}
|
||||
}
|
||||
35
app/Models/ExportLog.php
Normal file
35
app/Models/ExportLog.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class ExportLog extends Model
|
||||
{
|
||||
protected $guarded = [];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'generated_at' => 'datetime',
|
||||
'filter_parameters' => 'array',
|
||||
'purged_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
public function election(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Election::class);
|
||||
}
|
||||
|
||||
public function generatedBy(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'generated_by_user_id');
|
||||
}
|
||||
|
||||
public function purgedBy(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'purged_by_user_id');
|
||||
}
|
||||
}
|
||||
24
app/Models/JkmRepresentative.php
Normal file
24
app/Models/JkmRepresentative.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class JkmRepresentative extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
public function election(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Election::class);
|
||||
}
|
||||
|
||||
public function pusatMengundi(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(PusatMengundi::class);
|
||||
}
|
||||
}
|
||||
24
app/Models/KkmRepresentative.php
Normal file
24
app/Models/KkmRepresentative.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class KkmRepresentative extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
public function election(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Election::class);
|
||||
}
|
||||
|
||||
public function pusatMengundi(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(PusatMengundi::class);
|
||||
}
|
||||
}
|
||||
29
app/Models/PoliceEscort.php
Normal file
29
app/Models/PoliceEscort.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class PoliceEscort extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
public function election(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Election::class);
|
||||
}
|
||||
|
||||
public function pusatMengundi(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(PusatMengundi::class);
|
||||
}
|
||||
|
||||
public function saluranMengundi(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(SaluranMengundi::class);
|
||||
}
|
||||
}
|
||||
41
app/Models/Position.php
Normal file
41
app/Models/Position.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Database\Factories\PositionFactory;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Position extends Model
|
||||
{
|
||||
/** @use HasFactory<PositionFactory> */
|
||||
use HasFactory, SoftDeletes;
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'is_public_applyable' => 'boolean',
|
||||
'is_assignable' => 'boolean',
|
||||
'allows_dual_role' => 'boolean',
|
||||
];
|
||||
}
|
||||
|
||||
public function quotas(): HasMany
|
||||
{
|
||||
return $this->hasMany(PositionQuota::class);
|
||||
}
|
||||
|
||||
public function applications(): HasMany
|
||||
{
|
||||
return $this->hasMany(Application::class, 'requested_position_id');
|
||||
}
|
||||
|
||||
public function staffAssignments(): HasMany
|
||||
{
|
||||
return $this->hasMany(StaffAssignment::class);
|
||||
}
|
||||
}
|
||||
34
app/Models/PositionQuota.php
Normal file
34
app/Models/PositionQuota.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class PositionQuota extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
public function election(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Election::class);
|
||||
}
|
||||
|
||||
public function pusatMengundi(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(PusatMengundi::class);
|
||||
}
|
||||
|
||||
public function saluranMengundi(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(SaluranMengundi::class);
|
||||
}
|
||||
|
||||
public function position(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Position::class);
|
||||
}
|
||||
}
|
||||
74
app/Models/PusatMengundi.php
Normal file
74
app/Models/PusatMengundi.php
Normal file
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Database\Factories\PusatMengundiFactory;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class PusatMengundi extends Model
|
||||
{
|
||||
/** @use HasFactory<PusatMengundiFactory> */
|
||||
use HasFactory, SoftDeletes;
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
public function election(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Election::class);
|
||||
}
|
||||
|
||||
public function dun(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Dun::class);
|
||||
}
|
||||
|
||||
public function daerahMengundi(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(DaerahMengundi::class);
|
||||
}
|
||||
|
||||
public function saluranMengundis(): HasMany
|
||||
{
|
||||
return $this->hasMany(SaluranMengundi::class);
|
||||
}
|
||||
|
||||
public function positionQuotas(): HasMany
|
||||
{
|
||||
return $this->hasMany(PositionQuota::class);
|
||||
}
|
||||
|
||||
public function applications(): HasMany
|
||||
{
|
||||
return $this->hasMany(Application::class);
|
||||
}
|
||||
|
||||
public function policeEscorts(): HasMany
|
||||
{
|
||||
return $this->hasMany(PoliceEscort::class);
|
||||
}
|
||||
|
||||
public function kkmRepresentatives(): HasMany
|
||||
{
|
||||
return $this->hasMany(KkmRepresentative::class);
|
||||
}
|
||||
|
||||
public function jkmRepresentatives(): HasMany
|
||||
{
|
||||
return $this->hasMany(JkmRepresentative::class);
|
||||
}
|
||||
|
||||
public function staffAssignments(): HasMany
|
||||
{
|
||||
return $this->hasMany(StaffAssignment::class);
|
||||
}
|
||||
|
||||
public function wheelchairAllocation(): HasOne
|
||||
{
|
||||
return $this->hasOne(WheelchairAllocation::class);
|
||||
}
|
||||
}
|
||||
38
app/Models/SaluranMengundi.php
Normal file
38
app/Models/SaluranMengundi.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Database\Factories\SaluranMengundiFactory;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class SaluranMengundi extends Model
|
||||
{
|
||||
/** @use HasFactory<SaluranMengundiFactory> */
|
||||
use HasFactory, SoftDeletes;
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
public function election(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Election::class);
|
||||
}
|
||||
|
||||
public function pusatMengundi(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(PusatMengundi::class);
|
||||
}
|
||||
|
||||
public function positionQuotas(): HasMany
|
||||
{
|
||||
return $this->hasMany(PositionQuota::class);
|
||||
}
|
||||
|
||||
public function staffAssignments(): HasMany
|
||||
{
|
||||
return $this->hasMany(StaffAssignment::class);
|
||||
}
|
||||
}
|
||||
76
app/Models/StaffAssignment.php
Normal file
76
app/Models/StaffAssignment.php
Normal file
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Database\Factories\StaffAssignmentFactory;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class StaffAssignment extends Model
|
||||
{
|
||||
/** @use HasFactory<StaffAssignmentFactory> */
|
||||
use HasFactory, SoftDeletes;
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'assigned_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
public function election(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Election::class);
|
||||
}
|
||||
|
||||
public function application(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Application::class);
|
||||
}
|
||||
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
public function position(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Position::class);
|
||||
}
|
||||
|
||||
public function pusatMengundi(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(PusatMengundi::class);
|
||||
}
|
||||
|
||||
public function saluranMengundi(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(SaluranMengundi::class);
|
||||
}
|
||||
|
||||
public function reportsTo(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(self::class, 'reports_to_assignment_id');
|
||||
}
|
||||
|
||||
public function teamMembers(): HasMany
|
||||
{
|
||||
return $this->hasMany(self::class, 'reports_to_assignment_id');
|
||||
}
|
||||
|
||||
public function histories(): HasMany
|
||||
{
|
||||
return $this->hasMany(StaffAssignmentHistory::class);
|
||||
}
|
||||
|
||||
public function attendance(): HasOne
|
||||
{
|
||||
return $this->hasOne(Attendance::class);
|
||||
}
|
||||
}
|
||||
21
app/Models/StaffAssignmentHistory.php
Normal file
21
app/Models/StaffAssignmentHistory.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class StaffAssignmentHistory extends Model
|
||||
{
|
||||
protected $guarded = [];
|
||||
|
||||
public function staffAssignment(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(StaffAssignment::class);
|
||||
}
|
||||
|
||||
public function changedBy(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'changed_by_user_id');
|
||||
}
|
||||
}
|
||||
27
app/Models/SystemNote.php
Normal file
27
app/Models/SystemNote.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||
|
||||
class SystemNote extends Model
|
||||
{
|
||||
protected $guarded = [];
|
||||
|
||||
public function election(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Election::class);
|
||||
}
|
||||
|
||||
public function noteable(): MorphTo
|
||||
{
|
||||
return $this->morphTo();
|
||||
}
|
||||
|
||||
public function createdBy(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'created_by_user_id');
|
||||
}
|
||||
}
|
||||
50
app/Models/User.php
Normal file
50
app/Models/User.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Database\Factories\UserFactory;
|
||||
use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Attributes\Hidden;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Spatie\Permission\Traits\HasRoles;
|
||||
|
||||
#[Fillable(['name', 'email', 'password'])]
|
||||
#[Hidden(['password', 'remember_token'])]
|
||||
class User extends Authenticatable implements MustVerifyEmail
|
||||
{
|
||||
/** @use HasFactory<UserFactory> */
|
||||
use HasFactory, HasRoles, Notifiable;
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'email_verified_at' => 'datetime',
|
||||
'password' => 'hashed',
|
||||
];
|
||||
}
|
||||
|
||||
public function profile(): HasOne
|
||||
{
|
||||
return $this->hasOne(UserProfile::class);
|
||||
}
|
||||
|
||||
public function applications(): HasMany
|
||||
{
|
||||
return $this->hasMany(Application::class);
|
||||
}
|
||||
|
||||
public function staffAssignments(): HasMany
|
||||
{
|
||||
return $this->hasMany(StaffAssignment::class);
|
||||
}
|
||||
}
|
||||
16
app/Models/UserProfile.php
Normal file
16
app/Models/UserProfile.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class UserProfile extends Model
|
||||
{
|
||||
protected $guarded = [];
|
||||
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
}
|
||||
27
app/Models/WheelchairAllocation.php
Normal file
27
app/Models/WheelchairAllocation.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class WheelchairAllocation extends Model
|
||||
{
|
||||
protected $guarded = [];
|
||||
|
||||
public function election(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Election::class);
|
||||
}
|
||||
|
||||
public function pusatMengundi(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(PusatMengundi::class);
|
||||
}
|
||||
|
||||
public function transactions(): HasMany
|
||||
{
|
||||
return $this->hasMany(WheelchairTransaction::class);
|
||||
}
|
||||
}
|
||||
29
app/Models/WheelchairTransaction.php
Normal file
29
app/Models/WheelchairTransaction.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class WheelchairTransaction extends Model
|
||||
{
|
||||
protected $guarded = [];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'taken_at' => 'datetime',
|
||||
'returned_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
public function allocation(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(WheelchairAllocation::class, 'wheelchair_allocation_id');
|
||||
}
|
||||
|
||||
public function recordedBy(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'recorded_by_user_id');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user