Here is my code in model Pos ` /**
* Get all of the details for the Pos
*
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function details(): HasMany
{
return $this->hasMany(PosDetail::class, ['session_id', 'branch_id', 'strukno']);
}`
And here is my code in model PosDetail
/**
* Get the pos that owns the PosDetail
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function pos(): BelongsTo
{
return $this->belongsTo(Pos::class, ['session_id', 'branch_id', 'strukdate', 'strukno'], ['session_id', 'branch_id', 'strukdate', 'strukno']);
}
What i try to get the data Pos is with this code
$post = Pos::all(); return $post;
That code is work in laravel 9, but not with laravel 10. Any different syntax between ver. 9 and 10?
The
hasManyandbelongsTomethods in Laravel only support a single foreign key, not an array of keys.So it should be like this
Ex: if you want to fetch data from
poswith thedetailsthe.or