Timestamps are not updating while attaching data in pivot table

If you want your pivot table to have automatically maintained
created_at and updated_at timestamps, use the withTimestamps()
method on the relationship definition.

return $this->belongsToMany('Role')->withTimestamps();
  • For Laravel 4.2: Working With Pivot Tables
  • Laravel 5.0: Working With Pivot Tables
  • Laravel 5.1: Retrieving Intermediate Table Columns
  • Laravel 5.2: Filtering Relationships Via Intermediate Table Columns
  • Laravel 5.3: Filtering Relationships Via Intermediate Table Columns
  • Laravel 5.4: Retrieving Intermediate Table Columns
  • Laravel 5.5: Retrieving Intermediate Table Columns
  • Laravel 5.6: Retrieving Intermediate Table Columns
  • Laravel 5.7: Retrieving Intermediate Table Columns
  • Laravel 5.8: Retrieving Intermediate Table Columns

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)