New-OMIS/Modules/Employee/app/Repositories/EmployeeRepository.php

60 lines
1.5 KiB
PHP
Raw Permalink Normal View History

2024-04-07 11:54:18 +00:00
<?php
namespace Modules\Employee\Repositories;
2024-04-16 05:09:23 +00:00
use Illuminate\Support\Facades\DB;
2024-04-07 11:54:18 +00:00
use Modules\Employee\Models\Employee;
class EmployeeRepository implements EmployeeInterface
{
public function findAll()
{
2024-04-11 10:52:12 +00:00
return Employee::paginate(20);
2024-04-07 11:54:18 +00:00
}
public function getEmployeeById($employeeId)
{
return Employee::findOrFail($employeeId);
}
2024-04-10 09:30:24 +00:00
public function getEmployeeByEmail($email)
{
return Employee::where('email', $email)->first();
}
2024-04-07 11:54:18 +00:00
public function delete($employeeId)
{
Employee::destroy($employeeId);
}
public function create($employeeDetails)
{
return Employee::create($employeeDetails);
}
public function update($employeeId, array $newDetails)
{
return Employee::whereId($employeeId)->update($newDetails);
}
2024-04-11 10:52:12 +00:00
public function pluck()
{
2024-04-16 05:09:23 +00:00
return Employee::pluck(DB::raw('CONCAT(first_name," ", middle_name , " ",last_name) AS full_name'), 'id');
2024-04-11 10:52:12 +00:00
}
2024-04-07 11:54:18 +00:00
// public function uploadImage($file)
// {
// if ($req->file()) {
// $fileName = time() . '_' . $req->file->getClientOriginalName();
// $filePath = $req->file('file')->storeAs('uploads', $fileName, 'public');
// $fileModel->name = time() . '_' . $req->file->getClientOriginalName();
// $fileModel->file_path = '/storage/' . $filePath;
// $fileModel->save();
// return back()
// ->with('success', 'File has been uploaded.')
// ->with('file', $fileName);
// }
// }
}