uccdev

uccdev

Member Since 1 Year Ago

Experience Points
7,690
Total
Experience

2,310 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed
35
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start your engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-in-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist Created with Sketch.

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

Level 2
7,690 XP
Feb
26
3 months ago
Activity icon

Replied to Laravel CURL Project Works Fine On Local Machine - FAILS On Server?

As a followup to this, I've replaced buzzi with a different, matching server:

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
10.65. myServer myServer.website.com

However, I still have a curl error number zero. This method here:

 //gets the data from a successful curl request, and returns said data
public function setHeaders($curl) {
  echo "<h1>SetHeaders()</h1>";
  $resp = curl_exec($curl);
  $header_size = curl_getinfo( $curl, CURLINFO_HEADER_SIZE );
  $header = substr( $resp, 0, $header_size );
  $body = substr( $resp, $header_size); //$header_size
  $code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
  if (curl_getinfo($curl, CURLINFO_HTTP_CODE) != 200) {
    echo "<h3>Curl errno: " . curl_getinfo($curl, CURLINFO_HTTP_CODE) . "</h3>";
    echo "<h3>Curl error(): " . curl_error($curl) . "</h3>";
    dd($body);
    return null; 
  }
  $data = json_decode($body, true);
  return $data;
}

This gives me the following output on the screen:

 "SetHeaders()"
 "Curl errno: 0"
 "Curl error(): Failed connect to my.test.instructure.com:443; Operation now in progress"

  "" [dd($body) returns an empty string]

I am trying to understand the curl error message: what does 443 mean? And why would a cURL request that succeeds on my local machine fail when coming from my server?

Any help would be very valuable.

Feb
19
3 months ago
Activity icon

Replied to Laravel CURL Project Works Fine On Local Machine - FAILS On Server?

Thank you for that. I tried both commands. To the curl --ipv4 -v "https://my.test.instructure.com/api/v1/accounts/1/admins?per_page=20" command, I got a full cURL log trace. Of the lines there, these two stood out:

HTTP/1.1 401 Unauthorized
...
"status":"unauthenticated","errors":[{"message":"user authorisation required"}

A check of my /etc/hosts file read like this:

 127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
 ::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
 143.239.2.37 buzzi buzzi.website.com

What exactly should be there instead?

Activity icon

Replied to Laravel CURL Project Works Fine On Local Machine - FAILS On Server?

cURL is definitely installed, curl -V works fine

@braunson curl_error($ch) gave me the following:

 Failed connect to my.test.instructure.com:443; Operation now in progress

From what I've read, it seems this is a timeout error?

I think it might be the program being behind a firewall. How can I check if it is?

Feb
18
3 months ago
Activity icon

Started a new Conversation Laravel CURL Project Works Fine On Local Machine - FAILS On Server?

I have a laravel project that makes a cURL request to a Canvas API endpoint. This project runs perfectly on my virtual machine. But on the centOS 7 server I've ported it to, its cURL requests don't work at all.

I get the following errors:

curl_getinfo($curl, CURLINFO_HTTP_CODE) returns curl error number 0. From what research I've done, this implies the server is refusing the connection

curl_exec($curl) returns false.

a dd of $curl or $resp dd($curl) returns a very empty string.

Below are some sample curl functions I use:

  //NOTE: $this->headers = ["Authorization: Bearer " . myServerAccessToken];
 //sets URL and $curl
 public function getAdmins() {
     $adminsURL = "https://my.test.instructure.com/api/v1/accounts/1/admins?per_page=20";
     $curl = curl_init();

     self::requestCurl($curl, $adminsURL, $this->headers);
     $resp = curl_exec($curl);
     dd($resp); //shows false
     return self::setHeaders($curl);
   }

  //something missing here?
 public function requestCurl($curl, $url, $headers) {
     return 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_CUSTOMREQUEST => 'GET',
       CURLOPT_HEADER => TRUE
     ]);
   }

 //returns "curl errno: 0"
 public function setHeaders($curl) {
     $resp = curl_exec($curl);
     $header_size = curl_getinfo( $curl, CURLINFO_HEADER_SIZE );
     $header = substr( $resp, 0, $header_size );
     $body = substr( $resp, $header_size); //$header_size
     $code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
     if (curl_getinfo($curl, CURLINFO_HTTP_CODE) != 200) {
       echo "<h3>Curl errno: " . curl_getinfo($curl, CURLINFO_HTTP_CODE) . "</h3>";
       dd($body); //EMPTY.
       return null;  //TODO error handling (I think returning null will be enough?)
     }
     $data = json_decode($body, true);
     return $data;
   }
    

