diff options
Diffstat (limited to 'Year_3/TSDWL/LARAVEL/iBook/resources/views')
4 files changed, 65 insertions, 3 deletions
diff --git a/Year_3/TSDWL/LARAVEL/iBook/resources/views/books/create.blade.php b/Year_3/TSDWL/LARAVEL/iBook/resources/views/books/create.blade.php index 398c7b4..5bd20b0 100644 --- a/Year_3/TSDWL/LARAVEL/iBook/resources/views/books/create.blade.php +++ b/Year_3/TSDWL/LARAVEL/iBook/resources/views/books/create.blade.php @@ -7,11 +7,11 @@      @csrf      <div>          <label for="name">Name: </label> -        <input type="text" name="name" id="name"> +        <input type="text" name="name" id="name" required>      </div>      <div>          <label for="published_at">Published at: </label> -        <input type="date" name="published_at" id="published_at"> +        <input type="datetime" name="published_at" id="published_at">      </div>      <div>          <label for="is_online">Is online?: </label> @@ -19,8 +19,14 @@      </div>      <div>          <label for="author_id">Author: </label> -        <input type="text" name="name" id="name"> +        <select id="author_id" name="author_id"> +            <option value="">Select an author</option> +            @foreach ($authors as $author) +            <option value="{{ $author->id }}">{{ $author->name }}</option> +            @endforeach +        </select>      </div> +    <button type="submit">Save</button>  </form>  @endsection diff --git a/Year_3/TSDWL/LARAVEL/iBook/resources/views/books/edit.blade.php b/Year_3/TSDWL/LARAVEL/iBook/resources/views/books/edit.blade.php new file mode 100644 index 0000000..1889b18 --- /dev/null +++ b/Year_3/TSDWL/LARAVEL/iBook/resources/views/books/edit.blade.php @@ -0,0 +1,34 @@ +@extends('layout') + +@section('content') +<h1>Edit `{{ $book->name }}`</h1> + +<form method="post" action="/books/<?php echo $book->id; ?>"> +    @csrf +    @method('put') +    <div> +        <label for="name">Name: </label> +        <input type="text" name="name" id="name" required value="<?php echo $book->name; ?>"> +    </div> +    <div> +        <label for="published_at">Published at: </label> +        <input type="datetime" name="published_at" id="published_at" value="<?php echo $book->published_at; ?>"> +    </div> +    <div> +        <label for="is_online">Is online?: </label> +        <input type="checkbox" name="is_online" id="is_online" <?php echo ($book->is_online ? 'checked': ''); ?>> +    </div> +    <div> +        <label for="author_id">Author: </label> +        <select id="author_id" name="author_id"> +            <option value="">Select an author</option> +            @foreach ($authors as $author) +            <option value="{{ $author->id }}" <?php if($author->id == $book->author_id) { echo 'selected'; +                                              } ?>> +{{ $author->name }}</option> +            @endforeach +        </select> +    </div> +    <button type="submit">Save</button> +</form> +@endsection diff --git a/Year_3/TSDWL/LARAVEL/iBook/resources/views/books/index.blade.php b/Year_3/TSDWL/LARAVEL/iBook/resources/views/books/index.blade.php new file mode 100644 index 0000000..65a4a42 --- /dev/null +++ b/Year_3/TSDWL/LARAVEL/iBook/resources/views/books/index.blade.php @@ -0,0 +1,15 @@ +@extends('layout') + +@section('content') + +<h1>Hello world! They're my books:</h1> +@foreach ($books as $book) +<p> +    <a href="/books/{{ $book->id }}">{{ $book->name }}</a> +    @if ($book->author_id) +    <span>by {{ $book->author->name }}</span> +    @endif +</p> +@endforeach + +@endsection diff --git a/Year_3/TSDWL/LARAVEL/iBook/resources/views/layout.blade.php b/Year_3/TSDWL/LARAVEL/iBook/resources/views/layout.blade.php new file mode 100644 index 0000000..e19db99 --- /dev/null +++ b/Year_3/TSDWL/LARAVEL/iBook/resources/views/layout.blade.php @@ -0,0 +1,7 @@ +<!DOCTYPE html> +<html> +    <head></head> +    <body> +        @yield('content') +    </body> +</html>  |