X3ND1 GANTENG
Server IP : 108.163.255.210  /  Your IP : 3.142.135.24
Web Server : Apache
System : Linux blossom.urlnameserver.com 3.10.0-1160.80.1.el7.x86_64 #1 SMP Tue Nov 8 15:48:59 UTC 2022 x86_64
User :  ( 1172)
PHP Version : 7.2.34
Disable Function : eval,escapeshellarg,proc_close,proc_get_status,proc_nice,proc_open,symlink,system,pcntl_exec,getrusage,chown,chgp,closelog,openlog,syslog,define_syslog_variables,php_ini_loaded_file,getservbyname,getservbyport,posix_getgid,posix_getgrgid,proc_terminate,pfsockopen,apache_child_terminate,posix_mkfifo,posix_setpgid,posix_setuid,hypot,pg_host,pos,posix_access,posix_getcwd,posix_getservbyname,myshellexec,getpid,posix_getsid,posix_isatty,posix_kill,posix_mknod,posix_setgid,posix_setsid,posix_setuid,posix_times,posix_uname,ps_fill,posix_getpwuid,global,ini_restore,zip_open,zip_read,rar_open,bzopen,bzread,bzwrite,apache_get_modules,apache_get_version,phpversionphpinfo,php_ini_scanned_files,get_current_user,disk_total_space,diskfreespace,leak,imap_list,hypo,filedump,safe_mode,getmygid,apache_getenv,apache_setenv,bzread,bzwrite,bzopen,phpini,higlight_file,dos_conv,get_cwd,er_log,cmd,e_name,vdir,get_dir,only_read,ftok,ftpexec,posix_getpwnam,mysql_list_dbs,disk_free_space,session_save_path,confirm_phpdoc_compiled,zip_entry_rea,php_u,psockopen,crack_opendict,crack_getlastmessage,crack_closedict,crack_check,fpassthru,posix_get_last_error,posix_getlogin,posix_getgroups,posix_strerror,posix_getrlimit,posix_getpgrp,posix_getgrnam,pos,dl
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /home/unilinki/public_html/csrability.in/app/Http/Controllers/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ BERANDA ]     

Current File : /home/unilinki/public_html/csrability.in/app/Http/Controllers/JobController.php
<?php namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Mail;
use Exception;
use App\Job;
use App\Rfp;
use App\User;
use App\Application;
use App\TempJob;
use App\Advertisement;
use App\Subscribe;
use App\Savejob;
use App\Saverfp;
use App\City;
use App\State;
use App\Country;
use App\AdditionalAttachment;
use App\JobAttachment;
use App\JobSector;
use App\RfpSector;
use Carbon\Carbon;
use App\Mail\VerificationEmail;
use App\Mail\ReVerification;
use Illuminate\Support\Str;
use App\Video;

class JobController extends Controller
{

    public function jobApply(Request $request, $id)
    {
       try
       {
           
           $applyData = Job::where('id', $id)->get();
           
           if($applyData->isEmpty())
           {
               $message = array('flag'=>'alert-danger', 'message'=>'No application found with provided id');
               return back()->with(['message'=>$message]);
           }
           
           return view('front.pages.application.index')->with(['applyData'=>$applyData->first(),
               'title'=>'Application'
           ]);
           
       }
       catch (Exception $e)
       {
           Log::error($e);
           $message = array('flag'=>'alert-danger', 'message'=>$e->getMessage());
           return back()->with(['message'=>$message]);
           
           
       }
    }



    public function jobDetail(Request $request, $id)
    {
       try
       {

        //$userId = Auth::user()->id;

        $todayDate = date("Y-m-d");

        $detailData = TempJob::where('id', $id)->get();  

        $featuredjobdetail = Job::orderBy(DB::raw('RAND()'))->where('job_type', 'Featured')->where('job_status', '0')->where('portal_date','<=', $todayDate)->paginate(5);
        $premiumjobdetail = Job::orderBy(DB::raw('RAND()'))->where('job_type', 'Prime')->where('job_status', '0')->where('portal_date','<=', $todayDate)->paginate(5);
        $savedjob = Application::orderBy('id', 'desc')->get();
        // dd($content);

        $jobscity = DB::table('cities')
        ->leftJoin('jobs', 'cities.id', '=', 'jobs.city')
        ->select('jobs.city', 'cities.city', 'cities.id', 'jobs.id as city_id')
        ->get();

        $jobsstate = DB::table('states')
        ->leftJoin('jobs', 'states.id', '=', 'jobs.state')
        ->select('jobs.state', 'states.name', 'states.id', 'jobs.id as state_id')
        ->get();

        $jobscountry = DB::table('countries')
        ->leftJoin('jobs', 'countries.id', '=', 'jobs.country')
        ->select('jobs.country', 'countries.name', 'countries.id','jobs.id as job_id')
        ->get();

        $users = User::orderBy('created_at', 'desc')->where('is_deleted', '=', '0')->get(); 
        $organisations = DB::table('jobs')->distinct('organisation')->pluck('organisation');

        return view('front.pages.job.details')->with(['title'=>'Job Details', 'detailData'=>$detailData->first(), 'featuredjobdetail' => $featuredjobdetail, 'premiumjobdetail' => $premiumjobdetail, 'savedjob' => $savedjob, 'jobscity' => $jobscity, 'jobsstate' => $jobsstate, 'jobscountry' => $jobscountry, 'users' => $users, 'organisations' => $organisations
           ]);
           
       }
       catch (Exception $e) 
       {
        echo $e->getMessage();die;
           $message = array('flag'=>'alert-danger', 'message'=>$e->getMessage());
           return back()->with(['message'=>$message]);
       }
    }


