phplaravellaravel-5voyager

data duplicating when use custom controller in laravel's voyager admin panel


I use laravel 5.4 and voyager admin panel. There's module I created called recipes. I created database table, model and CUSTOM controller and views for this module. I also created BREAD, and indicated there my custom controller. the problem is the when I fill form and submit it, data been duplicated in table, I have 2 identical rows in my table every time I create the item. I think the problem is that it sends 2 requests, one of requests is from my custom route and controller, and another one is from voyager itself. but don't know how to fix it.

print screen from my BREAD BREAD's printscreen

my routes

Route::group(['prefix' => 'admin', 'middleware' => ['admin']], function () {

   \Voyager::routes(); //voyager routes

   // routes for my custom module
   // I can comment this routes, but result is the same
   Route::resource('/recipes', 'Admin\RecipesController');

});

my controller

public function store(Request $request)
{
    $recipe = Recipe::create($request->except(['modules']));
    return redirect()
        ->route("recipes.index")
        ->with([
            'message'    => __('voyager.generic.successfully_added_new')." recipe",
            'alert-type' => 'success'
        ]);
}

any idea?


Solution

  • the issue was because of form element class form-edit-add, as it seems there was event bound to this class. I removed it and now it works fine