Initial commit
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class AcademicYear extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'start_year',
|
||||
'end_year',
|
||||
'is_active',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'is_active' => 'boolean',
|
||||
];
|
||||
}
|
||||
|
||||
public function classes(): HasMany
|
||||
{
|
||||
return $this->hasMany(SchoolClass::class);
|
||||
}
|
||||
|
||||
public function students(): HasMany
|
||||
{
|
||||
return $this->hasMany(Student::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class AppSetting extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'key',
|
||||
'value',
|
||||
];
|
||||
|
||||
public static function getValue(string $key, mixed $default = null): mixed
|
||||
{
|
||||
return static::query()->where('key', $key)->value('value') ?? $default;
|
||||
}
|
||||
|
||||
public static function setValue(string $key, mixed $value): void
|
||||
{
|
||||
static::query()->updateOrCreate(
|
||||
['key' => $key],
|
||||
['value' => $value]
|
||||
);
|
||||
}
|
||||
|
||||
public static function brandingDefaults(): array
|
||||
{
|
||||
return [
|
||||
'app_name' => 'Database Kesiswaan',
|
||||
'app_short_name' => 'DK',
|
||||
'app_logo' => null,
|
||||
'app_favicon' => null,
|
||||
'public_portal_logo' => null,
|
||||
];
|
||||
}
|
||||
|
||||
public static function branding(): array
|
||||
{
|
||||
$defaults = static::brandingDefaults();
|
||||
|
||||
foreach (array_keys($defaults) as $key) {
|
||||
$defaults[$key] = static::getValue($key, $defaults[$key]);
|
||||
}
|
||||
|
||||
return $defaults;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class Department extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'code',
|
||||
'name',
|
||||
'description',
|
||||
'is_active',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'is_active' => 'boolean',
|
||||
];
|
||||
}
|
||||
|
||||
public function classes(): HasMany
|
||||
{
|
||||
return $this->hasMany(SchoolClass::class);
|
||||
}
|
||||
|
||||
public function students(): HasMany
|
||||
{
|
||||
return $this->hasMany(Student::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class District extends Model
|
||||
{
|
||||
public $incrementing = false;
|
||||
protected $keyType = 'string';
|
||||
|
||||
protected $fillable = ['id', 'regency_id', 'name'];
|
||||
|
||||
public function regency(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Regency::class);
|
||||
}
|
||||
|
||||
public function villages(): HasMany
|
||||
{
|
||||
return $this->hasMany(Village::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class DocumentType extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'code',
|
||||
'name',
|
||||
'description',
|
||||
'max_file_size_kb',
|
||||
'allowed_extensions',
|
||||
'is_required',
|
||||
'is_active',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'max_file_size_kb' => 'integer',
|
||||
'is_required' => 'boolean',
|
||||
'is_active' => 'boolean',
|
||||
];
|
||||
}
|
||||
|
||||
public function studentDocuments(): HasMany
|
||||
{
|
||||
return $this->hasMany(StudentDocument::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class Province extends Model
|
||||
{
|
||||
public $incrementing = false;
|
||||
protected $keyType = 'string';
|
||||
|
||||
protected $fillable = ['id', 'name'];
|
||||
|
||||
public function regencies(): HasMany
|
||||
{
|
||||
return $this->hasMany(Regency::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class Regency extends Model
|
||||
{
|
||||
public $incrementing = false;
|
||||
protected $keyType = 'string';
|
||||
|
||||
protected $fillable = ['id', 'province_id', 'name'];
|
||||
|
||||
public function province(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Province::class);
|
||||
}
|
||||
|
||||
public function districts(): HasMany
|
||||
{
|
||||
return $this->hasMany(District::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class SchoolClass extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'classes';
|
||||
|
||||
protected $fillable = [
|
||||
'academic_year_id',
|
||||
'department_id',
|
||||
'name',
|
||||
'level',
|
||||
'homeroom_teacher',
|
||||
'capacity',
|
||||
'is_active',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'capacity' => 'integer',
|
||||
'is_active' => 'boolean',
|
||||
];
|
||||
}
|
||||
|
||||
public function academicYear(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(AcademicYear::class);
|
||||
}
|
||||
|
||||
public function department(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Department::class);
|
||||
}
|
||||
|
||||
public function students(): HasMany
|
||||
{
|
||||
return $this->hasMany(Student::class, 'class_id');
|
||||
}
|
||||
|
||||
public function academicHistories(): HasMany
|
||||
{
|
||||
return $this->hasMany(StudentAcademicHistory::class, 'class_id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
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 Student extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
use SoftDeletes;
|
||||
|
||||
protected static function booted(): void
|
||||
{
|
||||
static::deleting(function (Student $student) {
|
||||
if ($student->isForceDeleting()) {
|
||||
$student->documents()->withTrashed()->get()->each->forceDelete();
|
||||
$student->parents()->delete();
|
||||
$student->academicHistories()->delete();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$student->documents()->get()->each->delete();
|
||||
$student->parents()->delete();
|
||||
});
|
||||
|
||||
static::restoring(function (Student $student) {
|
||||
$student->documents()->onlyTrashed()->restore();
|
||||
});
|
||||
}
|
||||
|
||||
protected $fillable = [
|
||||
'student_number',
|
||||
'nisn',
|
||||
'full_name',
|
||||
'gender',
|
||||
'place_of_birth',
|
||||
'date_of_birth',
|
||||
'religion',
|
||||
'nationality',
|
||||
'family_card_number',
|
||||
'child_order',
|
||||
'number_of_siblings',
|
||||
'phone_number',
|
||||
'email',
|
||||
'address',
|
||||
'province_id',
|
||||
'regency_id',
|
||||
'district_id',
|
||||
'village_id',
|
||||
'village',
|
||||
'district',
|
||||
'city',
|
||||
'province',
|
||||
'postal_code',
|
||||
'academic_year_id',
|
||||
'department_id',
|
||||
'class_id',
|
||||
'entry_date',
|
||||
'status',
|
||||
'self_service_status',
|
||||
'self_service_last_access_at',
|
||||
'self_service_submitted_at',
|
||||
'self_service_access_code',
|
||||
'self_service_code_generated_at',
|
||||
'photo_path',
|
||||
'notes',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'date_of_birth' => 'date',
|
||||
'entry_date' => 'date',
|
||||
'self_service_last_access_at' => 'datetime',
|
||||
'self_service_submitted_at' => 'datetime',
|
||||
'self_service_code_generated_at' => 'datetime',
|
||||
'child_order' => 'integer',
|
||||
'number_of_siblings' => 'integer',
|
||||
];
|
||||
}
|
||||
|
||||
public function academicYear(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(AcademicYear::class);
|
||||
}
|
||||
|
||||
public function department(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Department::class);
|
||||
}
|
||||
|
||||
public function classRoom(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(SchoolClass::class, 'class_id');
|
||||
}
|
||||
|
||||
public function provinceRef(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Province::class, 'province_id');
|
||||
}
|
||||
|
||||
public function regencyRef(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Regency::class, 'regency_id');
|
||||
}
|
||||
|
||||
public function districtRef(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(District::class, 'district_id');
|
||||
}
|
||||
|
||||
public function villageRef(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Village::class, 'village_id');
|
||||
}
|
||||
|
||||
public function parents(): HasMany
|
||||
{
|
||||
return $this->hasMany(StudentParent::class);
|
||||
}
|
||||
|
||||
public function documents(): HasMany
|
||||
{
|
||||
return $this->hasMany(StudentDocument::class);
|
||||
}
|
||||
|
||||
public function academicHistories(): HasMany
|
||||
{
|
||||
return $this->hasMany(StudentAcademicHistory::class)->latest('academic_year_id');
|
||||
}
|
||||
|
||||
public function exitRecord(): HasOne
|
||||
{
|
||||
return $this->hasOne(StudentExit::class);
|
||||
}
|
||||
|
||||
public function transferRecord(): HasOne
|
||||
{
|
||||
return $this->hasOne(StudentTransfer::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class StudentAcademicHistory extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'student_id',
|
||||
'academic_year_id',
|
||||
'department_id',
|
||||
'class_id',
|
||||
'status',
|
||||
'start_date',
|
||||
'end_date',
|
||||
'notes',
|
||||
'is_current',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'start_date' => 'date',
|
||||
'end_date' => 'date',
|
||||
'is_current' => 'boolean',
|
||||
];
|
||||
}
|
||||
|
||||
public function student(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Student::class);
|
||||
}
|
||||
|
||||
public function academicYear(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(AcademicYear::class);
|
||||
}
|
||||
|
||||
public function department(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Department::class);
|
||||
}
|
||||
|
||||
public function classRoom(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(SchoolClass::class, 'class_id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class StudentDocument extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'student_id',
|
||||
'document_type_id',
|
||||
'file_name',
|
||||
'file_path',
|
||||
'file_extension',
|
||||
'mime_type',
|
||||
'file_size',
|
||||
'document_number',
|
||||
'issued_date',
|
||||
'expired_date',
|
||||
'description',
|
||||
'verification_status',
|
||||
'verification_note',
|
||||
'uploaded_by',
|
||||
'verified_by',
|
||||
'verified_at',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'file_size' => 'integer',
|
||||
'issued_date' => 'date',
|
||||
'expired_date' => 'date',
|
||||
'verified_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
public function student(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Student::class);
|
||||
}
|
||||
|
||||
public function documentType(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(DocumentType::class);
|
||||
}
|
||||
|
||||
public function uploadedBy(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'uploaded_by');
|
||||
}
|
||||
|
||||
public function verifiedBy(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'verified_by');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class StudentExit extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'student_id',
|
||||
'student_number',
|
||||
'nisn',
|
||||
'full_name',
|
||||
'academic_year_id',
|
||||
'department_id',
|
||||
'class_id',
|
||||
'entry_date',
|
||||
'exit_date',
|
||||
'exit_reason',
|
||||
'exit_letter_file_name',
|
||||
'exit_letter_file_path',
|
||||
'exit_letter_mime_type',
|
||||
'exit_letter_file_size',
|
||||
'status',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'entry_date' => 'date',
|
||||
'exit_date' => 'date',
|
||||
];
|
||||
}
|
||||
|
||||
public function student(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Student::class);
|
||||
}
|
||||
|
||||
public function academicYear(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(AcademicYear::class);
|
||||
}
|
||||
|
||||
public function department(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Department::class);
|
||||
}
|
||||
|
||||
public function classRoom(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(SchoolClass::class, 'class_id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class StudentParent extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'student_id',
|
||||
'relation_type',
|
||||
'name',
|
||||
'nik',
|
||||
'birth_year',
|
||||
'education',
|
||||
'occupation',
|
||||
'phone_number',
|
||||
'address',
|
||||
'is_alive',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'birth_year' => 'integer',
|
||||
'is_alive' => 'boolean',
|
||||
];
|
||||
}
|
||||
|
||||
public function student(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Student::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class StudentTransfer extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'student_id',
|
||||
'student_number',
|
||||
'nisn',
|
||||
'full_name',
|
||||
'academic_year_id',
|
||||
'department_id',
|
||||
'class_id',
|
||||
'entry_date',
|
||||
'transfer_date',
|
||||
'transfer_reason',
|
||||
'transfer_letter_file_name',
|
||||
'transfer_letter_file_path',
|
||||
'transfer_letter_mime_type',
|
||||
'transfer_letter_file_size',
|
||||
'status',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'entry_date' => 'date',
|
||||
'transfer_date' => 'date',
|
||||
];
|
||||
}
|
||||
|
||||
public function student(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Student::class);
|
||||
}
|
||||
|
||||
public function academicYear(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(AcademicYear::class);
|
||||
}
|
||||
|
||||
public function department(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Department::class);
|
||||
}
|
||||
|
||||
public function classRoom(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(SchoolClass::class, 'class_id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
// use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use Database\Factories\UserFactory;
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Attributes\Hidden;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
|
||||
#[Fillable(['name', 'email', 'role', 'password'])]
|
||||
#[Hidden(['password', 'remember_token'])]
|
||||
class User extends Authenticatable
|
||||
{
|
||||
/** @use HasFactory<UserFactory> */
|
||||
use HasFactory, Notifiable;
|
||||
|
||||
public function isAdmin(): bool
|
||||
{
|
||||
return $this->role === 'admin';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'email_verified_at' => 'datetime',
|
||||
'password' => 'hashed',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class Village extends Model
|
||||
{
|
||||
public $incrementing = false;
|
||||
protected $keyType = 'string';
|
||||
|
||||
protected $fillable = ['id', 'district_id', 'name'];
|
||||
|
||||
public function district(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(District::class);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user