    public function jobsDetails(Request $request, $id)
    {
       try
       {

        //$userId = Auth::user()->id;

        $todayDate = date("Y-m-d");

        $jobdetailData = Job::where('id', $id)->get();

        $sectors = JobSector::where('job_id', $id)->get();

        $appliedjob = Application::orderBy('id', 'desc')->get();

        $attachment = JobAttachment::orderBy('id', 'desc')->get();

        $featuredjobdetail = Job::orderBy(DB::raw('RAND()'))->where('job_type', 'Featured')->where('job_status', '0')->where('portal_date','<=', $todayDate)->paginate(5);
        $premiumjobdetail = Job::orderBy(DB::raw('RAND()'))->where('job_type', 'Prime')->where('job_status', '0')->where('portal_date','<=', $todayDate)->paginate(5);

        $savedjob = Savejob::orderBy('id', 'desc')->get();

        $jobapplied = Application::orderBy('id', 'desc')->get();
        // dd($content);

        $jobscity = DB::table('cities')
        ->leftJoin('jobs', 'cities.id', '=', 'jobs.city')
        ->select('jobs.city', 'cities.city', 'cities.id', 'jobs.id as city_id')
        ->get();

        $jobsstate = DB::table('states')
        ->leftJoin('jobs', 'states.id', '=', 'jobs.state')
        ->select('jobs.state', 'states.name', 'states.id', 'jobs.id as state_id')
        ->get();

        $jobscountry = DB::table('countries')
        ->leftJoin('jobs', 'countries.id', '=', 'jobs.country')
        ->select('jobs.country', 'countries.name', 'countries.id','jobs.id as job_id')
        ->get(); 

        $users = User::orderBy('created_at', 'desc')->where('is_deleted', '=', '0')->get(); 
        $organisations = DB::table('jobs')->distinct('organisation')->pluck('organisation');         
          
        return view('front.pages.job.jobdetail')->with(['title'=>'Job Details', 'jobdetailData'=>$jobdetailData->first(), 'featuredjobdetail' => $featuredjobdetail, 'premiumjobdetail' => $premiumjobdetail, 'savedjob' => $savedjob, 'appliedjob' => $appliedjob, 'jobscity' => $jobscity, 'jobsstate' => $jobsstate, 'jobscountry' => $jobscountry, 'attachment' => $attachment, 'sectors' => $sectors, 'users' => $users, 'jobapplied' => $jobapplied, 'organisations' => $organisations
           ]);
           
       }
       catch (Exception $e) 
       {
        echo $e->getMessage();die;
           $message = array('flag'=>'alert-danger', 'message'=>$e->getMessage());
           return back()->with(['message'=>$message]);
       }
    }



    public function jobStore(Request $request)
    {
               
       $userId = Auth::user()->id;
       
       try 
       {  

        $request->validate([  
           'attachment' => 'required|file|mimes:pdf,docx,doc|max:2048', 
       ]);

            if($request->attachment->getClientOriginalName()){
            $ext = $request->attachment->getClientOriginalExtension();
            $file1 = date('YmdHis').rand(1,99999).'.'.$ext;     
            $request->attachment->storeAs('public/attachment',$file1);
          }
          else
          {
            $file1='';
          }

            $save['user_id']=$request->input('user_id');
            $save['job_title']= $request->input('job_title');
            $save['publish_date'] = $request->input('publish_date');
            $save['closing_date'] = $request->input('closing_date');
            $save['organisation'] = $request->input('organisation');
            $save['job_id'] = $request->input('job_id');
            $save['new_name'] = $request->input('new_name');
            $save['new_email'] = $request->input('new_email');
            $save['new_contact'] = $request->input('new_contact');
            $save['new_exp'] = $request->input('new_exp');
            $save['new_designation'] = $request->input('new_designation');
            $save['attachment'] = $file1;
            $save['created_at']   = date('Y-m-d H:i:s');
            $save['status']   = 0;
           if(Application::create($save))
           {
               $message = array('flag'=>'alert-success', 'message'=>'Your Application has been successfully submitted.');
               return back()->with(['message'=>$message]);
           }else{
           $message = array('flag'=>'alert-danger', 'message'=>'Unable to add new Application, Please try again');
           }
           $message = array('flag'=>'alert-success', 'message'=>'New Application Added Successfully');
           return redirect()->route('jobs')->with(['message'=>$message]); 
           
       } 
       catch (Exception $e) 
       {
        echo $e->getMessage();die;
           $message = array('flag'=>'alert-danger', 'message'=>$e->getMessage());
           return back()->with(['message'=>$message]);
       }
    }


    public function jobSave(Request $request)
    {
               
      $userId = Auth::user()->id;
       
      try 
      {  

            $save['user_id']=$request->input('user_id');
            $save['job_id']= $request->input('job_id');
            $save['created_at']   = date('Y-m-d H:i:s');
           if(Savejob::create($save))
           {
               $message = array('flag'=>'alert-success', 'message'=>'Job saved Successfully');
               return back()->with(['message'=>$message]);
           }else{
           $message = array('flag'=>'alert-danger', 'message'=>'Unable to save job, Please try again');
           }
           $message = array('flag'=>'alert-success', 'message'=>'Job saved Successfully');
           return back()->with(['message'=>$message]);
           
       } 
       catch (Exception $e) 
       {
        echo $e->getMessage();die;
           $message = array('flag'=>'alert-danger', 'message'=>$e->getMessage());
           return back()->with(['message'=>$message]);
       }
    }



