feat: establish reservation portal foundation
This commit is contained in:
23
app/Domain/Reservations/Models/AssetBlock.php
Normal file
23
app/Domain/Reservations/Models/AssetBlock.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Reservations\Models;
|
||||
|
||||
use App\Domain\Inventory\Models\SnipeAsset;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class AssetBlock extends Model
|
||||
{
|
||||
protected $fillable = ['snipe_asset_id', 'starts_at', 'ends_at', 'reason', 'created_by'];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return ['starts_at' => 'immutable_datetime', 'ends_at' => 'immutable_datetime'];
|
||||
}
|
||||
|
||||
/** @return BelongsTo<SnipeAsset, $this> */
|
||||
public function asset(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(SnipeAsset::class, 'snipe_asset_id');
|
||||
}
|
||||
}
|
||||
53
app/Domain/Reservations/Models/Reservation.php
Normal file
53
app/Domain/Reservations/Models/Reservation.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Reservations\Models;
|
||||
|
||||
use App\Domain\Reservations\Enums\ReservationStatus;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Concerns\HasUuids;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class Reservation extends Model
|
||||
{
|
||||
use HasUuids;
|
||||
|
||||
protected $fillable = [
|
||||
'uuid', 'reference', 'requester_id', 'purpose', 'usage_location', 'starts_at',
|
||||
'ends_at', 'status', 'approval_deadline', 'approved_by', 'approved_at',
|
||||
'rejected_by', 'rejected_at', 'decision_reason', 'cancelled_by',
|
||||
'cancelled_at', 'cancellation_reason',
|
||||
];
|
||||
|
||||
/** @return list<string> */
|
||||
public function uniqueIds(): array
|
||||
{
|
||||
return ['uuid'];
|
||||
}
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'status' => ReservationStatus::class,
|
||||
'starts_at' => 'immutable_datetime',
|
||||
'ends_at' => 'immutable_datetime',
|
||||
'approval_deadline' => 'immutable_datetime',
|
||||
'approved_at' => 'immutable_datetime',
|
||||
'rejected_at' => 'immutable_datetime',
|
||||
'cancelled_at' => 'immutable_datetime',
|
||||
];
|
||||
}
|
||||
|
||||
/** @return BelongsTo<User, $this> */
|
||||
public function requester(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'requester_id');
|
||||
}
|
||||
|
||||
/** @return HasMany<ReservationItem, $this> */
|
||||
public function items(): HasMany
|
||||
{
|
||||
return $this->hasMany(ReservationItem::class);
|
||||
}
|
||||
}
|
||||
40
app/Domain/Reservations/Models/ReservationItem.php
Normal file
40
app/Domain/Reservations/Models/ReservationItem.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Reservations\Models;
|
||||
|
||||
use App\Domain\Inventory\Models\SnipeAsset;
|
||||
use App\Domain\Reservations\Enums\ReservationItemStatus;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class ReservationItem extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'reservation_id', 'snipe_asset_id', 'starts_at', 'ends_at', 'status',
|
||||
'delivered_at', 'returned_at', 'checkout_reference', 'checkin_reference',
|
||||
'condition_out', 'condition_in', 'notes',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'status' => ReservationItemStatus::class,
|
||||
'starts_at' => 'immutable_datetime',
|
||||
'ends_at' => 'immutable_datetime',
|
||||
'delivered_at' => 'immutable_datetime',
|
||||
'returned_at' => 'immutable_datetime',
|
||||
];
|
||||
}
|
||||
|
||||
/** @return BelongsTo<Reservation, $this> */
|
||||
public function reservation(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Reservation::class);
|
||||
}
|
||||
|
||||
/** @return BelongsTo<SnipeAsset, $this> */
|
||||
public function asset(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(SnipeAsset::class, 'snipe_asset_id');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user