コード例 #1
0
 /**
  * Update the specified resource in storage.
  *
  * @param  Request  $request
  * @param  int  $id
  * @return Response
  */
 public function update(Request $request)
 {
     $subSubCategory = SubSubCategory::where('id', $request['subsubCategoryID'])->first();
     $subSubCategory->name = $request['name'];
     $subSubCategory->save();
     \Session::flash('success', $request['name'] . ' has been successfully updated!');
     return redirect()->back();
 }
コード例 #2
0
 public function child_category($slug)
 {
     $category = SubSubCategory::where('slug', '=', $slug)->first();
     $keyword = Input::has('keyword') ? Input::get('keyword') : null;
     $cat_id = $category->category_id;
     $sub_cat_id = $category->sub_category_id;
     $main_cat = Category::where('id', '=', $cat_id)->first();
     $sub_cat = SubCategory::where('id', '=', $sub_cat_id)->first();
     if ($category === null) {
         return redirect('/search');
     } else {
         $products = $this->searchProduct(null, null, $slug);
         //$products = Product::where('sub_sub_category_id', $category->id)->paginate(12);
         return view('search.search', compact('products', 'category', 'main_cat', 'sub_cat', 'keyword'));
     }
 }
コード例 #3
0
ファイル: SubCategory.php プロジェクト: Nelabh/abstract
 public function getSubCategories($id)
 {
     $subcategories = SubSubCategory::where('sub_category_id', '=', $id)->get();
     return $subcategories;
 }
