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.

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

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

composer create-project --prefer-dist laravel/laravel CustomerService "5.8.*"

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.

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

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

$ php artisan make:model Service -m

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();
        });
    }

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

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

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’)

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

Thanks