migrant-web/app/Http/Controllers/Admin/WorkerController.php
2026-05-15 17:40:21 +05:30

90 lines
2.7 KiB
PHP

<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Inertia\Inertia;
class WorkerController extends Controller
{
/**
* Display a listing of all workers.
*/
public function index()
{
// Scaffolding mock dataset for worker management
$workers = [
[
'id' => 101,
'name' => 'Maria Santos',
'email' => 'maria.santos@example.com',
'nationality' => 'Philippines',
'category' => 'Childcare',
'experience' => '5+ Years',
'status' => 'active',
'joined_at' => '2026-01-12',
],
[
'id' => 102,
'name' => 'Lakshmi Sharma',
'email' => 'l.sharma@example.com',
'nationality' => 'India',
'category' => 'Elderly Care',
'experience' => '3-5 Years',
'status' => 'active',
'joined_at' => '2026-02-05',
],
[
'id' => 103,
'name' => 'Siti Aminah',
'email' => 'siti.a@example.com',
'nationality' => 'Indonesia',
'category' => 'Housekeeping',
'experience' => '2 Years',
'status' => 'inactive',
'joined_at' => '2026-03-18',
],
[
'id' => 104,
'name' => 'Fatima Zahra',
'email' => 'fatima.z@example.com',
'nationality' => 'Morocco',
'category' => 'Cooking',
'experience' => '8 Years',
'status' => 'active',
'joined_at' => '2026-04-02',
],
[
'id' => 105,
'name' => 'Grace Omondi',
'email' => 'grace.o@example.com',
'nationality' => 'Kenya',
'category' => 'General Helper',
'experience' => '4 Years',
'status' => 'active',
'joined_at' => '2026-04-25',
],
];
return Inertia::render('Admin/Workers/Index', [
'workers' => $workers,
]);
}
/**
* Toggle worker active/inactive status.
*/
public function toggleStatus(Request $request, $id)
{
$validated = $request->validate([
'status' => 'required|in:active,inactive',
]);
// In a real app, you would update the database here:
// User::where('id', $id)->update(['status' => $validated['status']]);
return back()->with('success', "Worker status has been updated to {$validated['status']}.");
}
}