employee crud

This commit is contained in:
2024-04-10 15:15:24 +05:45
parent d92366b1f4
commit b5c603ceec
13 changed files with 420 additions and 194 deletions

View File

@ -7,6 +7,7 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Laravel\Sanctum\HasApiTokens;
use Modules\Employee\Models\Employee;
use Spatie\Permission\Traits\HasRoles;
class User extends Authenticatable
@ -45,7 +46,8 @@ class User extends Authenticatable
'email_verified_at' => 'datetime',
];
// public function employee(){
// return $this->belongsTo(Employee::class,'employee_id');
// }
public function employee()
{
return $this->hasOne(Employee::class, 'users_id');
}
}

View File

@ -0,0 +1,33 @@
<?php
namespace Modules\Department\Repositories;
use Modules\Department\Models\Department;
class DepartmentService
{
public function findAll()
{
return Department::paginate(20);
}
public function getDepartmentById($DepartmentId)
{
return Department::findOrFail($DepartmentId);
}
public function delete($DepartmentId)
{
Department::destroy($DepartmentId);
}
public function create($DepartmentDetails)
{
return Department::create($DepartmentDetails);
}
public function update($DepartmentId, array $newDetails)
{
return Department::whereId($DepartmentId)->update($newDetails);
}
}