Sunday, April 19, 2015

CRUD Operations in Laravel 5 with MYSQL, RESTFUL

CRUD Operations in Laravel 5 with MYSQL, RESTFUL

Here we are to see the changes from laravel 4.3 to laravel 5, At the end of this tutorial, you should be able to create a basic application in Laravel 5 with MYSQL where you could Create, Read, Update and Delete Books; also we will learn how to use images in our application. We will use RESTFUL for this tutorial.

1. Create bookstore project

Lets create the project called bookstore; for this in the command line type the following command.
 
composer create-project laravel/laravel bookstore --prefer-dist

2. Testing bookstore project

Go to the project folder and execute the following command
 
php artisan serve

Open a web browser and type localhost:8000
bookstore project
Testing bookstore project

Until this point our project is working fine. Otherwise learn how to install Laravel in previous posts.

3. Create database for bookstore

Using your favorite DBMS for MYSQL create a database called library and a table called books with the following fields:
table for bookstore

Please make sure you have exactly these fields in your table, specially update_at and created_at, because Eloquent require them for timestamps.

4. Database setup for bookstore

Here is one of the biggest changes in laravel 5 for security (application and database) Go to bookstore/.env and change the configuration like shown here:

.env file
APP_ENV=local
APP_DEBUG=true
APP_KEY=tqI5Gj43QwYFzSRhHc7JLi57xhixnDYH

DB_HOST=localhost
DB_DATABASE=library
DB_USERNAME=root
DB_PASSWORD=your_mysql_password

CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync

MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null

5. Create book controller for bookstore

In the command line locate inside your library project type the following command:
 
php artisan make:controller BookController

Just make sure a new class was created in bookstore/app/Http/Controllers

BookController.php file
<?php namespace App\Http\Controllers;

use App\Http\Requests;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;

class BookController extends Controller {
   /**
    * Display a listing of the resource.
    *
    * @return Response
    */
   public function index()
   {
      //
   }
   /**
    * Show the form for creating a new resource.
    *
    * @return Response
    */
   public function create()
   {
      //
   }
   /**
    * Store a newly created resource in storage.
    *
    * @return Response
    */
   public function store()
   {
      //
   }
   /**
    * Display the specified resource.
    *
    * @param  int  $id
    * @return Response
    */
   public function show($id)
   {
      //
   }

   /**
    * Show the form for editing the specified resource.
    *
    * @param  int  $id
    * @return Response
    */
   public function edit($id)
   {
      //
   }
   /**
    * Update the specified resource in storage.
    *
    * @param  int  $id
    * @return Response
    */
   public function update($id)
   {
      //
   }
   /**
    * Remove the specified resource from storage.
    *
    * @param  int  $id
    * @return Response
    */
   public function destroy($id)
   {
      //
   }
}

6. Create book model

In the command line type the following command:
 
php artisan make:model Book

A new class was created in bookstore/app/ 
Book.php file
<?php namespace App;
use Illuminate\Database\Eloquent\Model;
class Book extends Model {
   //
}

7. Install Form and Html Facades

In order to use Form and Html facades in laravel 5 as they are being removed from core in 5 and will need to be added as an optional dependency: Type the follow command:
 
composer require illuminate/html

After successful installation we will get the following message
 
Using version ~5.0 for illuminate/html
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
  - Installing illuminate/html (v5.0.0)
    Loading from cache
Writing lock file
Generating autoload files
Generating optimized class loader
Add in providers config/app.php the following line of code
 
'Illuminate\Html\HtmlServiceProvider',
Add in aliases config/app.php the following lines of code
 
'Form'     => 'Illuminate\Html\FormFacade',
'Html'     => 'Illuminate\Html\HtmlFacade',

8. Restful Controller

In laravel 5, a resource controller defines all the default routes for a given named resource to follow REST principles, where we could find more information about it. So when you define a resource in your bookstore/app/Http/routes.php like:

routes.php file
<?php
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
/*
Route::get('/', 'WelcomeController@index');

Route::get('home', 'HomeController@index');

Route::controllers([
   'auth' => 'Auth\AuthController',
   'password' => 'Auth\PasswordController',
]);*/
Route::resource('books','BookController');

As we can see we block the original code to avoid the default authentication laravel created for us.
A restful controller follows the standard blueprint for a restful resource, which mainly consists of:
Domain Method URI Name Action Midleware

GET|HEAD books books.index App\Http\Controllers\BookController@index

GET|HEAD books/create books.create App\Http\Controllers\BookController@create

POST books books.store App\Http\Controllers\BookController@store

GET|HEAD books/{books} books.show App\Http\Controllers\BookController@show

GET|HEAD books/{books}/edit books.edit App\Http\Controllers\BookController@edit

PUT books/{books} books.update App\Http\Controllers\BookController@update

PATCH books/{books}
App\Http\Controllers\BookController@update

DELETE books/{books} books.destroy App\Http\Controllers\BookController@destroy

To get the table from above; type in the command line:
 
php artisan route:list

9. Insert dummy data

Until this point our project is ready to implement our CRUD operation using Laravel 5 and MySQL, insert some dummy data in the table we created in step 3.

In order to display images for books cover we need to create a folder called img inside bookstore/public and download some books cover picture and rename the name according to the field image in our table as shown above with extension jpg.

10. Create layout for bookstore

Go to folder bookstore/resources/view and create a new folder called layout; inside that new folder create a php file called template.blade.php and copy the following code:

template.blade.php file
 
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>BookStore</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap
/3.3.4/css/bootstrap.min.css">
</head>
<body>
    <div class="container">
        @yield('content')
    </div>
</body>
</html>

11. Create view to show book list

Now let's try to fetch books from our database via the Eloquent object. For this let's modify the index method in our app/Http/Controllers/BookController.php. and modify like show bellow.(note that we added use App\Book, because we need to make reference to Book model)
 
<?php namespace App\Http\Controllers;

use App\Book;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;

class BookController extends Controller {

   /**
    * Display a listing of the resource.
    *
    * @return Response
    */
   public function index()
   {
      //
        $books=Book::all();
        return view('books.index',compact('books'));
    }

To display book list we need to create a view: Go to folder bookstore/resources/view and create a folder called books; inside this new folder create a new file called index.blade.php and copy the following code

index..blade.php file
 
@extends('layout/template')

@section('content')
 <h1>Peru BookStore</h1>
 <a href="{{url('/books/create')}}" class="btn btn-success">Create Book</a>
 <hr>
 <table class="table table-striped table-bordered table-hover">
     <thead>
     <tr class="bg-info">
         <th>Id</th>
         <th>ISBN</th>
         <th>Title</th>
         <th>Author</th>
         <th>Publisher</th>
         <th>Thumbs</th>
         <th colspan="3">Actions</th>
     </tr>
     </thead>
     <tbody>
     @foreach ($books as $book)
         <tr>
             <td>{{ $book->id }}</td>
             <td>{{ $book->isbn }}</td>
             <td>{{ $book->title }}</td>
             <td>{{ $book->author }}</td>
             <td>{{ $book->publisher }}</td>
             <td><img src="{{asset('img/'.$book->image.'.jpg')}}" height="35" width="30"></td>
             <td><a href="{{url('books',$book->id)}}" class="btn btn-primary">Read</a></td>
             <td><a href="{{route('books.edit',$book->id)}}" class="btn btn-warning">Update</a></td>
             <td>
             {!! Form::open(['method' => 'DELETE', 'route'=>['books.destroy', $book->id]]) !!}
             {!! Form::submit('Delete', ['class' => 'btn btn-danger']) !!}
             {!! Form::close() !!}
             </td>
         </tr>
     @endforeach

     </tbody>

 </table>
@endsection
Let’s see how our book list are displayed; in the command like type php artisan serve, after open a browser and type localhost:8888/books

12. Read book(Display single book)

Let’s implement Read action, create a new file in bookstore/resources/view/books called show.blade.php and paste the code:

show.blade.php file
@extends('layout/template')
@section('content')
    <h1>Book Show</h1>

    <form class="form-horizontal">
        <div class="form-group">
            <label for="image" class="col-sm-2 control-label">Cover</label>
            <div class="col-sm-10">
                <img src="{{asset('img/'.$book->image.'.jpg')}}" height="180" width="150" class="img-rounded">
            </div>
        </div>
        <div class="form-group">
            <label for="isbn" class="col-sm-2 control-label">ISBN</label>
            <div class="col-sm-10">
                <input type="text" class="form-control" id="isbn" placeholder={{$book->isbn}} readonly>
            </div>
        </div>
        <div class="form-group">
            <label for="title" class="col-sm-2 control-label">Title</label>
            <div class="col-sm-10">
                <input type="text" class="form-control" id="title" placeholder={{$book->title}} readonly>
            </div>
        </div>
        <div class="form-group">
            <label for="author" class="col-sm-2 control-label">Author</label>
            <div class="col-sm-10">
                <input type="text" class="form-control" id="author" placeholder={{$book->author}} readonly>
            </div>
        </div>
        <div class="form-group">
            <label for="publisher" class="col-sm-2 control-label">Publisher</label>
            <div class="col-sm-10">
                <input type="text" class="form-control" id="publisher" placeholder={{$book->publisher}} readonly>
            </div>
        </div>

        <div class="form-group">
            <div class="col-sm-offset-2 col-sm-10">
                <a href="{{ url('books')}}" class="btn btn-primary">Back</a>
            </div>
        </div>
    </form>
@stop
Modify app/Http/Controllers/BookController.php
 
public function show($id)
{
   $book=Book::find($id);
   return view('books.show',compact('book'));
}
Refresh the brower and click in Read action and we will see the book in detail:

13. Create book

Create a new file in bookstore/resources/view/books called create.blade.php and paste the code:

create.blade.php file
 
@extends('layout.template')
@section('content')
    <h1>Create Book</h1>
    {!! Form::open(['url' => 'books']) !!}
    <div class="form-group">
        {!! Form::label('ISBN', 'ISBN:') !!}
        {!! Form::text('isbn',null,['class'=>'form-control']) !!}
    </div>
    <div class="form-group">
        {!! Form::label('Title', 'Title:') !!}
        {!! Form::text('title',null,['class'=>'form-control']) !!}
    </div>
    <div class="form-group">
        {!! Form::label('Author', 'Author:') !!}
        {!! Form::text('author',null,['class'=>'form-control']) !!}
    </div>
    <div class="form-group">
        {!! Form::label('Publisher', 'Publisher:') !!}
        {!! Form::text('publisher',null,['class'=>'form-control']) !!}
    </div>
    <div class="form-group">
        {!! Form::label('Image', 'Image:') !!}
        {!! Form::text('image',null,['class'=>'form-control']) !!}
    </div>
    <div class="form-group">
        {!! Form::submit('Save', ['class' => 'btn btn-primary form-control']) !!}
    </div>
    {!! Form::close() !!}
@stop
Modify app/Http/Controllers/BookController.php
 
public function create()
{
   return view('books.create');
}

/**
 * Store a newly created resource in storage.
 *
 * @return Response
 */
public function store()
{
   $book=Request::all();
   Book::create($book);
   return redirect('books');
}
Now we need to modify the Book model for mass assignment
 
<?php namespace App;
use Illuminate\Database\Eloquent\Model;
class Book extends Model {
   //
    protected $fillable=[
        'isbn',
        'title',
        'author',
        'publisher',
        'image'
    ];
}

refresh the Brower and click on create Book

14. Update Book

Create a new file in bookstore/resources/view/books called edit.blade.php and paste the code:

edit.blade.php file
 
@extends('layout.template')
@section('content')
    <h1>Update Book</h1>
    {!! Form::model($book,['method' => 'PATCH','route'=>['books.update',$book->id]]) !!}
    <div class="form-group">
        {!! Form::label('ISBN', 'ISBN:') !!}
        {!! Form::text('isbn',null,['class'=>'form-control']) !!}
    </div>
    <div class="form-group">
        {!! Form::label('Title', 'Title:') !!}
        {!! Form::text('title',null,['class'=>'form-control']) !!}
    </div>
    <div class="form-group">
        {!! Form::label('Author', 'Author:') !!}
        {!! Form::text('author',null,['class'=>'form-control']) !!}
    </div>
    <div class="form-group">
        {!! Form::label('Publisher', 'Publisher:') !!}
        {!! Form::text('publisher',null,['class'=>'form-control']) !!}
    </div>
    <div class="form-group">
        {!! Form::label('Image', 'Image:') !!}
        {!! Form::text('image',null,['class'=>'form-control']) !!}
    </div>
    <div class="form-group">
        {!! Form::submit('Update', ['class' => 'btn btn-primary']) !!}
    </div>
    {!! Form::close() !!}
@stop
Modify app/Http/Controllers/BookController.php
 
public function edit($id)
{
   $book=Book::find($id);
   return view('books.edit',compact('book'));
}

/**
 * Update the specified resource in storage.
 *
 * @param  int  $id
 * @return Response
 */
public function update($id)
{
   //
   $bookUpdate=Request::all();
   $book=Book::find($id);
   $book->update($bookUpdate);
   return redirect('books');
}
refresh the brower, select the book and click Update button

15. Delete Book

Delete is easy just modify app/Http/Controllers/BookController.php
 
public function destroy($id)
{
   Book::find($id)->delete();
   return redirect('books');
}
Refresh the Brower and click in delete button for deleting one book and redirect to book list.

180 comments:

  1. Excellent learning resource! Thank you :-)

    ReplyDelete
  2. How would you get Laravel's basic authentication working with this?

    ReplyDelete
  3. very nice i want to learn from u

    ReplyDelete
  4. hi. please share your code to github

    ReplyDelete
  5. Just owsm...!!!

    If you have any other post on laravel 5, please give me the link, I want to learn more from you.

    ReplyDelete
  6. Awesome Example....but im getting error in new book create method
    error description:
    ErrorException in BookController.php line 42:
    Non-static method Illuminate\Http\Request::all() should not be called statically, assuming $this from incompatible context

    ReplyDelete
    Replies
    1. try change the declaration:
      #use Illuminate\Http\Request;

      by:
      #use Request;

      Regards.

      Delete
    2. or if you still want to apply
      use Illuminate\Http\Request;

      just change your code a little bit,
      from :
      public function store()
      {
      $book=Request::all();
      Book::create($book);
      return redirect('books');
      }

      to:

      public function store(Request $request)
      {
      $book=$request->all(); // important!!
      Book::create($book);
      return redirect('books');
      }

      works with update too :)

      courtesy of http://stackoverflow.com/questions/28573860/laravel-requestall (comment from shock_gone_wild)

      Delete
  7. You forgot to Call the model in controller Please Add it !!

    ReplyDelete
    Replies
    1. Can you tell me how to call Model in Controller ?

      Delete
    2. Please how do you call the Model in Controller?

      Delete
  8. Please i am getting this error after creating the index.blade.php file and adding the necessary code.Please what am i doing wrong.

    Whoops, looks like something went wrong.

    1/1
    FatalErrorException in BookController.php line 18:
    Class 'App\Http\Controllers\Book' not found
    in BookController.php line 18

    ReplyDelete
  9. This comment has been removed by the author.

    ReplyDelete
  10. I have a problem
    Why do not my images appear ?
    please help me.

    ReplyDelete
    Replies
    1. create folder img on bookstore/public/ and store your image manually there

      Delete
  11. Awesome Blog. Thank you so much :) . I have one problem in my project. I have keep all my models in App/models directory. I have used this blog to develop my work. All other CURD operations are working fine except Delete. Can you please help me to resolve the error?

    ReplyDelete
  12. I started the project all over again and i am getting this error. i got to step 11. i am not sure if it is because i am using a newer version of laravel. 5.1.2.

    Sorry, the page you are looking for could not be found.

    NotFoundHttpException in RouteCollection.php line 143:

    in RouteCollection.php line 143
    at RouteCollection->match(object(Request)) in Router.php line 744
    at Router->findRoute(object(Request)) in Router.php line 653
    at Router->dispatchToRoute(object(Request)) in Router.php line 629
    at Router->dispatch(object(Request)) in Kernel.php line 229
    at Kernel->Illuminate\Foundation\Http\{closure}(object(Request))
    at call_user_func(object(Closure), object(Request)) in Pipeline.php line 139
    at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in VerifyCsrfToken.php line 50
    at VerifyCsrfToken->handle(object(Request), object(Closure))
    at call_user_func_array(array(object(VerifyCsrfToken), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
    at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in ShareErrorsFromSession.php line 54
    at ShareErrorsFromSession->handle(object(Request), object(Closure))
    at call_user_func_array(array(object(ShareErrorsFromSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
    at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in StartSession.php line 61
    at StartSession->handle(object(Request), object(Closure))
    at call_user_func_array(array(object(StartSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
    at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37
    at AddQueuedCookiesToResponse->handle(object(Request), object(Closure))
    at call_user_func_array(array(object(AddQueuedCookiesToResponse), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
    at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in EncryptCookies.php line 59
    at EncryptCookies->handle(object(Request), object(Closure))
    at call_user_func_array(array(object(EncryptCookies), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
    at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in CheckForMaintenanceMode.php line 42
    at CheckForMaintenanceMode->handle(object(Request), object(Closure))
    at call_user_func_array(array(object(CheckForMaintenanceMode), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
    at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
    at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
    at Pipeline->then(object(Closure)) in Kernel.php line 118
    at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 86
    at Kernel->handle(object(Request)) in index.php line 54
    at require_once('C:\xampp\htdocs\Projects\Laravel_Projects\LearningSite2\public\index.php') in server.php line 21

    ReplyDelete
    Replies
    1. Hi, add:
      Route::resource('books','BookController');
      In:
      bookstore/app/Http/routes.php

      Delete
    2. same prblm bt addding Route::resource('Books','BookController')in place of Route::resource('books','BookController@index');

      Delete
    3. I got the same problem. I have used
      Route::resource('books','BookController');
      in routes.php file.
      Whta mihht be other isssues?

      Delete
    4. I also got the same error.I placed following code
      Route::resource('books','BookController');
      Anyone can provide me solution?

      Delete
  13. Great post!! Thank you very much

    ReplyDelete
  14. Nice post but unable to save and update data from mysql :)

    ReplyDelete
    Replies
    1. or if you still want to apply
      use Illuminate\Http\Request;

      just change your code a little bit,
      from :
      public function store()
      {
      $book=Request::all();
      Book::create($book);
      return redirect('books');
      }

      to:

      public function store(Request $request)
      {
      $book=$request->all(); // important!!
      Book::create($book);
      return redirect('books');
      }

      works with update too :)

      courtesy of http://stackoverflow.com/questions/28573860/laravel-requestall (comment from shock_gone_wild)

      Delete
    2. i have changed my cod as you show above but it still giving that error

      Delete
    3. all(); // important!!
      Book::create($book);
      return redirect('books');
      }



      /**
      * Display the specified resource.
      *
      * @param int $id
      * @return Response
      */
      public function show($id)
      {
      $book=Book::find($id);
      return view('books.show',compact('book'));
      }

      /**
      * Show the form for editing the specified resource.
      *
      * @param int $id
      * @return Response
      */

      public function edit($id)
      {
      $book=Book::find($id);
      return view('books.edit',compact('book'));
      }

      /**
      * Update the specified resource in storage.
      *
      * @param int $id
      * @return Response
      */

      public function update($id)
      {
      $bookUpdate=Request::all();
      $book=Book::find($id);
      $book->update($bookUpdate);
      return redirect('books');
      }

      /**
      * Remove the specified resource from storage.
      *
      * @param int $id
      * @return Response
      */
      public function destroy($id)
      {
      //
      }
      }

      Delete
  15. https://github.com/chavewain/laravel-book-store.git

    Download the code

    ReplyDelete
  16. i got this messages :

    SQLSTATE[42S02]: Base table or view not found: 1146 Table 'bookstore.books' doesn't exist (SQL: select * from `books`)


    My table is 'book', how to fixed?

    ReplyDelete
    Replies
    1. if your DB table name is book, change your query to "select * from book"

      Delete
  17. rename your table name. Laravel 5 very sensitive with 's'.

    ReplyDelete
  18. the code show the following message

    Non-static method Illuminate\Http\Request::all() should not be called statically, assuming $this from incompatible context

    ReplyDelete
    Replies
    1. If you using:
      use Illuminate\Http\Request;
      Pls use: $request->all();
      and using use Request;
      Pls use: Request->all()

      Delete
  19. hy george, nice tutorials, work with me, please can you add file image upload proses,

    ReplyDelete
  20. hi,
    this is very nice tutorials and i created step by step as you given and every thing working like show,create and list but when i click on edit then it display
    NotFoundHttpException in RouteCollection.php line 145:

    i have seen that for create it working so as logically why not edit opened.
    please give me the solution for that so i can go ahead...

    Thanks...

    ReplyDelete
  21. why the input type file in my project looks like input teype text and you didn't tell about upload images to folder >.< if anyone has solved this issue please kindly comment here, Thanks

    ReplyDelete
  22. Lol this explanation didn't tell CRUD upload images, a common CRUD :D

    ReplyDelete
  23. Very good tutorial please keep writing. I am using the last version and running php artisan route:list you see error messages about provider and then aliases

    I fix trying :

    into providers:

    Illuminate\Html\HtmlServiceProvider::class,

    into aliases:
    'Form' => Illuminate\Html\FormFacade\View::class,
    'Html' => Illuminate\Html\HtmlFacade\View::class,

    ReplyDelete
  24. I'm having trouble putting the artisan serve php, to run the same shows an invalid request error (unexpected eof)

    ReplyDelete
  25. I'm having trouble putting the artisan serve php, to run the same shows an invalid request error (unexpected eof)

    pls help me

    ReplyDelete
  26. NotFoundHttpException in RouteCollection.php line 143:

    in RouteCollection.php line 143
    at RouteCollection->match(object(Request)) in Router.php line 746
    at Router->findRoute(object(Request)) in Router.php line 655
    at Router->dispatchToRoute(object(Request)) in Router.php line 631
    at Router->dispatch(object(Request)) in Kernel.php line 236
    at Kernel->Illuminate\Foundation\Http\{closure}(object(Request))
    at call_user_func(object(Closure), object(Request)) in Pipeline.php line 139
    at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in VerifyCsrfToken.php line 50
    at VerifyCsrfToken->handle(object(Request), object(Closure))
    at call_user_func_array(array(object(VerifyCsrfToken), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
    at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in ShareErrorsFromSession.php line 54
    at ShareErrorsFromSession->handle(object(Request), object(Closure))
    at call_user_func_array(array(object(ShareErrorsFromSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
    at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in StartSession.php line 62
    at StartSession->handle(object(Request), object(Closure))
    at call_user_func_array(array(object(StartSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
    at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37
    at AddQueuedCookiesToResponse->handle(object(Request), object(Closure))
    at call_user_func_array(array(object(AddQueuedCookiesToResponse), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
    at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in EncryptCookies.php line 59
    at EncryptCookies->handle(object(Request), object(Closure))
    at call_user_func_array(array(object(EncryptCookies), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
    at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in CheckForMaintenanceMode.php line 42
    at CheckForMaintenanceMode->handle(object(Request), object(Closure))
    at call_user_func_array(array(object(CheckForMaintenanceMode), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
    at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
    at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
    at Pipeline->then(object(Closure)) in Kernel.php line 122
    at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 87
    at Kernel->handle(object(Request)) in index.php line 54

    what to do????to overcome this issue....
    even though i had added resource controller in routes.php

    ReplyDelete
  27. Nice tutorial! As a beginner, I learned a lot. I just want to ask, how do I display the book image? This tutorial seems to have missed out to discuss how to display the book image. Thanks.

    ReplyDelete
    Replies
    1. Oh... got it, i just move img folder inside public folder

      Delete
  28. hi! I have tried, but the update function is not working. Please help me to fix this.

    ReplyDelete
  29. Thank you very much!! PHP Rebirth!!

    ReplyDelete
  30. I love Laravel 5 (PHP), Struts2 & Spring MVC (Java), ASP.NET MVC (.NET), Ruby on Rails (Ruby) and Django (Python) !!

    ReplyDelete
  31. This comment has been removed by the author.

    ReplyDelete
  32. 1/1
    FatalErrorException in C:\xampp\htdocs\laravel\shop\vendor\laravel\framework\src\Illuminate\Foundation\ProviderRepository.php line 146:
    Class 'Illuminate\Html\HtmlServiceProvider' not found

    ReplyDelete
  33. Nice Post! This is a great post. I like this topic.This site has lots of advantage.I found many interesting things from this site. It helps me in many ways.Thanks for posting this again. Thanks a million and please keep up the effective work Thank yo so much for sharing this kind of info- hire laravel developer

    ReplyDelete
  34. Why my books from database not shows?

    ReplyDelete
  35. its a wonderful tutorial for beginners like me. Hats off to you.

    ReplyDelete
  36. How to insert the image in create...while inserting a new book , how to add an image also

    ReplyDelete
  37. hi i am getting error when i update entry..

    ErrorException in BookController.php line 84:
    Non-static method Illuminate\Http\Request::all() should not be called statically, assuming $this from incompatible context

    ReplyDelete
  38. and when i create new entry after fill form then save getting error

    ErrorException in BookController.php line 45:
    Non-static method Illuminate\Http\Request::all() should not be called statically, assuming $this from incompatible context

    ReplyDelete
  39. excellent tutorial man ! thank you very much. love you. :)

    ReplyDelete
  40. Excellent Tutorial,this has really helped me in learning the framework

    ReplyDelete
  41. pls also include validator for the forms? thank you.

    ReplyDelete
  42. This comment has been removed by the author.

    ReplyDelete
  43. image does not appear in show page what i do?

    ReplyDelete
    Replies
    1. It is working friend.Place them in correct location and give permission to the folder if use linux.Save the image name correctly in database.

      Delete
  44. Nice article.Good to start Laravel here.Read others comments to understand bugs and solove them. -Ujitha Sudasingha-

    ReplyDelete
  45. Hello, i have a question: why the Title of the books is truncated at the show view?

    Btw, nice article

    ReplyDelete
    Replies
    1. you should modify show.blad.php :

      change placeholder={{$article->title}}
      to : value="{{$article->title}}"

      Delete
  46. i have a problem

    InvalidArgumentException in FileViewFinder.php line 140:
    View [books.index] not found.

    ReplyDelete
  47. FatalErrorException in HtmlServiceProvider.php line 36: Call to undefined method Illuminate\Foundation\Application::bindShared()

    ReplyDelete
  48. Hi Jorge, Thanks for this great article, I learn too much from this article. Please can you write any article for file upload.

    ReplyDelete
  49. Hi guys
    really i have seen your post very useful content this post thanks for sharing software development

    ReplyDelete
  50. thanks for your short and nice tutorial. Appreciate your job.

    ReplyDelete
  51. Hi guys,

    Tks for this tutorial :)

    I have just one case in updated session. An error when I write the form method PATCH in edit.blade.php (Laravel 5.2)

    MethodNotAllowedHttpException in RouteCollection.php line 219:

    1. in RouteCollection.php line 219
    2. At RouteCollection->methodNotAllowed(array('GET','HEAD','POST')) in RouteCollection.php line 206
    3...

    Please, someone had this issue already? Can help me?

    Tks in advance

    ReplyDelete
  52. FatalErrorException in Facade.php line 218: Call to undefined method Illuminate\Html\FormFacade::open()

    ReplyDelete


  53. Warning: Unknown: failed to open stream: No such file or directory in Unknown on line 0

    Fatal error: Unknown: Failed opening required 'D:\xampp\htdocs\Laravel/server.php' (include_path='.;D:\xampp\php\PEAR') in Unknown on line 0

    ReplyDelete
  54. If you get

    "Call to undefined method Illuminate\Foundation\Application::bindShared()"

    this error---

    Then Goto:
    path-to-your-project/vendor/illuminate/html/HtmlServiceProvider.php

    replace: bindShared() with singleton() on line no : 36 and 49

    ReplyDelete
    Replies
    1. some config has been deprecated, ! using "composer require laravelcollective/html" and then

      using this in providers app.php
      Collective\Html\HtmlServiceProvider::class,
      and using this in aliases app.php
      'Form' => Collective\Html\FormFacade::class,
      'Html' => Collective\Html\HtmlFacade::class,

      Delete
  55. We can dynamically create crud in laravel and other frameworks using http://crudgenerator.in

    ReplyDelete
  56. Plz try http://crudgenerator.in
    This can generate crud in laravel with your input dynamically

    ReplyDelete
  57. Thanks a Lot ...Great tutorial...

    ReplyDelete
  58. FatalErrorException in HtmlServiceProvider.php line 36:
    Call to undefined method Illuminate\Foundation\Application::bindShared()

    ReplyDelete
    Replies
    1. some config has been deprecated, ! using "composer require laravelcollective/html" and then

      using this in providers app.php
      Collective\Html\HtmlServiceProvider::class,
      and using this in aliases app.php
      'Form' => Collective\Html\FormFacade::class,
      'Html' => Collective\Html\HtmlFacade::class,

      Delete
  59. how can we connect this crud application with laravel default authentication??

    ReplyDelete
  60. Hello sir
    great work
    but am getting this error

    FatalErrorException in cd6cf93df43ac902465014e5e515c4168afd89c7.php line 3:
    Class 'Form' not found

    ReplyDelete
  61. Nice Tutorial
    but i'm getting this error

    ErrorException in BookController.php line 77:
    Non-static method Illuminate\Http\Request::all() should not be called statically, assuming $this from incompatible context

    ReplyDelete
  62. nice its really good for beginner

    ReplyDelete
  63. Complete Laravel bootstrap ajax CRUD with search, sort and pagination https://laracast.blogspot.com/2016/06/laravel-ajax-crud-search-sort-and.html

    ReplyDelete
  64. This comment has been removed by the author.

    ReplyDelete
  65. PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'homestead'@'localhost' (using password: YES)

    ReplyDelete
  66. It's working for me thanks to all friends :)

    ReplyDelete
  67. This comment has been removed by the author.

    ReplyDelete
  68. this error is not removed by me please help me
    ErrorException in BookController.php line 81:
    Non-static method Illuminate\Http\Request::all() should not be called statically, assuming $this from incompatible context

    ReplyDelete
  69. NotFoundHttpException in RouteCollection.php line 161:

    i am getting this error when i try to open index.php file from public folder

    ReplyDelete
  70. Route::resource('books','BookController'); in this case it gives me error: NotFoundHttpException in RouteCollection.php line 161:
    when i chang it with| Route::resource('/','BookController');
    and put BookController in to Http/controller folder it works How can I fix it help me please

    ReplyDelete
  71. Very Very Excellent Tutorial.
    I enjoy the work you done.
    Thanks

    ReplyDelete
  72. ErrorException in b1039a3acfcceed94f9e7040fdfb4ada464da0f7.php line 8:
    Trying to get property of non-object (View: /opt/lampp/htdocs/dblaravel/resources/views/books/show.blade.php)

    ReplyDelete
  73. I have a problem... I cannot submit a form with create view.. when i click on submit button it doesn't go to anywhere it stays where it is.. can anyone help me..

    ReplyDelete
  74. Hi,
    I've a issue FatalErrorException in BookController.php line 18:
    Class 'App\Book' not found

    ReplyDelete
  75. Thanks for sharing your laravel development blog. Endive Software is world no.1 Laravel development company.

    ReplyDelete
  76. This is a clear and step by step documentation.we can generate laravel crud with our table name and table fields http://phpcodebuilder.com/crud-generator

    ReplyDelete
  77. Thanks for sharing great learning resource! Thank you :-)
    I work as Baymediasoft - a Laravel development Company based out in India.

    ReplyDelete
  78. George has an interesting blog that is in line with my interest and, therefore, I will be visiting this site frequently to learn new software development techniques hoping that I will be a software developer guru within the shortest time possible. Find time and read this article on How to Start Off a Research Proposal, which I also found to be interesting.

    ReplyDelete
  79. Hey Nice Article, keep Writing, Do you know you can also post your laravel related articles
    on http://www.laravelinterviewquestions.com/submit-an-article too.
    Thanks !

    ReplyDelete
  80. Great post! I am see the programming coding and step by step execute the outputs.I am gather this coding more information. It's helpful for me . Also great blog here with all of the valuable information you have.
    top web development agency | top seo companies


    ReplyDelete
  81. Perfect @Jorge, your post is really very simple to start development with Laravel, specially for beginners.

    ReplyDelete
  82. how should i request from a POSTMAN

    ReplyDelete
  83. Thanks for the sharing information about Laravel Development, it was awesome post. As a web developer at Kunsh Technologies - Offshore Software Development Company, I believe that this information helps in implementation of advance Web and mobile application development according latest LAravel PHP framework Technology.

    ReplyDelete
  84. Thanks for sharing with us, keep posting, and please do post more about Laravel Application Development

    ReplyDelete
  85. This comment has been removed by the author.

    ReplyDelete
  86. hello ! please visit bellow site and please give me an idea can i buy this gig from fiverr.com Laravel
    https://www.fiverr.com/ahmedwali5990/be-your-laravel-website-expert

    ReplyDelete


  87. Hi Your Blog is very nice!!

    Get All Top Interview Questions and answers PHP, Magento, laravel,Java, Dot Net, Database, Sql, Mysql, Oracle, Angularjs, Vue Js, Express js, React Js,
    Hadoop, Apache spark, Apache Scala, Tensorflow.

    Mysql Interview Questions for Experienced
    php interview questions for freshers
    php interview questions for experienced
    python interview questions for freshers
    tally interview questions and answers



    ReplyDelete

  88. You are doing a great job. I would like to appreciate your work for good accuracy

    CCNA Training Institute Training in Chennai

    ReplyDelete
  89. I enjoy what you guys are usually up too. This sort of clever work and coverage! Keep up the wonderful works guysl.Good going.
    oneplus service center in chennai
    oneplus service centre chennai
    oneplus service centre

    ReplyDelete
  90. nice course. thanks for sharing this post this post harried me a lot.
    MCSE Training in Noida

    ReplyDelete
  91. Jika Sudah Merasa Cukup Mengerti Baru Bisa Bermain Meja Besar
    Agar Anda bisa mencoba untuk menaikan jumlah chip dengan mencoba bermain pada meja besar setelah berlatih pada meja kecil
    asikqq
    dewaqq
    sumoqq
    interqq
    pionpoker
    bandar ceme
    hobiqq
    paito warna terlengkap
    Syair HK

    ReplyDelete

  92. Qbigpro is the best web designing company in chennai.we are doing web designing and developing website creation website maintenance graphic designing google ads logo creation in our company.






    Qbigpro is the best web designing company in chennai.we are doing web designing and developing website creation website maintenance graphic designing google ads logo creation in our company.





    Qbigpro is the best web designing company in Chennai.we are doing web designing and developing website creation website maintenance graphic designing google. web design company in velachery






    ReplyDelete
  93. Superb! Your blog is incredible. I am delighted with it. Thanks for sharing with me more information.web design company in velachery

    ReplyDelete
  94. IOS App Development

    iOS App Development - I.B.C. App Maker eliminates the need for any tutorials and teaches you how to make an iOS app online with a few simple steps, without any previous knowledge of mobile application development.

    to get more - https://www.ibcappmaker.com/en/platforms/create-ios-app-online

    ReplyDelete
  95. Being new to the blogging world I feel like there is still so much to learn. Your tips helped to clarify a few things for me as well as giving.microsoft azure training in bangalore

    ReplyDelete
  96. smart outsourcing solutions is the best outsourcing training
    in Dhaka, if you start outsourcing please
    visit us: Online earn bd

    ReplyDelete
  97. One of the best article i read today. Thanks for sharing so much detailed information of Laravel Development. I will visit here for more updates, Thank you!

    ReplyDelete
  98. I have to search sites with relevant information on given topic and provide them to teacher our opinion and the article.
    machine learning course

    artificial intelligence course in mumbai

    ReplyDelete
  99. Who we are
    Nuevas is a company specializing in easy-to-use, practical wireless solutions for the protection and management of people, fleets of vehicles, containers and assets. Our main focus is on

    "What are our products?Nuevas is a company specializing in easy-to-use, practical wireless solutions for the protection and management of people, fleets of vehicles, containers and assets. Our main focus is on

    "
    "GPS tracking devicesGPS Vehicle Tracking System
    Comprehensive GPS Vehicle Tracking System Straight From Our Leading Team
    At present, safety is your first-hand priority. Unless you are properly covered, keeping a single foot out of your home is hazardous to your health. That’s when you have to call up for our GPS vehicle tracking system from Nuevas Technologies Pvt. Ltd. "
    "Vehicle tracking system functions on mentioned technologyFAQ's
    1. How does GPS work?
    Read more.......
    "
    "Maximizing Performance from vehicles and service representatives of our clients.Vehical tracking service Provider in Pune- India
    Keep In Touch With Your Vehicle Through Our Well-Trained Service Providers
    Read more"
    Vehicle Tracking System Manufacturer in Pune-India We are living in the era of information technology. Everything is available on single click done with your fingertip. Meanwhile, Logistic Systems have also undergone revolutionary improvements and became modern by implementing technological advancements in the 21st century. GPS i.e., Global Positioning System is gaining more significance than ever. GPS in Logistics is generally termed as Vehicle Tracking System. Let’s have a quick look on some of the key points, why this system is important in Logistics?Read more.....
    GPS vehicle tracking system dealer in Pune-India
    "RFID Tracking Devices
    "

    "Thanks for sharing such a wonderful article as i waiting for such article
    Keep on sharing the good content.Welcome to the Ozanera Products and Services Portal.Over the years we’ve seen doctors and hospitals really struggle to find reliable hospital products and services fast.
    Thank you."

    "Hospital Products
    Welcome To Our Services
    Ozanera is an initiative born out of our experience with two critical aspect of running hospitals that we realized needed a major overhaul. One is how hospitals source products and services.
    Thank you."

    "What makes us special
    In our decades of experience serving the hospital industry we realized there was a yawning gap between the talent requirements of the healthcare industry and what the industry had access to. "

    ReplyDelete
  100. You have written an informative post. Looking forward to read more.
    Laravel Web Development Services

    ReplyDelete
  101. If you want any information regarding Swimming Pool Filtration Plant then, no one can beat the reliability of this website. Here you will get instant assistance regarding your queries against filtration plant.

    ReplyDelete
  102. This website is the best place to explore reasonable deals for the installation of a swimming pool filtration plant also the team holds years of experience so one would get a trusted after-sales service.

    ReplyDelete
  103. Useful information, your blog is sharing unique information....Thanks for sharing!!!. oracle training in chennai

    ReplyDelete
  104. Get a free quote for laravel web development requirements from a top laravel development company in Australia, UK, USA, Delhi, Noida, Gurugram, Ghaziabad, Faridabad. For more information visit our website.


    Laravel development company

    ReplyDelete
  105. Get in touch with Infotrench Top iPhone / ios app development company. We provide the best services in Australia, UK, USA, Delhi, Noida, Gurugram, Ghaziabad, Faridabad.
    iphone app development company, laravel development company

    ReplyDelete
  106. There is so many PHP frameworks but Laravel is considered the best framework for web development.
    Here are a few reason Why Laravel is the Top PHP Framework
    Hire Laravel expert for your business.

    ReplyDelete
  107. Great post! This is very useful for me and gain more information, Thanks for sharing with us.
    DevOps Training in Chennai

    DevOps Course in Chennai

    ReplyDelete
  108. WordPress Development Company - Infotrench provides custom WordPress development services in UK, USA, Delhi, Noida.
    wordpress development company

    ReplyDelete
  109. The Pros and Cons of Group Health Insurance By Timothy Hebert | Submitted On May 09, 2010 Suggest Article Comments Print ArticleShare this article on FacebookShare this article on TwitterShare.# BOOST Your GOOGLE RANKING.It’s Your Time To Be On #1st Page
    Our Motive is not just to create links but to get them indexed as will
    Increase Domain Authority (DA).We’re on a mission to increase DA PA of your domain
    High Quality Backlink Building Service
    1000 Backlink at cheapest . With that in mind, this article will investigate the upsides and downsides

    ReplyDelete
  110. A good blog always comes-up with new and exciting information and while reading I have feel that this blog is really have all those quality that qualify a blog to be a one
    data scientist training and placement

    ReplyDelete
  111. Infycle Technologies, the top software training institute and placement center in Chennai offers the Best Digital Marketing course in Chennai for freshers, students, and tech professionals at the best offers. In addition to Digital Marketing, other in-demand courses such as DevOps, Data Science, Python, Selenium, Big Data, Java, Power BI, Oracle will also be trained with 100% practical classes. After the completion of training, the trainees will be sent for placement interviews in the top MNC's. Call 7504633633 to get more info and a free demo.

    ReplyDelete
  112. Grab the Digital Marketing Training in Chennai from Infycle Technologies, the best software training institute, and Placement center in Chennai which is providing professional software courses such as Data Science, Artificial Intelligence, Cyber Security, Big Data, Java, Hadoop, Selenium, Android, and iOS Development, DevOps, Oracle, etc with 100% hands-on practical training. Dial 7502633633 to get more info and a free demo and to grab the certification for having a peak rise in your career.

    ReplyDelete
  113. Your blog site is one of the best site more then other site.Thank you for sharing your valuable post.
    salman

    ReplyDelete
  114. Really it is a learnable blog site.Thanks for share your post.
    salman

    ReplyDelete
  115. I will be grateful to the author for selecting this amazing article relevant to my topic. Here is a detailed summary of the article’s subject matter that was particularly useful to me.Online Shopping Market

    ReplyDelete
  116. Brilliant Blog! I might want to thank you for the endeavors you have made recorded as a hard copy of this post. I am trusting a similar best work from you later on also. I needed to thank you for these sites! Much obliged for sharing. Incredible sites!
    data science institutes in hyderabad

    ReplyDelete
  117. Wonderful illustrated information. I thank you about that. No doubt it will be very useful for my future projects. Would like to see some other posts on the same subject! data science training in surat

    ReplyDelete
  118. Wonderful blog. I am delighted in perusing your articles. This is genuinely an incredible pursuit for me. I have bookmarked it and I am anticipating perusing new articles. Keep doing awesome!
    data analytics courses in hyderabad

    ReplyDelete
  119. It was a great experience after reading. Informative content and knowledge to all. Keep sharing more blogs with us.
    Data Science Courses in Hyderabad

    ReplyDelete
  120. Good One, it is one of the very great blog I have ever read. It has increased my knowledge.


    Seraro is one of the best Python Developer Staffing Agency in Atlanta.
    We have dedicated team for hiring of Vue JS Developer , Angular JS Developer, Express JS , Backbone JS Developer

    ReplyDelete
  121. There is a lot of information already in the comments above, but I will add my own anyway https://www.cleveroad.com/blog/telemedicine-software-development

    ReplyDelete
  122. http://www.timtalksmovieswithseth.com/2018/11/121-chicken-little-amazon-reviews-spark.html?showComment=1650017770452#c5314620168537823255

    ReplyDelete
  123. Thanks for posting this info. I just want to let you know that I just check out your site and I find it very interesting and informative. I can't wait to read lots of your posts.
    cyber security training malaysia

    ReplyDelete
  124. Thanks for sharing this content. it's really helpful. If you website technical SEO audit contact us

    ReplyDelete
  125. Superb post.Thanks for sharing such an valuable post.
    SQL training in Pune

    ReplyDelete
  126. This comment has been removed by the author.

    ReplyDelete