81 lines
1.9 KiB
PHP
Executable File
81 lines
1.9 KiB
PHP
Executable File
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
class Transaction extends Model
|
|
{
|
|
use HasFactory, SoftDeletes;
|
|
protected $fillable = [
|
|
"user_id", "user_sa_id", "work_id", "form", "spk", "police_number", "warranty", "date", "qty", "status", "dealer_id",
|
|
"claimed_at", "claimed_by"
|
|
];
|
|
|
|
protected $casts = [
|
|
'claimed_at' => 'datetime',
|
|
];
|
|
|
|
/**
|
|
* Get the work associated with the Transaction
|
|
*
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
*/
|
|
public function work()
|
|
{
|
|
return $this->belongsTo(Work::class, 'work_id', 'id');
|
|
}
|
|
|
|
/**
|
|
* Get the dealer associated with the Transaction
|
|
*
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
*/
|
|
public function dealer()
|
|
{
|
|
return $this->belongsTo(Dealer::class);
|
|
}
|
|
|
|
/**
|
|
* Get the user who created the transaction
|
|
*
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
*/
|
|
public function user()
|
|
{
|
|
return $this->belongsTo(User::class);
|
|
}
|
|
|
|
/**
|
|
* Get the SA user associated with the transaction
|
|
*
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
*/
|
|
public function userSa()
|
|
{
|
|
return $this->belongsTo(User::class, 'user_sa_id');
|
|
}
|
|
|
|
/**
|
|
* Get the precheck associated with the transaction
|
|
*
|
|
* @return \Illuminate\Database\Eloquent\Relations\HasOne
|
|
*/
|
|
public function precheck()
|
|
{
|
|
return $this->hasOne(Precheck::class);
|
|
}
|
|
|
|
/**
|
|
* Get the postcheck associated with the transaction
|
|
*
|
|
* @return \Illuminate\Database\Eloquent\Relations\HasOne
|
|
*/
|
|
public function postcheck()
|
|
{
|
|
return $this->hasOne(Postcheck::class);
|
|
}
|
|
}
|