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

Alvaro Alday

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.

Frnak

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

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Why doesn't this code work when wrapped in a generic function?

Why showing and hiding view from viewWillAppear or viewDidAppear doesn't work

Why this function definition from a curried function doesn't work in scala?

Why doesn't the copy constructor work when I return an automatic variable from function?

Why doesn't this function print to screen when called in a loop?

Why does PowerShell code behave different when called from a function?

compadd doesn't work when called from nested functions

Why doesn't UIkeyboard animate when called from a Custom Cell?

HttpPost function in controller doesn't get called

Calling model method from controller "Call to a member function ... on a non-object", but works when called from view

ClearTimeout doesn't work when called at beginning of the function

Script doesn't work when called from another directory

Why doesn't work a view controller at landscape when I show it?

Why doesn't ulimit -n work when called inside a script?

Why doesn't ulimit -n work when called inside a script?

Why Java code doesn't work when moved into a function?

@PreAuthorize doesn't work with function which is called from another function

Simple controller make angular doesn't work

show() View Controller doesn't work

View not loading when called from a Controller in Laravel

Function doesn't work when called with addEventListener or onclick, doesn't show up any error msg

Controller action with different URI doesn't work

Javascript redirect (window.location.href) doesn't work in an Asp.NET Core project when called from an EventListener function

Why the function doesn't work when I click on the respective element?

Firebase function doesn't execute when called from domain

How to make IPython display work when called from a function

Why the database view show data correct but when I called it in controller show different result?

clearTimeout() doesn't work when called from an event

why preventdefault() doesn't seem to work if called inside of reducer function?