    public function jobList(Request $request)
    {

      //$userId = Auth::user()->id;
       // $content = Job::paginate(6);
        $todayDate = date("Y-m-d");

        $content = TempJob::orderBy('id', 'desc')->where('job_status', '0')->where('job_description','!=', 'null')->limit(5)->get();
        $jobcontent = Job::orderBy('id', 'desc')->where('job_type', 'Standard')->where('job_status', '0')->where('portal_date','<=', $todayDate)->limit(5)->get();
        $savedjob = Application::orderBy('id', 'desc')->get();
        $featuredjobs = Job::orderBy(DB::raw('RAND()'))->where('job_type', 'Featured')->where('job_status', '0')->where('portal_date','<=', $todayDate)->paginate(5);
        $premiumjobs = Job::orderBy(DB::raw('RAND()'))->where('job_type', 'Prime')->where('job_status', '0')->where('portal_date','<=', $todayDate)->paginate(5);

        $jobscity = DB::table('cities')
        ->leftJoin('jobs', 'cities.id', '=', 'jobs.city')
        ->select('jobs.city', 'cities.city', 'cities.id', 'jobs.id as city_id')
        ->get();

        $jobsstate = DB::table('states')
        ->leftJoin('jobs', 'states.id', '=', 'jobs.state')
        ->select('jobs.state', 'states.name', 'states.id', 'jobs.id as state_id')
        ->get();

        $jobscountry = DB::table('countries')
        ->leftJoin('jobs', 'countries.id', '=', 'jobs.country')
        ->select('jobs.country', 'countries.name', 'countries.id','jobs.id as job_id')
        ->get();

        $advertisement = Advertisement::orderBy('created_at', 'desc')->where('status', '0')->where('position', '1')->get();
        $advertisement1 = Advertisement::orderBy('created_at', 'desc')->where('status', '0')->where('position', '2')->get();
        $advertisement2 = Advertisement::orderBy('created_at', 'desc')->where('status', '0')->where('position', '3')->get();
        $usercontent = User::where('user_type', '5')->where('is_deleted', '0')->orderBy('id', 'desc')->paginate(5);
        $users = User::orderBy('created_at', 'desc')->where('is_deleted', '=', '0')->get(); 
        $organisations = DB::table('jobs')->distinct('organisation')->pluck('organisation');
        // dd($content);
        $video = Video::orderBy('created_at', 'desc')->limit(1)->get();
        return view('front.pages.job.index',array('title'=>'CSR Jobs', 'content'=>$content, 'usercontent'=>$usercontent, 'jobcontent'=>$jobcontent, 'advertisement'=>$advertisement, 'featuredjobs' => $featuredjobs, 'premiumjobs' => $premiumjobs, 'savedjob' => $savedjob, 'jobscity' => $jobscity, 'jobsstate' => $jobsstate, 'jobscountry' => $jobscountry, 'users' => $users, 'organisations' => $organisations, 'advertisement1' => $advertisement1, 'advertisement2' => $advertisement2, 'video' => $video));
    }

    public function login(Request $request)
    {
      $users = User::orderBy('created_at', 'desc')->where('is_deleted', '=', '0')->get();
      return view('front.login',array('title'=>'CSR Jobs', 'users' => $users));
    }
    
    public function loginAccess(Request $request)
    {
        $request->validate([
            'email'=>'required',
            'password'=>'required'
        ]);
        
        try 
        {
            $credentials = array('email' => $request->input('email'), 'password' => $request->input('password'), 'user_type' => [5]);
            
            if (Auth::attempt($credentials)) {
                
                //return redirect()->route('user.dashboard');
                //return redirect()->route('jobs',['user_id'=>base64_encode(\Auth::user()->id)]);
                return redirect()->route('jobs');
            }

            //$nonverified = array('email' => $request->input('email'), 'password' => $request->input('password'), 'user_type' => [9]);
            $user = User::where('email', $request->input('email'))->where('user_type', '9')->first();

       if($user != null ){
           // $nonverified1=User::where('email', $request->input('email'))->where('user_type', '9')->get();
           // print_r($nonverified1);die;
           // if($nonverified1) {
             //print_r('A1');die;
              $message = array(
                'flag' => 'alert-danger',
               // 'message' => 'Either your Credentials are wrong or Your account has not been activated. Kindly check your inbox for the link to authenticate and activate your account. If you have not received the email, please click on ‘Re-send email’'
              'message' => 'The email id entered here is not  authenticated. Kindly check your inbox for the link to authenticate and activate your account. If you have not received the email, please click on "Re-send Activation Link" below’'
              );
              return back()->with(['message'=>$message]);
                
                // return redirect()->back()->with('message3', "Your account is not Activated. Kindly check mail in the inbox and click to authenticate and activate your account!!");
            }else{
             //print_r('A2');die;
            $message = array(
                'flag' => 'alert-danger',
                'message' => 'Invalid username or password.'
            );
            return back()->with(['message'=>$message]);
            }
            $request->session()->flash('message', $message);            
            return redirect()->back()->withInput($request->only('email', 'remember'));
        }
        catch (Exception $e)        
        {
            return back();
        }
        
    }

    public function registerPage(Request $request)
    {
        return view('front.register');
    }


    public function register(Request $request)
    {
        $request->validate([
            'email' => 'required|unique:users'
        ]);

        try {

            $last_user = User::orderBy('created_at', 'desc')->first();
            $new_user = ($request->user_id = $last_user->id + 1);
            $user_id = ('CLNT000'.$new_user);
                
            $user = User::create([
                'name' => $request->input('first_name').' '.$request->input('last_name'),
                'first_name' => $request->input('first_name'),
                'last_name' => $request->input('last_name'),
                'email' => $request->input('email'),
                'password' => \Hash::make($request->input('password')),
                'user_type' => 9,
                'user_id' =>$user_id,
                'email_verification_token' => Str::random(32),
            ]);

            if($user)
            {
              # Send OTP in email after successful registration
                                             
              \Mail::to($user->email)->send(new VerificationEmail($user));

              $message = array('flag'=>'alert-success', 'message'=>'You have successfully been registered. A mail has been sent to the mail id you provided. Kindly authenticate your mail to step into world of information!!');
              return back()->with(['message'=>$message]);
            }
           
            $message = array('flag'=>'alert-danger', 'message'=>'Unable to Create User, Please try again');
            return back()->with(['message'=>$message]); 

        } catch (Exception $e) {
            \Log::error($e->getMessage());
            return back();
        }
    }

