forked from eatvio/eatvio-infra
added create recipe page
This commit is contained in:
@@ -17,6 +17,10 @@ class Create extends Component
|
||||
|
||||
public $state = 'active';
|
||||
|
||||
public $state_ingredient = 'active';
|
||||
|
||||
public $state_article = 'active';
|
||||
|
||||
public $tags = [];
|
||||
|
||||
public $title;
|
||||
@@ -39,20 +43,21 @@ class Create extends Component
|
||||
|
||||
public $ingredients_unit = 'gr';
|
||||
|
||||
public $state_row = ['ingredient' => 'true', 'article' => 'false'];
|
||||
|
||||
protected $listeners = ['stepRemoved' => '$refresh'];
|
||||
|
||||
public function render()
|
||||
|
||||
|
||||
public function toggleStateRow(string $currentRow): void
|
||||
{
|
||||
return view('livewire.recipe.create');
|
||||
collect($this->state_row)->keys()->map(fn($key) => $key === $currentRow
|
||||
? $this->state_row[$currentRow] = 'true'
|
||||
: $this->state_row[$key] = 'false');
|
||||
}
|
||||
|
||||
public function addIngredient(): void
|
||||
{
|
||||
// dd(
|
||||
// $this->ingredients_name,
|
||||
// $this->ingredients_portion,
|
||||
// $this->ingredients_unit
|
||||
// );
|
||||
$this->ingredients[] = [
|
||||
'name' => $this->ingredients_name,
|
||||
'portion' => $this->ingredients_portion,
|
||||
@@ -99,7 +104,7 @@ class Create extends Component
|
||||
public function parentComponentTagRemoved($tag)
|
||||
{
|
||||
$this->tags = collect($this->tags)
|
||||
->filter(fn ($curTag) => $curTag['name'] !== $tag)
|
||||
->filter(fn($curTag) => $curTag['name'] !== $tag)
|
||||
->all();
|
||||
}
|
||||
|
||||
@@ -117,9 +122,20 @@ class Create extends Component
|
||||
$this->publish();
|
||||
}
|
||||
|
||||
protected function rules()
|
||||
{
|
||||
return [
|
||||
'image' => 'required|image|max:2048',
|
||||
'state' => 'required|in:active,archived',
|
||||
'description' => 'required|min:3',
|
||||
'type' => 'required|min:3',
|
||||
'video_url' => 'nullable|url|max:2048',
|
||||
'cooking_time' => 'nullable|numeric',
|
||||
];
|
||||
}
|
||||
|
||||
public function publish()
|
||||
{
|
||||
// dd($this->description);
|
||||
$this->validate();
|
||||
|
||||
$recipe = new Recipe();
|
||||
@@ -134,7 +150,7 @@ class Create extends Component
|
||||
$recipe->ingredients = $this->ingredients;
|
||||
$recipe->save();
|
||||
|
||||
$tagsIds = collect($this->tags)->map(fn ($curTag) => $curTag['id']);
|
||||
$tagsIds = collect($this->tags)->map(fn($curTag) => $curTag['id']);
|
||||
$recipe->tags()->attach($tagsIds);
|
||||
|
||||
$user = Auth::user();
|
||||
@@ -143,19 +159,6 @@ class Create extends Component
|
||||
return redirect()->route('recipe.show', $recipe->id);
|
||||
}
|
||||
|
||||
protected function rules()
|
||||
{
|
||||
return [
|
||||
'image' => 'required|image|max:2048',
|
||||
'state' => 'required|in:active,archived',
|
||||
'description' => 'required|min:3',
|
||||
'type' => 'required|min:3',
|
||||
'video_url' => 'nullable|url|max:2048',
|
||||
'cooking_time' => 'nullable|numeric',
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
private function transformSteps($steps)
|
||||
{
|
||||
return collect($steps)->map(
|
||||
@@ -163,7 +166,7 @@ class Create extends Component
|
||||
if (gettype($step['image']) === 'string') {
|
||||
$data['image'] = $step['image'];
|
||||
} else {
|
||||
$data['image'] = ! is_null($step['image']) ? $step['image']->store('steps', 'public') : '';
|
||||
$data['image'] = !is_null($step['image']) ? $step['image']->store('steps', 'public') : '';
|
||||
}
|
||||
|
||||
$data['description'] = $step['description'];
|
||||
@@ -173,8 +176,11 @@ class Create extends Component
|
||||
)->toArray();
|
||||
}
|
||||
|
||||
// public function updated($property)
|
||||
// {
|
||||
// dd($property, $this->$property);
|
||||
// }
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.recipe.create');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
<section class="py-5 diet" id="main">
|
||||
<div class="diet__container">
|
||||
<div class="diet__header">
|
||||
<div class="diet__header">
|
||||
<a class="diet__back icon-arrow-short-left" href="{{ route('recipe.index') }}">
|
||||
<span>Мой блог</span>
|
||||
<span>Мой блог</span>
|
||||
</a>
|
||||
<h1 class="diet__title">{{ __('recipe.adding') }}</h1>
|
||||
</div>
|
||||
</div>
|
||||
<div class="diet__form">
|
||||
<div class="diet__form-row">
|
||||
<div class="label">{{ __('recipe.title') }}</div>
|
||||
@@ -24,53 +24,82 @@
|
||||
</select>
|
||||
</div>
|
||||
<div class="diet__form-row">
|
||||
<div class="diet__form-columns lg-columns">
|
||||
<div class="diet__form-column">
|
||||
<div class="label">{{ __('recipe.picture') }}</div>
|
||||
<label class="file">
|
||||
<input wire:model="image" type="file" name="file" class="file__input hidden" hidden="">
|
||||
@error('image') <span class="error">{{ $message }}</span> @enderror
|
||||
<div class="diet__form-columns lg-columns">
|
||||
<div class="diet__form-column">
|
||||
<div class="label">{{ __('recipe.picture') }}</div>
|
||||
<label class="file">
|
||||
<input wire:model="image" type="file" name="file" class="file__input hidden"
|
||||
hidden="">
|
||||
@error('image')
|
||||
<span class="error">{{ $message }}</span>
|
||||
@enderror
|
||||
<span class="file__content">
|
||||
@if(is_null($image))
|
||||
<span class="file__formats">
|
||||
<img src="/img/formats-2.svg" alt="formats">
|
||||
</span>
|
||||
<span class="file__title">{{ __('recipe.tap_to_select_or_drag_and_drop') }}</span>
|
||||
@if (is_null($image))
|
||||
<span class="file__formats">
|
||||
<img src="/img/formats-2.svg" alt="formats">
|
||||
</span>
|
||||
<span class="file__title">{{ __('recipe.tap_to_select_or_drag_and_drop') }}</span>
|
||||
@else
|
||||
<p><img src="{{ $image->temporaryUrl() }}" /> </p>
|
||||
<p><img src="{{ $image->temporaryUrl() }}" /> </p>
|
||||
@endif
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="diet__form-column diet__form-column-lg">
|
||||
<div class="diet__form-row">
|
||||
<div class="label">
|
||||
Тип записи
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="diary__stats-tablist" role="tablist" aria-labelledby="label">
|
||||
<button class="btn" role="tab" type="button" id="tab-1" aria-selected="true" aria-controls="tabpanel-1">Рецепт</button>
|
||||
<button class="btn" role="tab" type="button" id="tab-2" aria-selected="false" aria-controls="tabpanel-2" tabindex="-1">Cтатья</button>
|
||||
<div class="diet__form-column diet__form-column-lg">
|
||||
<div class="diet__form-row">
|
||||
<div class="label">
|
||||
Тип записи
|
||||
</div>
|
||||
<div class="diary__stats-tablist" role="tablist" aria-labelledby="label">
|
||||
<button class="btn" role="tab" type="button" id="tab-1"
|
||||
wire:click="toggleStateRow('ingredient')"
|
||||
aria-selected="{{ $state_row['ingredient'] }}"
|
||||
aria-controls="tabpanel-1">Рецепт</button>
|
||||
<button class="btn" role="tab" type="button" id="tab-2"
|
||||
wire:click="toggleStateRow('article')" aria-selected="{{ $state_row['article'] }}"
|
||||
aria-controls="tabpanel-2" tabindex="-1">Cтатья</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="tabpanel" role="tabpanel" id="tabpanel-1" tabindex="0" aria-labelledby="tab-1">
|
||||
<div @class([
|
||||
'tabpanel',
|
||||
'tabpanel--hidden' => $state_row['ingredient'] !== 'true',
|
||||
]) role="tabpanel" id="tabpanel-1" tabindex="0"
|
||||
aria-labelledby="tab-1">
|
||||
<div class="diet__form-column">
|
||||
<div class="diet__form-row">
|
||||
<div class="label">{{ __('recipe.cooking_time') }}</div>
|
||||
<div class="dropdown" x-data="{ open: false }" >
|
||||
<button
|
||||
type="button"
|
||||
<div class="dropdown" x-data="{ open: false }">
|
||||
<button type="button"
|
||||
:class="open ? 'dropdown__button active' : 'dropdown__button'"
|
||||
x-on:click="open = ! open">
|
||||
{{ __('recipe.t' . $cooking_time . 'm') }}
|
||||
</button>
|
||||
<ul :class="open ? 'dropdown__list visible' : 'dropdown__list'">
|
||||
<li wire:click="$set('cooking_time','10')" @click="open = !open" :class="$wire.cooking_time =='10'? 'dropdown__list-item active' : 'dropdown__list-item'">{{ __('recipe.t10m') }}</li>
|
||||
<li wire:click="$set('cooking_time','20')" @click="open = !open" :class="$wire.cooking_time =='20' ? 'dropdown__list-item active' : 'dropdown__list-item'">{{ __('recipe.t20m') }}</li>
|
||||
<li wire:click="$set('cooking_time','30')" @click="open = !open" :class="$wire.cooking_time =='30' ? 'dropdown__list-item active' : 'dropdown__list-item'">{{ __('recipe.t30m') }}</li>
|
||||
<li wire:click="$set('cooking_time','60')" @click="open = !open" :class="$wire.cooking_time =='60' ? 'dropdown__list-item active' : 'dropdown__list-item'">{{ __('recipe.t60m') }}</li>
|
||||
<li wire:click="$set('cooking_time','120')" @click="open = !open" :class="$wire.cooking_time =='120' ? 'dropdown__list-item active' : 'dropdown__list-item'">{{ __('recipe.t120m') }}</li>
|
||||
<li wire:click="$set('cooking_time','14400')" @click="open = !open" :class="$wire.cooking_time =='14400' ? 'dropdown__list-item active' : 'dropdown__list-item'">{{ __('recipe.t14400m') }}</li>
|
||||
<li wire:click="$set('cooking_time','10')" @click="open = !open"
|
||||
:class="$wire.cooking_time == '10' ? 'dropdown__list-item active' :
|
||||
'dropdown__list-item'">
|
||||
{{ __('recipe.t10m') }}</li>
|
||||
<li wire:click="$set('cooking_time','20')" @click="open = !open"
|
||||
:class="$wire.cooking_time == '20' ? 'dropdown__list-item active' :
|
||||
'dropdown__list-item'">
|
||||
{{ __('recipe.t20m') }}</li>
|
||||
<li wire:click="$set('cooking_time','30')" @click="open = !open"
|
||||
:class="$wire.cooking_time == '30' ? 'dropdown__list-item active' :
|
||||
'dropdown__list-item'">
|
||||
{{ __('recipe.t30m') }}</li>
|
||||
<li wire:click="$set('cooking_time','60')" @click="open = !open"
|
||||
:class="$wire.cooking_time == '60' ? 'dropdown__list-item active' :
|
||||
'dropdown__list-item'">
|
||||
{{ __('recipe.t60m') }}</li>
|
||||
<li wire:click="$set('cooking_time','120')" @click="open = !open"
|
||||
:class="$wire.cooking_time == '120' ? 'dropdown__list-item active' :
|
||||
'dropdown__list-item'">
|
||||
{{ __('recipe.t120m') }}</li>
|
||||
<li wire:click="$set('cooking_time','14400')" @click="open = !open"
|
||||
:class="$wire.cooking_time == '14400' ? 'dropdown__list-item active' :
|
||||
'dropdown__list-item'">
|
||||
{{ __('recipe.t14400m') }}</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
@@ -81,143 +110,187 @@
|
||||
<div class="dropdown" x-data="{ open: false }">
|
||||
<button type="button"
|
||||
:class="open ? 'dropdown__button active' : 'dropdown__button'"
|
||||
x-on:click="open = ! open"
|
||||
>{{ $state == 'active' ? __('recipe.record_state_active') : __('recipe.record_state_not_active') }}
|
||||
x-on:click="open = ! open">{{ $state_ingredient == 'active' ? __('recipe.record_state_active') : __('recipe.record_state_not_active') }}
|
||||
</button>
|
||||
<ul :class="open ? 'dropdown__list visible' : 'dropdown__list'">
|
||||
<li wire:click="$set('state','active')" @click="open = !open" :class="$wire.state == 'active' ? 'dropdown__list-item active' : 'dropdown__list-item'">{{ __('recipe.record_state_active') }}</li>
|
||||
<li wire:click="$set('state','archived')" @click="open = !open" :class="$wire.state == 'archived' ? 'dropdown__list-item active' : 'dropdown__list-item'">{{ __('recipe.record_state_not_active') }}</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="diet__form-column diet__form-column-xl">
|
||||
@if(!empty($ingredients))
|
||||
<div class="content__table diet__form-row">
|
||||
<div class="content__table-wrapper">
|
||||
<table class="cabinet__table-content">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{{ __('recipe.name_of_product')}}</th>
|
||||
<th>{{ __('recipe.portion')}}</th>
|
||||
<th>{{ __('recipe.units')}}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach($ingredients as $ingredient)
|
||||
<tr>
|
||||
<td>{{ $ingredient['name'] }}</td>
|
||||
<td>{{ $ingredient['portion'] }}</td>
|
||||
<td>{{ __('recipe.' . $ingredient['unit']) }}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
<ul :class="open ? 'dropdown__list visible' : 'dropdown__list'">
|
||||
<li wire:click="$set('state_ingredient','active')" @click="open = !open"
|
||||
:class="$wire.state_ingredient == 'active' ? 'dropdown__list-item active' :
|
||||
'dropdown__list-item'">
|
||||
{{ __('recipe.record_state_active') }}</li>
|
||||
<li wire:click="$set('state_ingredient','archived')" @click="open = !open"
|
||||
:class="$wire.state_ingredient == 'archived' ? 'dropdown__list-item active' :
|
||||
'dropdown__list-item'">
|
||||
{{ __('recipe.record_state_not_active') }}</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="diet__form-column diet__form-column-xl">
|
||||
@if (!empty($ingredients))
|
||||
<div class="content__table diet__form-row">
|
||||
<div class="content__table-wrapper">
|
||||
<table class="cabinet__table-content">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{{ __('recipe.name_of_product') }}</th>
|
||||
<th>{{ __('recipe.portion') }}</th>
|
||||
<th>{{ __('recipe.units') }}</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach ($ingredients as $k => $ingredient)
|
||||
<tr>
|
||||
<td>{{ $ingredient['name'] }}</td>
|
||||
<td>{{ $ingredient['portion'] }}</td>
|
||||
<td>{{ __('recipe.' . $ingredient['unit']) }}</td>
|
||||
<td>
|
||||
<button wire:click="removeIngredient({{ $k }})"
|
||||
type="button"
|
||||
class="diet__form-add btn btn-primary">-</button>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
<div class="diet__form-columns">
|
||||
<div class="diet__form-column diet__form-column-lg">
|
||||
<input wire:model="ingredients_name" type="text" name="name"
|
||||
class="input" placeholder="Введите название продукта">
|
||||
</div>
|
||||
<div class="diet__form-column">
|
||||
<div class="diet__form-adding">
|
||||
<div class="diet__form-column">
|
||||
<input wire:model="ingredients_portion" type="num" name="portion"
|
||||
class="input" placeholder="Порция">
|
||||
<select wire:model="ingredients_unit" name="unit" class="input">
|
||||
<option value="gr">гр</option>
|
||||
<option value="teespoon">ч. ложек</option>
|
||||
<option value="tablespoon">ст. ложек</option>
|
||||
<option value="ml">мл</option>
|
||||
<option value="pcs">шт</option>
|
||||
<option value="clove">зубчик</option>
|
||||
<option value="to_taste">по вкусу</option>
|
||||
</select>
|
||||
<button wire:click="addIngredient" type="button"
|
||||
class="btn btn-primary icon-plus"></button>
|
||||
</div>
|
||||
<button type="button" class="icon-gear"></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div @class([
|
||||
'tabpanel',
|
||||
'tabpanel--hidden' => $state_row['article'] !== 'true',
|
||||
]) role="tabpanel" id="tabpanel-2" tabindex="0"
|
||||
aria-labelledby="tab-2">
|
||||
<div class="diet__form-column">
|
||||
<div class="diet__form-row">
|
||||
<div class="label">{{ __('recipe.record_state') }}</div>
|
||||
<div class="dropdown" x-data="{ open: false }">
|
||||
<button type="button"
|
||||
:class="open ? 'dropdown__button active' : 'dropdown__button'"
|
||||
x-on:click="open = ! open">{{ $state_article == 'active' ? __('recipe.record_state_active') : __('recipe.record_state_not_active') }}
|
||||
</button>
|
||||
<ul :class="open ? 'dropdown__list visible' : 'dropdown__list'">
|
||||
<li wire:click="$set('state_article','active')" @click="open = !open"
|
||||
:class="$wire.state_article == 'active' ? 'dropdown__list-item active' :
|
||||
'dropdown__list-item'">
|
||||
{{ __('recipe.record_state_active') }}</li>
|
||||
<li wire:click="$set('state_article','archived')" @click="open = !open"
|
||||
:class="$wire.state_article == 'archived' ? 'dropdown__list-item active' :
|
||||
'dropdown__list-item'">
|
||||
{{ __('recipe.record_state_not_active') }}</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
<div class="diet__form-columns">
|
||||
<div class="diet__form-column diet__form-column-lg">
|
||||
<input wire:model="ingredients_name" type="text" name="name" class="input" placeholder="Введите название продукта">
|
||||
</div>
|
||||
<div class="diet__form-column">
|
||||
<div class="diet__form-adding">
|
||||
<div class="diet__form-column">
|
||||
<input wire:model="ingredients_portion" type="num" name="portion" class="input" placeholder="Порция">
|
||||
<select wire:model="ingredients_unit" name="unit" class="input">
|
||||
<option value="gr">гр</option>
|
||||
<option value="teespoon">ч. ложек</option>
|
||||
<option value="tablespoon">ст. ложек</option>
|
||||
<option value="ml">мл</option>
|
||||
<option value="pcs">шт</option>
|
||||
<option value="clove">зубчик</option>
|
||||
<option value="to_taste">по вкусу</option>
|
||||
</select>
|
||||
<button wire:click="addIngredient" type="button" class="btn btn-primary icon-plus"></button>
|
||||
</div>
|
||||
<button type="button" class="icon-gear"></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="diet__form-row">
|
||||
<div class="label">{{ __('recipe.content') }}</div>
|
||||
<div class="label">{{ __('recipe.content') }}</div>
|
||||
<div class="wysiwyg" wire:ignore>
|
||||
<div
|
||||
class="form-textarea w-full"
|
||||
x-data="{}"
|
||||
x-init="ClassicEditor.create($refs.myIdentifierHere,
|
||||
{
|
||||
toolbar: {
|
||||
items: [
|
||||
'heading', '|',
|
||||
'bold', 'italic', '|',
|
||||
'bulletedList', 'numberedList', '|',
|
||||
'outdent', 'indent', '|',
|
||||
'blockQuote', 'undo', 'redo'
|
||||
],
|
||||
shouldNotGroupWhenFull: true
|
||||
}
|
||||
})
|
||||
.then( function(editor){
|
||||
editor.model.document.on('change:data', () => {
|
||||
console.log(editor.getData());
|
||||
// $dispatch('input', editor.getData())
|
||||
@this.set('description', editor.getData());
|
||||
})
|
||||
})
|
||||
.catch( error => {
|
||||
console.error( error );
|
||||
});"
|
||||
wire:ignore
|
||||
wire:key="myIdentifierHere"
|
||||
x-ref="myIdentifierHere"
|
||||
<div class="form-textarea w-full" x-data="{}" x-init="ClassicEditor.create($refs.myIdentifierHere, {
|
||||
toolbar: {
|
||||
items: [
|
||||
'heading', '|',
|
||||
'bold', 'italic', '|',
|
||||
'bulletedList', 'numberedList', '|',
|
||||
'outdent', 'indent', '|',
|
||||
'blockQuote', 'undo', 'redo'
|
||||
],
|
||||
shouldNotGroupWhenFull: true
|
||||
}
|
||||
})
|
||||
.then(function(editor) {
|
||||
editor.model.document.on('change:data', () => {
|
||||
console.log(editor.getData());
|
||||
// $dispatch('input', editor.getData())
|
||||
@this.set('description', editor.getData());
|
||||
})
|
||||
})
|
||||
.catch(error => {
|
||||
console.error(error);
|
||||
});" wire:ignore
|
||||
wire:key="myIdentifierHere" x-ref="myIdentifierHere"
|
||||
wire:model.live.debounce.9999999ms="description"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@php
|
||||
$stepsCount = count($steps);
|
||||
@endphp
|
||||
@for($i = 0; $i < $stepsCount; $i++)
|
||||
<div class="diet__form-row">
|
||||
<div class="label">
|
||||
{{ __('recipe.step') }} {{ $i + 1 }}
|
||||
@if($i == 0)
|
||||
<span>{{ __('recipe.total_steps') }}: {{ $stepsCount }}</span>
|
||||
@endif
|
||||
</div>
|
||||
<div class="diet__form-step">
|
||||
<label class="file">
|
||||
<input class="file__input hidden" hidden="" type="file" name="step[{{$i}}][image]" wire:model="steps.{{$i}}.image" id="step[{{$i}}][image]" />
|
||||
<span class="file__content">
|
||||
@if ($steps[$i]['image'])
|
||||
<img src="{{ $steps[$i]['image']->temporaryUrl() }}">
|
||||
@else
|
||||
<img src="/img/add-file.svg" width="40" height="40" alt="formats">
|
||||
@endif
|
||||
</span>
|
||||
</label>
|
||||
<textarea name="desc-step-1" class="textarea" wire:model="steps.{{$i}}.description" id="step[{{$i}}][description]" placeholder="Введите описание шага"></textarea>
|
||||
<div class="diet__form-column">
|
||||
<button type="button" wire:click="removeStep({{$i}})" class="diet__form-add btn {{ $i == 0 ? 'btn-gray' : 'btn-primary' }}" @disabled($i == 0)>-</button>
|
||||
<button type="button" wire:click="addStep" class="diet__form-add btn btn-primary" data-bs-original-title="Добавить шаг">+</button>
|
||||
@for ($i = 0; $i < $stepsCount; $i++)
|
||||
<div class="diet__form-row">
|
||||
<div class="label">
|
||||
{{ __('recipe.step') }} {{ $i + 1 }}
|
||||
@if ($i == 0)
|
||||
<span>{{ __('recipe.total_steps') }}: {{ $stepsCount }}</span>
|
||||
@endif
|
||||
</div>
|
||||
<div class="diet__form-step">
|
||||
<label class="file">
|
||||
<input class="file__input hidden" hidden="" type="file"
|
||||
name="step[{{ $i }}][image]" wire:model="steps.{{ $i }}.image"
|
||||
id="step[{{ $i }}][image]" />
|
||||
<span class="file__content">
|
||||
@if ($steps[$i]['image'])
|
||||
<img src="{{ $steps[$i]['image']->temporaryUrl() }}">
|
||||
@else
|
||||
<img src="/img/add-file.svg" width="40" height="40" alt="formats">
|
||||
@endif
|
||||
</span>
|
||||
</label>
|
||||
<textarea name="desc-step-1" class="textarea" wire:model="steps.{{ $i }}.description"
|
||||
id="step[{{ $i }}][description]" placeholder="Введите описание шага"></textarea>
|
||||
<div class="diet__form-column">
|
||||
<button type="button" wire:click="removeStep({{ $i }})"
|
||||
class="diet__form-add btn {{ $i == 0 ? 'btn-gray' : 'btn-primary' }}"
|
||||
@disabled($i == 0)>-</button>
|
||||
<button type="button" wire:click="addStep" class="diet__form-add btn btn-primary"
|
||||
data-bs-original-title="Добавить шаг">+</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endfor
|
||||
<div class="diet__form-row">
|
||||
<div class="label" data-tags="{{ json_encode($tags) }}">{{ __('recipe.tags') }}</div>
|
||||
<!--input type="text" name="link" class="input" placeholder="Введите теги через запятую"-->
|
||||
<livewire:tags-component key="tags-component" />
|
||||
<div class="label" data-tags="{{ json_encode($tags) }}">{{ __('recipe.tags') }}</div>
|
||||
<!--input type="text" name="link" class="input" placeholder="Введите теги через запятую"-->
|
||||
<livewire:tags-component key="tags-component" />
|
||||
</div>
|
||||
<div class="diet__form-row">
|
||||
<div class="label">{{ __('recipe.video_link') }}</div>
|
||||
<input type="text" name="link" wire:model="video_url" class="input" placeholder="Прикрепите ссылку на YouTube видео">
|
||||
<div class="label">{{ __('recipe.video_link') }}</div>
|
||||
<input type="text" name="link" wire:model="video_url" class="input"
|
||||
placeholder="Прикрепите ссылку на YouTube видео">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
{{-- <div class="container mb-4 py-3 overflow-hidden --bg_white --shadow --radius --mw-1000">
|
||||
@@ -259,7 +332,7 @@
|
||||
<div class="mb-4 fs-4_5 --reciept">
|
||||
<div class="tab-pane fade show active">
|
||||
@php $lastIngedient = count($ingredients) - 1; @endphp
|
||||
@foreach($ingredients as $k => $ingredient)
|
||||
@foreach ($ingredients as $k => $ingredient)
|
||||
<div class="d-flex align-items-top flex-wrap flex-sm-nowrap mb-4" data-row="{{ $k }}">
|
||||
<div class="w-100">
|
||||
<input type="text" wire:model="ingredients.{{$k}}.name" class="form-control fs-4_5 py-3 w-100" placeholder="Введите название продукта...." required="">
|
||||
@@ -303,9 +376,12 @@
|
||||
</div> --}}
|
||||
<div class="diet__container">
|
||||
<div class="diet__btns">
|
||||
<button wire:click="draft" class="diet__btn btn btn-gray" type="button">{{ __('recipe.to_drafts') }}</button>
|
||||
<button wire:click="preview" class="diet__btn btn btn-gray" type="button">{{ __('recipe.preview') }}</button>
|
||||
<button wire:click="publish" class="diet__btn btn btn-primary" type="submit">{{ __('recipe.publish') }}</button>
|
||||
<button wire:click="draft" class="diet__btn btn btn-gray"
|
||||
type="button">{{ __('recipe.to_drafts') }}</button>
|
||||
<button wire:click="preview" class="diet__btn btn btn-gray"
|
||||
type="button">{{ __('recipe.preview') }}</button>
|
||||
<button wire:click="publish" class="diet__btn btn btn-primary"
|
||||
type="submit">{{ __('recipe.publish') }}</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -315,4 +391,3 @@
|
||||
@endforeach
|
||||
</div>
|
||||
</section>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user