HEX
Server: Apache/2.4.46 (Ubuntu)
System: Linux localhost 5.11.0-49-generic #55-Ubuntu SMP Wed Jan 12 17:36:34 UTC 2022 x86_64
User: root (0)
PHP: 7.4.16
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/html/sarvodayahospital/app/Http/Controllers/CareerController.php
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Models\Career;
use App\Models\CMSPage;
use App\Models\Hospital;
use App\Models\JobCategory;
use Artesaos\SEOTools\Facades\OpenGraph;
use Artesaos\SEOTools\Facades\SEOMeta;

class CareerController extends Controller
{
    public function index(Request $request)
    {
        $seo = [];

        $location = $request->filled('location') ? $request->get('location') : '';
        $designation = $request->filled('designation') ? $request->get('designation') : '';
        $category = $request->filled('category') ? $request->get('category') : '';

        $query = Career::query();
        $query->when(
            $location,
            function ($q) use ($location) {
                $q->whereHas('hospital', function ($q) use ($location) {
                    $q->where('Slug', $location);
                });
            }
        );

        $query->when(
            $designation,
            function ($q) use ($designation) {
                $q->where('Designation', 'like', "%{$designation}%");
            }
        );

        $query->when(
            $category,
            function ($q) use ($category) {
                $q->where('Category', $category);
            }
        );

        $careers = $query->orderBy('published_at', 'DESC')->paginate(10)->appends(request()->query());

        $hospitals = Hospital::query()
            ->whereNotIn('Slug', ['sarvodaya-imaging-centre-with-nrch', 'sarvodaya-imaging-centre-with-ndmc'])
            ->pluck('Slug', 'HospitalName');

        $hospitalHasJobs = Hospital::whereHas('career')->get();
        $latest = Career::orderBy('published_at', 'DESC')->take(5)->get();
        $categories = JobCategory::where('IsActive', true)->orderBy('CategoryName', 'ASC')->get();

        $cmsPage = CMSPage::query()
            ->where('Slug', request()->path())
            ->firstOrFail();

        if ($cmsPage) {
            $seo = $cmsPage->seoComponent()->first();
        }

        return view('pages.career', compact('careers', 'hospitals', 'latest', 'hospitalHasJobs', 'categories', 'seo'));
    }

    public function show($slug)
    {
        $seo = [];

        $career = Career::query()->with('hospital')->where('Slug', $slug)->firstOrFail();
        $latest = Career::orderBy('published_at', 'DESC')->take(5)->get();
        $hospitals = Hospital::whereHas('career')->get();

        if ($career) {
            $seo = $career->seoComponent()->first();
        }

        return view('pages.single-career', compact('career', 'latest', 'hospitals', 'seo'));
    }
}