public function store()
    {
        $data = Input::all();

        // Handle validation errors.
        if ($validationMessages = $this->validationMessages($data)) {
            return back()->withInput()->withErrors($validationMessages);
        }

        if (($response = $this->prepare($data)) instanceof Response) {
            return $response;
        }

        DB::transaction(function () {
            $inserts = $this->prepareInsert($this->updates);

            foreach ($inserts as $column => $value) {
                $this->model->setAttribute($column, $value);
            }

            $this->model->save();

            $this->updateRelation($this->relations);
        });

        if (($response = $this->complete($this->saved)) instanceof Response) {
            return $response;
        }

        if ($response = $this->ajaxResponse(trans('admin.save_succeeded'))) {
            return $response;
        }

        return $this->redirectAfterStore();
    }
public function store()
    {
        $data = Input::all();

        // Handle validation errors.
        if ($validationMessages = $this->validationMessages($data)) {
            return back()->withInput()->withErrors($validationMessages);
        }

        if (($response = $this->prepare($data)) instanceof Response) {
            return $response;
        }

        DB::transaction(function () {
            $inserts = $this->prepareInsert($this->updates);

            foreach ($inserts as $column => $value) {
                $this->model->setAttribute($column, $value);
            }

            $this->model->save();

            $this->updateRelation($this->relations);
        });

        if (($response = $this->complete($this->saved)) instanceof Response) {
            return $response;
        }

        if ($response = $this->ajaxResponse(trans('admin.save_succeeded'))) {
            return $response;
        }

        return $this->redirectAfterStore();
    }
public function store ( ) { $ data = Input :: all ( ) ; // Handle validation errors. if ( $ validationMessages = $ this -> validationMessages ( $ data ) ) { return back ( ) -> withInput ( ) -> withErrors ( $ validationMessages ) ; } if ( ( $ response = $ this -> prepare ( $ data ) ) instanceof Response ) { return $ response ; } DB :: transaction ( function ( ) { $ inserts = $ this -> prepareInsert ( $ this -> updates ) ; foreach ( $ inserts as $ column => $ value ) { $ this -> model -> setAttribute ( $ column , $ value ) ; } $ this -> model -> save ( ) ; $ this -> updateRelation ( $ this -> relations ) ; } ) ; if ( ( $ response = $ this -> complete ( $ this -> saved ) ) instanceof Response ) { return $ response ; } if ( $ response = $ this -> ajaxResponse ( trans ( 'admin.save_succeeded' ) ) ) { return $ response ; } return $ this -> redirectAfterStore ( ) ; }
Store a new record.

@return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\Http\JsonResponse
Store a new record .