Can anyone suggest why this might be happening, and what I could try to fix it? Any advice would be appreciated

Feb
14
3 months ago
Activity icon

Replied to Server Is Looking For Path "vendor/laravelcollective/html/src/helpers.php" Which Doesn't Seem To Exist?

Worked perfectly! The folder is there, and my server's running the site just fine now. Thank you!

Activity icon

Replied to Server Is Looking For Path "vendor/laravelcollective/html/src/helpers.php" Which Doesn't Seem To Exist?

no, it is apache apache. Over the vendor directory, permissions are drwxrwxr-x

Activity icon

Replied to Server Is Looking For Path "vendor/laravelcollective/html/src/helpers.php" Which Doesn't Seem To Exist?

I got the runtime error /var/www/MyProject/vendor/laravelcollective/html does not exist and could not be created

I gather this is a permissions issue, though I'm not sure which permissions to assign my non-root account to bypass this

Activity icon

Replied to Server Is Looking For Path "vendor/laravelcollective/html/src/helpers.php" Which Doesn't Seem To Exist?

I have two problems there, as I have two accounts. One does not have write permission over composer.json, but the other account is the root account, which the server warns me never to run composer commands from. What is the best approach to this, with that in mind?

Activity icon

Replied to Server Is Looking For Path "vendor/laravelcollective/html/src/helpers.php" Which Doesn't Seem To Exist?

I have not. Were you recommending that I call composer require laravelcollective/html on my server?

Activity icon

Replied to Server Is Looking For Path "vendor/laravelcollective/html/src/helpers.php" Which Doesn't Seem To Exist?

Sti3bas, I've run that command now successfully, and indeed, my computer version of the project has the vendor/laravelcollective/html/src folder path. I've git-pushed then pulled the project to my server version of it. However, I still do not see any vendor/laravelcollective folder path.

Has this happened before?

Activity icon

Replied to Server Is Looking For Path "vendor/laravelcollective/html/src/helpers.php" Which Doesn't Seem To Exist?

Thanks for the reply.

composer.json actually does have a laravelcollective value:

  "require": {
    "php": "^7.2",
    "fideloper/proxy": "^4.0",
    "guzzlehttp/guzzle": "^6.4",
    "laravel/framework": "^6.0",
    "laravel/passport": "^7.5",
    "laravel/tinker": "^1.0",
    "laravelcollective/html": "^6.0",
    "mtownsend/collection-xml": "^1.1",
    "mtownsend/request-xml": "^1.1",
    "mtownsend/response-xml": "^1.1"
  },

I just do not have a laravelcollective folder at all for it to point to. Having not touched this file in this project's lifetime, I can't say why.

Activity icon

Started a new Conversation Server Is Looking For Path "vendor/laravelcollective/html/src/helpers.php" Which Doesn't Seem To Exist?

I've uploaded my laravel project onto an apache server. It has an HTTP 500 error.

The logs say it's looking for the following:

 [php7:error] [pid 11339] [client 143.239.128.189:64623] PHP Fatal error:  require(): Failed opening required '/var/www/myProjectPath/vendor/composer/../laravelcollective/html/src/helpers.php' (include_path='.:/usr/share/pear:/usr/share/php') in /var/www/myProjectPath/vendor/composer/autoload_real.php on line 66``

