My page can't find my Model. Why?

I'm new to Laravel and I'm trying to figure this out.

I'm working through the tutorial at https://www.youtube.com/watch?v=v6SZerzfgIg.

My code right now looks like this:

Here's my "home.blade.php:"

<form action="/insert" method="Post">

Open in new window


My web.php page has my routes structured like this:

Route::get('/home', 'HomeController@index')->name('home');

Route::get('/display','InsertController@index');

Route::post('/insert', 'InsertController@add');

Open in new window


My InsertController looks like this:

use Illuminate\Http\Request;

class InsertController extends Controller
{
	
	public function display() {
		
	}
	
    public function add(Request $request) {
		
		add::display(Request::all());

	}
   
}

Open in new window


I'm thinking that "add::display(Request::all())" is targeting my "add" model sitting in my "app" directory. At that point, I've got this:

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class add extends Model
{
    protected $fillable = ['question_text', 'keywords', 'required', 'type', 'answer_a', 'answer_b', 'answer_c', 'answer_d', 'answer_e'];
}

Open in new window


I'm wrong, apparently. Because when I submit my form, I get this error:

Class 'App\Http\Controllers\add' not found

What am I doing wrong? And am I right in assuming that this code:

add::display(Request::all());

...is going to submit my data and then grab the "display" method and show that page?

I'm a mess...

Straighten me out, please...
Bruce GustPHP DeveloperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Julian HansenCommented:
Why is Add extending model? Surely it should be extending Controllers?
Bruce GustPHP DeveloperAuthor Commented:
Julian, I'm working through some tutorials which is why what I'm about to say may make you think I've got monkeys flying out of my nose.

My thought was that on line #12 of my InsertController.php...

add::display(Request::all());

..."add" was referring to my "add.php" Model. Some of this syntax is still fresh out of the box for me, so I'm not yet confident in the flow of things, but is that right and does that relate at all to what you're asking above?

Thanks!
Julian HansenCommented:
Sorry Bruce - you are correct - I was doing a speed view of the video and missed that you were building the model.

Can you show us more of the code so we can try and replicate.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Bruce GustPHP DeveloperAuthor Commented:
Julian!

I have since been able to figure this out, but I do appreciate your weighing in. I'm going to wrap this question up just for the sake of database hygiene, but I've got another question brewing so feel free to check that out as well at https://www.experts-exchange.com/questions/29139247/Can-you-pass-variables-into-a-Class-in-PHP.html#questionAdd

Thanks!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Laravel

From novice to tech pro — start learning today.