/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { $this->validate($request, Point::$validation_rules); $point = new Point(); $point->name = $request->input('name'); $point->description = $request->input('description'); $point->parent_id = $request->input('parent_id'); $point->line_id = $request->input('line_id'); $point->type_id = $request->input('type_id'); $point->user_id = $request->input('user_id'); // Check if the chosen point type is available if (in_array($point->type_id, \Config::get('sf.unique_type_ids'))) { $type_check = Point::where('line_id', $point->line_id)->where('type_id', $point->type_id)->first(); if (!empty($type_check)) { Flash::danger(trans('alerts.point.point_already_set')); return redirect()->back()->withInput(); } } $point->save(); Flash::success(trans('alerts.point.added')); return redirect(action("StorylineController@show", ['id' => $point->line_id])); }