/** * Show the form for editing the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function edit($id) { $survey = Survey::find($id); $areas = SurveyArea::where('survey_id', $id)->get(); return view('survey.edit')->with('survey', $survey)->with('areas', $areas); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $area = SurveyArea::find($id); $area->deleted = 1; $area->save(); $area->delete(); return response(['ok' => true], 203); }
/** * Begin process * * @return \Illuminate\Http\Response */ public function postCreateSurvey(Request $request, $ticket_id) { $Ticket = Ticket::find($ticket_id); $Ticket->status = 2; //in porcess $Ticket->user_id = \Auth::user()->id; //in porcess $Ticket->audit_start_date = date('Y-m-d'); $Ticket->save(); //record tickets vs surveys history $TicketSurvey = new TicketSurvey(); $TicketSurvey->ticket_id = $request->ticket_id; $TicketSurvey->ref_number = $Ticket->ref_number; $TicketSurvey->survey_id = $request->survey_id; //$TicketSurvey->group_id = $request->group_id; $TicketSurvey->created_by = \Auth::user()->id; $TicketSurvey->save(); //record tickets vs areas history $SurveyAreas = SurveyArea::where('survey_id', $request->survey_id)->get(); foreach ($SurveyAreas as $SurveyArea) { $TicketArea = new TicketArea(); $TicketArea->ticket_id = $request->ticket_id; $TicketArea->ref_number = $Ticket->ref_number; $TicketArea->area_id = $SurveyArea->id; $TicketArea->name = $SurveyArea->name; $TicketArea->position = $SurveyArea->position; $TicketArea->created_by = \Auth::user()->id; $TicketArea->save(); } //record items or activites $SurveyItems = SurveyItem::where('survey_id', $request->survey_id)->where('active', 1)->get(); foreach ($SurveyItems as $SurveyItem) { $TicketItem = new TicketItem(); $TicketItem->ticket_id = $request->ticket_id; $TicketItem->ref_number = $Ticket->ref_number; $TicketItem->survey_id = $request->survey_id; $TicketItem->area_id = $SurveyItem->area_id; $TicketItem->name = $SurveyItem->name; $TicketItem->weight = $SurveyItem->weight; $TicketItem->created_by = \Auth::user()->id; $TicketItem->save(); } return response(['ok' => true], 200); }
/** * Show the form for editing the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function edit($id) { $areas = SurveyArea::where('survey_id', $id)->get(); }