Now, my project folder does have this path: vendor/laravelcollective/html/src/helpers.php But this is not the path that is being sought for: my project has no vendor/laravelcollective path, and yet one is being looked for.

Can anyone explain to me why it might be looking for this? I'd appreciate any insight

Feb
12
3 months ago
Activity icon

Started a new Conversation HTTP Error 500 On One Project On Server But Not The Other?

I've been uploading projects to a centos server lately. One of them is recognised, and shows me the main laravel index page.

The other is not recognised, and gives me a http 500 message.

I cannot check the logs of this page as its storage/logs folder on the server is empty.

I've checked the public directories of both and they seem to be effectively the same: they both have a css folder, a favicon.ico, a robots.txt file and an index.php file.

I change which directory the document root is pointing to. (e.g DocumentRoot = "/var/www/workingProject/public", vs DocumentRoot = "var/www/Err500Project/public")

Any advice on what I can do? I can provide more information on request, I'm just not sure what to look for

Jan
10
4 months ago
Activity icon

Started a new Conversation How To Make PHP Form Refer To A Value On The Same HTML Page?

In PHP Laravel, I have a page which deals with API endpoint data. Right now it paginates this data, which I've managed accordingly:

 <form action="courseList" method="get">
  <input type="hidden" name="pageNumber" value="2"> <!--where '2' is the next page''
  <input type="submit" name="Submit" value="Next Page">
 </form>'

This passes in a single pageNumber argument, which works fine for my URL routing:

Route::get('/c/courseList/{pageNumber}', '[email protected]')->name('courseList');

Which then starts with:

