100 lines
2.2 KiB
PHP
100 lines
2.2 KiB
PHP
<?php
|
|
|
|
namespace Modules\HRM\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
use Modules\HRM\Database\Factories\EmployeeFactory;
|
|
|
|
class Employee extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $fillable = [
|
|
'restaurant_id',
|
|
'first_name',
|
|
'last_name',
|
|
'username',
|
|
'email',
|
|
'phone',
|
|
'password',
|
|
'otp_code',
|
|
'isVerified',
|
|
'email_verified_at',
|
|
'address',
|
|
'avatar',
|
|
'role_id',
|
|
'user_type',
|
|
'facebook',
|
|
'twitter',
|
|
'linkedin',
|
|
'google_plus',
|
|
'nid',
|
|
'platform',
|
|
'device_info',
|
|
'last_active_time',
|
|
'status',
|
|
'department_id',
|
|
'designation_id',
|
|
'salary_type_id',
|
|
'address',
|
|
'gender',
|
|
'date_of_birth',
|
|
'joining_date',
|
|
'basic_salary',
|
|
'created_by',
|
|
'deleted_at',
|
|
];
|
|
|
|
public const TABLE_NAME = 'users';
|
|
|
|
protected $table = self::TABLE_NAME;
|
|
|
|
public function attendances(): HasMany
|
|
{
|
|
return $this->hasMany(Attendance::class);
|
|
}
|
|
|
|
public function attendanceLogs(): HasMany
|
|
{
|
|
return $this->hasMany(AttendanceLog::class);
|
|
}
|
|
|
|
public function department(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Department::class)->select('id', 'parent_id', 'name');
|
|
}
|
|
|
|
public function designation(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Designation::class)->select('id', 'department_id', 'title')->with('department');
|
|
}
|
|
|
|
public function salaryType(): BelongsTo
|
|
{
|
|
return $this->belongsTo(SalaryType::class);
|
|
}
|
|
|
|
public function loans(): HasMany
|
|
{
|
|
return $this->hasMany(Loan::class);
|
|
}
|
|
|
|
public function awards(): HasMany
|
|
{
|
|
return $this->hasMany(Award::class);
|
|
}
|
|
|
|
public function leaves(): HasMany
|
|
{
|
|
return $this->hasMany(LeaveApplication::class);
|
|
}
|
|
|
|
protected static function newFactory(): EmployeeFactory
|
|
{
|
|
return EmployeeFactory::new();
|
|
}
|
|
}
|