Skip to content
Advertisement

Laravel 9.x Contact form can’t connect to class

I’m trying to make a contact form. Main idea is user will send data, I will save the data to database, I will get the data from database, I will send the data as an email.

I was following a tutorial -> https://www.positronx.io/laravel-contact-form-example-tutorial/

When I tried to reach classes on my controller it can not find it.

Controller says this

But I have the file here

When I run the code I’m having this -> Cannot instantiate abstract class IlluminateDatabaseEloquentModel

ContactUsFormController.php

JavaScript

This one making me thinking. In the tutorial he didn’t write a single code into this file but still calling a class from there. appMailscontact.php

JavaScript

appModelsContact.php

JavaScript

Do I have a typo? What I am missing? Sorry I’m a beginner

Advertisement

Answer

the issue you call Model::create(); model is just an abstract class, not your concrete model

replace

JavaScript

with

JavaScript

also change namespace AppMail; in your Contact model to namespace AppModels;

to know more information about Mail facade check this

https://laravel.com/docs/9.x/mail#sending-mail

I hope it’s useful

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement