/** * Store a newly created resource in storage. * * @param \Garble\Http\Requests\TextsRequest $request * * @return \Illuminate\Http\Response */ public function storeModel(TextsRequest $request) { $modelAttributes = []; foreach ($this->modelInstance->getFillable() as $key) { $input = $request->input($key); if (!empty($input)) { $modelAttributes[$key] = $input; } } $model = $this->modelInstance->create($modelAttributes); $model->save(); $attributes = ['slug' => $request->input('slug'), 'text_type' => $this->type, 'text_id' => $model->id, 'user_id' => $request->input('user_id')]; $text = Text::create($attributes); $text->save(); return $this->redirectToIndex(); }