DEV Community

Cover image for Laravel 8 CRUD App, A simple guide

Laravel 8 CRUD App, A simple guide

Kingsconsult on September 09, 2020

Laravel is a PHP-based web framework with an expressive, elegant syntax. It is termed the framework for web artisan. The foundation has already lai...
Collapse
 
lodzax profile image
Lloyd Magora

Thanks for the great tutorial, however I'm facing a challenge when i deploy the app to a localhost server, I added some modals and these dont open on the production server but open on the dev server, pliz help me

Collapse
 
voland700 profile image
Max Volcov • Edited

I try create Controller and Model:

Collapse
 
kingsconsult profile image
Kingsconsult

add this

use App\Http\Controllers\ProjectController;

to the top of your web route file

and also you did not add the model for Project, the model should be

php artisan make:controller ProjectController --resource --model=Project

Collapse
 
voland700 profile image
Max Volcov

Thank you! This problem was solved.

Collapse
 
kuz_inc profile image
Null

im new in laravel, can i combine this with your jetstream tutorial ?

Collapse
 
kingsconsult profile image
Kingsconsult

Yes, I wrote this before the jetstream, you can start with the jetstream because it will create the resources/views/layouts folder automatically for you, then you add the necessary code, but in the case where you have finished this tutorial, just rename the layout folder to prevent error

Collapse
 
kingsconsult profile image
Kingsconsult

You can also reach out to me personally if you are having any errors

Collapse
 
ann143 profile image
Ann143

When I run the project, this was the result "SQLSTATE[42S22]: Column not found: 1054 Unknown column 'updated_at' in 'field list' (SQL: insert into projects (name, introduction, location, cost, updated_at, created_at) values (Apple, This is fruit., Cebu, 10, 2021-05-05 01:49:18, 2021-05-05 01:49:18))". What is the problem of this? I am beginner with Laravel.

Collapse
 
nannim profile image
Nannim

could you review your ProjectsController, projects table in the database and Projects model to make sure you are not missing an entity that may be offsetting the sequence of items to be entered into the database from the form? else

it appears that within your database, you need to ensure that you have a projects table, you can delete it and create it again using

php artisan make:migration create_projects_table

this will create a table in your database/migrations directory,
Laravel will do this by default containing the updated_at, created at
make sure there's also an Id attribute
making three attributes in the create_projects_table (supposedly by default) file then you can add the name, introduction, location and cost
next you need to run

php artisan migrate

it should work now

Collapse
 
abel4545 profile image
Abel4545

ErrorException
Use of undefined constant ‘projects’ - assumed '‘projects’' (this will throw an Error in a future version of PHP)

Collapse
 
dswwood profile image
dswwood

The problem is that the code you copied has back-quotes rather than 'forward-quotes'.

Collapse
 
nmossa profile image
nmossa

change
Route::resource('projects', ProjectController::class);
to
Route::resource("projects", ProjectController::class);
double quota. It should work with you. I got the same problem. Very helpful

Collapse
 
martydotcom profile image
martydotcom

Thank you, worked for me

Collapse
 
abel4545 profile image
Abel4545

ErrorException
Use of undefined constant ‘projects’ - assumed '‘projects’' (this will throw an Error in a future version of PHP) why this happen help !!!!1

Collapse
 
kingsconsult profile image
Kingsconsult

What were you doing that it throws the error?

Collapse
 
abel4545 profile image
Abel4545

just i did according your lessen finally this happen

Thread Thread
 
abel4545 profile image
Abel4545

its when i finished everything according the lesson the i tryed in the browser localhost:8000/projects this happen

Collapse
 
waldekgraban profile image
Waldemar Graban

Why is SOLID missing?
Why are the operations on the object not in the service?
Why is Eloquent in the controller and not in the repository?
Why is validation not in request?

But overall the rest is fine :)

Collapse
 
yunweneric profile image
Yunwen Eric

Works well for me.
Thanks a million

Collapse
 
martydotcom profile image
martydotcom

Excellent tutorial, works great and looks great, thank you

Collapse
 
martydotcom profile image
martydotcom

Just what I'm looking for, I will give it a go, thanks for the tutorial

Collapse
 
daynur2 profile image
¶°***Dayour***°¶¿™

This is a great tutorial. Very helpful. Thank you