phase 5
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Resources\JobCategoryResource;
|
||||
use App\Models\JobCategory;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class JobCategoryController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of job categories
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$categories = JobCategory::withCount('jobs')
|
||||
->orderBy('name')
|
||||
->get();
|
||||
|
||||
return JobCategoryResource::collection($categories);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified category
|
||||
*/
|
||||
public function show(string $slug)
|
||||
{
|
||||
$category = JobCategory::where('slug', $slug)
|
||||
->withCount('jobs')
|
||||
->firstOrFail();
|
||||
|
||||
return new JobCategoryResource($category);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user