MYHOSPITALNOW.COM

Find Trusted Doctors & Hospitals

Discover healthcare providers, compare hospitals, and explore treatment options worldwide.

Free Treatment Quotes • Doctor Search • Hospital Comparison

Find Healthcare Options

www.myhospitalnow.com

How to implement CRUD functions in the Laravel PHP Framework? Part-1

How to implement CRUD functions in the Laravel PHP Framework?

Within computer programming, the acronym CRUD stands for create, read, update and delete.

Step 1. Create a DataBase CustomerService.

PhpMyAdmin Databases page creating a new database named CustomerService

Step 2. Right Click inside htdocs folder and open Git Bash.

Windows Explorer htdocs folder with the right-click menu showing Git Bash Here

Step 3. To create a Project,  we have to write following command.

composer create-project --prefer-dist laravel/laravel CustomerService "5.8.*"Code language: JavaScript (javascript)
Git Bash running composer create-project laravel/laravel CustomerService 5.8 in htdocs

Step 4. Open Folder CustomerService in sublime text.

Mysql Database connection Laravel

Step 5. Go to .env file to set the project path and give the project DB_DATABASE name and DB_USERNAME name.

Laravel .env file in Sublime Text with APP_URL set to the CustomerService public path
Laravel .env file in Sublime Text with DB_DATABASE CustomerService and DB_USERNAME root selected

Step 6. Go to config/database.php give the project DB_DATABASE name and DB_USERNAME name.

Config/database.php in Sublime Text with mysql database set to CustomerService and username root

Step 7.  To create one model for creating table, write following command.

$ php artisan make:model Service -m
Git Bash terminal running php artisan make:model Service -m in the CustomerService project

Step 8. To generate migration file for our Crud Operation in database/migrations folder.

 public function up()
    {
        Schema::create('services', function (Blueprint $table) {
            $table->bigIncrements('service_id');
            $table->string('service_name');
            $table->timestamps();
        });
    }Code language: PHP (php)
Laravel create_services_table migration with service_id, service_name and timestamps columns in up()

Step 9. After writing the above code in that migration file, migrate this table into the MySQL database, so we have to write the following command.

$ php artisan migrate
Git Bash terminal running php artisan migrate in the CustomerService project

Step 10.  Laravel use PHP blade templating for display output on the web page. By using the blade template we can extend the master template from the child template.  Create master.blade.php file in Resource/views

Master.blade.php layout with jQuery, Bootstrap links and @yield('content') inside a container div

Step 11. To create child file resources/views/Service folder with name create.blade.php. To extend the master template by using this @extends(‘master’). 

Create.blade.php extending master with error alerts and a form to add a service name

Step 12.  To display this view file in the browser, so Create one controller and define the route of that controller then after we can display view file in the browser. To Create a Controller in App/Http/Controller folder so, write the following command.

$ php artisan make:controller ServiceController --resource
Git Bash terminal running php artisan make:controller ServiceController --resource

Thanks

Find Trusted Cardiac Hospitals

Compare heart hospitals by city and services — all in one place.

Explore Hospitals
With MotoShare.in, you can book a bike instantly, enjoy doorstep delivery, and ride without worries. Perfect for travelers, professionals, and adventure enthusiasts looking for a seamless mobility solution.

Related Posts

Todo Application in Laravel

1.Create Project in Laravel Composer create-project laravel/laravel todolist 2.Create CRUD Controller php artisan make:controller TodosController –resource 3.Route setup of CRUD Controller routes/web.php 4.Create Database todolist localhost/phpmyadmin create…

Read More

How to display a table in a Verticle or Horizontal form in the Laravel PHP Framework? Part-1

How to display a table in a Verticle or Horizontal form in the Laravel PHP Framework? How to Store Seed file into Database. Click There are two…

Read More

Simple Ajax CRUD Application in Laravel

Step 1 – Create a fresh laravel projet First off all , create a project using following command given below – Change Directory to AjaxCrud folder Step…

Read More

HOW TO CREATE EVENT CALENDAR IN LARAVEL? PART-3

Step 1.Create a Database in phpMyAdmin. (Write the same name of database which was written in .enf databse name). Step 2.  We use the migrate command to…

Read More

HOW TO CREATE EVENT CALENDAR IN LARAVEL? PART-2

Step 1.Create a Laravel Project Firstly, Create a new project in laravel, so we open Git Bash,  Go to My Computer/This PC–>LocalDisk(C:)–>Xampp–>Htdocs (Press right click on Mouse)…

Read More

CRUD Operations in Laravel PHP Framework

Step 1 – Download Laravel 5.8 In first step you have to download Laravel 5.8 version. For this you have to go to command prompt, in which…

Read More