    public function resendemail(Request $request)
    {
      try {

        $email = $request->input('email');

        $data = [
            'email_verification_token' => Str::random(32),
        ];

        $rs = User::where(['email'=> $email])->update($data);

        if($rs){       

          \Mail::to($email)->send(new ReVerification($data));

          $message = array('flag'=>'alert-success', 'message'=>'A mail have been sent to the mail id you provided. Kindly authenticate your mail to step into world of information!!');
          return back()->with(['message'=>$message]);
        }

        $message = array('flag'=>'alert-danger', 'message'=>'Unable to send Mail, Please try again');
        return back()->with(['message'=>$message]);  

      } catch (Exception $e) {
          \Log::error($e->getMessage());
          return back();
      }



    }

    public function VerifyEmail($token = null)
    {
      if($token == null) {

        session()->flash('message', 'Invalid Login attempt');

        return redirect()->route('user.verified');

      }

       $user = User::where('email_verification_token',$token)->first();

       if($user == null ){

        session()->flash('message', 'Invalid Login attempt');

        return redirect()->route('user.verified');

       }

       $user->update([
        
        'user_type' => 5,
        'email_verified_at' => Carbon::now(),
        'email_verification_token' => ''

       ]);
       
        session()->flash('message', 'Your account is activated, you can log in now');

        return redirect()->route('user.verified');

    }

    public function verified(Request $request)
    {
        return view('front.pages.verified',array('title'=>'Account Verified'));
    }

    public function resend(Request $request)
    {
        return view('front.pages.resend',array('title'=>'Resend Email'));
    }
    
    public function saveProfile(Request $request)
    {
        if($request->ajax())
        {
            try 
            {
                $userId = Auth::user()->id;


                $name = $request->input('name');
                $location = $request->input('location');

                $rs = User::where('id', $userId)->update(['name'=>$request->input('name')]);
                $rs = User::where('id', $userId)->update(['location'=>$request->input('location')]);

                if($rs) return response()->json(['message'=>'Update Sucessfully']);
                return response()->json(['message'=>'Updated Failed']);
            } 
            catch (Exception $e) {
                \Log::error($e->getMessage());
            }
        }
        return;
    }


    public function saveProfile1(Request $request)
    {
        if($request->ajax())
        {
            try 
            {
                $userId = Auth::user()->id;

                $expyear = $request->input('expyear');
                $avail = $request->input('avail');
                $citizen = $request->input('citizen');
                $language = $request->input('language');

                $rs = User::where('id', $userId)->update(['expyear'=>$request->input('expyear')]);
                $rs = User::where('id', $userId)->update(['avail'=>$request->input('avail')]);
                $rs = User::where('id', $userId)->update(['citizen'=>$request->input('citizen')]);
                $rs = User::where('id', $userId)->update(['language'=>$request->input('language')]);
                
                if($rs) return response()->json(['message'=>'Update Sucessfully']);
                return response()->json(['message'=>'Updated Failed']);
            } 
            catch (Exception $e) {
                \Log::error($e->getMessage());
            }
        }
        return;
    }


    public function saveProfile2(Request $request)
    {
        if($request->ajax())
        {
            try 
            {
                $userId = Auth::user()->id;

                $skills = $request->input('skills');
                $expertise = $request->input('expertise');

                $rs = User::where('id', $userId)->update(['skills'=>$request->input('skills')]);
                $rs = User::where('id', $userId)->update(['expertise'=>$request->input('expertise')]);
                
                if($rs) return response()->json(['message'=>'Update Sucessfully']);
                return response()->json(['message'=>'Updated Failed']);
            } 
            catch (Exception $e) {
                \Log::error($e->getMessage());
            }
        }
        return;
    }


    public function saveProfile3(Request $request)
    {
        if($request->ajax())
        {
            try 
            {
                $userId = Auth::user()->id;

                $landline = $request->input('landline');
                $contact = $request->input('contact');

                $rs = User::where('id', $userId)->update(['landline'=>$request->input('landline')]);
                $rs = User::where('id', $userId)->update(['contact'=>$request->input('contact')]);
                
                if($rs) return response()->json(['message'=>'Update Sucessfully']);
                return response()->json(['message'=>'Updated Failed']);
            } 
            catch (Exception $e) {
                \Log::error($e->getMessage());
            }
        }
        return;
    }


    public function saveProfile4(Request $request)
    {
        if($request->ajax())
        {
            try 
            {
                $userId = Auth::user()->id;

                $referrer = $request->input('referrer');

                $rs = User::where('id', $userId)->update(['referrer'=>$request->input('referrer')]);
                
                if($rs) return response()->json(['message'=>'Update Sucessfully']);
                return response()->json(['message'=>'Updated Failed']);
            } 
            catch (Exception $e) {
                \Log::error($e->getMessage());
            }
        }
        return;
    }




    public function updateImage(Request $request)
    {
        if($request->ajax())
        {
            try 
            {                
                if($request->hasFile('user-image'))
                {
                    $userId = Auth::user()->id;
                    $file = $request->file('user-image');
   
                    //Move Uploaded File
                    $destinationPath = 'public/uploads';
                    $file->move($destinationPath, $file->getClientOriginalName());

                    $rs = User::where('id', $userId)->update(['user_image'=> $file->getClientOriginalName()]);

                    if($rs) return response()->json(['message'=>'Update Sucessfully']);
                    return response()->json(['message'=>'Updated Failed']);
                }

            } 
            catch (Exception $e) {
                \Log::error($e->getMessage());
            }
        }
    }


