51 lines
1.1 KiB
PHP
51 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
/**
|
|
* @mixin IdeHelperQuote
|
|
*/
|
|
class Quote extends Model
|
|
{
|
|
use SoftDeletes;
|
|
|
|
public function request(): void
|
|
{
|
|
// Send the quote
|
|
// If success, add it to the transactions
|
|
|
|
Log::create([
|
|
'user_id' => auth()?->user()?->id,
|
|
'quote_id' => $this->id,
|
|
'content' => 'Quote requested.'
|
|
]);
|
|
}
|
|
protected $fillable = [
|
|
'quote',
|
|
];
|
|
|
|
public static function boot(): void
|
|
{
|
|
parent::boot();
|
|
|
|
self::created(function ($model) {
|
|
Log::create([
|
|
'user_id' => auth()?->user()?->id,
|
|
'quote_id' => $model->id,
|
|
'content' => 'Quote created.'
|
|
]);
|
|
});
|
|
|
|
self::deleted(function ($model) {
|
|
Log::create([
|
|
'user_id' => auth()?->user()?->id,
|
|
'quote_id' => $model->id,
|
|
'content' => 'Quote deleted.'
|
|
]);
|
|
});
|
|
}
|
|
}
|