Eloquent BelongsToMany doesn't let you override format for the pivot table, since behind the scenes it relies on the base Grammar's getDateFormat method, rather than model's getDateFormat. I would say it is inconsistency that needs to be addressed, nonetheless you just can't do it.
I was looking for, how update timestamps only on pivot and didn't found anything useful... after a lot of search I realize that was just touch pivot relation using :
$model->pivot->touch()
This will update pivot updated_at but don't touch on model's timestamps.
@JarekTkaczyk how are doing sir ? Been a long time. Couldn't you write something like this ? Rough concept have not run or tested it, but wonder if this could be made to work?
class AppServiceProvider
{
public function boot()
{
/**
* we pass it instance or just date and return new date
*/
Carbon::macro('dateFormater', function ($instance) {
$dt = Carbon::parse($instance->created_at);
if (!isset($self) && isset($this)) {
$self = $this;
}
return $dt->format('m-d');
});
/**
* we pass builder callback
*/
Builder::macro('myAppTags', function($callback) {
if (count(call_user_func($callback->bindTo($this)))) {
foreach ($variable as $key => $value) {
variable[$key]['new_date'] = Carbon::macro('dateFormater')
}
}
return $this;
});
/**
* Start here.
*/
SomeModel::myAppTags(function () {
return $this->belongsToMany('Tag')->withTimestamps();
});
}
}