This commit is contained in:
Doar Mihai
2026-04-03 01:04:19 +03:00
parent 2b930a0636
commit 1cbe5bfe3b
12 changed files with 536 additions and 2 deletions
@@ -0,0 +1,30 @@
<?php
namespace App\Http\Controllers\Web;
use App\Http\Controllers\Controller;
use App\Models\JobCategory;
use App\Repositories\JobRepository;
use Illuminate\Http\Request;
class HomeController extends Controller
{
public function __construct(
private JobRepository $jobRepository
) {}
/**
* Display the homepage with featured jobs
*/
public function index()
{
$featuredJobs = $this->jobRepository->getFeaturedJobs(10);
$recentJobs = $this->jobRepository->getRecentJobs(7, 6);
$stats = $this->jobRepository->getStatistics();
$categories = JobCategory::withCount('jobs')
->orderBy('name')
->get();
return view('home', compact('featuredJobs', 'recentJobs', 'stats', 'categories'));
}
}
+113
View File
@@ -0,0 +1,113 @@
<?php
namespace App\Http\Controllers\Web;
use App\Http\Controllers\Controller;
use App\Models\Job;
use App\Models\JobCategory;
use App\Repositories\JobRepository;
use App\Services\JobSearchService;
use Illuminate\Http\Request;
class JobController extends Controller
{
public function __construct(
private JobSearchService $searchService,
private JobRepository $jobRepository
) {}
/**
* Display a listing of jobs with search and filters
*/
public function index(Request $request)
{
$filters = $request->only([
'keywords',
'location',
'category_id',
'job_type',
'experience_level',
'remote',
'salary_min',
'salary_max',
'posted_within',
'company',
'sort',
]);
$perPage = $request->input('per_page', 20);
$jobs = $this->searchService->search($filters, $perPage);
$categories = JobCategory::withCount('jobs')->orderBy('name')->get();
$filterOptions = $this->searchService->getFilterOptions();
return view('jobs.index', compact('jobs', 'categories', 'filterOptions', 'filters'));
}
/**
* Display the specified job
*/
public function show(int $id)
{
$job = Job::with(['source', 'category', 'jobLocation'])
->findOrFail($id);
$similarJobs = $this->jobRepository->getSimilarJobs($job, 5);
return view('jobs.show', compact('job', 'similarJobs'));
}
/**
* Display jobs by category
*/
public function category(string $slug, Request $request)
{
$category = JobCategory::where('slug', $slug)->firstOrFail();
$filters = $request->only([
'keywords',
'location',
'job_type',
'experience_level',
'remote',
'salary_min',
'salary_max',
'posted_within',
'sort',
]);
$filters['category_id'] = $category->id;
$perPage = $request->input('per_page', 20);
$jobs = $this->searchService->search($filters, $perPage);
$filterOptions = $this->searchService->getFilterOptions();
return view('jobs.category', compact('category', 'jobs', 'filterOptions', 'filters'));
}
/**
* Display remote jobs
*/
public function remote(Request $request)
{
$filters = $request->only([
'keywords',
'category_id',
'job_type',
'experience_level',
'salary_min',
'salary_max',
'posted_within',
'sort',
]);
$filters['remote'] = true;
$perPage = $request->input('per_page', 20);
$jobs = $this->searchService->search($filters, $perPage);
$categories = JobCategory::withCount('jobs')->orderBy('name')->get();
$filterOptions = $this->searchService->getFilterOptions();
return view('jobs.remote', compact('jobs', 'categories', 'filterOptions', 'filters'));
}
}