0

I have a project I'm working on right now, in which I created a database to hold some info. I've already created a view and a controller where I can add data to the DB and it works. But for some reason when I try to use on a view to list my information it won't work.

Here's my model:

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Banner extends Model
{
    protected $fillable = ['descricption','image'];
}

And these are the first few lines of my view which laravel point to error:

@php

use\app\Banner;
$banner = new Banner;
$banners = Banner::all();

@endphp

Whenever I try to open this view, I get the "Class 'app\Banner' not found" error. What am I doing wrong? Since it worked to add data to the database before, and I did remember of putting the use\app\Banner;

1 Answer 1

1

The namespace is App not app. Always act like case sensitivity matters and you won't have these problems.

use App\Banner;

Side Note: you can pass this data to your view instead of having to do this query in your view.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you! I can't believe it was such a trivial error.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.