update addon HRM
Some checks failed
Build, Push and Deploy / build-and-push (push) Failing after 3m30s
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 15s
Build, Push and Deploy / deploy-staging (push) Has been skipped
Build, Push and Deploy / deploy-production (push) Has been skipped

This commit is contained in:
2026-05-04 23:04:09 +07:00
parent 7be161f4e4
commit 3e1b64e008
131 changed files with 8281 additions and 290 deletions

View File

@@ -0,0 +1,69 @@
<?php
namespace Modules\HrmAddon\App\Models;
use App\Models\Branch;
use App\Models\Scopes\BranchScope;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Factories\HasFactory;
class Attendance extends Model
{
use HasFactory;
protected $fillable = [
'business_id',
'branch_id',
'employee_id',
'shift_id',
'time_in',
'time_out',
'date',
'duration',
'month',
'note',
];
public function branch(): BelongsTo
{
return $this->belongsTo(Branch::class)->withTrashed();
}
protected static function booted()
{
static::addGlobalScope(new BranchScope);
if (auth()->check() && auth()->user()->accessToMultiBranch()) {
static::addGlobalScope('withBranch', function ($builder) {
$builder->with('branch:id,name');
});
}
}
public static function boot()
{
parent::boot();
static::creating(function ($model) {
$model->branch_id = auth()->user()->branch_id ?? auth()->user()->active_branch_id;
});
}
public function employee()
{
return $this->belongsTo(Employee::class);
}
public function shift()
{
return $this->belongsTo(Shift::class);
}
protected $casts = [
'business_id' => 'integer',
'branch_id' => 'integer',
'employee_id' => 'integer',
'shift_id' => 'integer',
];
}

View File

@@ -0,0 +1,18 @@
<?php
namespace Modules\HrmAddon\App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;
class Department extends Model
{
use HasFactory;
protected $fillable = ['business_id', 'name', 'description', 'status'];
protected $casts = [
'business_id' => 'integer',
'status' => 'integer',
];
}

View File

@@ -0,0 +1,21 @@
<?php
namespace Modules\HrmAddon\App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;
class Designation extends Model
{
use HasFactory;
/**
* The attributes that are mass assignable.
*/
protected $fillable = ['business_id', 'name', 'description', 'status'];
protected $casts = [
'business_id' => 'integer',
'status' => 'integer',
];
}

View File

@@ -0,0 +1,84 @@
<?php
namespace Modules\HrmAddon\App\Models;
use App\Models\Branch;
use App\Models\Scopes\BranchScope;
use App\Traits\ImageUrlTrait;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class Employee extends Model
{
use HasFactory, ImageUrlTrait;
protected $fillable = [
'name',
'business_id',
'branch_id',
'designation_id',
'department_id',
'shift_id',
'phone',
'amount',
'email',
'gender',
'country',
'birth_date',
'join_date',
'image',
'status',
];
public function branch(): BelongsTo
{
return $this->belongsTo(Branch::class)->withTrashed();
}
public static function boot()
{
parent::boot();
static::creating(function ($model) {
$model->branch_id = auth()->user()->branch_id ?? auth()->user()->active_branch_id;
});
}
protected static function booted()
{
static::addGlobalScope(new BranchScope);
if (auth()->check() && auth()->user()->accessToMultiBranch()) {
static::addGlobalScope('withBranch', function ($builder) {
$builder->with('branch:id,name');
});
}
}
public function department()
{
return $this->belongsTo(Department::class);
}
public function designation()
{
return $this->belongsTo(Designation::class);
}
public function shift()
{
return $this->belongsTo(Shift::class);
}
protected $casts = [
'business_id' => 'integer',
'designation_id' => 'integer',
'department_id' => 'integer',
'shift_id' => 'integer',
'amount' => 'double',
];
protected $imageFields = ['image'];
}

View File

