Bootstrap 3 Laravel PHP

Laravel 5.2 CRUD Application

Laravel 5.2 CRUD (Create, Read, Update, Delete ) Application
Written by Yogesh Koli

In this tutorial I am going to provide step by step guide to implement CREAT, READ, UPDATE and DELETE Operations using Laravel 5.2 PHP Framework. 

Development Platform:

Laravel Provides Homestead development environment, it’s my preferred option while working with laravel project, it has all required configuration ready to use for the framework, if you have’t heard about homestead just visit Laravel official website for download and installation. however you can also continue with your existing environment it can be LAMP, MAPM or WAMP just make sure with the following softwares and extensions.

  • PHP >= 5.5.9
  • OpenSSL PHP Extension
  • PDO PHP Extension
  • Mbstring PHP Extension
  • Tokenizer PHP Extension
  • Composer

If you have your server configuration ready to use then let’s get started with the first step to install Laravel framework.

Step 1: Install Laravel:

Open up the terminal and navigate cd to your server root directory and type in following command to install Laravel, application directory is depend on where your server root is located, for example LAMP is having it set to /var/www/.

let’s see what happen next!

Laravel Installing process

After Installing laravel successfully you should see crud-demo folder with laravel application, change the file permissions to be able read, write and execute to do that use following command, make sure you have provided correct path.

You can try to run newly installed laravel project on browser, in my case the URL is: it should show up laravel welcome screen.



Step 2: Database Connection Settings:

Create a database and change settings from .env file showing below, make sure to mention password if database user is having password set.

Step 3: Database migration:

Basically we are going to setup database table with laravel migration, use following command to create migration file from terminal and open it up in the editor. ( All migration files are located in database/migrations folder)

Update the Schema to specify table fields as showing below:

If you ready with the migration file use following to migrate the table.

You will get Migration table created successfully. message in your terminal.

Let’s go the next step to create Laravel Model for task table.

Step 4: Create Eloquent Model:

Open the Task.php file, it should be located in app/Task.php directory and add $fillable variable.

Step 5: Define Routes:

In Laravel we have to define routes to handle request and response,  route can be define in app/Http/routes.php file. open up the routes file and add following code to define routes for our CRUD operations.

Route::get('/', 'TaskController@index'); – To list task by default on home page.

Route::resource('tasks', 'TaskController'); – Resource route it will generate CRUD URI.

ex. or we can use resource route that is  both will work same.

We need to add our resource controller for tasks routes, go ahead and create controller using following command:

Controller are located in app/Http/Controllers directory, you open up the TaskController to view file it should match with below controller file:


Use following command to list and make sure you have all required routes ready to use.

In this case if you run the above command it will list out following routes:

Routes List

Step 6: Install required HTML Package:

I am going to use FORM class in the our blade templates, laravel has removed HTML package from the default configuration, follow next steps to pull html package in using composer

Edit your composer.json file:

Next, use terminal to update composer:

You will see composer is going to pull the package from the repository to our project.

Add new provides in config/app.php file:

Add following classes the aliases array of config/app.php file:

We are good to go the next step to do some designing and coding.

Step 7: Design Layout using Blade Template:

We are going to use layout for all crud pages, Layout is basically a master page for all child pages from the project, Laravel layouts help us to re-use same code within multiple pages.

Create layout page under resources/views/layouts/master.blade.php and add following code:

We have our master page ready to use along with the basic bootstrap design now we will have to pull in bootstrap files from and add those files to public directory of the project.

Next you will see @yield('content') – this is section we are going implement in the child pages.

let’s create folder named task under resources/views/, here we are going to store our views so it will good to organise our project folder structure. I would prefer you to use this kind of file structure for every project it’s good to have organised.

List view:

Create resources/views/task/list.blade.php file and following code:

If you have a look on above code, you will see what I was talking about calling our layout page, so at the very top we are extending the layout page and implementing the  content section which is going to render in the content variable of layout.

In content section first, we have bootstrap design I am using bootstrap panel here to get more better look, you can look the bootstrap css classes for panel for example panel-heading and panel-body.

Next there is html table to loop throughout the $tasks variable which are going to see step by step, for now just keep in mind that whenever you need to call, you should pass $tasks variable.


Don’t forgot we are going to have pagination at the of the task list, rendor() is going to help to generate pagination.

Let’s have a look on our listing view:

Task List View

Create View:

Create new file under resources/views/task/create.blade.php, we are going to use this view to have our create new task form, use following code and add to the create.blade.php page.

Here again we using same master page, so that’s the reusability Okay next we have our create task form here along with the Error section.

Add New Task View

Edit View:

Add resources/views/task/edit.blade.php and add following code:

Edit View

Show View:

Add resources/views/task/show.blade.php to have task details page, go ahead and use following code:

Show Task View

Step 8: Update TaskController file:

Finally we have to do focus on the import part of the tutorial, which our TaskController, go ahead and edit TaskController.php file, and try to math with the following functions. we needs to update our each function.


If you checkout the controller I have added all the operations that we going to needs to handle our resource route along with the blade templates:

Quick description RESTful functions:

index() – use to get task from the table and return with task.list view.

create() – returns task.create view.

store() – handle post request getting from create view, validated the request, create new task and redirect to tasks.index route along with the success message.

show() – find the task details according to the ID and returns view.

edit() – find the task details with the specified ID and returns task.edit view.

update() – handle request coming from edit view, validate the request, update the record and redirect to the tasks.index route.

destroy() – handle Delete method, deletes the record from the table using eloquent modal and redirects back to the tasks.index route.

We are done, I think having read this tutorial you should be able to use laravel now with the it’s important features like eloquent, middleware, routes and controller.

Go start building great laravel applications.

Feel free to comments if you get any issues using this tutorial or you have any question, I always do my best to respond.

To download complete source for this tutorial you can simply visit Github repository to clone/download source code –

Don’t forgot to tell to your friend as well, sharing is caring.

Thanks keep learning….!

About the author

Yogesh Koli

Yogesh Koli is a software engineer & a Blogger lives in India. He's driven by an addiction to learning and a love for adventure. he has 5+ years of experience working with the front-end, back-end, web application development, and system design.

4 Comment threads
3 Thread replies
Most reacted comment
Hottest comment thread
6 Comment authors
Yogesh Koliangamba meeteiCj LuzanoNajouaYogesh Koli Recent comment authors

This site uses Akismet to reduce spam. Learn how your comment data is processed.

newest oldest most voted
Notify of
angamba meetei
angamba meetei

thanks for this tuitorials, it works find in 5.4, got some error regarding html but i fixed it and run it fine. cool. thanks.

Yogesh Koli

Great, Keep Going!

Yogesh Koli

HTML package is missing from the project, follow the Step 6: Install required HTML Package and you will be good to go.

Cj Luzano
Cj Luzano

i do the step but it’s still the same


Thanks a lot for this intersting tutorial. But, I am facing an issue : when I click on “Add New Task” , I got this error : The requested URL /tasks/create was not found on this server.

J.V Krakowski

What does “public $fillable = [ ];” mean?