Alvaro Alday
Alvaro Alday

Reputation: 363

Why view::make doesn't work when called from a different function in controller?

This is a fairly simple question, and I made this work in other controllers, but I don't seem to be able to figure out what's exactly going on in this specific case, and why it's not working.

I have this two functions in my controller:

public function create(Request $request)
{
    //
    $this->edit($request, null);
}

public function edit(Request $request, Group $group = null)
{
    //

    return View::make('groups.create')
        ->with('controllerUrl', $this->controllerUrl)
        ->with('record', $group);
}

In this example the create function sends me to a blank page.

This is my route:

Route::group(['middleware'=>['web', 'CheckWritePermission']], function ()
{
    Route::resource('some_model', 'SomeModelController');
    Route::resource('model', 'ModelController');
    Route::resource('groups', 'GroupController');
});

For some reason doing it like this in other controllers works, and for some other it doesn't in this case.

I'm very confused as to why this is, because doing it like this works just fine.

public function create(Request $request)
{
    //
    // $this->edit($request, null);
    return View::make('groups.create')
        ->with('controllerUrl', $this->controllerUrl)
        ->with('record', $group);
}

I just want to understand why in some cases it works and in others it doesn't.

Upvotes: 0

Views: 33

Answers (1)

Frnak
Frnak

Reputation: 6802

You are missing a return statement

return $this->edit($request, null);

your edit method does return something, but your create method doesn't, therefore page stays blank

Upvotes: 2

Related Questions