Beispiel #1
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(CreatePostskillRequest $request)
 {
     if ($this->captchaCheck() == false) {
         return redirect()->back()->withErrors(['Wrong Captcha'])->withInput();
     }
     if (Auth::user()->identifier == 1) {
         $request['individual_id'] = Auth::user()->induser_id;
     }
     $request['post_type'] = 'skill';
     // $skillIds = explode(',', $request['linked_skill_id']);
     $request['linked_skill'] = implode(',', $request['linked_skill_id']);
     $request['city'] = implode(',', $request['prefered_location']);
     $pref_locations = $request['prefered_location'];
     $request['unique_id'] = "S" . rand(111, 999) . rand(111, 999);
     $temp = explode(', ', $request['role']);
     $request['functional_area'] = $temp[0];
     $request['role'] = $temp[1];
     $request['education'] = implode('-', $request['education']);
     $post = Postjob::create($request->all());
     // $post->skills()->attach($skillIds);
     foreach ($pref_locations as $loc) {
         $tempArr = explode('-', $loc);
         if (count($tempArr) == 3) {
             $post->preferredLocation()->attach($loc, array('locality' => $tempArr[0], 'city' => $tempArr[1], 'state' => $tempArr[2]));
         }
         if (count($tempArr) == 2) {
             $post->preferredLocation()->attach($loc, array('locality' => 'none', 'city' => $tempArr[0], 'state' => $tempArr[1]));
         }
     }
     return redirect("/mypost");
 }
Beispiel #2
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(CreatePostjobRequest $request)
 {
     if (Auth::user()->identifier == 1) {
         $request['individual_id'] = Auth::user()->induser_id;
     } else {
         $request['corporate_id'] = Auth::user()->corpuser_id;
     }
     if ($this->captchaCheck() == false) {
         return redirect()->back()->withErrors(['Wrong Captcha'])->withInput();
     }
     $request['post_type'] = 'job';
     $request['education'] = implode(',', $request['education']);
     if ($request['linked_skill_id'] != null) {
         $request['linked_skill'] = implode(',', $request['linked_skill_id']);
     }
     if ($request['prefered_location'] != null) {
         $request['city'] = implode(',', $request['prefered_location']);
     }
     $temp = explode(', ', $request['role']);
     $request['functional_area'] = $temp[0];
     $request['role'] = $temp[1];
     $pref_locations = $request['prefered_location'];
     $request['unique_id'] = "J" . rand(111, 999) . rand(111, 999);
     $post = Postjob::create($request->all());
     foreach ($pref_locations as $loc) {
         $tempArr = explode('-', $loc);
         if (count($tempArr) == 3) {
             $post->preferredLocation()->attach($loc, array('locality' => $tempArr[0], 'city' => $tempArr[1], 'state' => $tempArr[2]));
         }
         if (count($tempArr) == 2) {
             $post->preferredLocation()->attach($loc, array('locality' => 'none', 'city' => $tempArr[0], 'state' => $tempArr[1]));
         }
     }
     if ($request['connections'] != null) {
         $taggedUsers = $request['connections'];
         $post->taggeduser()->attach($taggedUsers, array('mode' => 'tagged', 'tag_share_by' => Auth::user()->induser_id));
         $induserIds = implode(', ', $taggedUsers);
         $userIds = User::whereRaw('induser_id in (' . $induserIds . ')')->get(['id']);
         foreach ($userIds as $r) {
             $to_user = $r->id;
             if ($to_user != null) {
                 $notification = new Notification();
                 $notification->from_user = Auth::user()->id;
                 $notification->to_user = $to_user;
                 $notification->remark = 'has tagged you to post: ' . $request['unique_id'];
                 $notification->operation = 'user tagging';
                 $notification->save();
             }
         }
     }
     if ($request['groups'] != null) {
         $taggedGroups = $request['groups'];
         $post->taggedGroup()->attach($taggedGroups, array('mode' => 'tagged', 'tag_share_by' => Auth::user()->induser_id));
     }
     return redirect("/mypost");
 }