#How to format the date of a pivot column with Carbon ?
1 messages · Page 1 of 1 (latest)
and in your pivot model cast your game_release_date
read this for better informationn
what's your models names?
have you define $table of other models maybe?
why you're sending GamePlatformRegion::class as second parameter of belongsToMany ? get rid of it
and add this to you're pivot model, just edit datetime format to what you want
'game_release_date' => 'datetime:Y-m-d',
];```
look that second parameter in belongsToMany function is for foreign pivot key
first of all get rid of all those GamePlatformRegion::class as second parameter
and you have used it in more than one function
then let's see what comes next
in your game model
{
return $this->belongsToMany(Platform::class)->with('regions');
}
when using many to many,when you don't tell it your pivot table it searches for your pivot table by firstmodel_relatedmodel naming convention
or whatever convention it's called
add your pivot table by using()
yes
well that's odd
what version of laravel is it?
ok
is everything working fine now?
it says send that table name as a second parameter
but your sending that class and it works
go with the first one, laravel belongsToMany function is wriiten like this
$parentKey = null, $relatedKey = null, $relation = null)```
and it's in hasManyThrough that we send model name as second argument
maybe you're phpstorm is mixing those
at least I would use the first one
at least it's what it is at core
nice👍