    public function subscriptionPlans(Request $request)
    {
       try
       {
           
           return view('front.pages.job.subscription')->with([
               'title'=>'Subscription Plans'
           ]);
           
       }
       catch (Exception $e)
       {
           Log::error($e);
           $message = array('flag'=>'alert-danger', 'message'=>$e->getMessage());
           return back()->with(['message'=>$message]);
           
           
       }
    }


    public function userDetails(Request $request, $id)
    {
       try
       {

        $userdetailData = User::where('id', $id)->get();

        $userdetaillist = User::orderBy('created_at', 'desc')->where('user_type', '5')->paginate(5);

        // dd($content);

        $organisations = DB::table('jobs')->distinct('organisation')->pluck('organisation');
              
                    
           
           return view('front.userprofile')->with(['title'=>'User Details', 'userdetailData'=>$userdetailData->first(), 'userdetaillist'=>$userdetaillist, 'organisations'=>$organisations
           ]);
           
       }
       catch (Exception $e) 
       {
        echo $e->getMessage();die;
           $message = array('flag'=>'alert-danger', 'message'=>$e->getMessage());
           return back()->with(['message'=>$message]);
       }
    }

    public function indexsearch(Request $request) 
      {
        //$userId = Auth::user()->id;
        $todayDate = date("Y-m-d");
        $searchTerm = $request->input('searchTerm');
        $posts = Job::search($searchTerm)->orderBy('created_at', 'desc')->where('job_status', '0')->where('job_type', 'Standard')->where('portal_date','<=', $todayDate)->paginate(10);
        $savedjob = Application::orderBy('id', 'desc')->get();
        $featuredjobs = Job::search($searchTerm)->orderBy(DB::raw('RAND()'))->where('job_type', 'Featured')->where('job_status', '0')->where('portal_date','<=', $todayDate)->paginate(5);
        $premiumjobs = Job::search($searchTerm)->orderBy(DB::raw('RAND()'))->where('job_type', 'Prime')->where('job_status', '0')->where('portal_date','<=', $todayDate)->paginate(5);
        $usercontent = User::where('user_type', '5')->where('is_deleted', '0')->orderBy('id', 'desc')->paginate(5);

        $jobscity = DB::table('cities')
        ->leftJoin('jobs', 'cities.id', '=', 'jobs.city')
        ->select('jobs.city', 'cities.city', 'cities.id', 'jobs.id as city_id')
        ->get();

        $jobsstate = DB::table('states')
        ->leftJoin('jobs', 'states.id', '=', 'jobs.state')
        ->select('jobs.state', 'states.name', 'states.id', 'jobs.id as state_id')
        ->get();

        $jobscountry = DB::table('countries')
        ->leftJoin('jobs', 'countries.id', '=', 'jobs.country')
        ->select('jobs.country', 'countries.name', 'countries.id','jobs.id as job_id')
        ->get();

        $users = User::orderBy('created_at', 'desc')->where('is_deleted', '=', '0')->get();
        $organisations = DB::table('jobs')->distinct('organisation')->pluck('organisation');  
        $advertisement = Advertisement::orderBy('created_at', 'desc')->where('status', '0')->where('position', '1')->get();
        $advertisement1 = Advertisement::orderBy('created_at', 'desc')->where('status', '0')->where('position', '2')->get();
        $advertisement2 = Advertisement::orderBy('created_at', 'desc')->where('status', '0')->where('position', '3')->get();
        $video = Video::orderBy('created_at', 'desc')->limit(1)->get();

        return view('front.pages.job.jobresult', compact('posts', 'searchTerm'))->with([
             'title'=>'Result', 'usercontent'=>$usercontent, 'advertisement'=>$advertisement, 'featuredjobs' => $featuredjobs, 'premiumjobs' => $premiumjobs, 'savedjob' => $savedjob, 'jobscity' => $jobscity, 'jobsstate' => $jobsstate, 'jobscountry' => $jobscountry, 'users' => $users, 'organisations' => $organisations, 'advertisement1' => $advertisement1, 'advertisement2' => $advertisement2, 'video' => $video
         ]);
      }


    public function scrapesearch(Request $request) 
      {
        //$userId = Auth::user()->id;
        $todayDate = date("Y-m-d");
        $searchTerm = $request->input('searchTerm');
        $posts = TempJob::search($searchTerm)->where('job_status', '0')->where('job_description','!=', 'null')->orderBy('created_at', 'desc')->paginate(10);
        $savedjob = Application::orderBy('id', 'desc')->get();
        $featuredjobs = Job::orderBy(DB::raw('RAND()'))->where('job_type', 'Featured')->where('job_status', '0')->where('portal_date','<=', $todayDate)->paginate(5);
        $premiumjobs = Job::orderBy(DB::raw('RAND()'))->where('job_type', 'Prime')->where('job_status', '0')->where('portal_date','<=', $todayDate)->paginate(5);
        $advertisement = Advertisement::orderBy('created_at', 'desc')->where('status', '0')->limit(3)->get();
        $usercontent = User::where('user_type', '5')->where('is_deleted', '0')->orderBy('id', 'desc')->paginate(5);

        $jobscity = DB::table('cities')
        ->leftJoin('jobs', 'cities.id', '=', 'jobs.city')
        ->select('jobs.city', 'cities.city', 'cities.id', 'jobs.id as city_id')
        ->get();

        $jobsstate = DB::table('states')
        ->leftJoin('jobs', 'states.id', '=', 'jobs.state')
        ->select('jobs.state', 'states.name', 'states.id', 'jobs.id as state_id')
        ->get();

        $jobscountry = DB::table('countries')
        ->leftJoin('jobs', 'countries.id', '=', 'jobs.country')
        ->select('jobs.country', 'countries.name', 'countries.id','jobs.id as job_id')
        ->get(); 

        $users = User::orderBy('created_at', 'desc')->where('is_deleted', '=', '0')->get();
        
        return view('front.pages.job.scraperesult', compact('posts', 'searchTerm'))->with([
             'title'=>'Result', 'usercontent'=>$usercontent, 'advertisement'=>$advertisement, 'featuredjobs' => $featuredjobs, 'premiumjobs' => $premiumjobs, 'savedjob' => $savedjob, 'jobscity' => $jobscity, 'jobsstate' => $jobsstate, 'jobscountry' => $jobscountry, 'users' => $users
         ]);
      }


