- Added `rejections` table to track rejection reasons and related entities. - Created `attendances` table for employee attendance records with geolocation data. - Introduced `payroll_periods`, `payrolls`, and `payroll_adjustments` tables for payroll management. - Established `leave_requests` table to manage employee leave applications. - Implemented `purchases` and `purchase_items` tables for tracking supplier purchases. - Created `media` table for file storage and management. - Added `activity_log` table for tracking system activities. - Established `orders` and `order_items` tables for managing customer orders. - Created `cuttings`, `cutting_materials`, and `cutting_results` tables for production management. - Introduced `system_configurations` table for application settings. - Added `push_subscriptions` table for managing user push notifications. - Created `homepage_configurations` table for homepage settings. - Established `product_prices` table for managing product pricing. - Added `owner_verification_requests` table for tracking ownership verification processes. - Created `notifications` table for user notifications. - Established `employee_advance_payments` table for managing advance payments to employees. - Created `retail_stock_histories` table for tracking stock changes. - Established `stok_opnames` and `stok_opname_items` tables for stock opname management. - Created `cutting_material_combinations` table for managing material combinations. - Added `restocks` and `restock_items` tables for managing stock replenishments. - Established `stock_mutations` table for tracking stock changes across various operations.
85 lines
2.0 KiB
PHP
85 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Attributes\Hidden;
|
|
use Illuminate\Database\Eloquent\Attributes\Scope;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
use App\Enums\EmploymentStatus;
|
|
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;
|
|
|
|
#[Hidden(['id'])]
|
|
class Employee extends Model
|
|
{
|
|
use HasFactory, SoftDeletes;
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'employment_status' => EmploymentStatus::class,
|
|
'base_salary' => 'integer',
|
|
'join_date' => 'date:Y-m-d',
|
|
'resign_date' => 'date:Y-m-d',
|
|
];
|
|
}
|
|
|
|
#[Scope]
|
|
protected function contract(Builder $query): void
|
|
{
|
|
$query->where('employment_status', EmploymentStatus::CONTRACT);
|
|
}
|
|
|
|
#[Scope]
|
|
protected function fullTime(Builder $query): void
|
|
{
|
|
$query->where('employment_status', EmploymentStatus::FULL_TIME);
|
|
}
|
|
|
|
#[Scope]
|
|
protected function internship(Builder $query): void
|
|
{
|
|
$query->where('employment_status', EmploymentStatus::INTERNSHIP);
|
|
}
|
|
|
|
#[Scope]
|
|
protected function partTime(Builder $query): void
|
|
{
|
|
$query->where('employment_status', EmploymentStatus::PART_TIME);
|
|
}
|
|
|
|
#[Scope]
|
|
protected function resigned(Builder $query): void
|
|
{
|
|
$query->where('employment_status', EmploymentStatus::RESIGNED);
|
|
}
|
|
|
|
public function attendances(): HasMany
|
|
{
|
|
return $this->hasMany(Attendance::class);
|
|
}
|
|
|
|
public function employeeAdvances(): HasMany
|
|
{
|
|
return $this->hasMany(EmployeeAdvance::class);
|
|
}
|
|
|
|
public function leaveRequests(): HasMany
|
|
{
|
|
return $this->hasMany(LeaveRequest::class);
|
|
}
|
|
|
|
public function payrolls(): HasMany
|
|
{
|
|
return $this->hasMany(Payroll::class);
|
|
}
|
|
|
|
public function user(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class);
|
|
}
|
|
}
|