- Implemented LecturerEdit and LecturerIndex components for managing lecturers. - Created StudentCreate and StudentEdit components for adding and editing students. - Developed StudentIndex component for listing students with search and pagination. - Added department and user types for better type safety. - Updated routes for lecturers and students, including reset password functionality. - Removed AppSidebar from dashboard for a cleaner layout.
39 lines
1.1 KiB
PHP
39 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Services\Admin\Master;
|
|
|
|
use App\Models\Department;
|
|
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
|
|
|
|
class DepartmentService
|
|
{
|
|
public function paginated(int $perPage = 25, string $search = '', string $sort = 'created_at', string $direction = 'desc', array $filters = []): LengthAwarePaginator
|
|
{
|
|
return Department::query()
|
|
->select(['id', 'code', 'name', 'degree_level'])
|
|
->when($search, fn ($q) => $q->where('name', 'like', "%{$search}%")->orWhere('code', 'like', "%{$search}%"))
|
|
->orderBy($sort, $direction)
|
|
->paginate($perPage);
|
|
}
|
|
|
|
public function create(array $data): Department
|
|
{
|
|
return Department::create($data);
|
|
}
|
|
|
|
public function update(Department $department, array $data): Department
|
|
{
|
|
$department->code = $data['code'];
|
|
$department->name = $data['name'];
|
|
$department->degree_level = $data['degree_level'] ?? null;
|
|
$department->update();
|
|
|
|
return $department;
|
|
}
|
|
|
|
public function delete(Department $department): bool
|
|
{
|
|
return $department->delete();
|
|
}
|
|
}
|