It sounds like trivial but I have been searching for a while and I didn't find a suitable answer!!
How to get a model using uuid inside my controller? I have tried find
and where('uuid', $uuid)
but it always gets a null value!
Code
public function index()
{
$uuid = '90236239-5f28-4d74-948e-eb6c921b323c';
return User::where('uuid', $uuid)->first();
Part of the model
use App\Traits\UuidTrait;
class Userextends BaseModel
{
use UuidTrait;
protected $casts = [
'uuid' => EfficientUuid::class,
];
}
Solved by
whereUuid($uuid)->first();