
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 get all posts which contains comments in laravel
- Eager loading dynamically in laravel
- Recursive function example code PHP Laravel
- Rendering HTML from database table to view in Laravel
- Class 'Facade\Ignition\IgnitionServiceProvider' not found
- Class 'App\Rules\Hash' not found in Laravel
- How to add dynamic page title in Laravel view
- Laravel 9 route group with controller
- Call to a member function getRelationExistenceQuery() on array in Laravel
- Route [password.request] not defined
- Laravel form request validation
- Generate random string lowercase in Laravel
- How to get single column value in laravel
- Argument 1 passed to Illuminate\Database\Query\Builder::cleanBindings() must be of the type array, null given
- Target class [admin] does not exist.
- Json encode method in laravel
- If condition in foreach loop in laravel
- Include External CSS and JS file in Laravel
- Input file with max size validation in laravel
- Array to string conversion laravel Controller
- How to pass data to multiple partial view files in laravel
- How to call model in blade laravel
- SQLSTATE[23000]: Integrity constraint violation: 1022 Can't write; duplicate key in table
- How to create pivot table in laravel using migration
- Update existing pivot table data in laravel