feat: implement proposal management system including database schema, Filament resources, and client-facing preview views
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class Proposal extends Model
|
||||
{
|
||||
use HasFactory, SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'uuid',
|
||||
'slug',
|
||||
'title',
|
||||
'client_name',
|
||||
'client_email',
|
||||
'content',
|
||||
'total_price',
|
||||
'currency',
|
||||
'status',
|
||||
'valid_until',
|
||||
'client_feedback',
|
||||
'accepted_name',
|
||||
'accepted_at',
|
||||
'views_count',
|
||||
'meta',
|
||||
'created_by',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'valid_until' => 'date',
|
||||
'accepted_at' => 'datetime',
|
||||
'meta' => 'array',
|
||||
'views_count' => 'integer',
|
||||
'total_price' => 'decimal:2',
|
||||
];
|
||||
|
||||
protected static function boot()
|
||||
{
|
||||
parent::boot();
|
||||
|
||||
static::creating(function ($proposal) {
|
||||
if (empty($proposal->uuid)) {
|
||||
$proposal->uuid = (string) Str::uuid();
|
||||
}
|
||||
if (empty($proposal->created_by) && auth()->check()) {
|
||||
$proposal->created_by = auth()->id();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the user who created the proposal.
|
||||
*/
|
||||
public function creator()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'created_by');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the public url for the proposal.
|
||||
*/
|
||||
public function getUrlAttribute()
|
||||
{
|
||||
return route('proposals.show', $this->slug);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user