sleeping-owl / admin

Administrative interface builder for Laravel
http://sleeping-owl.github.io/
MIT License
504 stars 258 forks source link

Route error? #190

Open s6carlo opened 9 years ago

s6carlo commented 9 years ago

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 commented 9 years ago

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

maslakoff commented 9 years ago

I have the same problem. Have you solved it?

s6carlo commented 9 years ago

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.