I am Laravel Eloquent ORM using PgSql, when i use with()
method is return error.
SQLSTATE[42883]: Undefined function: 7 ERROR: operator does not exist: uuid = integer LINE 1:
Laravel Version 10.7.1 Php Version 8.1.17
Here is the table structure, for some reason i change the table name.
parents
--------
id (uuid)
name (string)
user_id (uuid)
description (text)
details
---------
id (uuid)
parent_id (uuid)
title (stirng)
description (tinytext)
here is the code from controller
/**
* Display the specified resource.
*/
public function show(string $id)
{
$this->authorize('viewParent', \App\Models\Parent::class);
$model = \App\Models\Parent::with(['user', 'parentChilds'])->findOrFail($id);
return view("$this->view.show", [
'model' => $model,
'title' => "$this->title",
'route' => $this->route,
]);
}
But when i use method $modelParent->parentChilds()->createMany([...data])
it retur no error
Parent Model
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'title',
'user_id',
'description',
];
/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected $casts = [
'id' => 'string',
];
/**
* Get the user that owns the MinuteOfMeeting
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function user(): BelongsTo
{
return $this->belongsTo(User::class, 'user_id')->withTrashed();
}
/**
* Get all of the minuteOfMeetingDetails for the MinuteOfMeeting
*
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function parentChilds(): HasMany
{
return $this->hasMany(ParentChild::class, 'parent_id', 'id');
}
Child Model
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'parent_id',
'title',
'description'
];
/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected $casts = [
'id' => 'string',
'parent_id' => 'string',
];
/**
* Get the minuteOfMeeting that owns the MinuteOfMeetingDetail
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function parent(): BelongsTo
{
return $this->belongsTo(Parent::class, 'parent', 'id')->withTrashed();
}