    public function jobsubscribe(Request $request)
    {
        try {
                
            $rs = Subscribe::create([
                'email' => $request->input('email')
            ]);

            if($rs)
            {
              # Send OTP in email after successful registration
                $data = array();
                
                $data['email'] = $request->input('email');
                                
                Mail::send('mail.subscribe', $data, function ($message) use ($data) {
                    $message->to($data['email']);
                    $message->from('admin@csrability.com', 'CSR Ability');
                    $message->subject('Thank You for Subscribing');
                });

              return redirect()->back()->with('message6', 'Subscribed Successfully!'); 
            }

            return redirect()->back()->with('message7', 'Already Subscribed!');

        } catch (Exception $e) {
            \Log::error($e->getMessage());
            return back();
        }
    }


    public function dashboard()
    {
        return view('front.dashboard');
    }

    public function jobsFilter(Request $request)
    {
       try
       {

        //$userId = Auth::user()->id;
        $todayDate = date("Y-m-d");

        $jobs = JobSector::whereIn('sector_id', array_keys(request()->sector_id))->groupBy('job_id')->get();
        $allsectors = JobSector::orderBy('created_at', 'desc')->get();
        $jobcontent = Job::orderBy('id', 'desc')->where('job_type', 'Standard')->where('job_status', '0')->where('portal_date','<=', $todayDate)->limit(5)->get();
        $featuredjobs = Job::orderBy(DB::raw('RAND()'))->where('job_type', 'Featured')->where('job_status', '0')->where('portal_date','<=', $todayDate)->paginate(5);
        $premiumjobs = Job::orderBy(DB::raw('RAND()'))->where('job_type', 'Prime')->where('job_status', '0')->where('portal_date','<=', $todayDate)->paginate(5);
        $advertisement = Advertisement::orderBy('created_at', 'desc')->where('status', '0')->where('position', '1')->get();
        $advertisement1 = Advertisement::orderBy('created_at', 'desc')->where('status', '0')->where('position', '2')->get();
        $advertisement2 = Advertisement::orderBy('created_at', 'desc')->where('status', '0')->where('position', '3')->get();
        $video = Video::orderBy('created_at', 'desc')->limit(1)->get();
        $usercontent = User::where('user_type', '5')->where('is_deleted', '0')->orderBy('id', 'desc')->paginate(5);

        $jobscity = DB::table('cities')
        ->leftJoin('jobs', 'cities.id', '=', 'jobs.city')
        ->select('jobs.city', 'cities.city', 'cities.id', 'jobs.id as city_id')
        ->get();

        $jobsstate = DB::table('states')
        ->leftJoin('jobs', 'states.id', '=', 'jobs.state')
        ->select('jobs.state', 'states.name', 'states.id', 'jobs.id as state_id')
        ->get();

        $jobscountry = DB::table('countries')
        ->leftJoin('jobs', 'countries.id', '=', 'jobs.country')
        ->select('jobs.country', 'countries.name', 'countries.id','jobs.id as job_id')
        ->get();
        $savedjob = Application::orderBy('id', 'desc')->get();

        $users = User::orderBy('created_at', 'desc')->where('is_deleted', '=', '0')->get();
        $organisations = DB::table('jobs')->distinct('organisation')->pluck('organisation');

        return view('front.pages.job.jobfilter')->with(['title'=>'Job Filter', 'allsectors'=>$allsectors, 'usercontent'=>$usercontent, 'jobcontent'=>$jobcontent, 'advertisement'=>$advertisement, 'featuredjobs' => $featuredjobs, 'premiumjobs' => $premiumjobs, 'jobscity' => $jobscity, 'jobsstate' => $jobsstate, 'jobscountry' => $jobscountry, 'savedjob' => $savedjob, 'users' => $users, 'jobs' => $jobs, 'organisations' => $organisations, 'advertisement1' => $advertisement1, 'advertisement2' => $advertisement2, 'video' => $video
           ]);
           
       }
       catch (Exception $e) 
       {
        echo $e->getMessage();die;
           $message = array('flag'=>'alert-danger', 'message'=>$e->getMessage());
           return back()->with(['message'=>$message]);
       }
    }




    /////////////////////////    RFP SECTION  //////////////////////////////////////



