2026-06-27 14:38:18 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @property int $id
|
|
|
|
|
* @property int $character_id
|
|
|
|
|
* @property int $crime_id
|
|
|
|
|
* @property bool $success
|
|
|
|
|
* @property int $reward
|
|
|
|
|
* @property int $experience_gained
|
|
|
|
|
* @property \Illuminate\Support\Carbon $attempted_at
|
|
|
|
|
*/
|
|
|
|
|
class CrimeAttempt extends Model
|
|
|
|
|
{
|
|
|
|
|
use HasFactory;
|
|
|
|
|
|
|
|
|
|
protected $fillable = [
|
|
|
|
|
'character_id',
|
|
|
|
|
'crime_id',
|
|
|
|
|
'success',
|
|
|
|
|
'reward',
|
|
|
|
|
'experience_gained',
|
2026-06-28 15:52:41 +03:00
|
|
|
'nerve_cost',
|
2026-06-27 14:38:18 +03:00
|
|
|
'attempted_at',
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
protected $casts = [
|
|
|
|
|
'success' => 'boolean',
|
|
|
|
|
'attempted_at' => 'datetime',
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
public $timestamps = false;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the character who attempted this crime.
|
|
|
|
|
*/
|
|
|
|
|
public function character(): BelongsTo
|
|
|
|
|
{
|
|
|
|
|
return $this->belongsTo(Character::class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the crime that was attempted.
|
|
|
|
|
*/
|
|
|
|
|
public function crime(): BelongsTo
|
|
|
|
|
{
|
|
|
|
|
return $this->belongsTo(Crime::class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Check if the crime was successful
|
|
|
|
|
*/
|
|
|
|
|
public function isSuccessful(): bool
|
|
|
|
|
{
|
|
|
|
|
return $this->success;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Check if the crime failed
|
|
|
|
|
*/
|
|
|
|
|
public function isFailed(): bool
|
|
|
|
|
{
|
|
|
|
|
return !$this->success;
|
|
|
|
|
}
|
|
|
|
|
}
|