base commit
This commit is contained in:
41
app/Models/Bonus.php
Normal file
41
app/Models/Bonus.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\BonusType;
|
||||
use App\Models\Concerns\LogsHrActivity;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Bonus extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
use LogsHrActivity;
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'employee_id',
|
||||
'bonus_date',
|
||||
'bonus_type',
|
||||
'amount',
|
||||
'reason',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'bonus_date' => 'date',
|
||||
'bonus_type' => BonusType::class,
|
||||
'amount' => 'decimal:2',
|
||||
];
|
||||
}
|
||||
|
||||
public function employee(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Employee::class);
|
||||
}
|
||||
}
|
||||
21
app/Models/Concerns/LogsHrActivity.php
Normal file
21
app/Models/Concerns/LogsHrActivity.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Models\Concerns;
|
||||
|
||||
use Spatie\Activitylog\LogOptions;
|
||||
use Spatie\Activitylog\Traits\LogsActivity;
|
||||
|
||||
trait LogsHrActivity
|
||||
{
|
||||
use LogsActivity;
|
||||
|
||||
public function getActivitylogOptions(): LogOptions
|
||||
{
|
||||
return LogOptions::defaults()
|
||||
->logFillable()
|
||||
->logOnlyDirty()
|
||||
->dontSubmitEmptyLogs();
|
||||
}
|
||||
}
|
||||
42
app/Models/Department.php
Normal file
42
app/Models/Department.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\Concerns\LogsHrActivity;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Department extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
use LogsHrActivity;
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'code',
|
||||
'description',
|
||||
'is_active',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'is_active' => 'boolean',
|
||||
];
|
||||
}
|
||||
|
||||
public function employees(): HasMany
|
||||
{
|
||||
return $this->hasMany(Employee::class);
|
||||
}
|
||||
|
||||
public function users(): HasMany
|
||||
{
|
||||
return $this->hasMany(User::class);
|
||||
}
|
||||
}
|
||||
47
app/Models/DisciplinaryReport.php
Normal file
47
app/Models/DisciplinaryReport.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\DisciplinarySeverity;
|
||||
use App\Models\Concerns\LogsHrActivity;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class DisciplinaryReport extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
use LogsHrActivity;
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'employee_id',
|
||||
'report_date',
|
||||
'title',
|
||||
'description',
|
||||
'severity',
|
||||
'attachment_path',
|
||||
'created_by',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'report_date' => 'date',
|
||||
'severity' => DisciplinarySeverity::class,
|
||||
];
|
||||
}
|
||||
|
||||
public function employee(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Employee::class);
|
||||
}
|
||||
|
||||
public function creator(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'created_by');
|
||||
}
|
||||
}
|
||||
105
app/Models/Employee.php
Normal file
105
app/Models/Employee.php
Normal file
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\EmploymentStatus;
|
||||
use App\Enums\Gender;
|
||||
use App\Models\Concerns\LogsHrActivity;
|
||||
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;
|
||||
|
||||
class Employee extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
use LogsHrActivity;
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'employee_number',
|
||||
'full_name',
|
||||
'national_id',
|
||||
'gender',
|
||||
'birth_date',
|
||||
'phone',
|
||||
'address',
|
||||
'department_id',
|
||||
'position_id',
|
||||
'shift_id',
|
||||
'employment_status',
|
||||
'hire_date',
|
||||
'termination_date',
|
||||
'notes',
|
||||
'profile_photo_path',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'gender' => Gender::class,
|
||||
'birth_date' => 'date',
|
||||
'employment_status' => EmploymentStatus::class,
|
||||
'hire_date' => 'date',
|
||||
'termination_date' => 'date',
|
||||
];
|
||||
}
|
||||
|
||||
public function department(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Department::class);
|
||||
}
|
||||
|
||||
public function position(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Position::class);
|
||||
}
|
||||
|
||||
public function shift(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Shift::class);
|
||||
}
|
||||
|
||||
public function vacations(): HasMany
|
||||
{
|
||||
return $this->hasMany(Vacation::class);
|
||||
}
|
||||
|
||||
public function sickLeaves(): HasMany
|
||||
{
|
||||
return $this->hasMany(SickLeave::class);
|
||||
}
|
||||
|
||||
public function unpaidLeaves(): HasMany
|
||||
{
|
||||
return $this->hasMany(UnpaidLeave::class);
|
||||
}
|
||||
|
||||
public function disciplinaryReports(): HasMany
|
||||
{
|
||||
return $this->hasMany(DisciplinaryReport::class);
|
||||
}
|
||||
|
||||
public function explanations(): HasMany
|
||||
{
|
||||
return $this->hasMany(Explanation::class);
|
||||
}
|
||||
|
||||
public function bonuses(): HasMany
|
||||
{
|
||||
return $this->hasMany(Bonus::class);
|
||||
}
|
||||
|
||||
public function gifts(): HasMany
|
||||
{
|
||||
return $this->hasMany(Gift::class);
|
||||
}
|
||||
|
||||
public function documents(): HasMany
|
||||
{
|
||||
return $this->hasMany(EmployeeDocument::class);
|
||||
}
|
||||
}
|
||||
40
app/Models/EmployeeDocument.php
Normal file
40
app/Models/EmployeeDocument.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\DocumentType;
|
||||
use App\Models\Concerns\LogsHrActivity;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class EmployeeDocument extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
use LogsHrActivity;
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'employee_id',
|
||||
'document_type',
|
||||
'title',
|
||||
'file_path',
|
||||
'uploaded_at',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'document_type' => DocumentType::class,
|
||||
'uploaded_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
public function employee(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Employee::class);
|
||||
}
|
||||
}
|
||||
38
app/Models/Explanation.php
Normal file
38
app/Models/Explanation.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\Concerns\LogsHrActivity;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Explanation extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
use LogsHrActivity;
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'employee_id',
|
||||
'explanation_date',
|
||||
'reason',
|
||||
'description',
|
||||
'attachment_path',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'explanation_date' => 'date',
|
||||
];
|
||||
}
|
||||
|
||||
public function employee(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Employee::class);
|
||||
}
|
||||
}
|
||||
39
app/Models/Gift.php
Normal file
39
app/Models/Gift.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\Concerns\LogsHrActivity;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Gift extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
use LogsHrActivity;
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'employee_id',
|
||||
'gift_date',
|
||||
'gift_name',
|
||||
'value',
|
||||
'reason',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'gift_date' => 'date',
|
||||
'value' => 'decimal:2',
|
||||
];
|
||||
}
|
||||
|
||||
public function employee(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Employee::class);
|
||||
}
|
||||
}
|
||||
28
app/Models/Position.php
Normal file
28
app/Models/Position.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\Concerns\LogsHrActivity;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Position extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
use LogsHrActivity;
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'description',
|
||||
];
|
||||
|
||||
public function employees(): HasMany
|
||||
{
|
||||
return $this->hasMany(Employee::class);
|
||||
}
|
||||
}
|
||||
41
app/Models/Shift.php
Normal file
41
app/Models/Shift.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\Concerns\LogsHrActivity;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Shift extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
use LogsHrActivity;
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'code',
|
||||
'starts_at',
|
||||
'ends_at',
|
||||
'description',
|
||||
'is_active',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'starts_at' => 'datetime:H:i:s',
|
||||
'ends_at' => 'datetime:H:i:s',
|
||||
'is_active' => 'boolean',
|
||||
];
|
||||
}
|
||||
|
||||
public function employees(): HasMany
|
||||
{
|
||||
return $this->hasMany(Employee::class);
|
||||
}
|
||||
}
|
||||
42
app/Models/SickLeave.php
Normal file
42
app/Models/SickLeave.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\Concerns\LogsHrActivity;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class SickLeave extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
use LogsHrActivity;
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'employee_id',
|
||||
'start_date',
|
||||
'end_date',
|
||||
'days',
|
||||
'medical_institution',
|
||||
'reason',
|
||||
'document_path',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'start_date' => 'date',
|
||||
'end_date' => 'date',
|
||||
'days' => 'integer',
|
||||
];
|
||||
}
|
||||
|
||||
public function employee(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Employee::class);
|
||||
}
|
||||
}
|
||||
51
app/Models/UnpaidLeave.php
Normal file
51
app/Models/UnpaidLeave.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\ApprovalStatus;
|
||||
use App\Models\Concerns\LogsHrActivity;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class UnpaidLeave extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
use LogsHrActivity;
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'employee_id',
|
||||
'start_date',
|
||||
'end_date',
|
||||
'days',
|
||||
'reason',
|
||||
'status',
|
||||
'approved_by',
|
||||
'approved_at',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'start_date' => 'date',
|
||||
'end_date' => 'date',
|
||||
'days' => 'integer',
|
||||
'status' => ApprovalStatus::class,
|
||||
'approved_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
public function employee(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Employee::class);
|
||||
}
|
||||
|
||||
public function approver(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'approved_by');
|
||||
}
|
||||
}
|
||||
42
app/Models/User.php
Normal file
42
app/Models/User.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use BezhanSalleh\FilamentShield\Traits\HasPanelShield;
|
||||
use Database\Factories\UserFactory;
|
||||
use Filament\Models\Contracts\FilamentUser;
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Attributes\Hidden;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Spatie\Permission\Traits\HasRoles;
|
||||
|
||||
#[Fillable(['name', 'email', 'password', 'department_id'])]
|
||||
#[Hidden(['password', 'remember_token'])]
|
||||
class User extends Authenticatable implements FilamentUser
|
||||
{
|
||||
/** @use HasFactory<UserFactory> */
|
||||
use HasFactory, HasPanelShield, HasRoles, Notifiable;
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'email_verified_at' => 'datetime',
|
||||
'password' => 'hashed',
|
||||
];
|
||||
}
|
||||
|
||||
public function department(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Department::class);
|
||||
}
|
||||
}
|
||||
57
app/Models/Vacation.php
Normal file
57
app/Models/Vacation.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\ApprovalStatus;
|
||||
use App\Enums\VacationType;
|
||||
use App\Models\Concerns\LogsHrActivity;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Vacation extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
use LogsHrActivity;
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'employee_id',
|
||||
'type',
|
||||
'start_date',
|
||||
'end_date',
|
||||
'return_date',
|
||||
'days',
|
||||
'status',
|
||||
'reason',
|
||||
'attachment_path',
|
||||
'approved_by',
|
||||
'approved_at',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'type' => VacationType::class,
|
||||
'start_date' => 'date',
|
||||
'end_date' => 'date',
|
||||
'return_date' => 'date',
|
||||
'days' => 'integer',
|
||||
'status' => ApprovalStatus::class,
|
||||
'approved_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
public function employee(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Employee::class);
|
||||
}
|
||||
|
||||
public function approver(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'approved_by');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user