public function searchByCourse(Request $request) { ...

This gives $request a pageNumber value, and it works. That's great.

Now I want to be able to add a "Sort" value to $request. But the catch is that this value has to be defined outside of the form I'm using. It has to come from another HTML field in the page.

I'd like to put it in as a hidden value inside the form field I listed above, and have its value stored there. e.g:

 <input type="radio" name="myOtherInput" value="x">
 ...

 <form action="courseList" method="get">
     <input type="hidden" name="sort" value="nameOfHTMLFieldItem"> ...

I've tried researching this problem, but most results are about passing values from external pages, not dealing with the internal.

Is this possible? How might I do it?

Dec
10
5 months ago
Activity icon

Replied to "Call To Undefined Method" Of A Clearly Defined Method?

"I would argue that calling a controller method from another controller is bad practice. You should extract the logic to its own service class, or at least a trait."

Would it do to put the function inside of a Helper class, that both controllers use? That I might store in an App\Helpers directory?

Dec
09
5 months ago
Activity icon

Started a new Conversation "Call To Undefined Method" Of A Clearly Defined Method?

I have a class IndexController class with its own method verifyUser.

 public function verifyUser($user) {
     echo "Test!";
  }

Its actual code isn't as important as the nature that it isn't called when I want it to be.

It works perfectly fine in its base class, but when I try to call it in other classes I get different results:

   $this->indexController = new IndexController();
   $this->indexController->verifyUser(auth()->user());

I can confirm that auth()->user() is fine. The error message I get is something else: Call to undefined method: IndexController::verifyUser()

I can reword the call in a few different ways, such as:

 IndexController::verifyUser(auth()->user());

Or

 $thing = $this->indexController->verifyUser(auth()->user());

But it doesn't fit it.

I note that if I simply paste the code that verifyUser has into my new class, it works just fine. It's just this one form of method calling. I don't get why it works. Could anyone shed some light on why I might be getting this issue?

Dec
05
5 months ago
Activity icon

Replied to Is It Possible To Paginate Two Different Tables On The Same View?

I see, Snapey, thank you. What name exactly should I give them? Should the name match the div they are in? Or the name of the table they're referring to? Or the dataset, like courseData?

EDIT: I ask because I've modified my View with the following, where I put userData= value, and it unfortunately gave me a curl error:

  <?php //TODO Page Information. Configured for "v1/accounts/1/courses" endpoint, reconfigure to "v1/courses" endpoint
  //dd($cata);
  if (isset($uPageNums)) {
    ?><a href="<?php echo $uPageNums[0]; ?>" rel="<?php echo $uRels[0]; ?>"><?php echo $uRels[0]; ?></a>
    <?php
//      echo "<a href='" . $pageNum . "' rel='current'>Current</a>";
      if ($uPages[1] != null ) {
        ?> <a href="userData=<?php echo $uPageNums[1]; ?>" rel="<?php echo $uRels[1]; ?>"><?php echo $uRels[1]; ?></a>
      <?php
    } else { echo "Error"; }
      if ($uPages[2] != null) {
      ?>  <a href="userData=<?php echo $uPageNums[2]; ?>" rel="<?php echo $uRels[2]; ?>"><?php echo $uRels[2]; ?></a>
      <?php
      }
      if ($uPages[3] != null) {
        ?> <a href="userData=<?php echo $uPageNums[3]; ?>" rel="<?php echo $uRels[3]; ?>"><?php echo $uRels[3]; ?></a>
<?php }
  } else {
    echo "No user pageNums set!";
  }
Dec
04
5 months ago
Activity icon

Replied to Is It Possible To Paginate Two Different Tables On The Same View?

Thank you jl. I need to finish work now but I will give them another look in the morning.

Also, thanks, that makes me feel much better :D

Activity icon

Replied to Is It Possible To Paginate Two Different Tables On The Same View?

Also I've updated the original post. It now shows how I get the thread data. Just in case it's useful for understanding or giving feedback

Activity icon

Replied to Is It Possible To Paginate Two Different Tables On The Same View?

Thanks for your reply jlr. I am not using JS Ajax. I use PHP Laravel with custom functions to get the pagination links from my API endpoint. Then in the View, I use basic HTML in two separate divs to display the data.

EDIT: Thank you for the link. It seems to refer to Eloquent pagination in general, which is quite different to how I do it. As someone who's new to using Eloquent pagination, could you suggest how I might use it?

Activity icon

Started a new Conversation Is It Possible To Paginate Two Different Tables On The Same View?

So I have a laravel project that fetches data from not one, but two API endpoints. API endpoints like Canvas, so I cannot use any DB::table queries or other tricks. It gets the data from a Courses endpoint as well as a Users endpoint. I've been requested to fit the data of both tables on the same view.

Displaying all the data is fine, I'm able to collect the data from both tables in my controller and parse it to the view:

return view('index')
  ->with("courseData", $courseData) //course Data
  ->with("cPages", $cPages) //course pages
  ->with("cRels", $cRels) //course references 
  ->with("cPageNums", $pageNums) //course page numbers
  ->with("userData", $userData) //user data
  ->with("uPages", $uPages) //user pages
  ->with("uRels", $uRels) //user references
  ->with("uPageNums", $uPageNums); //user page numbers

I'm also able to successfully paginate the Courses table.

if (isset($cPageNums)) {
      ?><a href="<?php echo $cPageNums[0]; ?>" rel="<?php echo $cRels[0]; ?>"><?php echo $cRels[0]; ?></a>
      <?php
        if ($cPages[1] != null ) {
          ?> <a href="<?php echo $cPageNums[1]; ?>" rel="<?php echo $cRels[1]; ?>"><?php echo $cRels[1]; ?></a>
        <?php
      } else { echo "Error"; }
        if ($cPages[2] != null) {
        ?>  <a href="<?php echo $cPageNums[2]; ?>" rel="<?php echo $cRels[2]; ?>"><?php echo $cRels[2]; ?></a>
        <?php
        }
        if ($cPages[3] != null) {
          ?> <a href="<?php echo $cPageNums[3]; ?>" rel="<?php echo $cRels[3]; ?>"><?php echo $cRels[3]; ?></a>
  <?php }
    } else {
      echo "No course pageNums set!";
    }

For comparison's sake, my User pagination code, which is only different in that it uses different variables:

if (isset($uPageNums)) {
        ?><a href="<?php echo $uPageNums[0]; ?>" rel="<?php echo $uRels[0]; ?>"><?php echo $uRels[0]; ?></a>
        <?php
      if ($uPages[1] != null ) {
        ?> <a href="<?php echo $uPageNums[1]; ?>" rel="<?php echo $uRels[1]; ?>"><?php echo $uRels[1]; ?></a>
      <?php
    } else { echo "Error"; }
      if ($uPages[2] != null) {
      ?>  <a href="<?php echo $uPageNums[2]; ?>" rel="<?php echo $uRels[2]; ?>"><?php echo $uRels[2]; ?></a>
      <?php
      }
      if ($uPages[3] != null) {
        ?> <a href="<?php echo $uPageNums[3]; ?>" rel="<?php echo $uRels[3]; ?>"><?php echo $uRels[3]; ?></a>
<?php }
  } else {
    echo "No user pageNums set!";
  }
  ?>

So what happens when I click the buttons these create in my view? Well if they're the Course buttons, they work perfectly fine. I move between all the pages I need to.

When I click the user ones? I move through the Course table instead. It's as if the page only recognises the one set, not the other. So I suppose I've two big questions.

  1. Is what I'm looking to do possible? Paginate between two tables on the same webpage? I'm aware it might be easier to simply have a separate view for each, but management would prefer this way.

  2. If it is possible, what can I do to accomplish that? Or what is the mistake I'm presently making?

Any help on this matter would be greatly appreciated.

EDIT: For further clarity, here is how I sort pagination. Canvas naturally paginates its data, so I try to retrieve its links directly from that. Then after extraction, I pass the data containing those onto the view.

    $explData = explode("\n",$resp); //Need the page links in order to move from data to data, since Canvas keeps all its data paginatable.

    $courseLinks = self::getLinks($explData); //gets links from data
    if (is_null($links)) {
      echo "exec'd data did not contain any links";
      return null;
    }
    $cPageLinks = explode(",", $links); //the actual strings in full. Array form.
    $cPages = array_fill(0, 4, null); //the page URL links
    $cRels = array_fill(0, 4, null); //references (i.e "current", "next", "prev", "last")
    $cPageNums = array_fill(0, 4, null); //amount of pages
    $i = 0;
    //loop to populate the above
    foreach($cPageLinks as $p) {  //get the important page details and store them in these arrays
      $cPages[$i] = AppHelper::instance()->get_string_between($cPageLinks[$i], "<", ">"); //helper method, returns raw string.
      $cRels[$i] = AppHelper::instance()->get_string_between($cPageLinks[$i], 'rel="', '"');
      $cPageNums[$i] = AppHelper::instance()->get_string_between($cPageLinks[$i], "?page=", "&");
      $i++;
}

This process is mirrored for getting the User endpoint's pages.

Dec
02
5 months ago
Activity icon

Started a new Conversation Optimal Way To Pass User Name? (Based Off Data From Web Endpoint)

I'm implementing a search option which lets someone find a user from a webpage, depending on their name.

Look at this code here:

 public function searchByUser(Request $request) {
    $first = $request->firstname;
    $sur = $request->surname;
    $userURL = "https://my.website.com/?search_term=$first+$sur";

If someone were to type "Claire" for the firstname with no surname, it'd give me every user with "Claire" in the name, and the same rules for the surname, as well as combined together.

Now, this is functional, but I'm wondering three things:

  1. Is it optimal?
  2. At the moment I've had to split the name into two variables: what if I wanted to keep them in one? At the moment that doesn't work because my code can't interpret the split too well (e.g instead of "John%20Smith", it sees "John Smith", which gives me a broken result)
  3. Furthermore, what if someone wants a middle name, or has a more complex name to put in? e.g a middle name, like "John Jacob Smith" I suppose I can make a "middle_name" variable, but if there's another complication to the name, what then? Is there a one-size-fits-all for this sort of thing?

If anyone has any advice, that'd be helpful

EDIT: I should clarify, this is based on data from a webpage endpoint, so MySQL solutions will unfortunately not work.