    public function rfpList(Request $request)
    {
        $todayDate = date("Y-m-d");
        $content = Rfp::orderBy('created_at', 'desc')->where('rfp_status', '0')->where('portal_date','<=', $todayDate)->paginate(10);
        $featuredjobs = Job::orderBy(DB::raw('RAND()'))->where('job_type', 'Featured')->where('job_status', '0')->where('portal_date','<=', $todayDate)->paginate(5);
        $premiumjobs = Job::orderBy(DB::raw('RAND()'))->where('job_type', 'Prime')->where('job_status', '0')->where('portal_date','<=', $todayDate)->paginate(5);
        $savedjob = Application::orderBy('id', 'desc')->get();
        // dd($content);

        $jobscity = DB::table('cities')
        ->leftJoin('jobs', 'cities.id', '=', 'jobs.city')
        ->select('jobs.city', 'cities.city', 'cities.id', 'jobs.id as city_id')
        ->get();

        $jobsstate = DB::table('states')
        ->leftJoin('jobs', 'states.id', '=', 'jobs.state')
        ->select('jobs.state', 'states.name', 'states.id', 'jobs.id as state_id')
        ->get();

        $jobscountry = DB::table('countries')
        ->leftJoin('jobs', 'countries.id', '=', 'jobs.country')
        ->select('jobs.country', 'countries.name', 'countries.id','jobs.id as job_id')
        ->get();

        $users = User::orderBy('created_at', 'desc')->where('is_deleted', '=', '0')->get(); 
        $organisations = DB::table('jobs')->distinct('organisation')->pluck('organisation');
        $advertisement = Advertisement::orderBy('created_at', 'desc')->where('status', '0')->where('position', '4')->get();
        $advertisement1 = Advertisement::orderBy('created_at', 'desc')->where('status', '0')->where('position', '5')->get();
        $usercontent = User::where('user_type', '5')->where('is_deleted', '0')->orderBy('id', 'desc')->paginate(5);

        return view('front.pages.rfp.index',array('title'=>'CSR RFP', 'content'=>$content, 'advertisement'=>$advertisement, 'featuredjobs' => $featuredjobs, 'premiumjobs' => $premiumjobs, 'savedjob' => $savedjob, 'jobscity' => $jobscity, 'jobsstate' => $jobsstate, 'jobscountry' => $jobscountry, 'users' => $users, 'organisations'=>$organisations, 'advertisement1' => $advertisement1, 'usercontent' => $usercontent));
    }


    public function rfpsearch(Request $request) 
    {
      $todayDate = date("Y-m-d");
      $searchTerm = $request->input('searchTerm');
      $posts = Rfp::search($searchTerm)->orderBy('created_at', 'desc')->where('rfp_status', '0')->paginate(10);
      $savedjob = Application::orderBy('id', 'desc')->get();
      $featuredjobs = Job::orderBy(DB::raw('RAND()'))->where('job_type', 'Featured')->where('job_status', '0')->where('portal_date','<=', $todayDate)->paginate(5);
      $premiumjobs = Job::orderBy(DB::raw('RAND()'))->where('job_type', 'Prime')->where('job_status', '0')->where('portal_date','<=', $todayDate)->paginate(5);
      
      $jobscity = DB::table('cities')
        ->leftJoin('jobs', 'cities.id', '=', 'jobs.city')
        ->select('jobs.city', 'cities.city', 'cities.id', 'jobs.id as city_id')
        ->get();

        $jobsstate = DB::table('states')
        ->leftJoin('jobs', 'states.id', '=', 'jobs.state')
        ->select('jobs.state', 'states.name', 'states.id', 'jobs.id as state_id')
        ->get();

        $jobscountry = DB::table('countries')
        ->leftJoin('jobs', 'countries.id', '=', 'jobs.country')
        ->select('jobs.country', 'countries.name', 'countries.id','jobs.id as job_id')
        ->get();

        $users = User::orderBy('created_at', 'desc')->where('is_deleted', '=', '0')->get();
        $organisations = DB::table('jobs')->distinct('organisation')->pluck('organisation');
        $advertisement = Advertisement::orderBy('created_at', 'desc')->where('status', '0')->where('position', '4')->get();
        $advertisement1 = Advertisement::orderBy('created_at', 'desc')->where('status', '0')->where('position', '5')->get();
        $usercontent = User::where('user_type', '5')->where('is_deleted', '0')->orderBy('id', 'desc')->paginate(5);

      return view('front.pages.rfp.rfpresult', compact('posts', 'searchTerm'))->with([
           'title'=>'Result', 'advertisement'=>$advertisement, 'featuredjobs' => $featuredjobs, 'premiumjobs' => $premiumjobs, 'savedjob' => $savedjob, 'jobscity' => $jobscity, 'jobsstate' => $jobsstate, 'jobscountry' => $jobscountry, 'users' => $users, 'organisations'=>$organisations, 'advertisement1' => $advertisement1, 'usercontent' => $usercontent
       ]);
    }


     public function rfpDetails(Request $request, $id)
    {
       try
       {

        $todayDate = date("Y-m-d");

        $rfpdetailData = Rfp::where('id', $id)->get();
        $savedjob = Application::orderBy('id', 'desc')->get();
        $attachment = AdditionalAttachment::orderBy('id', 'desc')->get();
        $rfpfeaturedjobdetail = Job::orderBy(DB::raw('RAND()'))->where('job_type', 'Featured')->where('job_status', '0')->where('portal_date','<=', $todayDate)->paginate(5);
        $rfppremiumjobdetail = Job::orderBy(DB::raw('RAND()'))->where('job_type', 'Prime')->where('job_status', '0')->where('portal_date','<=', $todayDate)->paginate(5);
        // dd($content);

        $sectors = RfpSector::where('rfp_id', $id)->get();

        $jobscity = DB::table('cities')
        ->leftJoin('jobs', 'cities.id', '=', 'jobs.city')
        ->select('jobs.city', 'cities.city', 'cities.id', 'jobs.id as city_id')
        ->get();

        $jobsstate = DB::table('states')
        ->leftJoin('jobs', 'states.id', '=', 'jobs.state')
        ->select('jobs.state', 'states.name', 'states.id', 'jobs.id as state_id')
        ->get();

        $jobscountry = DB::table('countries')
        ->leftJoin('jobs', 'countries.id', '=', 'jobs.country')
        ->select('jobs.country', 'countries.name', 'countries.id','jobs.id as job_id')
        ->get();

        $users = User::orderBy('created_at', 'desc')->where('is_deleted', '=', '0')->get(); 
        $organisations = DB::table('jobs')->distinct('organisation')->pluck('organisation');
              
        return view('front.pages.rfp.details')->with(['title'=>'Job Details', 'rfpdetailData'=>$rfpdetailData->first(), 'rfpfeaturedjobdetail' => $rfpfeaturedjobdetail, 'rfppremiumjobdetail' => $rfppremiumjobdetail, 'savedjob' => $savedjob, 'jobscity' => $jobscity, 'jobsstate' => $jobsstate, 'jobscountry' => $jobscountry, 'attachment' => $attachment, 'users' => $users, 'sectors' => $sectors, 'organisations'=>$organisations
           ]);
           
       }
       catch (Exception $e) 
       {
        echo $e->getMessage();die;
           $message = array('flag'=>'alert-danger', 'message'=>$e->getMessage());
           return back()->with(['message'=>$message]);
       }
    }


