app/Http/Controllers/CandidateController.php
/**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
Display a listing of the resource.
@return \Illuminate\Http\Response
Display a listing of the resource . @return \ Illuminate \ Http \ Response
public function index(Request $request)
    {
        $name = null;
        $status = null;
        if($request->has('name') && !empty($request->name)){
            $name = $request->name;
            $name = htmlspecialchars($name);
        }
        if($request->has('status') && !empty($request->status)) {
            $status = $request->status;
            $status = htmlspecialchars($status);
        }
        $candidates = CandidateInfo::searchContact($name, $status);
        if(!empty($candidates)) {
            $candidates = $candidates->orderBy('created_at', 'desc')->paginate(20);
        } else {
            $candidates = CandidateInfo::orderBy('created_at', 'desc')->paginate(20);
        }
        if($request->isXmlHttpRequest()) {
            return response(
                view('layouts.admin.candidate_contact.table', ['candidates' => $candidates, 'count' => count($candidates)]),
                200,
                ['Content-Type', 'application/json']
            );
        }
        return view('layouts.admin.candidate_contact.index')
            ->with('candidates', $candidates)
            ->with('count', count($candidates));
    }
public function index ( Request $ request ) { $ name = null ; $ status = null ; if ( $ request -> has ( 'name' ) && ! empty ( $ request -> name ) ) { $ name = $ request -> name ; $ name = htmlspecialchars ( $ name ) ; } if ( $ request -> has ( 'status' ) && ! empty ( $ request -> status ) ) { $ status = $ request -> status ; $ status = htmlspecialchars ( $ status ) ; } $ candidates = CandidateInfo :: searchContact ( $ name , $ status ) ; if ( ! empty ( $ candidates ) ) { $ candidates = $ candidates -> orderBy ( 'created_at' , 'desc' ) -> paginate ( 20 ) ; } else { $ candidates = CandidateInfo :: orderBy ( 'created_at' , 'desc' ) -> paginate ( 20 ) ; } if ( $ request -> isXmlHttpRequest ( ) ) { return response ( view ( 'layouts.admin.candidate_contact.table' , [ 'candidates' => $ candidates , 'count' => count ( $ candidates ) ] ) , 200 , [ 'Content-Type' , 'application/json' ] ) ; } return view ( 'layouts.admin.candidate_contact.index' ) -> with ( 'candidates' , $ candidates ) -> with ( 'count' , count ( $ candidates ) ) ; }
Display a listing of the resource.
Display a listing of the resource .