@@ -0,0 +1,41 @@
<?php
namespace Modules\HrmAddon\App\Models;
use App\Models\Branch;
use App\Models\Scopes\BranchScope;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Factories\HasFactory;
class Holiday extends Model
{
use HasFactory;
protected $fillable = ['name', 'business_id', 'branch_id', 'description', 'start_date', 'end_date'];
public function branch(): BelongsTo
{
return $this->belongsTo(Branch::class)->withTrashed();
}
protected static function booted()
{
static::addGlobalScope(new BranchScope);
if (auth()->check() && auth()->user()->accessToMultiBranch()) {
static::addGlobalScope('withBranch', function ($builder) {
$builder->with('branch:id,name');
});
}
}
public static function boot()
{
parent::boot();
static::creating(function ($model) {
$model->branch_id = auth()->user()->branch_id ?? auth()->user()->active_branch_id;
});
}
}

View File

@@ -0,0 +1,56 @@
<?php
namespace Modules\HrmAddon\App\Models;
use App\Models\Branch;
use App\Models\Scopes\BranchScope;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Factories\HasFactory;
class Leave extends Model
{
use HasFactory;
protected $fillable = ['business_id', 'branch_id', 'employee_id', 'leave_type_id', 'department_id', 'start_date', 'end_date', 'leave_duration', 'month', 'status', 'description'];
public function branch(): BelongsTo
{
return $this->belongsTo(Branch::class)->withTrashed();
}
protected static function booted()
{
static::addGlobalScope(new BranchScope);
if (auth()->check() && auth()->user()->accessToMultiBranch()) {
static::addGlobalScope('withBranch', function ($builder) {
$builder->with('branch:id,name');
});
}
}
public static function boot()
{
parent::boot();
static::creating(function ($model) {
$model->branch_id = auth()->user()->branch_id ?? auth()->user()->active_branch_id;
});
}
public function employee()
{
return $this->belongsTo(Employee::class);
}
public function leave_type()
{
return $this->belongsTo(LeaveType::class);
}
public function department()
{
return $this->belongsTo(Department::class);
}
}

View File

@@ -0,0 +1,13 @@
<?php
namespace Modules\HrmAddon\App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;
class LeaveType extends Model
{
use HasFactory;
protected $fillable = ['name', 'description', 'status', 'business_id'];
}

View File

@@ -0,0 +1,71 @@
<?php
namespace Modules\HrmAddon\App\Models;
use App\Models\Branch;
use App\Models\PaymentType;
use App\Models\Scopes\BranchScope;
use App\Models\Transaction;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Factories\HasFactory;
class Payroll extends Model
{
use HasFactory;
protected $fillable = [
'business_id',
'branch_id',
'employee_id',
'payment_type_id',
'month',
'date',
'note',
'amount',
'payemnt_year',
];
public function branch(): BelongsTo
{
return $this->belongsTo(Branch::class)->withTrashed();
}
protected static function booted()
{
static::addGlobalScope(new BranchScope);
if (auth()->check() && auth()->user()->accessToMultiBranch()) {
static::addGlobalScope('withBranch', function ($builder) {
$builder->with('branch:id,name');
});
}
}
public function employee()
{
return $this->belongsTo(Employee::class);
}
public function payment_type()
{
return $this->belongsTo(PaymentType::class);
}
public function transactions()
{
return $this->hasMany(Transaction::class, 'reference_id')
->where('platform', 'payroll');
}
public static function boot()
{
parent::boot();
static::creating(function ($model) {
$id = Payroll::where('business_id', auth()->user()->business_id)->count() + 1;
$model->puid = 'Ps_' . str_pad($id, 4, '0', STR_PAD_LEFT);
$model->branch_id = auth()->user()->branch_id ?? auth()->user()->active_branch_id;
});
}
}

View File

@@ -0,0 +1,21 @@
<?php
namespace Modules\HrmAddon\App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;
class Shift extends Model
{
use HasFactory;
/**
* The attributes that are mass assignable.
*/
protected $fillable = ['name', 'business_id', 'start_time', 'end_time', 'start_break_time','end_break_time', 'status', 'break_time', 'break_status'];
protected $casts = [
'business_id' => 'integer',
'status' => 'integer',
];
}