mardi 28 février 2017

How to access my model in laravel?

I can't seem to figure out what's wrong with this code. I'm running laravel 5.4.

The error: http://ift.tt/2m4rk2X

The Controller function:

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Thread;


class ThreadController extends Controller
{

    public function show($id) {

        return Thread::where('id', '=', $id)->messages();
    }
}

The Model:

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Thread extends Model
{
    public function messages()  
    {
        return $this->hasMany(Message::class)->get();
    }


}



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2mBJZkk
via IFTTT

Aucun commentaire:

Enregistrer un commentaire