public function index() { // grab desired commits array from github. Let's try utilizing "knplabs/github-api": "~1.4" first in composer.json $client = new \Github\Client(); $commits = $client->api('repo')->commits()->all('nodejs', 'node', array('sha' => 'master')); $numCommitsToParse = 25; $numCurrentCommitBeingParsed = 0; // save 25 most recent commits to db foreach ($commits as $commit) { if ($numCurrentCommitBeingParsed < $numCommitsToParse) { // grab new Commit instance $cm = new Commit(); // check to see if commit hash entry already exists $cmchk = Commit::where('hash', '=', $commit['sha'])->first(); // if it does not exist, save->db if ($cmchk == null) { $cm->author = $commit['commit']['author']['name']; $cm->hash = $commit['sha']; $cm->msg = $commit['commit']['message']; $cm->date = $commit['commit']['author']['date']; // save to db $cm->save(); $numCurrentCommitBeingParsed++; } } } /*** * * Yoink 25 most recent commits FROM DB (as specified in coding challenge * readme) * * Normally this functionality would probably live in a method somewhere else -- * ahhh the joys of having time to refactor :-) * */ #$savedCommits = Commit::orderBy('date', 'desc')->take(25)->get(); // moved 'orderBy' logic in above comment to Commit model scope $savedCommits = Commit::dateDescending()->take(25)->get(); /*** * * Now that we have the 25 most recent commits, we need to check to see if * the commit SHA (commits.hash) ends in a number, and if so, color that row * to light blue (#E6F1F6) * * !!!! Scratch that !!!! Let's move this functionality to the index.php angular view * where it should live. * */ // foreach ($savedCommits as $savedCommit) { // // if commits.hash ends with num then color row light blue... // } // json up the goodies and send 'em to angular //return Response::json(Commit::get()); /*** * Darn! Looks like Illuminate\Http\Response::json() is belly up. * Let's find something else to json encode with. Come on php, you can do it! */ // return JsonResponse::create($commits); // return JsonResponse::create($tmoo); return JsonResponse::create($savedCommits); }