Browse Source

hops refactor mkI

master
jk 3 years ago
parent
commit
67b6caa875
  1. 113
      resources/views/hops.blade.php
  2. 72
      resources/views/hops/create.blade.php
  3. 71
      resources/views/hops/edit.blade.php
  4. 56
      resources/views/hops/index.blade.php
  5. 7
      routes/web.php

113
resources/views/hops.blade.php

@ -1,117 +1,8 @@
@extends('layouts.app') @extends('layouts.app')
@section('content') @section('content')
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card">
@include('inc.navbar')
<div class="card-header"><a href="/home">Home</a> -> {{ __('Hop List') }}<span class="backlink"><a href="{{url()->previous()}}">Go Back</a></span></div>
<div class="card-body">
@if (Auth::user()->isAdmin())
<button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#addModal" type="button" name="button" >
Add Hop
</button>
<hr />
@endif
<table class="table table-striped table-dark" id="table-programs">
<!-- This piece of code is for error messages display purposes -->
@include('inc.messages')
<thead>
<tr>
<th scope="col">Hop Name</th>
<th scope="col">Profile</th>
<th scope="col">Bittering?</th>
<th scope="col">Aroma?</th>
</tr>
</thead>
<tbody>
@foreach ($hops as $hop)
<tr>
<td><a href="/hop/{{$hop->id}}">{{$hop->name}}</a> </td>
<td>{{str_replace(' ,',',',str_replace('"',' ',str_replace(',',', ',str_replace('}', '', str_replace('{','',$hop->profile)))))}} </td>
<td>@if($hop->bitter == 1) yes @else no @endif </td>
<td>@if($hop->aroma == 1) yes @else no @endif </td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<!-- this code if for the modal -->
<div class="modal fade bg-primary text-dark" tabindex="-1" role="dialog" id="addModal">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Add Hop</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close" >
<span aria-hidden="true">x</span>
</button>
</div>
<div class="modal-body">
<form class="" action="{{route('hops.store')}}" method="post">
{{csrf_field()}}
<div class="form-group">
<label for="">Name</label>
<input type="text" class="form-control" name="name">
</div>
<div class="form-group">
<label for="">Bittering?</label>
<input type="checkbox" class="form-control" name="bitter">
</div>
<div class="form-group">
<label for="">Aroma?</label>
<input type="checkbox" class="form-control" name="aroma">
</div>
<div class="form-group">
<label for="">Profile</label>
<textarea type="text" class="form-control" name="profile" ></textarea>
</div>
<div class="form-group">
<label for="">Alpha-Acid %</label>
<input type="text" class="form-control" name="alpha_acid">
</div>
<div class="form-group">
<label for="">Beta-Acid %</label>
<input type="text" class="form-control" name="beta_acid">
</div>
<div class="form-group">
<label for="">Total Oil %</label>
<input type="text" class="form-control" name="total_oil">
</div>
<div class="form-group">
<label for="">Cohumulone %</label>
<input type="text" class="form-control" name="cohumulone">
</div>
<div class="form-group">
<label for="">Myrcene %</label>
<input type="text" class="form-control" name="myrcene">
</div>
<div class="form-group">
<label for="">Humulene %</label>
<input type="text" class="form-control" name="humulene">
</div>
<div class="form-group">
<label for="">Farnesene %</label>
<input type="text" class="form-control" name="farnesene">
</div>
<div class="form-group">
<label for="">Caryophyllene</label>
<input type="text" class="form-control" name="caryophyllene">
</div>
<input type="submit" name="submit" value="Submit" class="btn btn-success">
</form>
</div>
</div>
</div>
<div class="container">
@yield('main')
</div> </div>
@endsection @endsection

72
resources/views/hops/create.blade.php

