Tambah tabel dan model Authorization
- Menambahkan migrasi untuk tabel "authorizations" guna menyimpan data otorisasi terkait permohonan. - Membuat model Authorization dengan relasi ke tabel Permohonan dan Users. - Menyediakan cast dan properti fillable untuk mempermudah manipulasi data.
This commit is contained in:
59
app/Models/Authorization.php
Normal file
59
app/Models/Authorization.php
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
|
use Modules\Usermanagement\Models\User;
|
||||||
|
|
||||||
|
class Authorization extends Model
|
||||||
|
{
|
||||||
|
protected $table = 'authorizations';
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'permohonan_id',
|
||||||
|
'jenis',
|
||||||
|
'approve_so',
|
||||||
|
'status_so',
|
||||||
|
'keterangan_so',
|
||||||
|
'approve_so_at',
|
||||||
|
'approve_eo',
|
||||||
|
'status_eo',
|
||||||
|
'keterangan_eo',
|
||||||
|
'approve_eo_at',
|
||||||
|
'approve_dd',
|
||||||
|
'status_dd',
|
||||||
|
'keterangan_dd',
|
||||||
|
'approve_dd_at',
|
||||||
|
'status',
|
||||||
|
'keterangan',
|
||||||
|
'request',
|
||||||
|
'alasan',
|
||||||
|
'user_id',
|
||||||
|
];
|
||||||
|
|
||||||
|
protected $casts = [
|
||||||
|
'approve_so' => 'boolean',
|
||||||
|
'approve_eo' => 'boolean',
|
||||||
|
'approve_dd' => 'boolean',
|
||||||
|
'approve_so_at' => 'datetime',
|
||||||
|
'approve_eo_at' => 'datetime',
|
||||||
|
'approve_dd_at' => 'datetime',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the permohonan that owns the authorization.
|
||||||
|
*/
|
||||||
|
public function permohonan(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Permohonan::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the user that owns the authorization.
|
||||||
|
*/
|
||||||
|
public function user(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(User::class);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('authorizations', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->foreignId('permohonan_id')->constrained('permohonan')->onDelete('cascade');
|
||||||
|
$table->string('jenis');
|
||||||
|
|
||||||
|
// SO fields
|
||||||
|
$table->boolean('approve_so')->default(false);
|
||||||
|
$table->string('status_so')->nullable();
|
||||||
|
$table->text('keterangan_so')->nullable();
|
||||||
|
$table->timestamp('approve_so_at')->nullable();
|
||||||
|
|
||||||
|
// EO fields
|
||||||
|
$table->boolean('approve_eo')->default(false);
|
||||||
|
$table->string('status_eo')->nullable();
|
||||||
|
$table->text('keterangan_eo')->nullable();
|
||||||
|
$table->timestamp('approve_eo_at')->nullable();
|
||||||
|
|
||||||
|
// DD fields
|
||||||
|
$table->boolean('approve_dd')->default(false);
|
||||||
|
$table->string('status_dd')->nullable();
|
||||||
|
$table->text('keterangan_dd')->nullable();
|
||||||
|
$table->timestamp('approve_dd_at')->nullable();
|
||||||
|
|
||||||
|
$table->string('status')->nullable();
|
||||||
|
$table->text('keterangan')->nullable();
|
||||||
|
$table->text('request')->nullable();
|
||||||
|
$table->text('alasan')->nullable();
|
||||||
|
$table->foreignId('user_id')->nullable()->constrained('users')->onDelete('set null');
|
||||||
|
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('authorizations');
|
||||||
|
}
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user