Unable to get data on edit function

  • I am facing trouble in getting data in controller.

    My Module is Questionnaire

    I am trying to edit category for a question,

    url like: http://localhost:8000/en/backend/questionnaire/questions/2/edit

    (There is data with id 2 in categories table.)

    $router->group(['prefix' =>'/questionnaire'], function (Router $router) {
    $router->bind('category', function ($id) {
    return app('Modules\Questionnaire\Repositories\CategoryRepository')->find($id);
    $router->get('categories/{category}/edit', [
    'as' => 'admin.questionnaire.category.edit',
    'uses' => 'CategoryController@edit',
    'middleware' => 'can:questionnaire.categories.edit'


    namespace Modules\Questionnaire\Http\Controllers\Admin;

    use Laracasts\Flash\Flash;
    use Illuminate\Http\Request;
    use Modules\Questionnaire\Entities\Category;
    use Modules\Questionnaire\Repositories\CategoryRepository;
    use Modules\Core\Http\Controllers\Admin\AdminBaseController;

    use Modules\Questionnaire\Http\Requests\CreateCategoryRequest;
    use Modules\Questionnaire\Http\Requests\UpdateCategoryRequest;
    use Illuminate\Support\Facades\Request as FacadesRequest;

    class CategoryController extends AdminBaseController
    public function edit(Category $category) {
    return view('questionnaire::admin.categories.edit', compact('category'));

    This is showing fillable fields but nothing in data.

  • admin

    Go into your category repository and see why it's not finding your category.

  • Is there anything to do with route binding, I have category in another Module too and when I edit category of my questionnaire module, bind function for another module get called.

    Bind in Questionnaire
    $router->group(['prefix' =>'/questionnaire'], function (Router $router) {
    $router->bind('category', function ($id) {
    // Not called
    return app('Modules\Questionnaire\Repositories\CategoryRepository')->find($id);

    Bind in Dosdonts
    $router->group(['prefix' => '/dosdonts'], function (Router $router) {
    $router->bind('category', function ($id) {
    // This get called
    return app('Modules\Dosdonts\Repositories\CategoryRepository')->find($id);

    Renaming category may get it resolved but what would be the better approach?

  • admin

    It's quite possible that the category bind name is already used. So make sure to use a unique name for it.

    That's why I suggested to see if your repository is called.

    (To insert code snippets, use the markdown syntax , using backticks please)

  • Global Moderator

    Marked as solved.
    Due to no response from OP on potential/actual solution proposal for over 1 month.

    If OP or someone else thinks this is not still solved, please respond with problem/concern.

Log in to reply

Looks like your connection to AsgardCms was lost, please wait while we try to reconnect.