i get this error i don't no why the line between section id and books
Undefined variable: section (View: C:\xampp\htdocs\lib\resources\views\books\create_book.blade.php)
the link <a href="{{url('admin_book/createbook',$section->id)}}"class="btn btn-success">New Book</a>
my create_book.blade.php
{!! Form::open(['url'=>'admin_book/store','method'=>'POST','files'=>'true']) !!}
{!! Form::hidden('section_id',$section->id) !!}
<div class="form-group ">
{!! Form::label('Book Title', 'Enter the Title of Book:') !!}
{!! Form::text("book_title",'',['class'=>'form-control']) !!}
</div>
<div class="form-group ">
{!! Form::label('Book Edition', 'Enter the Edition of Book:') !!}
{!! Form::text("book_edition",'',['class'=>'form-control']) !!}
</div>
<div class="form-group ">
{!! Form::label('Book Description', 'Enter the Description of Book:') !!}
{!! Form::textarea("book_description",'',['class'=>'form-control']) !!}
</div>
<div class="form-group">
{!! Form::label('upload', 'Upload an Image:') !!}
{!! Form::file('image','',['class'=>'form-control']) !!}
</div>
<br>
<div class="form-group">
{!! Form::submit('Create',['class'=>'btn btn-info btn-block']) !!}
</div>
{!! Form::close() !!}
and my booksControllers
public function create()
{
return view('books.create_book');
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$book_title = $request ->input('book_title');
$book_edition = $request ->input('book_edition');
$book_description = $request ->input('book_description');
$file = $request ->file('image');
$destinationPath = 'images';
$filename = $file ->getClientOriginalName();
$file ->move($destinationPath,$filename);
$section_id = $request -> section_id;
$new_book = new Book;
$new_book ->book_title = $book_title;
$new_book ->book_edition = $book_edition;
$new_book ->book_description = $book_description;
$new_book ->image_name = $filename;
$new_book ->section_id = $section_id;
$new_book ->save();
return redirect('admin_book/'.$section_id);
}
and my route
Route::get('admin_book/createbook','BooksController@create');
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire