
Update last created record in Laravel
You can easily update the last created record in Laravel. Sometimes you have to save the record and after that you have to do some other task and get some value from it and insert the value in same record which you created.
Answers 1
-
Update created record after create() method in laravel
//Import product class $product = Product::create(['name'=>$request->name]); $updateProduct = Product::where('id', $product->id)->update(['inventory_id'=>1]);
0Create() method in laravel return model object after the record is created. After that, you can update the product using the where condition on that project model.
Random Code Snippet Queries: Laravel
- Update email with unique validation in laravel
- Laravel route parameter
- Laravel save object to database
- How to pass external link in laravel blade to anchor tag
- How to call controller function from view in Laravel
- Add a subselect based on relationship using withAggregate method
- Cannot end a section without first starting one
- How to update record after save method in Laravel
- How to insert value to additional columns in pivot table in laravel
- If condition in foreach loop in laravel
- Create project factory and seed data in laravel
- Database transactions in laravel
- Call to a member function pluck() on null
- Update record after find method in lavavel
- Comment .env file in laravel
- Target class [App\Http\Controllers\Auth\Request] does not exist.
- How to run a specific seeder class in laravel
- Laravel route redirect not working
- Laravel form request validation
- How to insert dynamic value to additional column in pivot table in laravel
- Laravel csrf token mismatch for ajax POST Request
- Ignore Records where a field has NULL value in Laravel
- SQLSTATE[42S22]: Column not found: 1054 Unknown column 'users.post_id' in 'where clause
- Submit form without CSRF token in Laravel
- How to prevent host header attack in Laravel