
Touch parent updated_at in Laravel
Touch parent updated_at in Laravel
With this article, we’ll look at some examples of how to address the "Touch parent updated_at in Laravel" problem.
It will help you to update the updated_at column data of the parent table while updating the data of the child table. Like we make a comment on a specific post and we want to update the updated_at column of the related (post) records of the posts table then it will help you to do so-
Add touch property to child model to update the parent relationship to renew
--PATH app\Models\Comment.phpclass Comment extends Model { protected $touches = ['post']; }
It will update the updated_at column of the related record of the posts table if you make a comment on this particular post.
If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.
Don't forget to share this article! Help us spread the word by clicking the share button below.
We appreciate your support and are committed to providing you valuable and informative content.
We are thankful for your never ending support.
Random Code Snippet Queries: Laravel
- How to call controller function from view in Laravel
- Store logged in user details in session and display in view in laravel
- How to validate website url in laravel using validaiton
- The use statement with non-compound name 'Auth' has no effect
- How to check find method executed successfully in laravel
- How to check relationship is loaded or not in Laravel
- How to pass two variables in HREF in laravel
- Print last executed query in laravel
- How to get random string in Laravel
- How to pass query string to url in laravel
- Link storage folder in laravel 8
- Class 'App\Http\Controllers\User' not found
- Multiple Level eager loading in Laravel
- Where to use whereNotNull eloquent in laravel
- Syntax error or access violation: 1072 Key column 'role_id' doesn't exist in table (SQL: alter table `users` add constraint `users_role_id_foreign` foreign key (`role_id`) references `roles` (`id`))
- Target class [HomeController] does not exist
- Argument 1 passed to App\Http\Controllers\Auth\LoginController::authenticated() must be an instance of App\Http\Controllers\Auth\Request
- How to automatically update the timestamp of parent model in Laravel
- How to send ID to another page in Laravel
- How to check if user has created any post or not in laravel
- Generate unique username in Laravel
- How to change default timestamp fields name in Laravel
- How to get images from AWS s3 and display in Laravel blade
- How to validate form input data in laravel
- How to get all posts which contains comments in laravel