Refactor: Enforce type safety, fix close deadlock, implement assignee restrictions and notify admin fallbacks
This commit is contained in:
@@ -7,6 +7,9 @@ use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
use App\Enums\ContractType;
|
||||
use App\Enums\ContractStatus;
|
||||
|
||||
#[Fillable(['product_id', 'customer_id', 'type', 'start_date', 'end_date', 'status', 'printed_at', 'signed_status'])]
|
||||
class Contract extends Model
|
||||
{
|
||||
@@ -16,6 +19,8 @@ class Contract extends Model
|
||||
'start_date' => 'date',
|
||||
'end_date' => 'date',
|
||||
'printed_at' => 'date',
|
||||
'type' => ContractType::class,
|
||||
'status' => ContractStatus::class,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,11 @@ class Department extends Model
|
||||
return $this->belongsTo(User::class, 'manager_id');
|
||||
}
|
||||
|
||||
public function members(): HasMany
|
||||
{
|
||||
return $this->hasMany(User::class);
|
||||
}
|
||||
|
||||
public function feedbacks(): HasMany
|
||||
{
|
||||
return $this->hasMany(Feedback::class, 'current_department_id');
|
||||
|
||||
@@ -6,9 +6,18 @@ use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
use App\Enums\HandoverStatus;
|
||||
|
||||
#[Fillable(['product_id', 'customer_id', 'handover_date', 'status', 'remark'])]
|
||||
class Handover extends Model
|
||||
{
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'status' => HandoverStatus::class,
|
||||
'handover_date' => 'date',
|
||||
];
|
||||
}
|
||||
public function product(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Product::class);
|
||||
|
||||
@@ -6,11 +6,23 @@ use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
use App\Enums\ServiceType;
|
||||
use App\Enums\ContractStatus;
|
||||
|
||||
#[Fillable(['product_id', 'service_type', 'status', 'actual_collection_date', 'remark'])]
|
||||
class ProductService extends Model
|
||||
{
|
||||
protected $table = 'product_services';
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'service_type' => ServiceType::class,
|
||||
'status' => ContractStatus::class,
|
||||
'actual_collection_date' => 'date',
|
||||
];
|
||||
}
|
||||
|
||||
public function product(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Product::class);
|
||||
|
||||
@@ -7,6 +7,7 @@ use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Attributes\Hidden;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Spatie\Permission\Traits\HasRoles;
|
||||
@@ -14,7 +15,7 @@ use Illuminate\Contracts\Auth\Access\Authorizable;
|
||||
use Filament\Models\Contracts\FilamentUser;
|
||||
use Filament\Panel;
|
||||
|
||||
#[Fillable(['name', 'email', 'password', 'role'])]
|
||||
#[Fillable(['name', 'email', 'password', 'role', 'department_id'])]
|
||||
#[Hidden(['password', 'remember_token'])]
|
||||
class User extends Authenticatable implements FilamentUser
|
||||
{
|
||||
@@ -29,6 +30,11 @@ class User extends Authenticatable implements FilamentUser
|
||||
];
|
||||
}
|
||||
|
||||
public function department(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Department::class);
|
||||
}
|
||||
|
||||
public function canAccessPanel(Panel $panel): bool
|
||||
{
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user