
Touch parent updated_at in Laravel
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
Answers 1
-
Add touch property to child model to update the parent relationship to renew
--PATH app\Models\Comment.phpclass Comment extends Model { protected $touches = ['post']; }
0It will update the updated_at column of the related record of the posts table if you make a comment on this particular post.
Random Code Snippet Queries: Laravel
- How to get file extension from input type file in laravel
- Create project factory and seed data in laravel
- Create a record if not exist in laravel
- Return redirect laravel not working
- How to pass link from controller to view in laravel on ajax call
- Send post data from controller to view
- How to delete record in Laravel with ajax
- How to get path from current URL in Laravel
- Automatically remove records using Prunable trait in Laravel
- Get count of filter data, while return a small set of records
- Attempt to read property "avatar" on null in Laravel
- Get duplicate records in laravel
- Permission denied error while creating storage link in Laravel
- Update existing pivot table data in laravel
- How to display pivot table column value in laravel
- Import/Use Storage facade in laravel
- How to get last month records in Laravel
- Pagination in laravel
- Laravel 9 route group with controller
- Create project table with model and migration
- How to check query string exists or not in laravel blade
- Split an Eloquent Collection by half in Laravel
- Laravel specific table Migration
- How to get user information using hootlex/laravel-friendships package in laravel
- Illuminate\Database\QueryException could not find driver