mirror of https://github.com/kcal-app/kcal.git
Start Recipe controller (WIP)
This commit is contained in:
parent
c12796cb28
commit
a04be37acb
|
@ -3,6 +3,7 @@
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use App\Models\Recipe;
|
use App\Models\Recipe;
|
||||||
|
use Illuminate\Contracts\View\View;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
class RecipeController extends Controller
|
class RecipeController extends Controller
|
||||||
|
@ -20,11 +21,11 @@ class RecipeController extends Controller
|
||||||
/**
|
/**
|
||||||
* Show the form for creating a new resource.
|
* Show the form for creating a new resource.
|
||||||
*
|
*
|
||||||
* @return \Illuminate\Http\Response
|
* @return \Illuminate\Contracts\View\View
|
||||||
*/
|
*/
|
||||||
public function create()
|
public function create(): View
|
||||||
{
|
{
|
||||||
//
|
return view('recipes.create');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
@props(['disabled' => false])
|
||||||
|
|
||||||
|
<textarea {{ $disabled ? 'disabled' : '' }} {!! $attributes->merge(['class' => 'rounded-md shadow-sm border-gray-300 focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50']) !!}>
|
||||||
|
</textarea>
|
|
@ -42,7 +42,7 @@
|
||||||
<div class="font-bold border-b border-gray-300">Carbohydrates</div>
|
<div class="font-bold border-b border-gray-300">Carbohydrates</div>
|
||||||
<div class="text-right border-b border-gray-300">{{ $ingedient->carbohydrates < 1 ? $ingedient->carbohydrates * 1000 . "m" : $ingedient->carbohydrates }}g</div>
|
<div class="text-right border-b border-gray-300">{{ $ingedient->carbohydrates < 1 ? $ingedient->carbohydrates * 1000 . "m" : $ingedient->carbohydrates }}g</div>
|
||||||
<div class="font-bold">Protein</div>
|
<div class="font-bold">Protein</div>
|
||||||
<div class="text-right">{{$ingedient->protein}}g</div>
|
<div class="text-right">{{ $ingedient->protein < 1 ? $ingedient->protein * 1000 . "m" : $ingedient->protein }}g</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@endforeach
|
@endforeach
|
||||||
|
|
|
@ -15,6 +15,8 @@
|
||||||
|
|
||||||
<!-- Scripts -->
|
<!-- Scripts -->
|
||||||
<script src="{{ asset('js/app.js') }}" defer></script>
|
<script src="{{ asset('js/app.js') }}" defer></script>
|
||||||
|
|
||||||
|
@isset($styles) {{ $styles }} @endisset
|
||||||
</head>
|
</head>
|
||||||
<body class="font-sans antialiased">
|
<body class="font-sans antialiased">
|
||||||
<div class="min-h-screen bg-gray-100">
|
<div class="min-h-screen bg-gray-100">
|
||||||
|
@ -32,5 +34,7 @@
|
||||||
{{ $slot }}
|
{{ $slot }}
|
||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@isset($scripts) {{ $scripts }} @endisset
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -17,6 +17,32 @@
|
||||||
</x-nav-link>
|
</x-nav-link>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Recipes Dropdown -->
|
||||||
|
<div class="hidden sm:flex sm:items-center sm:ml-6">
|
||||||
|
<x-dropdown align="left" width="48">
|
||||||
|
<x-slot name="trigger">
|
||||||
|
<button class="flex items-center text-sm font-medium text-gray-500 hover:text-gray-700 hover:border-gray-300 focus:outline-none focus:text-gray-700 focus:border-gray-300 transition duration-150 ease-in-out">
|
||||||
|
<div>Recipes</div>
|
||||||
|
|
||||||
|
<div class="ml-1">
|
||||||
|
<svg class="fill-current h-4 w-4" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20">
|
||||||
|
<path fill-rule="evenodd" d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z" clip-rule="evenodd" />
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
</button>
|
||||||
|
</x-slot>
|
||||||
|
|
||||||
|
<x-slot name="content">
|
||||||
|
<x-dropdown-link :href="route('recipes.create')">
|
||||||
|
{{ __('Add Recipe') }}
|
||||||
|
</x-dropdown-link>
|
||||||
|
<x-dropdown-link :href="route('recipes.index')">
|
||||||
|
{{ __('List Recipes') }}
|
||||||
|
</x-dropdown-link>
|
||||||
|
</x-slot>
|
||||||
|
</x-dropdown>
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- Ingredients Dropdown -->
|
<!-- Ingredients Dropdown -->
|
||||||
<div class="hidden sm:flex sm:items-center sm:ml-6">
|
<div class="hidden sm:flex sm:items-center sm:ml-6">
|
||||||
<x-dropdown align="left" width="48">
|
<x-dropdown align="left" width="48">
|
||||||
|
@ -33,12 +59,10 @@
|
||||||
</x-slot>
|
</x-slot>
|
||||||
|
|
||||||
<x-slot name="content">
|
<x-slot name="content">
|
||||||
<x-dropdown-link :href="route('ingredients.create')"
|
<x-dropdown-link :href="route('ingredients.create')">
|
||||||
:active="request()->routeIs('ingredients.create')">
|
|
||||||
{{ __('Add Ingredient') }}
|
{{ __('Add Ingredient') }}
|
||||||
</x-dropdown-link>
|
</x-dropdown-link>
|
||||||
<x-dropdown-link :href="route('ingredients.index')"
|
<x-dropdown-link :href="route('ingredients.index')">
|
||||||
:active="request()->routeIs('ingredients.index')">
|
|
||||||
{{ __('List Ingredients') }}
|
{{ __('List Ingredients') }}
|
||||||
</x-dropdown-link>
|
</x-dropdown-link>
|
||||||
</x-slot>
|
</x-slot>
|
||||||
|
|
|
@ -0,0 +1,84 @@
|
||||||
|
<x-app-layout>
|
||||||
|
<x-slot name="header">
|
||||||
|
<h2 class="font-semibold text-xl text-gray-800 leading-tight">
|
||||||
|
{{ __('Add Recipe') }}
|
||||||
|
</h2>
|
||||||
|
</x-slot>
|
||||||
|
|
||||||
|
<div class="py-12">
|
||||||
|
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
|
||||||
|
@if(session()->has('message'))
|
||||||
|
<div class="bg-green-200 border-2 border-green-600 p-2 mb-2">
|
||||||
|
{{ session()->get('message') }}
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
@if ($errors->any())
|
||||||
|
<div class="flex flex-col space-y-2 pb-2">
|
||||||
|
@foreach ($errors->all() as $error)
|
||||||
|
<div class="bg-red-200 border-2 border-red-900 p-2">
|
||||||
|
{{ $error }}
|
||||||
|
</div>
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
<div class="bg-white overflow-hidden shadow-sm sm:rounded-lg">
|
||||||
|
<div class="p-6 bg-white border-b border-gray-200">
|
||||||
|
<form method="POST" action="{{ route('ingredients.store') }}">
|
||||||
|
@csrf
|
||||||
|
<div class="flex flex-col space-y-4">
|
||||||
|
<div class="grid grid-cols-5 gap-4">
|
||||||
|
<!-- Name -->
|
||||||
|
<div class="col-span-4">
|
||||||
|
<x-label for="name" :value="__('Name')" />
|
||||||
|
|
||||||
|
<x-input id="name"
|
||||||
|
class="block mt-1 w-full"
|
||||||
|
type="text"
|
||||||
|
name="name"
|
||||||
|
:value="old('name')"
|
||||||
|
required />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Servings -->
|
||||||
|
<div>
|
||||||
|
<x-label for="servings" :value="__('Servings')" />
|
||||||
|
|
||||||
|
<x-input id="servings"
|
||||||
|
class="block mt-1 w-full"
|
||||||
|
type="number"
|
||||||
|
name="servings"
|
||||||
|
:value="old('servings')" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Description -->
|
||||||
|
<div>
|
||||||
|
<x-label for="description" :value="__('Description')" />
|
||||||
|
|
||||||
|
<x-form.textarea id="description"
|
||||||
|
class="block mt-1 w-full"
|
||||||
|
name="description"
|
||||||
|
:value="old('description')" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<h3 class="pt-2 font-extrabold">Ingredients</h3>
|
||||||
|
<div class="flex flex-row space-x-4">
|
||||||
|
<x-input class="mt-1"
|
||||||
|
type="number"
|
||||||
|
name="ingredients_amount[]"
|
||||||
|
step="any"
|
||||||
|
required />
|
||||||
|
</div>
|
||||||
|
<div class="flex items-center justify-end mt-4">
|
||||||
|
<x-button class="ml-3">
|
||||||
|
{{ __('Add') }}
|
||||||
|
</x-button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</x-app-layout>
|
|
@ -1,6 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use App\Http\Controllers\IngredientController;
|
use App\Http\Controllers\IngredientController;
|
||||||
|
use App\Http\Controllers\RecipeController;
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -23,5 +24,6 @@ Route::get('/dashboard', function () {
|
||||||
})->middleware(['auth'])->name('dashboard');
|
})->middleware(['auth'])->name('dashboard');
|
||||||
|
|
||||||
Route::resource('ingredients', IngredientController::class);
|
Route::resource('ingredients', IngredientController::class);
|
||||||
|
Route::resource('recipes', RecipeController::class);
|
||||||
|
|
||||||
require __DIR__.'/auth.php';
|
require __DIR__.'/auth.php';
|
||||||
|
|
Loading…
Reference in New Issue