/**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     $input = $request->input();
     $data = $request->only('title', 'no_vacancy', 'qualification', 'location');
     $rules = array('title' => 'required', 'no_vacancy' => 'required', 'qualification' => 'required', 'location' => 'required');
     $v = \Validator::make($data, $rules);
     if ($v->fails()) {
         return view('employer.demand_create')->withErrors($v)->withInput($data);
     } else {
         $eid = Auth::user()->id;
         $insert = new Demand();
         $insert->eid = $eid;
         $insert->title = $input['title'];
         $insert->no_vacancy = $input['no_vacancy'];
         $insert->qualification = $input['qualification'];
         $insert->location = $input['location'];
         $insert->status = 0;
         $insert->description = $input['description'];
         $insert->save();
         /*$insert=DB::table('demand')->insert(
           			['eid' => $eid, 'title' => $input['title'],'no_vacancy' =>$input['no_vacancy'], 'qualification' => $input['qualification'], 'location' =>$input['location'], 'status' => 0, 'description' =>$input['description'] ]
         		);*/
         return \Redirect::to('demand');
     }
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     $input = $request->input();
     $data = $request->only('title', 'no_vacancy', 'qualification', 'location');
     $rules = array('title' => 'required', 'no_vacancy' => 'required', 'qualification' => 'required', 'location' => 'required');
     $v = \Validator::make($data, $rules);
     if ($v->fails()) {
         return view('employer.demand_create')->withErrors($v)->withInput($data);
     } else {
         $eid = Auth::user()->id;
         $insert = new Demand();
         $insert->eid = $eid;
         $insert->title = $input['title'];
         $insert->no_vacancy = $input['no_vacancy'];
         $insert->qualification = $input['qualification'];
         $insert->location = $input['location'];
         $insert->status = 0;
         $insert->description = $input['description'];
         $insert->save();
         $history = new History();
         $history->action_id = $insert->id;
         $history->action = 'Demand Created';
         $history->user = Auth::user()->name;
         $history->remark = '';
         $history->save();
         Session::flash('message', 'Demand Created Successfully');
         return \Redirect::to('demand');
     }
 }
 public function demand_view()
 {
     $query = Demanddelete::SELECT('demandId')->where('userId', Auth::user()->id)->get()->toArray();
     $empdemand = Demand::whereNotIn('id', $query)->orderBy('id', 'desc')->paginate(10);
     $empdemand->setPath('empdemand');
     return view('agent.demand')->with('empdemand', $empdemand);
 }
 /**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function create(Request $request)
 {
     if ($request['todate']) {
         $tdate = date("Y-m-d h:m:s", strtotime($request['todate']));
     } else {
         $tdate = date("Y-m-d h:m:s");
     }
     if ($request['fromdate']) {
         $fdate = date("Y-m-d h:m:s", strtotime($request['fromdate']));
     } else {
         $fdate = date("Y-m-d h:m:s");
     }
     if (Auth::user()->type == 1 && Auth::user()->loginas == 1) {
         $admin = count(Member::select('id')->where('type', 1)->whereBetween('created_at', [$fdate, $tdate])->get());
         $employer = count(Member::select('id')->where('type', 2)->whereBetween('created_at', [$fdate, $tdate])->get());
         $agent = count(Member::select('id')->where('type', 3)->whereBetween('created_at', [$fdate, $tdate])->get());
         $adminblock = count(Member::select('id')->whereTypeAndStatus(1, 0)->whereBetween('created_at', [$fdate, $tdate])->get());
         $employerblock = count(Member::select('id')->whereTypeAndStatus(2, 0)->whereBetween('created_at', [$fdate, $tdate])->get());
         $agentblock = count(Member::select('id')->whereTypeAndStatus(3, 0)->whereBetween('created_at', [$fdate, $tdate])->get());
         $resume = count(PersonalInformation::select('id')->whereBetween('created_at', [$fdate, $tdate])->get());
         $resumerequest = count(PersonalInformation::select('id')->where('approved_by', '!=', 0)->whereBetween('created_at', [$fdate, $tdate])->get());
         $resumeapproved = count(PersonalInformation::select('id')->where('approval_status', 1)->whereBetween('created_at', [$fdate, $tdate])->get());
         $demand = count(Demand::select('id')->whereBetween('created_at', [$fdate, $tdate])->get());
         return view('history.index')->with('admin', $admin)->with('employer', $employer)->with('agent', $agent)->with('adminblock', $adminblock)->with('employerblock', $employerblock)->with('agentblock', $agentblock)->with('resume', $resume)->with('resumerequest', $resumerequest)->with('resumeapproved', $resumeapproved)->with('demand', $demand);
     } else {
         if (Auth::user()->loginas == 2) {
             $resume = count(PersonalInformation::select('id')->whereBetween('created_at', [$fdate, $tdate])->get());
             $resumerequest = count(EmployerApproval::select('apid')->whereEmpid(Auth::user()->id)->whereBetween('created_at', [$fdate, $tdate])->get());
             $resumeapproved = count(PersonalInformation::select('id')->whereApproval_statusAndApproved_by(1, Auth::user()->id)->whereBetween('created_at', [$fdate, $tdate])->get());
             $demand = count(Demand::select('id')->whereEid(Auth::user()->id)->whereBetween('created_at', [$fdate, $tdate])->get());
             return view('history.index')->with('resume', $resume)->with('resumerequest', $resumerequest)->with('resumeapproved', $resumeapproved)->with('demand', $demand);
         } else {
             $resume = count(PersonalInformation::select('id')->where('agent_id', Auth::user()->id)->whereBetween('created_at', [$fdate, $tdate])->get());
             $resumerequest = count(PersonalInformation::select('id')->where('agent_id', Auth::user()->id)->where('approved_by', '!=', 0)->whereBetween('created_at', [$fdate, $tdate])->get());
             $resumeapproved = count(PersonalInformation::select('id')->where('agent_id', Auth::user()->id)->where('approval_status', 1)->whereBetween('created_at', [$fdate, $tdate])->get());
             $demand = count(Demand::select('id')->whereBetween('created_at', [$fdate, $tdate])->get());
             return view('history.index')->with('resume', $resume)->with('resumerequest', $resumerequest)->with('resumeapproved', $resumeapproved)->with('demand', $demand);
         }
     }
 }