Don't use query builder, use eloquent. Eloquent has all of query builder methods as well.
Apr 27, 2022
9
Level 1
Query Builder with Model Attributes
I'm Using Query Builder, and I would like to use setters in my model, how can I do it please
This is my code :
$tenantUser = DB::connection('tenant')->table('users')->insert($request->validated());
the password method, doesn't work because i'm using query builder:
protected function password(): Attribute
{
return Attribute::make(
set: fn ($value) => Hash::make($value)
);
}
Level 1
// $tenantUser = DB::connection('tenant')->table('users')->insert($request->validated());
$tenantUser = User::on('tenant')->create($request->validated()); // for static usage
Please or to participate in this conversation.