0 Best Reply Awards

  • Member Since 3 Years Ago
  • 63 Lessons Completed
  • 1 Favorite

20th June, 2018

lukeify started a new conversation Laravel Homestead-based Nginx/PHP Returns 500 After Several Hours Of Working Correctly • 3 months ago

Hi all. I'm encountering an extremely frustrating problem running the homestead base box of 6.1.0 on Virtualbox 5.2.12 — in short, after several hours of a working php/laravel environment on the Homestead VM, I'll start getting timeouts and 500 errors when I try to access my application. I can still remotely login to the MySQL database over port 33060 (default), but nginx/php is just not responding — and I'd like to figure out why. What steps should I take to resolve this?

The only workaround I've found so far is to do a complete vagrant destroy --force and rebuild the VM, which takes upwards of 20 minutes and is not a livable solution.

Will happily provide more information as necessary.

13th November, 2015

lukeify started a new conversation Polling Returns Laravel 500 NotFoundHttpException • 2 years ago

I'm trying to setup a node.js server, and it's not working.

Node.js code:

var app = require('express')();
var server = require('http').Server(app);

var io = require('')(server);

var redis = require('ioredis');
var Redis = new redis();


Redis.on('message', function(channel, message) {
    message = JSON.parse(message);

    console.log(channel, message);

io.on('connection', function() {

Serverside code:

var socket = io.connect('');

        socket.on('foo', function(data) {

All this does is triggers the following HTTP long polling requests in my client:

Server 500 error, #29 Symfony\Component\HttpKernel\Exception\NotFoundHttpException in /home/vagrant/myapp/vendor/laravel/framework/src/Illuminate/Routing/RouteCollection.php:161

What am I doing wrong?

13th October, 2015

lukeify started a new conversation Bidirectional Communication Between And Laravel? • 2 years ago

Watching this video:, it occurred to me that the way Jeffrey is 'causing an action to occur' is through an HTTP request to a page (fetching the '/' page adds a user). When that request occurs, an event is broadcasted through Redis which is then send out to all listeners via

Is this not an example of one way websocket communication, rather than bidirectional communication? It is not using the websocket architecture to actually send data to the server, rather just noticing a HTTP request is being made and then sending data over the websocket protocol from the (Node.js) server -> client.

I guess what I'm really trying to ask is is there a way to achieve true bidirectional communication over websockets between the client and a PHP server? i.e., a websocket request (not an HTTP request) goes to the PHP server, which then manipulates it and can broadcast an event back to any clients.

Consider this example: imagine a commentator annotating a video livestream, with viewers both watching the video and recieving updates from the commentator.

Can the Commentator make an update over the websocket protocol to the PHP server, rather than making a POST request over the HTTP protocol to the PHP server?

2nd March, 2015

lukeify started a new conversation Bashrc & Getting Off MAMP • 3 years ago

So I want to get off MAMP, and Jeremy is making it seem like Vagrant is the way to go. He says it's super simple. But 2 minutes into it, I'm already lost.

Step 2 is to add an alias to a ~/.bashrc file. Cool.

The only problem is, whatever he does over the next 30 seconds is pretty much voodoo wizardry to me. I don't get it. It goes too quickly. And he starts meandering off about aliases.

I don't use Vim/vi whatever it is, I run on a Mac, I have no idea which bashrc is. Can someone tell me, step by step, in plain human readable English, how I can add that snippet of text linked in the video to my bashrc file?

24th January, 2015

lukeify started a new conversation How To Force Laravel Eloquent To Play Nicely With A Query Which Returns No Results? • 3 years ago

I have a database query set up as a scoped query in one of my models, where in some instances no results may be returned, and it's perfectly fine for it to do so:

public function scopeLastFromLaunchSite($query, $site) {
    return $query->whereComplete()->whereHas('launchSite', function($q) use($site) {

This query works perfectly fine if there is at least one row in the result, but as soon as there is none, it returns a hugely lengthy Builder object that is filled with recursions which essentially crashes my browser.

My question is...

How can I detect this and simply return something like false or "No results were found."?

What I've tried...

I've tried using the firstOrFail() method in place of first(), but that simply returns a ModelNotFoundException which gives me two solutions:

  1. Handle it in global.php with App:error. This is not preferable as no returned results is not an error. Just one of the many possible outcomes.

  2. Catch the exception in each method, which results in code duplication. I've actually been unable to get this to work either. I try using the ModelNotFoundException class and catching it, but it never gets caught:

    use Illuminate\Database\Eloquent\ModelNotFoundException;
    // ...
    try {
        //my query
    } catch (Illuminate\Database\Eloquent\ModelNotFoundException $e) {
        return false;
    // otherwise, return as normal

How can I simply return false or some falsey value when a query on my model returns no results, instead of simply printing out this hugely lengthy error?

23rd January, 2015

lukeify started a new conversation Responsibility: Where Does $this->user Come From? • 3 years ago

While watching the Controller Responsibility video, he placed the Validation into a method on the User model at about 5:15. He references the validation with $this->user without instantiating a User. If I attempt to do the exact same thing, I get the message:

Undefined property: UsersController::$user

Additionally, if the validation fails, he seemingly grabs the errors directly from the uninstantiated user, $this->user->getErrors().

How is this possible? Is this just demonstrating how validation in the model might work, and I actually do have to instantiate the user? Or should I make my validation method static?

21st January, 2015

lukeify started a new conversation Create A Eloquent Relationship Between A Parent Table And A Lookup Table? • 3 years ago

I'm using Laravel 4.2 and I'm slowly building a complex website, and I've come across a relationship between two of my tables that I cannot immediately figure out how to map together with Eloquent. Here is the relevant schema:

table `missions`
mission_id (PK) | name           | launch_site_id (FK)
1              | someMission    | 1
2              | anotherMission | 3
3              | moreMissions   | 1

table `launch_sites`
launch_site_id (PK) | name   | location
1                  | Kwaj    | <some coordinate>
2                  | Florida | <some coordinate>
3                  | Russia  | <some coordinate>

As you can see, the table launch_sites is a lookup table for missions, and each mission has a single launch site (guaranteed).

I tried representing this with a hasOne & belongsTo relationship in Eloquent ORM:

class Mission extends Eloquent {
    public function launchSite() {
        return $this->hasOne('LaunchSite');

class LaunchSite extends Eloquent {
    protected $table = 'launch_sites';

    public function mission() {
        return $this->belongsTo('mission');

However, I quickly realized this would not work as a launch site does not "belong to" a mission. With this relationship, I get the error:

Column not found: 1054 Unknown column 'launch_sites.mission_id' in 'where clause' (SQL: select * from launch_sites where launch_sites.mission_id = 3 limit 1)

What relationship setup in Eloquent do I want so I can correctly query and fetch the launch site from a mission like so?

Mission::{{Some Query}}->with('launchSite'); 

18th January, 2015

lukeify left a reply on Translating A One To One Join SQL Query Into Laravel's Eloquent Syntax • 3 years ago

Hey henrique, that worked perfectly. Thanks!

17th January, 2015

lukeify started a new conversation Translating A One To One Join SQL Query Into Laravel's Eloquent Syntax • 3 years ago

I need some help translating the following query I have into Eloquent:

SELECT vehicles.vehicle, COUNT(vehicles.vehicle) AS vehiclecount 
FROM vehicles 
INNER JOIN missions ON missions.mission_id=vehicles.vehicle_id 
WHERE missions.status='Complete' GROUP BY vehicles.vehicle

This, for example, will output the following result:

vehicle  | vehiclecount
Falcon 9 | 3
FH       | 1

I already have both my Mission and Vehicle models linked with a one to one relationship:

class Vehicle extends Eloquent {
    public function mission() {
       return $this->belongsTo('Mission');

class Mission extends Eloquent {
    public function vehicle() {
        return $this->hasOne('Vehicle');

I am sure this query will either involve the use of the whereHas or selectRaw method, but I so far have been unable to correctly chain the correct methods together to produce the result I need.

16th January, 2015

lukeify started a new conversation View Presenters. Why Am I Failing At This? • 3 years ago

I'm trying to follow the "View Presenters" video, and I'm getting stuck on some of the final steps.

Firstly, my directory structure is the following:



In my presenter, I have a name method which should format the name as I like:

class StatisticPresenter {
public function name() {
    return $this->entity->name . ' | Some Presentation';

Yet, when called, Laravel gives me the error Undefined property: StatisticPresenter::$entity.

Why is this? Where does entity come from, anyway?

21st October, 2014

lukeify left a reply on Marked As Watched Not Working • 3 years ago

Same here. I can't seem to get videos I have watched to be marked as complete.

Edit Your Profile

Want to change your profile photo? We pull from