- Implemented push notifications with a service worker (sw.ts) to handle caching and notifications. - Added API routes for push subscription and notification management in routes/api.php. - Created NotificationTest to validate notification service functionality and ensure correct notifications are sent based on user roles and actions. - Updated Permissions component to manage notification permissions and subscriptions. - Enhanced CategoryIndex component to highlight categories based on notifications. - Excluded service worker from TypeScript compilation in tsconfig.json. - Updated Vite configuration to include service worker in the build process.
83 lines
2.0 KiB
PHP
83 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Enums\PayrollStatus;
|
|
use Illuminate\Database\Eloquent\Attributes\Guarded;
|
|
use Illuminate\Database\Eloquent\Attributes\Scope;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
use Illuminate\Database\Eloquent\Casts\Attribute;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
#[Guarded(['id'])]
|
|
class Payroll extends Model
|
|
{
|
|
use HasFactory, SoftDeletes;
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'status' => PayrollStatus::class,
|
|
'base_salary' => 'integer',
|
|
'bonus_amount' => 'integer',
|
|
'deduction_amount' => 'integer',
|
|
'total_amount' => 'integer',
|
|
'paid_at' => 'datetime',
|
|
];
|
|
}
|
|
|
|
protected function formattedAmount(): Attribute
|
|
{
|
|
return Attribute::make(
|
|
get: fn () => 'Rp '.number_format($this->total_amount, 0, ',', '.'),
|
|
);
|
|
}
|
|
|
|
#[Scope]
|
|
protected function cancelled(Builder $query): void
|
|
{
|
|
$query->where('status', PayrollStatus::CANCELLED);
|
|
}
|
|
|
|
#[Scope]
|
|
protected function paid(Builder $query): void
|
|
{
|
|
$query->where('status', PayrollStatus::PAID);
|
|
}
|
|
|
|
#[Scope]
|
|
protected function unpaid(Builder $query): void
|
|
{
|
|
$query->where('status', PayrollStatus::UNPAID);
|
|
}
|
|
|
|
public function cashTransaction(): BelongsTo
|
|
{
|
|
return $this->belongsTo(CashTransaction::class);
|
|
}
|
|
|
|
public function employee(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Employee::class);
|
|
}
|
|
|
|
public function paidBy(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class, 'paid_by_id');
|
|
}
|
|
|
|
public function payrollAdjustments(): HasMany
|
|
{
|
|
return $this->hasMany(PayrollAdjustment::class);
|
|
}
|
|
|
|
public function payrollPeriod(): BelongsTo
|
|
{
|
|
return $this->belongsTo(PayrollPeriod::class);
|
|
}
|
|
}
|