/** * Store a newly created resource in storage. * * @return Response */ public function store(LandingRequest $request) { $landing = new Landing(); $landing->title = $request->title; $landing->secondary = $request->secondary; $landing->title_for_universities = $request->title_for_universities; $landing->secondary_text_for_universities = $request->secondary_text_for_universities; $landing->programs = $request->programs; $landing->three_steps = $request->three_steps; $landing->lang = $request->lang; if ($request->status == 'on') { $landing->status = 1; } else { $landing->status = 0; } $landing->save(); return redirect('/admin/landing')->with('status', 'Главная страница добавлена!'); }
public function landing_duplicate($sample_id) { $landing_new = new Landing(); $landing_old = Landing::find($sample_id); $reasons_array = array(); $timeline_array = array(); $feedback_array = array(); $feedbacks_old = json_decode($landing_old->feedbacks, true); $timeline_old = json_decode($landing_old->timeline, true); $reasons_old = json_decode($landing_old->reasons, true); //Handle Feedbacks for ($j = 1; $j <= 3; $j++) { $author = 'feedback_author' . $j; $detail = 'feedback_detail' . $j; $ava = 'feedback_ava' . $j; $feedback_array['feedback_author' . $j] = $feedbacks_old[$author]; $feedback_array['feedback_detail' . $j] = $feedbacks_old[$detail]; $feedback_array['feedback_ava_name' . $j] = null; $feedback_array['feedback_ava_url' . $j] = null; } //Handle Reasons for ($j = 1; $j <= 3; $j++) { $name = 'reason_name' . $j; $detail = 'reason_detail' . $j; $img = 'reason_img' . $j; $reasons_array['reason_name' . $j] = $reasons_old[$name]; $reasons_array['reason_detail' . $j] = $reasons_old[$detail]; $reasons_array['reason_img_name' . $j] = null; $reasons_array['reason_img_url' . $j] = null; } //Handle Timeline Array $loop = $landing_old->class_number; for ($k = 1; $k <= $loop; $k++) { $class = 'class_name' . $k; $detail = 'class_detail' . $k; $img = 'class_img' . $k; $timeline_array['class_name' . $k] = $timeline_old[$class]; $timeline_array['class_detail' . $k] = $timeline_old[$detail]; $timeline_array['class_img_name' . $k] = null; $timeline_array['class_img_url' . $k] = null; } $timeline = json_encode($timeline_array); $feedbacks = json_encode($feedback_array); $reasons = json_encode($reasons_array); $landing_new->reasons = $reasons; $landing_new->feedbacks = $feedbacks; $landing_new->timeline = $timeline; $landing_new->cover_promo_url = null; $landing_new->cover_promo_name = null; $landing_new->course_id = $landing_old->course_id; $landing_new->demos = $landing_old->demos; $landing_new->policy = $landing_old->policy; $landing_new->seo_url = $landing_old->seo_url; $landing_new->class_number = $landing_old->class_number; $landing_new->video_url = $landing_old->video_url; $landing_new->save(); return redirect('/manage/courses'); }