mardi 15 décembre 2015

Laravel 5 - Loading Relationships Triggers Server Error 500

I just bought a Managed VPS on GoDaddy (with CentOS6 + cPanel, Apache 2.4.10, PHP 5.5) and moved my Laravel5 app from a GoDaddy shared hosting.

The app seems to be working, but I get an Internal Server Error 500 at a particular point where I eager-load some relationships. FYI, it's definitely not a .htaccess problem, as passing an empty array in the byGuid() method eliminated the error. Also, the relationships, when called directly as $obj->relationshipName, and not being eager-loaded, seems to work fine.

Request URI: http://ift.tt/1YhSkVc

Controller:

public function getObject(ViewObjectRequest $request) {
           $object = $this->objectsRepo->byGuid($request->guid, [
            'latestAmbientTemp',
            'latestHumidity',
            'latestWeight'
        ]);

        //some other code here, irrelevant....
   }

Repository:

public function byGuid($obj_guid, array $relationships = []){
        if(!is_null($obj= Obj::where('guid', $obj_guid)
            ->with($relationships)
            ->first())) return $obj;
    }

Relationships in Object:

public function latestAmbientTemp() {
        return $this->hasOne('BST\Models\TemperatureAmbient')->latest();
    }

public function latestHumidity() {
        return $this->hasOne('BST\Models\Humidity')->latest();
    }

public function latestWeight() {
        return $this->hasOne('BST\Models\Weight')->latest();
    }

Laravel log in storage/logs/somelog.log is empty. Apache log does not give any details about the errors:

[15/Dec/2015:07:45:14 -0700] "GET /obj/view/76a7443f-9e49-4634-9881-b9a936eb4e4c HTTP/1.1" 500 - "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.86 Safari/537.36"

Any ideas? I'm really stuck on this and removing the eager-loads is not desirable, so any help would be much appreciated! Thanks.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire