classes/Controllers/Base.php
public function store()
    {
        // Create a new object
        $item = new $this->model;

        // Remove nested model data from input and prepare to insert on save
        $input = (new NestedModels)->relateTo($item);

        // Hydrate the object
        $item->fill($input);

        // Validate and save.
        $this->validate($item);
        if ($this->parent) {
            $this->parent->{$this->parent_to_self}()->save($item);
        } else {
            $item->save();
        }

        // Redirect to edit view
        if (Request::ajax()) {
            return Response::json(['id' => $item->id]);
        } else {
            return Redirect::to(DecoyURL::relative('edit', $item->id))
            ->with('success', $this->successMessage($item, 'created'));
        }
    }
public function store()
    {
        // Create a new object
        $item = new $this->model;

        // Remove nested model data from input and prepare to insert on save
        $input = (new NestedModels)->relateTo($item);

        // Hydrate the object
        $item->fill($input);

        // Validate and save.
        $this->validate($item);
        if ($this->parent) {
            $this->parent->{$this->parent_to_self}()->save($item);
        } else {
            $item->save();
        }

        // Redirect to edit view
        if (Request::ajax()) {
            return Response::json(['id' => $item->id]);
        } else {
            return Redirect::to(DecoyURL::relative('edit', $item->id))
            ->with('success', $this->successMessage($item, 'created'));
        }
    }
public function store ( ) { // Create a new object $ item = new $ this -> model ; // Remove nested model data from input and prepare to insert on save $ input = ( new NestedModels ) -> relateTo ( $ item ) ; // Hydrate the object $ item -> fill ( $ input ) ; // Validate and save. $ this -> validate ( $ item ) ; if ( $ this -> parent ) { $ this -> parent -> { $ this -> parent_to_self } ( ) -> save ( $ item ) ; } else { $ item -> save ( ) ; } // Redirect to edit view if ( Request :: ajax ( ) ) { return Response :: json ( [ 'id' => $ item -> id ] ) ; } else { return Redirect :: to ( DecoyURL :: relative ( 'edit' , $ item -> id ) ) -> with ( 'success' , $ this -> successMessage ( $ item , 'created' ) ) ; } }
Store a new record

@return Symfony\Component\HttpFoundation\Response Redirect to edit view
Store a new record