Closed twigg closed 3 months ago
I have the same problem. whe use next example code
return DB::transaction(function () use ($args) {
$user = User::where('id', $args['id'])->firstOrFail();
$user->fill($args);
$user->save();
$roles = Role::whereIn('id', $args['role_id'])->pluck('id')->toArray();
$user->syncRoles($roles);
return $user;
});
If I disable tntsearch for user class everything works. I can create reproduction if you really need more info. I had to disable tnt for whole project.
I could solve it. By define SearchableArray and exclude all arrays from this list It can be only primitives
public function toSearchableArray(): array
{
return [
'id' => $this->id,
'first_name' => $this->first_name,
'last_name' => $this->last_name,
'status' => $this->status,
'address' => $this->address,
'postal_code' => $this->postal_code,
'email' => $this->email,
];
}
When trying to replicate a model with relationships TNTSearch fails with
mb_strtolower() expects parameter 1 to be string, array is given
error.This only happens when Laravel replicates a model with relationships and then tries to save it. This behavior doesn't happen for models without relationships. Same outcome for save() and push()
Example:
This works fine as expected.
TNTSearch will fail with the following: