Problem with routing
lukaszflorczak opened this issue · 2 comments
lukaszflorczak commented
Hey!
I use laravel-uuid
in my project and I found a problem with routing. I store UUIDs in uuid
column and I have also this code in user model:
// app/User.php
/**
* Get the route key for the model.
*
* @return string
*/
public function getRouteKeyName()
{
return 'uuid';
}
When I send GET
request (for example to http://127.0.0.1:8000/api/v1/users/5af0ed93-5575-4c91-951c-f4b065ea2aea
) I get an error:
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'id' in 'where clause' (SQL: select * from `users` where `id` = 1 limit 1)
My router:
// routes/api.php
Route::prefix('v1')->middleware(['auth:api'])->group(function () {
Route::resource('users', 'UserController', ['only' => ['update', 'show', 'destroy']]);
});
lukaszflorczak commented
Hey, any suggestion?
RandyBooth commented
You are missing a id column if you have not set it yet.