56 lines
1.3 KiB
PHP
56 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Carbon\Carbon;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class Pickup extends Model
|
|
{
|
|
use HasFactory;
|
|
protected $table = 'pickup';
|
|
protected $primaryKey = 'kode_pu';
|
|
public $incrementing = false;
|
|
|
|
protected $fillable = [
|
|
'id_customer',
|
|
'id_pegawai',
|
|
'status_penjemputan',
|
|
'bukti_pengiriman',
|
|
'image_path',
|
|
'image_bukti',
|
|
'keterangan',
|
|
'biaya',
|
|
'metode_pembayaran',
|
|
'penambahan_biaya',
|
|
'detail_biaya'
|
|
];
|
|
|
|
// Relationship dengan tabel User (sebagai customer)
|
|
public function user()
|
|
{
|
|
return $this->belongsTo(User::class, 'id_customer', 'id_user');
|
|
}
|
|
|
|
public function customer()
|
|
{
|
|
return $this->belongsTo(User::class, 'id_customer', 'id_user');
|
|
}
|
|
|
|
public function checkboxOptions()
|
|
{
|
|
return $this->hasMany(Items::class, 'kode_pu', 'kode_pu');
|
|
}
|
|
|
|
public function getFormattedCreatedAtAttribute()
|
|
{
|
|
return Carbon::parse($this->attributes['created_at'])->format('Y-m-d H:i');
|
|
}
|
|
|
|
public function getFormattedUpdatedAtAttribute()
|
|
{
|
|
return Carbon::parse($this->attributes['updated_at'])->format('Y-m-d H:i');
|
|
}
|
|
}
|