Crud: Delete Item Problem

Created on 13 Oct 2016  路  8Comments  路  Source: Laravel-Backpack/CRUD

when delete button clicked in row show this message:

There's been an error. Your item might not have been deleted.

screen shot 1395-07-22 at 15 35 47

how can i fix this ?

question

All 8 comments

Hi @A-Ronagh ,

This is odd. I've just checked the package and the delete functionality works, it throws me a green success message. You should open your network tab in Developer Tools to debug the problem - see what the ajax response is for that delete call - it should say the actual error.

If you've overwritten the destroy() method in your EntityCrudController that might be the culprit.

Cheers!

tnx for answer
in Network Tab request return 405 Method Not Allowed

screen shot 1395-07-22 at 20 12 27

Have you used CRUD::resource() in your routes file? Can I see it?

yes I Use CRUD::resource()

Route::group(['prefix' => 'adminpanel', 'middleware' => 'admin'], function()
{
// Route::get('dashboard', 'Admin\AdminController@index');
Route::get('config', 'Admin\AppConfigController@showEditForm');
Route::post('config/addCoin', 'Admin\AppConfigController@addCoin');
Route::post('config/addMessage', 'Admin\AppConfigController@addMessage');
Route::post('config/updateAppConfig', 'Admin\AppConfigController@updateAppConfig');
// [...] other routes

// Dick CRUD: Define the resources for the entities you want to CRUD.

// CRUD::resource('app-config', 'Admin\AppConfigCrudController');
CRUD::resource('app-user', 'Admin\AppUserCrudController');
CRUD::resource('channel-list', 'Admin\ChannelListCrudController');
CRUD::resource('channel-reported-list', 'Admin\ChannelReportedListCrudController');
CRUD::resource('channel-user-list', 'Admin\ChannelUserListCrudController');
CRUD::resource('price-list', 'Admin\PriceListCrudController');
CRUD::resource('question-list', 'Admin\QuestionListCrudController');
CRUD::resource('request-list', 'Admin\RequestListCrudController');
CRUD::resource('user-payment', 'Admin\UserPaymentCrudController');
});

screen shot 1395-07-22 at 21 38 03

Does a composer update fix it?

I check this tnx for answer :)

I ran into this due to nesting my CRUD models, so I had to add the following functions (edit and destroy) because the $id was returning as null.

Nested being:

Course -> Course Chapters -> Course Chapter Pages

This is from my Course Chapter Pages controller, where the general CRUD was not picking up the "last" ID in the chain of nested CRUDs.

You will need to do a dd($this) in the edit and destroy to make sure you pull back the right ID to pass to the parent. I hope this helps someone with my issue.

    public function edit($id)
    {
        return parent::edit($this->page);
    }

    public function destroy($id)
    {
        return parent::destroy($this->page);
    }

Yea... deleting is a problem. I had to add a route before the MyCrudController route resouce:
Route::post('/myroute/{id}/delete', 'MyCrudController@destroy');
And I edited the delete button link by adding /delete at the end.

Was this page helpful?
0 / 5 - 0 ratings