Commit 26996bc7 authored by Mohammad Javad Ghasemy's avatar Mohammad Javad Ghasemy 🦈

books is almost ready

parent 687a021c
......@@ -14,7 +14,8 @@ class BooksController extends Controller
*/
public function index()
{
//
$books = Books::all();
return view("pages.book.index")->with('books', $books);
}
/**
......@@ -24,7 +25,7 @@ class BooksController extends Controller
*/
public function create()
{
//
return view("pages.book.create");
}
/**
......@@ -35,7 +36,6 @@ class BooksController extends Controller
*/
public function store(Request $request)
{
//
}
/**
......@@ -44,9 +44,10 @@ class BooksController extends Controller
* @param \App\Models\Books $books
* @return \Illuminate\Http\Response
*/
public function show(Books $books)
public function show($id)
{
//
$book = Books::find($id);
return view("pages.book.show")->with("book", $book);
}
/**
......
......@@ -10,4 +10,6 @@ class Books extends Model
use HasFactory;
const CREATED_AT = 'creation_date';
const UPDATED_AT = 'last_update';
protected $table = "books";
public $timestamp = true;
}
......@@ -4,6 +4,7 @@ namespace Database\Factories;
use App\Models\Books;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
class BooksFactory extends Factory
{
......@@ -22,7 +23,9 @@ class BooksFactory extends Factory
public function definition()
{
return [
//
'name' => $this->faker->name,
'isbn' => Str::random(10),
'picture' => "NoImage.jpg",
];
}
}
@extends('layouts.app')
@section('content')
<div class="container">
<h3>create new book</h3>
{!! Form::open(['action' => 'App\Http\Controllers\BooksController@store', 'method' => 'POST']) !!}
<div class="row justify-content-center">
<div class="col-6">
<div class="form-group">
{{Form::label('name', "Name")}}
{{Form::text('name', '', ['class' => 'form-control', 'placeholder' => 'Good Book'])}}
</div>
<div class="form-group">
{{Form::label('isbn', "ISBN")}}
<div class="row">
<div class="col-9">
{{Form::text('isbn', '', ['id' => 'ISBN','class' => 'form-control', 'placeholder' => '121212121'])}}
</div>
<div class="col-3">
<button type="button" class="btn btn-primary w-100 h-100" onclick="fillByISBN()">Check ISBN</button>
</div>
</div>
</div>
<div class="form-group">
<div class="col-2">
{{Form::label('image', "Image")}}
</div>
<div class="col-6">
{{Form::file('image')}}
</div>
<div class="col-12">
<img>
</div>
</div>
<br>
<div class="col-4 offset-4">
{{Form::submit("Submit", ['class' => 'btn btn-primary w-100'])}}
</div>
</div>
</div>
{!! Form::close() !!}
</div>
@endsection
<script>
const fillByISBN = ()=>{
const isbn = document.getElementById('ISBN').value;
console.log(isbn);
}
</script>
\ No newline at end of file
@extends('layouts.app')
@section('content')
<div class="container">
<h3>Books</h3>
@if(count($books) > 0)
@foreach ($books as $book)
<div class="well">
<h3><a href="/book/{{$book->id}}">{{$book->name}}</a></h3>
<small>Made on {{$book->created_at}}</small>
</div>
@endforeach
@else
<p>No Book found</p>
@endif
</div>
@endsection
@extends('layouts.app')
@section('content')
<div class="container">
@if(!empty($book))
<div class="well">
<h3><a href="/book/{{$book->id}}">{{$book->name}}</a></h3>
<small>Made on {{$book->created_at}}</small>
</div>
@else
<p>No Book found</p>
@endif
</div>
@endsection
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment