Wednesday, December 26, 2018

Create simple CRUD using Laravel 5.7 (Part 2 - Create Controller and Model)


Hey guys...Welcome back. Today we are going to create controller and model files in Laravel.
For this we use the artisan commands. It’s easy.


First open command prompt. Go to the project directory.

cd\
cd\xampp\htdocs\MyFirstPro\blogs


To create controller, use command ‘ php artisan make:controller studentController
Also, we can set the modal also to this code.

Finally, we can make a command as ‘ php artisan make:controller StudentController --resource  --model=Student

When you fire this command there will ask for generate the Student model. Hit yes to that. Then you can create the controller file and the model file successfully.

Note : When you name the model file you must put the singular word of the table name for the file name. Here we use ‘students’ as the table name and you must put the ‘Student’ as the model file name. This is concept of the Laravel.

So.. Now we are creating the controller file and model file. You can see the controller file project folder->app->Http->Controllers folder and the model file in app folder.OK..

Now we have to create the view files now. In the next tutorial we will Do it. Thank you. Hope this will helpful to you. Hope your comments.

No comments:

Post a Comment

Create simple CRUD using Laravel 5.7 (Part 4 - Modify Controller, Model and Create route)

Hey guys...Welcome back. Today we are going to create controller and modal file in Laravel. In the controller file, you can see after we g...