update addon HRM
Some checks failed
Some checks failed
This commit is contained in:
69
Modules/HrmAddon/App/Models/Attendance.php
Normal file
69
Modules/HrmAddon/App/Models/Attendance.php
Normal 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',
|
||||
];
|
||||
}
|
||||
18
Modules/HrmAddon/App/Models/Department.php
Normal file
18
Modules/HrmAddon/App/Models/Department.php
Normal 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',
|
||||
];
|
||||
}
|
||||
21
Modules/HrmAddon/App/Models/Designation.php
Normal file
21
Modules/HrmAddon/App/Models/Designation.php
Normal 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',
|
||||
];
|
||||
}
|
||||
84
Modules/HrmAddon/App/Models/Employee.php
Normal file
84
Modules/HrmAddon/App/Models/Employee.php
Normal 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'];
|
||||
|
||||
}
|
||||
41
Modules/HrmAddon/App/Models/Holiday.php
Normal file
41
Modules/HrmAddon/App/Models/Holiday.php
Normal 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;
|
||||
});
|
||||
}
|
||||
}
|
||||
56
Modules/HrmAddon/App/Models/Leave.php
Normal file
56
Modules/HrmAddon/App/Models/Leave.php
Normal 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);
|
||||
}
|
||||
}
|
||||
13
Modules/HrmAddon/App/Models/LeaveType.php
Normal file
13
Modules/HrmAddon/App/Models/LeaveType.php
Normal 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'];
|
||||
}
|
||||
71
Modules/HrmAddon/App/Models/Payroll.php
Normal file
71
Modules/HrmAddon/App/Models/Payroll.php
Normal 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;
|
||||
});
|
||||
}
|
||||
}
|
||||
21
Modules/HrmAddon/App/Models/Shift.php
Normal file
21
Modules/HrmAddon/App/Models/Shift.php
Normal 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',
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user