first commit
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
<?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',
|
||||
'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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user