After create($request->all()) function - How to get the ID of the newly created record

  • How to get the ID of the newly created record.
    I use the asgard cms "create a module" function
    "Php artisan asgard: module: scaffold" command to generate the controller class.
    There is a function "store(Request $request)" created automatically.
    After have written in the record to the database I want the ID of the new record.
    In normal laravel is the function
    $User = new User;
    $User-> name = 'John';
    $User-> save();
    $InsertedId = $user->id;
    but that does not go with asgardcms store function
    Thanks for the help

  • Problem solved.
    Sorry, the command of laravel also works with asgardcms. My mistake.
    Best regards


  • Global Moderator

    @dieter in Store method right after ->create your entity will contain all stored information.


        public function store(CreatePageRequest $request)
             // Capture created entity
             $record = $this->page->create($request->all());
            flash(trans(' created'));
            return redirect()->route('');

Log in to reply

Looks like your connection to AsgardCms was lost, please wait while we try to reconnect.