🚀 DevOps & SRE Certification Program 📅 Starting: 1st of Every Month 🤝 +91 8409492687 🔍 Contact@DevOpsSchool.com

Upgrade & Secure Your Future with DevOps, SRE, DevSecOps, MLOps!

We spend hours on Instagram and YouTube and waste money on coffee and fast food, but won’t spend 30 minutes a day learning skills to boost our careers.
Master in DevOps, SRE, DevSecOps & MLOps!

Learn from Guru Rajesh Kumar and double your salary in just one year.


Get Started Now!

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

@extends('master')
@section('content')
<div class="row">
<div class="col-md-12">
<br />
<h3 aling="center">Add Data</h3>
<br />
@if(count($errors) > 0)
<div class="alert alert-danger">
<ul>
@foreach($errors->all() as $error)
<li>{{$error}}</li>
@endforeach
</ul>
</div>
@endif
@if(\Session::has('success'))
<div class="alert alert-success">
<p>{{ \Session::get('success') }}</p>
</div>
@endif
<form method="post" action="{{url('service')}}">
{{csrf_field()}}
<div class="form-group">
<input type="text" name="service_name" class="form-control" placeholder="Enter Service Name" />
</div>
<div class="form-group">
<input type="submit" class="btn btn-primary" />
<a href="{{route('service.index')}}" class="btn btn-primary" role="button">Back</a>
</div>
</form>
</div>
</div>
@endsection

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

Certification Courses

DevOpsSchool has introduced a series of professional certification courses designed to enhance your skills and expertise in cutting-edge technologies and methodologies. Whether you are aiming to excel in development, security, or operations, these certifications provide a comprehensive learning experience. Explore the following programs:

DevOps Certification, SRE Certification, and DevSecOps Certification by DevOpsSchool

Explore our DevOps Certification, SRE Certification, and DevSecOps Certification programs at DevOpsSchool. Gain the expertise needed to excel in your career with hands-on training and globally recognized certifications.