Components\ContactManager\Controllers\Backend\ContactController::store PHP Метод

store() публичный Метод

Store a newly created resource in storage.
public store ( )
    public function store()
    {
        $input = Input::all();
        if (isset($input['form_close'])) {
            return Redirect::to("{$this->link}contact-manager");
        }
        if (isset($input['form_save'])) {
            $redirect = "{$this->link}contact-manager";
        } else {
            $redirect = "{$this->link}contact-manager/create/{$input['form_id']}";
        }
        $input['location'] = json_encode(array('latitude' => $input['location-lat'], 'longitude' => $input['location-lon']));
        $display_options = $this->getDisplayOptions($input);
        $input['display_options'] = json_encode($display_options);
        $form = $this->getForm($input['form_id']);
        try {
            App::make('Components\\ContactManager\\Validation\\ContactValidator')->validateForCreation($input);
            $model_name = "Components\\ContactManager\\Models\\{$form['model']}";
            $entry = $model_name::create($input);
        } catch (ValidationException $e) {
            return Redirect::back()->withInput()->withErrors($e->getErrors());
        }
        if ($entry) {
            return Redirect::to($redirect)->with('success_message', trans('success_messages.contact_create'));
        } else {
            return Redirect::back()->with('error_message', trans('error_messages.contact_create'));
        }
    }