/** * Show the form for editing the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function edit($id) { $feedback = Feedback::find($id); $visibilities = Visibility::actual()->get()->lists('name', 'id'); $statuses = Status::actual()->get()->lists('name', 'id'); return view('backend.feedbacks.edit', ["feedback" => $feedback, "visibilities" => $visibilities, "statuses" => $statuses]); }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { $this->validate($request, ['content' => 'required', 'feedback_id' => 'required|exists:feedbacks,id', 'g-recaptcha-response' => 'required|captcha']); $data = $request->all(); $data['visibility_id'] = Visibility::actual()->where('name', 'public')->first()->id; $comment = Comment::create($data); return redirect(route('feedbacks.show', $comment->feedback_id)); }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { $this->validate($request, ["title" => "required", "content" => "required|min:10", 'g-recaptcha-response' => 'required|captcha']); $data = $request->all(); $data['visibility_id'] = Visibility::actual()->where('name', 'private')->first()->id; $data['status_id'] = Status::actual()->where('name', 'open')->first()->id; $feedback = Feedback::create($data); return redirect(route('feedbacks.index')); }
/** * Run the database seeds. * * @return void */ public function run() { factory(Feedback::class, 5)->create()->each(function ($item) { $visibility = Visibility::actual()->orderByRaw("RAND()")->first(); $status = Status::actual()->orderByRaw("RAND()")->first(); $item->visibility()->associate($visibility); $item->status()->associate($status); $item->save(); }); }
/** * Collate and return all data needed to create/edit a logged drive * * @return array */ private function generateFormData() { return ['vehicles' => Auth::user()->learner->vehicles->lists('human_friendly', 'id')->all(), 'tasks' => Task::lists('description', 'id')->all(), 'road_types' => RoadType::lists('description', 'id')->all(), 'road_conditions' => RoadCondition::lists('description', 'id')->all(), 'traffic_conditions' => TrafficCondition::lists('description', 'id')->all(), 'visibilities' => Visibility::lists('description', 'id')->all(), 'supervisors' => Auth::user()->learner->supervisors->lists('human_friendly', 'id')->all()]; }