Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Returning Laravel view after executing another function results in blank page

I have the following Laravel functions

public function addNewPhotoRequest($uuid) {
    $photos = DB::table('photos')->where('uuid', '=', request('qr_code'))->get();

    $new_photo_request = new Photos;
    $new_photo_request->uuid = $uuid;
    $new_photo_request->save();
        
    $this->submitPhotoRequest($new_photo_request->photo_id);
}

After executing the $this->submitPhotoRequest line, the function will not return the
view. I can’t return any views nor perform any redirects using the "Return Redirect XXX". It works fine if I put these statements in the addNewPhotoRequest function so I know there is nothing wrong with my views or routes. Any ideas? All that is returned is a blank white page with no errors reported. I can do a DD("test") on the submit photo request function, so I know the function works and is going to it correctly.

/**
 * Submit the API code if it matches a valid code within the database. 
 * This will allow the user to upload a photo and associate it with a database record.
 *
 * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
 */
public function submitPhotoRequest($photo_id)
{
    return view('upload_photo', ['api_code' => $photo_id]);      
}

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

If addNewPhotoRequest is the method being declared in the route, then you are missing the return….

Your code should be like this:

public function addNewPhotoRequest($uuid) {
    $photos = DB::table('photos')->where('uuid', '=', request('qr_code'))->get();

    $new_photo_request = new Photos;
    $new_photo_request->uuid = $uuid;
    $new_photo_request->save();
        
    return $this->submitPhotoRequest($new_photo_request->photo_id);
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading