first commit
This commit is contained in:
38
app/Models/Jabatan.php
Normal file
38
app/Models/Jabatan.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Spatie\Activitylog\LogOptions;
|
||||
use Spatie\Activitylog\Traits\LogsActivity;
|
||||
|
||||
class Jabatan extends Model
|
||||
{
|
||||
use HasFactory, LogsActivity, SoftDeletes;
|
||||
|
||||
protected $table = 'jabatan';
|
||||
|
||||
protected $fillable = ['nama', 'peringkat', 'kod', 'penerangan', 'status'];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return ['status' => 'boolean'];
|
||||
}
|
||||
|
||||
public function getActivitylogOptions(): LogOptions
|
||||
{
|
||||
return LogOptions::defaults()->logFillable()->logOnlyDirty();
|
||||
}
|
||||
|
||||
public function vot()
|
||||
{
|
||||
return $this->hasMany(Vot::class, 'jabatan_id');
|
||||
}
|
||||
|
||||
public function users()
|
||||
{
|
||||
return $this->hasMany(User::class, 'jabatan_id');
|
||||
}
|
||||
}
|
||||
44
app/Models/Permohonan.php
Normal file
44
app/Models/Permohonan.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Spatie\Activitylog\LogOptions;
|
||||
use Spatie\Activitylog\Traits\LogsActivity;
|
||||
|
||||
class Permohonan extends Model
|
||||
{
|
||||
use HasFactory, LogsActivity;
|
||||
|
||||
protected $table = 'permohonan';
|
||||
|
||||
protected $fillable = [
|
||||
'no_rujukan', 'user_id', 'jabatan_id', 'vot_id', 'kategori', 'tujuan',
|
||||
'jumlah_keseluruhan', 'status', 'catatan', 'gambar_1', 'gambar_2',
|
||||
'status_semakan', 'catatan_semakan', 'reviewed_by', 'reviewed_at',
|
||||
'approved_by', 'approved_at', 'submitted_at',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'jumlah_keseluruhan' => 'decimal:2',
|
||||
'submitted_at' => 'datetime',
|
||||
'reviewed_at' => 'datetime',
|
||||
'approved_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
public function getActivitylogOptions(): LogOptions
|
||||
{
|
||||
return LogOptions::defaults()->logFillable()->logOnlyDirty();
|
||||
}
|
||||
|
||||
public function user() { return $this->belongsTo(User::class); }
|
||||
public function jabatan() { return $this->belongsTo(Jabatan::class, 'jabatan_id'); }
|
||||
public function vot() { return $this->belongsTo(Vot::class, 'vot_id'); }
|
||||
public function items() { return $this->hasMany(PermohonanItem::class, 'permohonan_id'); }
|
||||
public function reviewer() { return $this->belongsTo(User::class, 'reviewed_by'); }
|
||||
public function approver() { return $this->belongsTo(User::class, 'approved_by'); }
|
||||
}
|
||||
26
app/Models/PermohonanItem.php
Normal file
26
app/Models/PermohonanItem.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class PermohonanItem extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'permohonan_id', 'item', 'kuantiti', 'harga_anggaran', 'jumlah',
|
||||
'status_item', 'catatan_pelaksana',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return ['harga_anggaran' => 'decimal:2', 'jumlah' => 'decimal:2'];
|
||||
}
|
||||
|
||||
public function permohonan()
|
||||
{
|
||||
return $this->belongsTo(Permohonan::class, 'permohonan_id');
|
||||
}
|
||||
}
|
||||
67
app/Models/User.php
Normal file
67
app/Models/User.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
// use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use Database\Factories\UserFactory;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Spatie\Permission\Traits\HasRoles;
|
||||
|
||||
class User extends Authenticatable
|
||||
{
|
||||
/** @use HasFactory<UserFactory> */
|
||||
use HasFactory, HasRoles, Notifiable;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var list<string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'email',
|
||||
'no_telefon',
|
||||
'jawatan',
|
||||
'jabatan_id',
|
||||
'status',
|
||||
'last_login_at',
|
||||
'password',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be hidden for serialization.
|
||||
*
|
||||
* @var list<string>
|
||||
*/
|
||||
protected $hidden = [
|
||||
'password',
|
||||
'remember_token',
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'email_verified_at' => 'datetime',
|
||||
'last_login_at' => 'datetime',
|
||||
'status' => 'boolean',
|
||||
'password' => 'hashed',
|
||||
];
|
||||
}
|
||||
|
||||
public function jabatan()
|
||||
{
|
||||
return $this->belongsTo(Jabatan::class, 'jabatan_id');
|
||||
}
|
||||
|
||||
public function permohonan()
|
||||
{
|
||||
return $this->hasMany(Permohonan::class);
|
||||
}
|
||||
}
|
||||
32
app/Models/Vot.php
Normal file
32
app/Models/Vot.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Spatie\Activitylog\LogOptions;
|
||||
use Spatie\Activitylog\Traits\LogsActivity;
|
||||
|
||||
class Vot extends Model
|
||||
{
|
||||
use HasFactory, LogsActivity;
|
||||
|
||||
protected $table = 'vot';
|
||||
|
||||
protected $fillable = ['kod', 'nama', 'jabatan_id', 'penerangan', 'status'];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return ['status' => 'boolean'];
|
||||
}
|
||||
|
||||
public function getActivitylogOptions(): LogOptions
|
||||
{
|
||||
return LogOptions::defaults()->logFillable()->logOnlyDirty();
|
||||
}
|
||||
|
||||
public function jabatan()
|
||||
{
|
||||
return $this->belongsTo(Jabatan::class, 'jabatan_id');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user