    public function rfpsubscriptionPlans(Request $request)
    {
       try
       {
           
           return view('front.pages.rfp.rfpsubscription')->with([
               'title'=>'Subscription Plans'
           ]);
           
       }
       catch (Exception $e)
       {
           Log::error($e);
           $message = array('flag'=>'alert-danger', 'message'=>$e->getMessage());
           return back()->with(['message'=>$message]);
           
           
       }
    }


    public function rfpSave(Request $request)
    {
               
      $userId = Auth::user()->id;
       
      try 
      {  

            $save['user_id']=$request->input('user_id');
            $save['rfp_id']= $request->input('rfp_id');
            $save['created_at']   = date('Y-m-d H:i:s');
           if(Saverfp::create($save))
           {
               $message = array('flag'=>'alert-success', 'message'=>'Rfp saved Successfully');
               return back()->with(['message'=>$message]);
           }else{
           $message = array('flag'=>'alert-danger', 'message'=>'Unable to save rfp, Please try again');
           }
           $message = array('flag'=>'alert-success', 'message'=>'Rfp saved Successfully');
           return back()->with(['message'=>$message]);
           
       } 
       catch (Exception $e) 
       {
        echo $e->getMessage();die;
           $message = array('flag'=>'alert-danger', 'message'=>$e->getMessage());
           return back()->with(['message'=>$message]);
       }
    }

    public function rfpsFilter(Request $request)
    {
       try
       {

        $todayDate = date("Y-m-d");

        $rfps = RfpSector::whereIn('sector_id', array_keys(request()->sector_id))->groupBy('rfp_id')->get();
        $allsectors = JobSector::orderBy('created_at', 'desc')->get();
        $content = Rfp::orderBy('created_at', 'desc')->where('rfp_status', '0')->where('portal_date','<=', $todayDate)->limit(10)->get();
        $featuredjobs = Job::orderBy(DB::raw('RAND()'))->where('job_type', 'Featured')->where('job_status', '0')->where('portal_date','<=', $todayDate)->paginate(5);
        $premiumjobs = Job::orderBy(DB::raw('RAND()'))->where('job_type', 'Prime')->where('job_status', '0')->where('portal_date','<=', $todayDate)->paginate(5);
        $savedjob = Application::orderBy('id', 'desc')->get();
        // dd($content);

        $jobscity = DB::table('cities')
        ->leftJoin('jobs', 'cities.id', '=', 'jobs.city')
        ->select('jobs.city', 'cities.city', 'cities.id', 'jobs.id as city_id')
        ->get();

        $jobsstate = DB::table('states')
        ->leftJoin('jobs', 'states.id', '=', 'jobs.state')
        ->select('jobs.state', 'states.name', 'states.id', 'jobs.id as state_id')
        ->get();

        $jobscountry = DB::table('countries')
        ->leftJoin('jobs', 'countries.id', '=', 'jobs.country')
        ->select('jobs.country', 'countries.name', 'countries.id','jobs.id as job_id')
        ->get();

        $users = User::orderBy('created_at', 'desc')->where('is_deleted', '=', '0')->get(); 
        $organisations = DB::table('jobs')->distinct('organisation')->pluck('organisation');
        $advertisement = Advertisement::orderBy('created_at', 'desc')->where('status', '0')->where('position', '4')->get();
        $advertisement1 = Advertisement::orderBy('created_at', 'desc')->where('status', '0')->where('position', '5')->get();
        $usercontent = User::where('user_type', '5')->where('is_deleted', '0')->orderBy('id', 'desc')->paginate(5);

        return view('front.pages.rfp.rfpfilter')->with(['title'=>'Rfp Filter', 'content'=>$content, 'advertisement'=>$advertisement, 'featuredjobs' => $featuredjobs, 'premiumjobs' => $premiumjobs, 'savedjob' => $savedjob, 'jobscity' => $jobscity, 'jobsstate' => $jobsstate, 'jobscountry' => $jobscountry, 'users' => $users, 'rfps' => $rfps, 'allsectors'=>$allsectors, 'organisations'=>$organisations, 'advertisement1' => $advertisement1, 'usercontent' => $usercontent
           ]);
           
       }
       catch (Exception $e) 
       {
        echo $e->getMessage();die;
           $message = array('flag'=>'alert-danger', 'message'=>$e->getMessage());
           return back()->with(['message'=>$message]);
       }
    }
    
    public function autocomplete(Request $request)
    {
        $data = Job::select("job_title as name")->where("job_title","LIKE","%{$request->input('query')}%")->where("job_status", "0")->get();

        return response()->json($data);
    }

}

Anon7 - 2022
SCDN GOK