admin icon indicating copy to clipboard operation
admin copied to clipboard

Route error?

Open s6carlo opened this issue 9 years ago • 3 comments

I have a table with id and product_code I want to use product_code as primary key, this is possibile:

Model ...
    protected $primaryKey = 'product_code';

The problem is if I try to edit or delete a table row, I get this error: Sorry, the page you are looking for could not be found. NotFoundHttpException in Application.php line 879:

The route http://localhost:8000/admin/mymodel/mytestcode/edit gives the error.

I think it come from the route

Route::get('{adminModel}/{adminModelId}/edit', [
        'as'   => 'admin.model.edit',
        'uses' => 'AdminController@getEdit',
    ]);

The route should use the model primary key and not the adminModelId

s6carlo avatar Jul 31 '15 10:07 s6carlo

Update: the problem is connected with string values as primary key.

If I set

protected $primaryKey = 'product_code';

I can edit products that have a number as product_code but not the one with a different value, the error is Object of class SleepingOwl\Admin\Model\ModelConfiguration could not be converted to string

s6carlo avatar Jul 31 '15 15:07 s6carlo

I have the same problem. Have you solved it?

maslakoff avatar Oct 12 '15 11:10 maslakoff

No not solved,but actually I found a way to "avoid" it. I need a model with a string key only for "join actions" (multiselect). So I wrote a new model with a string primary key that I use only for multiselect, while to display data I have a second model from the same table with a numeric primary key. It is not the best solution, but it fits my case.

s6carlo avatar Oct 12 '15 15:10 s6carlo