76 lines
1.8 KiB
PHP
76 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace Modules\Frontend\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
use Modules\Authentication\Models\User;
|
|
|
|
class Onboarding extends Model
|
|
{
|
|
use HasFactory, SoftDeletes;
|
|
|
|
/**
|
|
* The attributes that are mass assignable.
|
|
*/
|
|
protected $fillable = [
|
|
'restaurant_id', // 🏢 Restaurant Information
|
|
'restaurant_name',
|
|
'restaurant_email',
|
|
'restaurant_phone',
|
|
'restaurant_domain',
|
|
'restaurant_type',
|
|
'restaurant_address',
|
|
'restaurant_logo',
|
|
|
|
// 👤 Owner / User Information
|
|
'name',
|
|
'email',
|
|
'phone',
|
|
'password',
|
|
'avatar',
|
|
|
|
// 💰 Financial / Status
|
|
'amount',
|
|
'status',
|
|
'approved_by',
|
|
'approved_at',
|
|
];
|
|
|
|
/**
|
|
* The attributes that should be cast.
|
|
*/
|
|
protected $casts = [
|
|
'approved_at' => 'datetime',
|
|
'amount' => 'decimal:2',
|
|
];
|
|
|
|
// ✅ The user who approved the onboarding
|
|
public function approver(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class, 'approved_by');
|
|
}
|
|
|
|
// Automatically hash password when setting it
|
|
public function setPasswordAttribute($value): void
|
|
{
|
|
if (! empty($value)) {
|
|
$this->attributes['password'] = bcrypt($value);
|
|
}
|
|
}
|
|
|
|
// Scope to get only approved onboardings
|
|
public function scopeApproved($query): mixed
|
|
{
|
|
return $query->where('status', 'approved');
|
|
}
|
|
|
|
// Scope to get pending onboardings
|
|
public function scopePending($query): mixed
|
|
{
|
|
return $query->where('status', 'pending');
|
|
}
|
|
}
|