コード例 #4
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function captureCase(Request $request)
 {
     $reporter = $request['caseReporter'];
     $caseSeverity = $request['caseSeverity'];
     $userObj = User::where('username', '=', $reporter)->first();
     if (sizeof($userObj) <= 0) {
         $userAddressbookObj = addressbook::where('email', '=', $reporter)->first();
     }
     $user = sizeof($userObj) <= 0 ? $userAddressbookObj->id : $userObj->id;
     $addressbook = sizeof($userObj) <= 0 ? 1 : 0;
     $userName = sizeof($userObj) <= 0 ? $userAddressbookObj->FirstName : $userObj->name;
     $userSurname = sizeof($userObj) <= 0 ? $userAddressbookObj->Surname : $userObj->surname;
     $userEmail = sizeof($userObj) <= 0 ? $userAddressbookObj->email : $userObj->username;
     $cell = sizeof($userObj) <= 0 ? $userAddressbookObj->cellphone : $userObj->email;
     $caseDescription = $request['caseDescription'];
     $precinctObj = Municipality::where('slug', '=', $request['caseMunicipality'])->first();
     $categoryObj = Category::where('slug', '=', $request['caseCategory'])->first();
     $subCategoryObj = SubCategory::where('slug', '=', $request['caseSubCategory'])->first();
     if ($request['caseSubSubCategory'] > 0) {
         $subSubCategoryObj = SubSubCategory::where('slug', '=', $request['caseSubSubCategory'])->first();
         $subSubCategory = $subSubCategoryObj->id;
     } else {
         $subSubCategory = 0;
     }
     $gps = explode(",", $request['GPS']);
     $caseObj = new CaseReport();
     $caseObj->description = htmlentities($caseDescription);
     $caseObj->user = \Auth::user()->id;
     $caseObj->reporter = $user;
     $caseObj->addressbook = $addressbook;
     $caseObj->precinct = $precinctObj->id;
     $caseObj->category = $categoryObj->id;
     $caseObj->sub_category = $subCategoryObj->id;
     $caseObj->sub_sub_category = $subSubCategory;
     $caseObj->gps_lat = $gps[0];
     $caseObj->gps_lng = $gps[1];
     $caseObj->severity = $caseSeverity;
     $caseObj->status = "Pending";
     $caseObj->save();
     $data = array('name' => $userName, 'caseID' => $caseObj->id, 'caseDesc' => $caseObj->description);
     $caseOwner = new CaseOwner();
     $caseOwner->user = $user;
     $caseOwner->caseId = $caseObj->id;
     $caseOwner->type = 0;
     $caseOwner->active = 1;
     $caseOwner->save();
     \Mail::send('emails.sms', $data, function ($message) use($userEmail) {
         $message->from('*****@*****.**', 'Siyaleader');
         $message->to($userEmail)->subject("Siyaleader Notification - New Case Reported:");
     });
     if ($caseSeverity <= 4) {
         $severityData = array('severity' => $caseObj->severity, 'name' => $userName . ' ' . $userSurname, 'cell' => $cell, 'category' => $categoryObj->name, 'caseId' => $caseObj->id);
         \Mail::send('emails.severity', $severityData, function ($message) {
             $message->from('*****@*****.**', 'Siyaleader');
             $message->to('*****@*****.**')->subject("SEVERE");
         });
         $criticalTeam = CriticalTeam::all();
         foreach ($criticalTeam as $critical) {
             $caseOwner = new CaseOwner();
             $caseOwner->user = $critical->user;
             $caseOwner->caseId = $caseObj->id;
             $caseOwner->type = 5;
             //Critical Team
             $caseOwner->active = 1;
             $caseOwner->save();
             \Mail::send('emails.severity', $severityData, function ($message) use($critical) {
                 $userObj = User::find($critical->user);
                 $message->from('*****@*****.**', 'Siyaleader');
                 $message->to($userObj->username)->subject("Siyaleader Notification - New Severe Case Reported:");
             });
         }
     }
     if ($subSubCategory > 0) {
         $subSubCatResponders = CaseResponder::where('sub_sub_category', '=', $subSubCategory)->first();
         if (sizeof($subSubCatResponders) > 0) {
             if ($subSubCatResponders->firstResponder) {
                 $firstResponderUser = User::find($subSubCatResponders->firstResponder);
                 $caseOwner = new CaseOwner();
                 $caseOwner->user = $subSubCatResponders->firstResponder;
                 $caseOwner->caseId = $caseObj->id;
                 $caseOwner->type = 1;
                 $caseOwner->active = 1;
                 $caseOwner->save();
                 $data = array('name' => $firstResponderUser->name, 'caseID' => $caseObj->id, 'caseDesc' => $caseObj->description, 'caseReporter' => $caseObj->description);
                 \Mail::send('emails.responder', $data, function ($message) use($firstResponderUser) {
                     $message->from('*****@*****.**', 'Siyaleader');
                     $message->to($firstResponderUser->username)->subject("Siyaleader Notification - New Case Reported:");
                 });
             }
             if ($subSubCatResponders->secondResponder) {
                 $secondResponderUser = User::find($subSubCatResponders->secondResponder);
                 $caseOwner = new CaseOwner();
                 $caseOwner->user = $subSubCatResponders->secondResponder;
                 $caseOwner->caseId = $caseObj->id;
                 $caseOwner->type = 2;
                 $caseOwner->active = 1;
                 $caseOwner->save();
                 $data = array('name' => $secondResponderUser->name, 'caseID' => $caseObj->id, 'caseDesc' => $caseObj->description, 'caseReporter' => $caseObj->description);
                 \Mail::send('emails.responder', $data, function ($message) use($secondResponderUser) {
                     $message->from('*****@*****.**', 'Siyaleader');
                     $message->to($secondResponderUser->username)->subject("Siyaleader Notification - New Case Reported:");
                 });
             }
             if ($subSubCatResponders->thirdResponder) {
                 $thirdResponderUser = User::find($subSubCatResponders->thirdResponder);
                 $caseOwner = new CaseOwner();
                 $caseOwner->user = $subSubCatResponders->thirdResponder;
                 $caseOwner->caseId = $caseObj->id;
                 $caseOwner->type = 3;
                 $caseOwner->active = 1;
                 $caseOwner->save();
                 $data = array('name' => $thirdResponderUser->name, 'caseID' => $caseObj->id, 'caseDesc' => $caseObj->description, 'caseReporter' => $caseObj->description);
                 \Mail::send('emails.responder', $data, function ($message) use($thirdResponderUser) {
                     $message->from('*****@*****.**', 'Siyaleader');
                     $message->to($thirdResponderUser->username)->subject("Siyaleader Notification - New Case Reported:");
                 });
             }
         }
     }
     if ($subSubCategory == 0) {
         $subCatResponders = CaseResponder::where('sub_category', '=', $subCategoryObj->id)->first();
         if (sizeof($subCatResponders) > 0) {
             if ($subCatResponders->firstResponder) {
                 $firstResponderUser = User::find($subCatResponders->firstResponder);
                 $caseOwner = new CaseOwner();
                 $caseOwner->user = $subCatResponders->firstResponder;
                 $caseOwner->caseId = $caseObj->id;
                 $caseOwner->type = 1;
                 $caseOwner->active = 1;
                 $caseOwner->save();
                 $data = array('name' => $firstResponderUser->name, 'caseID' => $caseObj->id, 'caseDesc' => $caseObj->description, 'caseReporter' => $caseObj->description);
                 \Mail::send('emails.responder', $data, function ($message) use($firstResponderUser) {
                     $message->from('*****@*****.**', 'Siyaleader');
                     $message->to($firstResponderUser->username)->subject("Siyaleader Notification - New Case Reported:");
                 });
             }
             if ($subCatResponders->secondResponder) {
                 $secondResponderUser = User::find($subCatResponders->secondResponder);
                 $caseOwner = new CaseOwner();
                 $caseOwner->user = $subCatResponders->secondResponder;
                 $caseOwner->caseId = $caseObj->id;
                 $caseOwner->type = 2;
                 $caseOwner->active = 1;
                 $caseOwner->save();
                 $data = array('name' => $secondResponderUser->name, 'caseID' => $caseObj->id, 'caseDesc' => $caseObj->description, 'caseReporter' => $caseObj->description);
                 \Mail::send('emails.responder', $data, function ($message) use($secondResponderUser) {
                     $message->from('*****@*****.**', 'Siyaleader');
                     $message->to($secondResponderUser->username)->subject("Siyaleader Notification - New Case Reported:");
                 });
             }
             if ($subCatResponders->thirdResponder) {
                 $thirdResponderUser = User::find($subCatResponders->thirdResponder);
                 $caseOwner = new CaseOwner();
                 $caseOwner->user = $subCatResponders->thirdResponder;
                 $caseOwner->caseId = $caseObj->id;
                 $caseOwner->type = 3;
                 $caseOwner->active = 1;
                 $caseOwner->save();
                 $data = array('name' => $thirdResponderUser->name, 'caseID' => $caseObj->id, 'caseDesc' => $caseObj->description, 'caseReporter' => $caseObj->description);
                 \Mail::send('emails.responder', $data, function ($message) use($thirdResponderUser) {
                     $message->from('*****@*****.**', 'Siyaleader');
                     $message->to($thirdResponderUser->username)->subject("Siyaleader Notification - New Case Reported:");
                 });
             }
         }
     }
     return redirect()->back();
 }