Question and answer is powered by AnsPress.io
Get last inserted records from the database use Eloquent method in Laravel 5. You can try this code:
<?php $sql=MyModel::->orderBy('id','desc')->take(1)->get();
If you are using Laravel Eloquent method, then it will be helpful for you.
Apply it:
<?php $data = Tbl_MyTable::create([ 'name' => $request->name, 'status' => '1' ]); if($data) { $last_id = $data->id; } echo $last_id; ?>