52 lines
1002 B
PHP
52 lines
1002 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
/**
|
|
* @mixin IdeHelperRequestedQuote
|
|
*/
|
|
class RequestedQuote extends Model
|
|
{
|
|
use SoftDeletes;
|
|
|
|
protected $fillable = [
|
|
'quote',
|
|
'user_id',
|
|
];
|
|
|
|
public function logs(): hasMany
|
|
{
|
|
return $this->hasMany(Log::class);
|
|
}
|
|
|
|
public function approve(): void
|
|
{
|
|
Log::create([
|
|
'user_id' => auth()?->user()?->id,
|
|
'requested_quote_id' => $this->id,
|
|
'content' => 'Quote approved.',
|
|
]);
|
|
|
|
Quote::create([
|
|
'quote' => $this->quote,
|
|
]);
|
|
|
|
$this->delete();
|
|
}
|
|
|
|
public function reject(): void
|
|
{
|
|
Log::create([
|
|
'user_id' => auth()?->user()?->id,
|
|
'requested_quote_id' => $this->id,
|
|
'content' => 'Quote rejected.',
|
|
]);
|
|
|
|
$this->delete();
|
|
}
|
|
}
|