@ -0,0 +1,72 @@
@extends('hops')
@section('main')
<div class="row">
<div class="col-sm-8 offset-sm-2">
<h1 class="display-3">Add a Grain</h1>
<div>
@if ($errors->any())
<div class="alert alert-danger">
<ul>
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div><br />
@endif
<form method="post" action="{{ route('hops.store') }}">
@csrf
<div class="form-group">
<label for="">Name</label>
<input type="text" class="form-control" name="name">
</div>
<div class="form-group">
<label for="">Bittering?</label>
<input type="checkbox" class="form-control" name="bitter">
</div>
<div class="form-group">
<label for="">Aroma?</label>
<input type="checkbox" class="form-control" name="aroma">
</div>
<div class="form-group">
<label for="">Profile</label>
<textarea type="text" class="form-control" name="profile" ></textarea>
</div>
<div class="form-group">
<label for="">Alpha-Acid %</label>
<input type="text" class="form-control" name="alpha_acid">
</div>
<div class="form-group">
<label for="">Beta-Acid %</label>
<input type="text" class="form-control" name="beta_acid">
</div>
<div class="form-group">
<label for="">Total Oil %</label>
<input type="text" class="form-control" name="total_oil">
</div>
<div class="form-group">
<label for="">Cohumulone %</label>
<input type="text" class="form-control" name="cohumulone">
</div>
<div class="form-group">
<label for="">Myrcene %</label>
<input type="text" class="form-control" name="myrcene">
</div>
<div class="form-group">
<label for="">Humulene %</label>
<input type="text" class="form-control" name="humulene">
</div>
<div class="form-group">
<label for="">Farnesene %</label>
<input type="text" class="form-control" name="farnesene">
</div>
<div class="form-group">
<label for="">Caryophyllene</label>
<input type="text" class="form-control" name="caryophyllene">
</div>
<button type="submit" class="btn btn-primary">Add Grain</button>
</form>
</div>
</div>
</div>
@endsection

71
resources/views/hops/edit.blade.php

@ -0,0 +1,71 @@
@extends('hops')
@section('main') <div class="row">
<div class="col-sm-8 offset-sm-2">
<h1 class="display-3">Update Grain</h1>
@if ($errors->any())
<div class="alert alert-danger">
<ul>
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
<br />
@endif
<form method="post" action="{{ route('hops.update', $hop->id) }}">
@method('PATCH')
@csrf
<div class="form-group">
<label for="">Name</label>
<input type="text" class="form-control" name="name" value="{{$hop->name}}" />
</div>
<div class="form-group">
<label for="bitter">Bittering?</label>
<input type="checkbox" class="form-control" name="bitter" value="{{$hop->bitter}}" />
</div>
<div class="form-group">
<label for="aroma">Aroma?</label>
<input type="checkbox" class="form-control" name="aroma" value="{{$hop->aroma}}" />
</div>
<div class="form-group">
<label for="profile">Profile</label>
<textarea type="text" class="form-control" name="profile" >{{$hop->profile}}</textarea>
</div>
<div class="form-group">
<label for="alpha_acid">Alpha-Acid %</label>
<input type="text" class="form-control" name="alpha_acid" value="{{$hop->alpha_acid}}" />
</div>
<div class="form-group">
<label for="beta_acid">Beta-Acid %</label>
<input type="text" class="form-control" name="beta_acid" value="{{$hop->beta_acid}}" />
</div>
<div class="form-group">
<label for="total_oil">Total Oil %</label>
<input type="text" class="form-control" name="total_oil" value="{{$hop->total_oil}}" />
</div>
<div class="form-group">
<label for="cohumulone">Cohumulone %</label>
<input type="text" class="form-control" name="cohumulone" value="{{$hop->cohumulone}}" />
</div>
<div class="form-group">
<label for="myrcene">Myrcene %</label>
<input type="text" class="form-control" name="myrcene" value="{{$hop->myrcene}}" />
</div>
<div class="form-group">
<label for="humulene">Humulene %</label>
<input type="text" class="form-control" name="humulene" value="{{$hop->humulene}}" />
</div>
<div class="form-group">
<label for="farnesene">Farnesene %</label>
<input type="text" class="form-control" name="farnesene" value="{{$hop->farnesene}}" />
</div>
<div class="form-group">
<label for="caryophyllene">Caryophyllene</label>
<input type="text" class="form-control" name="caryophyllene" value="{{$hop->caryophyllene}}" />
</div>
<button type="submit" class="btn btn-primary">Update</button>
</form>
</div>
</div>
@endsection

56
resources/views/hops/index.blade.php

@ -0,0 +1,56 @@
@extends('layouts.app')
@section('content')
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card">
@include('inc.navbar')
<div class="card-header"><a href="/home">Home</a> -> {{ __('Hop List') }}<span class="backlink"><a href="{{url()->previous()}}">Go Back</a></span></div>
<div class="card-body">
@if (Auth::user()->isAdmin())
<a href="{{ route('hops.create') }}" class="btn btn-primary">Add Hop</a>
<hr />
@endif
<table class="table table-striped table-dark" id="table-programs">
<!-- This piece of code is for error messages display purposes -->
@include('inc.messages')
<thead>
<tr>
<th scope="col">Hop Name</th>
<th scope="col">Profile</th>
<th scope="col">Bittering?</th>
<th scope="col">Aroma?</th>
</tr>
@if (Auth::user()->isAdmin())<th colspan="2" scope="col">Admin</th>@endif
</thead>
<tbody>
@foreach ($hops as $hop)
<tr>
<td><a href="/hop/{{$hop->id}}">{{$hop->name}}</a> </td>
<td>{{str_replace(' ,',',',str_replace('"',' ',str_replace(',',', ',str_replace('}', '', str_replace('{','',$hop->profile)))))}} </td>
<td>@if($hop->bitter == 1) yes @else no @endif </td>
<td>@if($hop->aroma == 1) yes @else no @endif </td>
@if (Auth::user()->isAdmin())
<td><a href="{{ route('hops.edit',$hop->id)}}" class="btn btn-primary">Edit</a></td>
<td><form action="{{ route('hops.destroy', $hop->id)}}" method="post">
@csrf
@method('DELETE')
<button class="btn btn-danger" type="submit">Delete</button>
</form></td>
@endif
</tr>
@endforeach
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
@endsection

