mercredi 23 décembre 2015

Laravel 5 Creating default object from empty value

I have a simple model and I'm trying to create a new instance.

Can anybody tell me what I'm doing wrong!

I'm getting the error "Creating default object from empty value"

Within my controller I have the model defined:

    <?php

    namespace App\Http\Controllers;

    use Illuminate\Http\Request;

    use App\Keygen;

    use Auth;
    use Response;
    use App\Http\Requests;
    use App\Http\Controllers\Controller;

    class APIController extends Controller
    { 



    public function addKey(){
                $Key = NEW Keygen;
                $key->key = 'test';
                $key->save();
    }

}

To test this very basic function I have sent a get request to the url and routed it to the function on the controller.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire