Create method show () in Laravel


I am working on a library control system, when making an individual view of an element of the database I use the show method of my LibroController in the following way:

public function show($id)
    $libros = Libro::find($id);
    return view('', ['libro'=>$this->libro]);

and a show.blade.php view like this:




  {!!Form::model($libro,['route'=>  ['',$libro->id],'method'=>'POST','files'=> true])!!}

 <p class="info">AUTOR:&nbsp;&nbsp;{{$libro->autor}}</p>
 <p class="info">IDIOMA:&nbsp;&nbsp;{{$libro->idioma}}</p>
 <p class="info">PAGINAS:&nbsp;&nbsp;{{$libro->paginas}}</p>



As I understand it, using the {!!Form::model!!} would save me creating the route, but I still get the following error:

these are my routes

Route::get('/','[email protected]');
Route::get('contacto','[email protected]');
Route::get('reviews','[email protected]');
Route::get('admin','[email protected]');
Route::get('ver','[email protected]');

Route::get('password/email','Auth\[email protected]');
Route::post('password/email','Auth\[email protected]');
Route::get('password/reset/{token}','Auth\[email protected]');
Route::post('password/reset','Auth\[email protected]');



Any contribution is welcome.

asked by Santiago Avila 04.02.2017 в 00:50

1 answer


The problem is because you are passing the wrong value to the view in your controller. So $ this- > books does not exist and will give you the error you report.

So your code should work if you do it this way.

public function show($id)
    $libros = Libro::find($id);
    return view('', ['libro'=>$libros]);
answered by 28.03.2017 в 03:21