Laravel 5.4 From Scratch: Eloquent 101

Posted 1 year ago by Mick79

OK... bear with me.

I think I have followed the tutorial step by step. I have checked a few times, but clearly i have missed something. When using query scopes I am getting an error. Here is the code from my route and then my model.


  Route::get('/test', function () {


        return view('test', compact('tasks'));



namespace App;

use Illuminate\Database\Eloquent\Model;

class Task extends Model

    public function scopeIncomplete($query) {

        return $query->where('isComplete', 0)->get();


and the ERROR:

Type error: Too few arguments to function Illuminate\Support\Collection::get(), 0 passed in /Users/mick/Dropbox/Projects/laratest1/routes/web.php on line 23 and at least 1 expected

Someone please help :-)

For what it's worth, I think I know what it is but unsure as to how to resolve. The query scope is looking for an arguement ($query) - but where / how to pass that in in the route? Jeffrey didn't show the route in the video, he did it all in Tinker.


Please sign in or create an account to participate in this conversation.