uccdev
209
7
Laravel

Laravel Controller is not returning to view?

Posted 1 month ago by uccdev

My problem is simple. On the latest version of laravel, my controller function is not returning to the given view. here is all I have.

my controller's function:

       public function findBBDirect($pageNumber) {
           $token = $this->accessToken;
           $headers = ['Authorization: Bearer ' . $token];

           $curl = curl_init();
           $validReturn = true;
           $url = "https://my.url.com"

             curl_setopt_array($curl, [
               CURLOPT_RETURNTRANSFER => TRUE,
               CURLINFO_HEADER_OUT => TRUE,
               CURLOPT_URL => $url,
               CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
               CURLOPT_SSL_VERIFYPEER => TRUE,
               CURLOPT_HTTPHEADER => $headers,
               CURLOPT_HEADER => TRUE,
               CURLOPT_RETURNTRANSFER, TRUE
             ]);
             if (curl_errno($curl)) {
               echo 'Error:' . curl_error($curl) . "<br>";
             } else { echo " all good<br>"; }
             $resp = curl_exec($curl);

             $header_size = curl_getinfo( $curl, CURLINFO_HEADER_SIZE );
             $header = substr( $resp, 0, $header_size );
             $body = substr( $resp, $header_size );

             $data = json_decode($body, true);

             $explData = explode("\n",$resp);
             $buttons = ["Current", "Next", "Prev", "First"];
             $links = $explData[15];
             $pageLinks = explode(",", $links);
             $pages = array_fill(0, 4, null); //the page URL links
             $rels = array_fill(0, 4, null); //references (i.e "current", "next", "prev", "last")
             $pageNums = array_fill(0, 4, null); //amount of pages
             $i = 0;

             foreach($pageLinks as $p) {
               $pages[$i] = AppHelper::instance()->get_string_between($pageLinks[$i], "<", ">");
               $rels[$i] = AppHelper::instance()->get_string_between($pageLinks[$i], 'rel="', '"');
               $pageNums[$i] = AppHelper::instance()->get_string_between($pageLinks[$i], "?page=", "&");
               $i++;
             }

             if (array_key_exists("errors", $data)) {
               $validReturn = false;
               echo "Invalid page found.</br>";
             }
             else {
               foreach ($data as $d) {
                 if((array_key_exists("id", $d)) && (self::hasBBDirect($d["id"]))) {
                   echo "Matching folder FOUND in course " . $d["id"] . "</br>";
                 } else {
                   echo "No matching folder found in course " . $d["id"] . "<br>";
                 }
               }
             }
             curl_close($curl);
             echo "<h4>Going to view Folder</h4>"; //THE LAST line reached
       
             return view('folder')
                 ->with("data", $data)
                 ->with("rels", $rels)
                 ->with("pages", $pages)
                 ->with("pageNums", $pageNums);
             echo "<h4>Didn't go?</h4>";
         }

And my view, "folder.blade.php":

       <html>
    <head>
        <title>Placeholder</title>
    </head>
    <body>
        <h1>Hi</h1>
    </body>
       </html>
       
       

Why do I never get to the view? The code gets to the "return" call, and stops. What's wrong?

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.