7
routes/web.php

@ -25,10 +25,10 @@ Route::any('/register', function() {
Route::resource('breweries', 'App\Http\Controllers\BrewerieController'); Route::resource('breweries', 'App\Http\Controllers\BrewerieController');
Route::resource('beers', 'App\Http\Controllers\SummarieController'); Route::resource('beers', 'App\Http\Controllers\SummarieController');
Route::resource('grains', 'App\Http\Controllers\GrainController'); Route::resource('grains', 'App\Http\Controllers\GrainController');
Route::resource('hops', 'App\Http\Controllers\HopController');
Route::get('/home', [App\Http\Controllers\SummarieController::class, 'index'])->name('home'); Route::get('/home', [App\Http\Controllers\SummarieController::class, 'index'])->name('home');
Route::get('/adjuncts', [App\Http\Controllers\AdjunctController::class, 'index'])->name('adjuncts'); Route::get('/adjuncts', [App\Http\Controllers\AdjunctController::class, 'index'])->name('adjuncts');
//Route::get('/grains', [App\Http\Controllers\GrainController::class, 'index'])->name('grains');
Route::get('/hops', [App\Http\Controllers\HopController::class, 'index'])->name('hops');
//Route::get('/hops', [App\Http\Controllers\HopController::class, 'index'])->name('hops');
Route::get('/yeasts', [App\Http\Controllers\YeastController::class, 'index'])->name('yeasts'); Route::get('/yeasts', [App\Http\Controllers\YeastController::class, 'index'])->name('yeasts');
Route::get('/fermentations', [App\Http\Controllers\FermentationController::class, 'index'])->name('fermentations'); Route::get('/fermentations', [App\Http\Controllers\FermentationController::class, 'index'])->name('fermentations');
Route::get('/grainbills', [App\Http\Controllers\GrainbillController::class, 'index'])->name('grainbills'); Route::get('/grainbills', [App\Http\Controllers\GrainbillController::class, 'index'])->name('grainbills');
@ -41,8 +41,7 @@ Route::get('/grain/{grainID}', [App\Http\Controllers\GraincardController::class,
Route::get('/yeast/{yeastID}', [App\Http\Controllers\YeastcardController::class, 'index'])->name('yeast'); Route::get('/yeast/{yeastID}', [App\Http\Controllers\YeastcardController::class, 'index'])->name('yeast');
Route::get('/hop/{hopID}', [App\Http\Controllers\HopcardController::class, 'index'])->name('hop'); Route::get('/hop/{hopID}', [App\Http\Controllers\HopcardController::class, 'index'])->name('hop');
Route::get('/adjunct/{adjunctID}', [App\Http\Controllers\AdjunctcardController::class, 'index'])->name('adjunct'); Route::get('/adjunct/{adjunctID}', [App\Http\Controllers\AdjunctcardController::class, 'index'])->name('adjunct');
//Route::post('/grains', [App\Http\Controllers\GrainController::class, 'store'])->name('grains.store');
Route::post('/hops', [App\Http\Controllers\HopController::class, 'store'])->name('hops.store');
//Route::post('/hops', [App\Http\Controllers\HopController::class, 'store'])->name('hops.store');
Route::post('/yeasts', [App\Http\Controllers\YeastController::class, 'store'])->name('yeasts.store'); Route::post('/yeasts', [App\Http\Controllers\YeastController::class, 'store'])->name('yeasts.store');
Route::post('/adjuncts', [App\Http\Controllers\AdjunctController::class, 'store'])->name('adjuncts.store'); Route::post('/adjuncts', [App\Http\Controllers\AdjunctController::class, 'store'])->name('adjuncts.store');
Route::post('/grainbills', [App\Http\Controllers\GrainbillController::class, 'store'])->name('grainbills.store'); Route::post('/grainbills', [App\Http\Controllers\GrainbillController::class, 'store'])->name('grainbills.store');

Loading…
Cancel
Save