Merge pull request 'main' (#4) from eatvio/eatvio:main into main

Reviewed-on: apoloz/eatvio#4
This commit is contained in:
apoloz
2023-12-18 10:51:54 +00:00
12 changed files with 529 additions and 540 deletions

View File

@@ -13,14 +13,21 @@ class Create extends Component
public User $user;
public $body = '';
public $grade = 0;
public $isChecked = true;
public function render()
{
return view('livewire.diet.comment.create');
}
public function toggle()
{
$this->isChecked ? false : true;
}
public function save()
{
$this->toggle();
$comment = new DietComment();
$comment->grade = $this->grade;
$comment->body = $this->body;

View File

@@ -16,10 +16,18 @@ class Accordion extends Component
public function mount(Plan $plan): void
{
$this->plan = $plan;
$this->options1 = $plan->packet1_options;
$this->options2 = $plan->packet2_options;
$this->options3 = $plan->packet3_options;
// dd($this->unserializeOptions($plan->packet3_options));
$this->options1 = $this->unserializeOptions($plan->packet1_options);
$this->options2 = $this->unserializeOptions($plan->packet2_options);
$this->options3 = $this->unserializeOptions($plan->packet3_options);
}
private function unserializeOptions($str)
{
if (preg_match('/^".*"$/', $str)) {
return json_decode(mb_substr($str, 1, -1), true);
}
return json_decode($str, true);
}
public function render()

View File

@@ -2,28 +2,33 @@
namespace App\Livewire\Plan\Comment;
use Livewire\Component;
use App\Models\Plan;
use App\Models\PlanComment;
use App\Models\User;
use Livewire\Attributes\Validate;
use Livewire\Component;
class Create extends Component
{
public Plan $plan;
public User $user;
public $body = '';
public $grade = 0;
public $grade;
public $isChecked = false;
public function render()
{
return view('livewire.plan.comment.create');
}
public function toggle() {
$this->isChecked = !$this->isChecked;
}
public function save()
{
$this->validate([
'body' => 'required|min:10',
'body' => 'required|min:3',
'grade' => 'required',
]);
@@ -33,8 +38,10 @@ class Create extends Component
$comment->plan_id = $this->plan->id;
$comment->user_id = $this->user->id;
$comment->save();
$this->reset(['body']);
$this->toggle();
$this->reset(['body', 'grade']);
$this->dispatch('commentAdded')->to('plan.comment.show');
}
}

View File

@@ -31,6 +31,9 @@ class Create extends Component
public $input_items_2 = "";
public $input_items_3 = "";
public $isVisibleDuration = false;
public $isVisibleState = false;
protected function rules()
{
$rules = [
@@ -66,6 +69,29 @@ class Create extends Component
return view('livewire.plan.create');
}
public function showListDuration()
{
$this->isVisibleDuration = !$this->isVisibleDuration;
}
public function showListState()
{
$this->isVisibleState = !$this->isVisibleState;
}
public function toggleDuration($duration)
{
$this->duration = $duration;
$this->isVisibleDuration = false;
}
public function toggleState($state)
{
$this->state = $state;
$this->isVisibleState = false;
}
public function addPacketOption($options_type, $options_type_input)
{
$this->$options_type['short'] = $this->$options_type_input['short'];
@@ -74,6 +100,9 @@ class Create extends Component
$this->$options_type['items'][] = $this->input_items_1;
$this->$options_type['items'][] = $this->input_items_2;
$this->$options_type['items'][] = $this->input_items_3;
// delete empty value in items
$this->$options_type['items'] = array_filter($this->$options_type['items'], fn($item) => !empty($item));
$this->reset('input_items_1');
$this->reset('input_items_2');
$this->reset('input_items_3');
@@ -110,7 +139,7 @@ class Create extends Component
public function showPreview()
{
$this->state = "inactive";
$this->state = "unactive";
$this->publish();
}
}

View File

@@ -3,8 +3,9 @@
<button type="button" @class([
'settings__price-btn',
'_active' => $accordionState['options1'],
]) wire:click='toggleAccordionState("options1","options2", "options3")' data-spoller>
<strong>
])
wire:click='toggleAccordionState("options1","options2", "options3")' data-spoller>
<strong wire:model="options1">
{{ $options1['price'] ?? '0' }} ₽
</strong>
{{ $options1['short'] ?? '' }}
@@ -33,9 +34,10 @@
@if ($plan->packets_count == 3)
<div class="settings__price-item">
<button type="button" @class([
'settings__price-btn',
'_active' => $accordionState['options2'],
]) wire:click='toggleAccordionState("options2")' data-spoller>
'settings__price-btn',
'_active' => $accordionState['options2'],
]) wire:click='toggleAccordionState("options2")'
data-spoller>
<strong>
{{ $options2['price'] ?? '0' }} ₽
</strong>
@@ -65,9 +67,9 @@
<div class="settings__price-item">
<button type="button" @class([
'settings__price-btn',
'_active' => $accordionState['options3'],
]) wire:click='toggleAccordionState("options3")'
'settings__price-btn',
'_active' => $accordionState['options3'],
]) wire:click='toggleAccordionState("options3")'
data-spoller>
<strong>
{{ $options3['price'] ?? '0' }} ₽

View File

@@ -1,18 +1,45 @@
<div>
<form class="reviews__form">
<textarea wire:model="body" class="textarea textarea-white" placeholder="Введите отзыв"></textarea>
<div class="reviews__form-column">
<div class="reviews__form-rate star-rating">
<input wire:click="$set('grade', 5)" type="radio" name="rate" id="rate-5" value="5" class="star-rating__input hidden" hidden>
<input @class(['star-rating__input', 'hidden' => $isChecked]) wire:model="isChecked" wire:click="$set('grade', 5)" type="radio"
name="rate" id="rate-5" value="5" hidden>
<label class="star-rating__label" for="rate-5"></label>
<input wire:click="$set('grade',4)" type="radio" name="rate" id="rate-4" value="4" class="star-rating__input hidden" hidden>
<input @class(['star-rating__input', 'hidden' => $isChecked]) wire:model="isChecked" wire:click="$set('grade',4)" type="radio"
name="rate" id="rate-4" value="4" hidden>
<label class="star-rating__label" for="rate-4"></label>
<input wire:click="$set('grade',3)" type="radio" name="rate" id="rate-3" value="3" class="star-rating__input hidden" hidden>
<input @class(['star-rating__input', 'hidden' => $isChecked]) wire:model="isChecked" wire:click="$set('grade',3)" type="radio"
name="rate" id="rate-3" value="3" hidden>
<label class="star-rating__label" for="rate-3"></label>
<input wire:click="$set('grade',2)" type="radio" name="rate" id="rate-2" value="2" class="star-rating__input hidden" hidden>
<input @class(['star-rating__input', 'hidden' => $isChecked]) wire:model="isChecked" wire:click="$set('grade',2)" type="radio"
name="rate" id="rate-2" value="2" hidden>
<label class="star-rating__label" for="rate-2"></label>
<input wire:click="$set('grade',1)" type="radio" name="rate" id="rate-1" value="1" class="star-rating__input hidden" hidden>
<input @class(['star-rating__input', 'hidden' => $isChecked]) wire:model="isChecked" wire:click="$set('grade',1)" type="radio"
name="rate" id="rate-1" value="1" hidden>
<label class="star-rating__label" for="rate-1"></label>
</div>
<button wire:click.prevent="save" type="button" class="btn btn-primary">Оставь отзыв</button>
<button wire:click="save" type="button" class="btn btn-primary">Оставь отзыв</button>
</div>
</form>
@error('grade')
<div style="color:red;" role="alert">
<strong>{{ $message }}</strong>
</div>
@enderror
@error('body')
<div style="color:red;" role="alert">
<strong>{{ $message }}</strong>
</div>
@enderror
</div>

View File

@@ -23,7 +23,7 @@
'tabpanel',
'tabpanel--hidden' => $tabpanelState['negative']
]) role="tabpanel" id="tabpanel-1" tabindex="0" aria-labelledby="tab-1">
@foreach ($positivComments->get() as $comment)
@foreach ($positivComments->get() as $comment)
<div class="reviews__items">
<div class="review">
<div class="review__thumb">
@@ -44,7 +44,7 @@
<div class="review__rate icon-star">
{{ $comment->grade }}
</div>
{{-- @livewire('plan.comment.upvote', ['comment' => $comment]) --}}
<livewire:plan.comment.upvote :wire:key="$comment->id" :comment="$comment"></liviwire:plan.comment.upvote>
</div>
</div>
</div>
@@ -55,8 +55,8 @@
<div @class([
'tabpanel',
'tabpanel--hidden' => $tabpanelState['positive']
]) role="tabpanel" id="tabpanel-1" tabindex="0" aria-labelledby="tab-1">
@foreach ($negativeComments->get() as $comment)
]) role="tabpanel" id="tabpanel-2" tabindex="0" aria-labelledby="tab-1">
@foreach ($negativeComments->get() as $comment)
<div class="reviews__items">
<div class="review">
<div class="review__thumb">
@@ -77,7 +77,8 @@
<div class="review__rate icon-star">
{{ $comment->grade }}
</div>
{{-- @livewire('plan.comment.upvote', ['comment' => $comment]) --}}
<livewire:plan.comment.upvote :wire:key="$comment->id" :comment="$comment"></liviwire:plan.comment.upvote>
</div>
</div>
</div>

View File

@@ -1,4 +1,4 @@
<div class="d-flex align-items-center ms-3 ms-sm-0 mt-sm-4">
<div style="margin-left:20px;">
<button wire:click.stop.prevent="downvote" @class(["pt-1", 'text-red-400' => $isDownVoted])>
<svg width="20" height="18" @class(["me-1", "down-vote-filter" => $isDownVoted])><use xlink:href="#DislikeIcon"></use></svg>
</button>

View File

@@ -53,59 +53,44 @@
<div class="diet__form-column">
<div class="diet__form-row">
<div class="label">
Длительность плана питания
</div>
<div class="dropdown">
<!-- <button type="button" class="dropdown__button"> -->
<!-- 7 дней -->
<!-- </button> -->
<!-- <ul wire:model="duration" class="dropdown__list"> -->
<!-- <li data-value="7" class="dropdown__list-item active">7 дней</li> -->
<!-- <li data-value="8" class="dropdown__list-item">8 дней</li> -->
<!-- <li data-value="100 " class="dropdown__list-item">100 дней</li> -->
<!-- </ul> -->
<!-- <input type="text" name="action" class="dropdown__input hidden" hidden -->
<!-- value=""> -->
<div class="dropdown">
<div class="label">
Длительность плана питания
</div>
<!-- <label for="form-image">Длительность плана питания {{ $duration }}</label> -->
<select wire:model="duration" class="form-select my-3 ps-4 pe-5 py-3 --f_bold">
<option value="7" selected>7 дней</option>
<option value="8">8 дней</option>
<option value="100">100 дней</option>
</select>
</div>
<button @class(['dropdown__button', 'active' => $isVisibleDuration]) wire:click="showListDuration"
wire:model="duration" type="button">
{{ $duration }} дней
</button>
<ul @class(['dropdown__list', 'visible' => $isVisibleDuration])>
<li wire:click="toggleDuration('7')" @class(['dropdown__list-item', 'active' => $duration === '7'])
data-value="7">7 дней</li>
<li wire:click="toggleDuration('8')" @class(['dropdown__list-item', 'active' => $duration === '8'])
data-value="8">8 дней</li>
<li wire:click="toggleDuration('100')" @class(['dropdown__list-item', 'active' => $duration === '100'])
data-value="100 ">100 дней</li>
</ul>
<input type="text" name="action" class="dropdown__input hidden" hidden
value="">
</div>
</div>
<div class="diet__form-row">
<div class="diet__form-checkboxes">
<label class="checkbox-btn">
<input wire:model="type.slim"type="checkbox" name="slim"
class="checkbox-btn__input hidden" hidden>
<input wire:model="type.slim" type="checkbox" name="slim" class="checkbox-btn__input hidden" hidden>
<span class="checkbox-btn__content">
<input wire:model="type.slim" type="checkbox" class="btn-check"
name="dates" id="dates1" autocomplete="off">
<label class="btn --f_bold" for="dates1"><svg width="40"
height="40">
<use xlink:href="#SlimBig"></use>
</svg></label>
<!-- <img src="/img/slim.png" alt="icon slim"> -->
<svg width="40" height="60">
<use xlink:href="#SlimBig"></use>
</svg>
Slim
</span>
</label>
<label class="checkbox-btn">
<input wire:model="type.fit"type="checkbox" name="fit"
class="checkbox-btn__input hidden" hidden>
<input wire:model="type.fit" type="checkbox" name="fit" class="checkbox-btn__input hidden" hidden>
<span class="checkbox-btn__content">
<!-- <img src="/img/fit.png" alt="icon fit"> -->
<input wire:model="type.fit" type="checkbox" class="btn-check"
name="dates" id="dates2" autocomplete="off">
<label class="btn --f_bold" for="dates2"><svg width="40"
height="40">
<use xlink:href="#FitBig"></use>
</svg></label>
<svg width="40" height="60">
<use xlink:href="#FitBig"></use>
</svg>
Fit
</span>
</label>
@@ -119,53 +104,39 @@
Статус
</div>
<div class="dropdown">
<!-- <button type="button" class="dropdown__button"> -->
<!-- Активна -->
<!-- </button> -->
<!-- <ul wire:model="state" class="dropdown__list"> -->
<!-- <li data-value="active" class="dropdown__list-item active">Активна</li> -->
<!-- <li data-value="unactive" class="dropdown__list-item">Неактивна</li> -->
<!-- </ul> -->
<!-- <input type="text" name="status" class="dropdown__input hidden" hidden -->
<!-- value="unactive"> -->
<!-- <label for="form-image">Статус {{ $state }}</label> -->
<select wire:model="state" class="form-select my-3 ps-4 pe-5 py-3 --f_bold">
<option value="active" selected="">Активна</option>
<option value="inactive">Не активна</option>
<option value="draft">Черновик</option>
</select>
<button @class(['dropdown__button', 'active' => $isVisibleState]) wire:click="showListState" type="button">
{{ $state === 'active' ? 'Активна' : 'Неактивна'}}
</button>
<ul @class(['dropdown__list', 'visible' => $isVisibleState])>
<li wire:click="toggleState('active')" @class(['dropdown__list-item', 'active' => $state === 'active'])>
Активна</li>
<li wire:click="toggleState('unactive')" @class(['dropdown__list-item', 'active' => $state === 'unactive'])>Неактивна
</li>
</ul>
<input type="text" name="status" class="dropdown__input hidden" hidden
value="unactive">
</div>
</div>
<div class="diet__form-row">
<div class="diet__form-checkboxes">
<label class="checkbox-btn">
<input wire:model="type.wellness"type="checkbox" name="wellness"
<input wire:model="type.wellness" type="checkbox" name="wellness"
class="checkbox-btn__input hidden" hidden>
<span class="checkbox-btn__content">
<!-- <img src="/img/wellness.png" alt="icon wellness"> -->
<input wire:model="type.wellness" type="checkbox" class="btn-check"
name="status" id="status1" autocomplete="off">
<label class="btn --f_bold" for="status1"><svg width="40"
height="40">
<use xlink:href="#WellnessBig"></use>
</svg></label>
<svg width="40" height="60">
<use xlink:href="#WellnessBig"></use>
</svg>
Wellness
</span>
</label>
<label class="checkbox-btn">
<input wire:model="type.behavior" type="checkbox" name="behavior"
class="checkbox-btn__input hidden" hidden>
<input wire:model="type.behavior" type="checkbox" name="behavior" class="checkbox-btn__input hidden"
hidden>
<span class="checkbox-btn__content">
<!-- <img src="/img/behavior.png" alt="icon Behavior"> -->
<input wire:model="type.behavior" type="checkbox" class="btn-check"
name="status" id="status2" autocomplete="off">
<label class="btn --f_bold" for="status2"><svg width="40"
height="40">
<use xlink:href="#BehaviorBig"></use>
</svg></label>
<svg width="40" height="60">
<use xlink:href="#BehaviorBig"></use>
</svg>
Behavior
</span>
</label>
@@ -173,10 +144,10 @@
</div>
</div>
</div>
</div>
<div wire:ignore class="diet__form-row">
<div class="label">
Описание
@@ -206,260 +177,30 @@
});" wire:key="myIdentifierHere"
x-ref="myIdentifierHere" wire:model="details"></textarea>
<!-- x-ref="myIdentifierHere" wire:model="details"></textarea> -->
</div>
</div>
</div>
<div class="container px-0 mb-4 --mw-1000">
<div class="d-md-flex justify-content-between align-items-center">
<div class="h4 mb-3 mb-md-0 text-uppercase --f_grey">Оказание услуг</div>
<div class="d-flex align-items-center flex-wrap flex-lg-nowrap flex-column-reverse flex-lg-row">
<ul class="nav nav-pills flex-nowrap w-100 --bordered --radius --tabs_blue --bg_white" id="pills-tab" role="tablist">
<li class="nav-item" role="presentation">
<button wire:click="$set('packets_count', 1)" class="btn-lg nav-link px-0 px-md-5 py-3 --f_bold {{ $packets_count === 1 ? 'active' : '' }}" data-bs-toggle="pill" data-bs-target="#pills-0" type="button" role="tab" aria-controls="pills-0" aria-selected="false">1 Вариант</button>
</li>
<li class="nav-item" role="presentation">
<button wire:click="$set('packets_count', 3)" class="btn-lg nav-link px-0 px-md-5 py-3 --f_bold {{ $packets_count === 3 ? 'active' : ''}}" data-bs-toggle="pill" data-bs-target="#pills-1" type="button" role="tab" aria-controls="pills-1" aria-selected="true">3 Варианта</button>
</li>
</ul>
</div>
</div>
</div>
<div class="tab-content mb-4" id="pills-tabContent">
@if($packets_count === 1)
<div class="tab-pane fade active show" id="pills-0" role="tabpanel" aria-labelledby="pills-0-tab">
<div class="container mb-5 p-3 overflow-hidden --bg_white --shadow --radius --mw-1000">
<div class="row">
<div class="col-12 col-md-6 mb-3">
<label class="mb-3">Название</label>
<input wire:model="packet1_options_input.short" type="text" class="form-control fs-4_5 py-3 w-100" placeholder="Введите краткое описание варианта" required="">
</div>
<div class="col-12 col-md-6 mb-3">
<label class="mb-3">Цена</label>
<input wire:model="packet1_options_input.price" type="number" class="form-control fs-4_5 py-3 w-100" placeholder="Введите цену варианта" required="">
</div>
</div>
<div class="mb-3">
<label class="mb-3">Описание услуги:</label>
<textarea wire:model="packet1_options_input.description" type="text" class="form-control py-3 w-100" placeholder="Описание услуги" required=""></textarea>
</div>
<label class="mb-3">Содержание услуги:</label>
@isset($packet1_options['items'])
<ul class="mb-3">
@foreach($packet1_options['items'] as $item)
<li>
<td>{{ $item }}</td>
</li>
@endforeach
</ul>
@endisset
<div class="row">
<div class="col-12 col-md-10 mb-3">
<input wire:model="input_items" type="text" class="form-control py-3 w-100" placeholder="Содержание услуги" required="" />
</div>
<div class="col-12 col-md-2 mb-3">
<button wire:click="addPacketOption('packet1_options', 'packet1_options_input')" type="button" class="float-end btn btn-lg btn-primary btn-block px-5 fs-6 --f_bold">+</button>
</div>
</div>
</div>
@endif
@if($packets_count === 3)
<div class="tab-pane fade active show" id="pills-1" role="tabpanel" aria-labelledby="pills-1-tab">
<div class="container mb-5 p-3 overflow-hidden --bg_white --shadow --radius --mw-1000 --counter_variant">
<div class="row">
<div class="col-12 col-md-6 mb-3">
<label class="mb-3">Краткое описание</label>
<input wire:model="packet1_options_input.short" type="text" class="form-control fs-4_5 py-3 w-100" placeholder="Введите краткое описание варианта" required="">
</div>
<div class="col-12 col-md-6 mb-3">
<label class="mb-3">Цена</label>
<input wire:model="packet1_options_input.price" type="number" class="form-control fs-4_5 py-3 w-100" placeholder="Введите цену варианта" required="">
</div>
</div>
<div class="mb-3">
<label class="mb-3">Описание услуги:</label>
<textarea wire:model="packet1_options_input.description" type="text" class="form-control py-3 w-100" placeholder="Описание услуги" required=""></textarea>
</div>
<label class="mb-3">Содержание услуги:</label>
@isset($packet1_options['items'])
<ul class="mb-3">
@foreach($packet1_options['items'] as $item)
<li>
<td>{{ $item }}</td>
</li>
@endforeach
</ul>
@endisset
<div class="row">
<div class="col-12 col-md-10 mb-3">
<input type text wire:model="input_items" type="text" class="form-control py-3 w-100" placeholder="Содержание услуги" required=""></textarea>
</div>
<div class="col-12 col-md-2 mb-3">
<button wire:click="addPacketOption('packet1_options', 'packet1_options_input')" type="button" class="float-end btn btn-lg btn-primary btn-block px-5 fs-6 --f_bold">+</button>
</div>
</div>
</div>
<div class="container mb-5 p-3 overflow-hidden --bg_white --shadow --radius --mw-1000 --counter_variant">
<div class="row">
<div class="col-12 col-md-6 mb-3">
<label class="mb-3">Краткое описание</label>
<input wire:model="packet2_options_input.short" type="text" class="form-control fs-4_5 py-3 w-100" placeholder="Введите краткое описание варианта" required="">
</div>
<div class="col-12 col-md-6 mb-3">
<label class="mb-3">Цена</label>
<input wire:model="packet2_options_input.price" type="number" class="form-control fs-4_5 py-3 w-100" placeholder="Введите цену варианта" required="">
</div>
</div>
<div class="mb-3">
<label class="mb-3">Описание услуги:</label>
<textarea wire:model="packet2_options_input.description" type="text" class="form-control py-3 w-100" placeholder="Описание услуги" required=""></textarea>
</div>
<label class="mb-3">Содержание услуги:</label>
@isset($packet2_options['items'])
<ul class="mb-3">
@foreach($packet2_options['items'] as $item)
<li>
<td>{{ $item }}</td>
</li>
@endforeach
</ul>
@endisset
<div class="row">
<div class="col-12 col-md-10 mb-3">
<input type text wire:model="input_items" type="text" class="form-control py-3 w-100" placeholder="Содержание услуги" required=""></textarea>
</div>
<div class="col-12 col-md-2 mb-3">
<button wire:click="addPacketOption('packet2_options', 'packet2_options_input')" type="button" class="float-end btn btn-lg btn-primary btn-block px-5 fs-6 --f_bold">+</button>
</div>
</div>
</div>
<div class="container mb-5 p-3 overflow-hidden --bg_white --shadow --radius --mw-1000 --counter_variant">
<div class="row">
<div class="col-12 col-md-6 mb-3">
<label class="mb-3">Краткое описание</label>
<input wire:model="packet3_options_input.short" type="text" class="form-control fs-4_5 py-3 w-100" placeholder="Введите краткое описание варианта" required="">
</div>
<div class="col-12 col-md-6 mb-3">
<label class="mb-3">Цена</label>
<input wire:model="packet3_options_input.price" type="number" class="form-control fs-4_5 py-3 w-100" placeholder="Введите цену варианта" required="">
</div>
</div>
<div class="mb-3">
<label class="mb-3">Описание услуги:</label>
<textarea wire:model="packet3_options_input.description" type="text" class="form-control py-3 w-100" placeholder="Описание услуги" required=""></textarea>
</div>
<label class="mb-3">Содержание услуги:</label>
@isset($packet3_options['items'])
<ul class="mb-3">
@foreach($packet3_options['items'] as $item)
<li>
<td>{{ $item }}</td>
</li>
@endforeach
</ul>
@endisset
<div class="row">
<div class="col-12 col-md-10 mb-3">
<input type text wire:model="input_items" type="text" class="form-control py-3 w-100" placeholder="Содержание услуги" required=""></textarea>
</div>
<div class="col-12 col-md-2 mb-3">
<button wire:click="addPacketOption('packet3_options', 'packet3_options_input')" type="button" class="float-end btn btn-lg btn-primary btn-block px-5 fs-6 --f_bold">+</button>
</div>
</div>
</div>
</div>
</div>
<div class="diet__services">
<div class="diet__services-caption">
<div class="diet__services-title title">
ОКАЗАНИЕ УСЛУГ
</div>
<div class="diary__stats-tablist" role="tablist" aria-labelledby="label">
<button wire:click="$set('packets_count', 1)"
class="btn {{ $packets_count === 1 ? 'active' : '' }}" role="tab" type="button"
id="tab-1" aria-selected="{{ $packets_count === 1 ? 'true' : 'false' }}"
aria-controls="tabpanel-1">1 пакет</button>
<button wire:click="$set('packets_count', 3)"
class="btn {{ $packets_count === 3 ? 'active' : '' }}" role="tab" type="button"
id="tab-2" aria-selected="{{ $packets_count === 3 ? 'true' : 'false' }}"
aria-controls="tabpanel-2" tabindex="-1">3 пакета</button>
</div>
<div class="diet__services">
<div class="diet__services-caption">
<div class="diet__services-title title">
ОКАЗАНИЕ УСЛУГ
</div>
<div class="diary__stats-tablist" role="tablist" aria-labelledby="label">
<button wire:click="$set('packets_count', 1)"
class="btn {{ $packets_count === 1 ? 'active' : '' }}" role="tab" type="button"
id="tab-1" aria-selected="{{ $packets_count === 1 ? 'true' : 'false' }}"
aria-controls="tabpanel-1">1 пакет</button>
<button wire:click="$set('packets_count', 3)"
class="btn {{ $packets_count === 3 ? 'active' : '' }}" role="tab" type="button"
id="tab-2" aria-selected="{{ $packets_count === 3 ? 'true' : 'false' }}"
aria-controls="tabpanel-2" tabindex="-1">3 пакета</button>
</div>
@if ($packets_count === 1)
<div class="diet__services-body">
<div class="tabpanel" role="tabpanel" id="tabpanel-1" tabindex="0"
aria-labelledby="tab-1">
<div class="diet__services-form">
<div class="diet__services-row">
<div class="diet__services-column">
<div class="label">
Краткое описание
</div>
<input wire:model="packet1_options_input.short" type="text"
name="desc" class="input" placeholder="Введите краткое описание">
</div>
<div class="diet__services-column">
<div class="label">
Цена
</div>
<input wire:model="packet1_options_input.price" type="num"
name="price" class="input" placeholder="Введите цену варианта">
</div>
</div>
<div class="diet__services-row">
<div class="diet__services-column">
<div class="label">
Описание услуги:
</div>
<textarea wire:model="packet1_options_input.description" name="service" placeholder="Описание услуги"
class="textarea"></textarea>
</div>
</div>
<div class="diet__services-row">
<div class="diet__services-column">
<div class="label">
Содержание услуги
</div>
@isset($packet1_options['items'])
<ul class="mb-3">
@foreach ($packet1_options['items'] as $item)
<li>
<td>{{ $item }}</td>
</li>
@endforeach
</ul>
@endisset
<div class="row">
<div class="col-12 col-md-10 mb-3">
<input class="input" wire:model="input_items_1" type="text"
class="form-control py-3 w-100"
placeholder="Содержание услуги" required=""></input>
</div>
<div class="col-12 col-md-2 mb-3">
<button
wire:click="addPacketOption('packet1_options', 'packet1_options_input')"
type="button"
class="float-end btn btn-lg btn-primary btn-block px-5 fs-6 --f_bold">+</button>
</div>
</div>
</div>
</div>
</div>
</div>
@endif
</div>
@if ($packets_count === 3)
@if ($packets_count === 1)
<div class="diet__services-body">
<div class="tabpanel" role="tabpanel" id="tabpanel-1" tabindex="0"
aria-labelledby="tab-1">
@@ -500,7 +241,7 @@
Содержание услуги
</div>
@isset($packet1_options['items'])
<ul class="mb-3">
<ul>
@foreach ($packet1_options['items'] as $item)
<li>
<td>{{ $item }}</td>
@@ -508,166 +249,242 @@
@endforeach
</ul>
@endisset
<div class="row">
<div class="col-12 col-md-10 mb-3">
<input class="input" wire:model="input_items_1" type="text"
class="form-control py-3 w-100" placeholder="Содержание услуги"
required=""></input>
</div>
<div class="col-12 col-md-2 mb-3">
<button
wire:click="addPacketOption('packet1_options', 'packet1_options_input')"
type="button"
class="float-end btn btn-lg btn-primary btn-block px-5 fs-6 --f_bold">+</button>
</div>
<div class="diet__form-row">
<input wire:model="input_items_1" type="text" name="name"
class="input" placeholder="Содержание услуги" required="">
</div>
<button
wire:click="addPacketOption('packet1_options', 'packet1_options_input')"
type="button" class="btn btn-primary icon-plus"></button>
</div>
</div>
</div>
</div>
</div>
@endif
<div class="diet__services-body">
<div class="tabpanel" role="tabpanel" id="tabpanel-1" tabindex="0"
aria-labelledby="tab-1">
<div class="diet__services-form">
<div class="diet__services-row">
<div class="diet__services-column">
<div class="label">
Краткое описание
</div>
<input wire:model="packet2_options_input.short" type="text"
name="desc" class="input" placeholder="Введите краткое описание">
</div>
<div class="diet__services-column">
<div class="label">
Цена
<span>
2 вариант
</span>
</div>
<input wire:model="packet2_options_input.price" type="num"
name="price" class="input" placeholder="Введите цену варианта">
@if ($packets_count === 3)
<div class="diet__services-body">
<div class="tabpanel" role="tabpanel" id="tabpanel-1" tabindex="0"
aria-labelledby="tab-1">
<div class="diet__services-form">
<div class="diet__services-row">
<div class="diet__services-column">
<div class="label">
Краткое описание
</div>
<input wire:model="packet1_options_input.short" type="text" name="desc"
class="input" placeholder="Введите краткое описание">
</div>
<div class="diet__services-row">
<div class="diet__services-column">
<div class="label">
Описание услуги:
</div>
<textarea wire:model="packet2_options_input.description" name="service" placeholder="Описание услуги"
class="textarea"></textarea>
<div class="diet__services-column">
<div class="label">
Цена
<span>
1 вариант
</span>
</div>
<input wire:model="packet1_options_input.price" type="num" name="price"
class="input" placeholder="Введите цену варианта">
</div>
<div class="diet__services-row">
<div class="diet__services-column">
<div class="label">
Содержание услуги
</div>
@isset($packet2_options['items'])
<ul class="mb-3">
@foreach ($packet2_options['items'] as $item)
<li>
<td>{{ $item }}</td>
</li>
@endforeach
</ul>
@endisset
<div class="row">
<div class="col-12 col-md-10 mb-3">
<input class="input" wire:model="input_items_2" type="text"
class="form-control py-3 w-100"
placeholder="Содержание услуги" required=""></input>
</div>
<div class="col-12 col-md-2 mb-3">
<button
wire:click="addPacketOption('packet2_options', 'packet2_options_input')"
type="button"
class="float-end btn btn-lg btn-primary btn-block px-5 fs-6 --f_bold">+</button>
</div>
</div>
</div>
<div class="diet__services-row">
<div class="diet__services-column">
<div class="label">
Описание услуги:
</div>
<textarea wire:model="packet1_options_input.description" name="service" placeholder="Описание услуги"
class="textarea"></textarea>
</div>
</div>
<div class="diet__services-row">
<div class="diet__services-column">
<div class="label">
Содержание услуги
</div>
@isset($packet1_options['items'])
<ul>
@foreach ($packet1_options['items'] as $item)
<li>
<td>{{ $item }}</td>
</li>
@endforeach
</ul>
@endisset
<div class="diet__form-row">
<input wire:model="input_items_1" type="text" name="name"
class="input" placeholder="Содержание услуги" required="">
</div>
<button
wire:click="addPacketOption('packet1_options', 'packet1_options_input')"
type="button" class="btn btn-primary icon-plus"></button>
</div>
</div>
</div>
</div>
</div>
<div class="diet__services-body">
<div class="tabpanel" role="tabpanel" id="tabpanel-1" tabindex="0"
aria-labelledby="tab-1">
<div class="diet__services-form">
<div class="diet__services-row">
<div class="diet__services-column">
<div class="label">
Краткое описание
</div>
<input wire:model="packet2_options_input.short" type="text" name="desc"
class="input" placeholder="Введите краткое описание">
</div>
<div class="diet__services-column">
<div class="label">
Цена
<span>
2 вариант
</span>
</div>
<input wire:model="packet2_options_input.price" type="num" name="price"
class="input" placeholder="Введите цену варианта">
</div>
</div>
<div class="diet__services-row">
<div class="diet__services-column">
<div class="label">
Описание услуги:
</div>
<textarea wire:model="packet2_options_input.description" name="service" placeholder="Описание услуги"
class="textarea"></textarea>
</div>
</div>
<div class="diet__services-row">
<div class="diet__services-column">
<div class="label">
Содержание услуги
</div>
@isset($packet2_options['items'])
<ul>
@foreach ($packet2_options['items'] as $item)
<li>
<td>{{ $item }}</td>
</li>
@endforeach
</ul>
@endisset
<div class="diet__form-row">
<input wire:model="input_items_2" type="text" name="name"
class="input" placeholder="Содержание услуги" required="">
</div>
<button
wire:click="addPacketOption('packet2_options', 'packet2_options_input')"
type="button" class="btn btn-primary icon-plus"></button>
</div>
</div>
</div>
</div>
</div>
<div class="diet__services-body">
<div class="tabpanel" role="tabpanel" id="tabpanel-1" tabindex="0"
aria-labelledby="tab-1">
<div class="diet__services-form">
<div class="diet__services-row">
<div class="diet__services-column">
<div class="label">
Краткое описание
</div>
<input wire:model="packet3_options_input.short" type="text" name="desc"
class="input" placeholder="Введите краткое описание">
</div>
<div class="diet__services-column">
<div class="label">
Цена
<span>
3 вариант
</span>
</div>
<input wire:model="packet3_options_input.price" type="num" name="price"
class="input" placeholder="Введите цену варианта">
</div>
</div>
<div class="diet__services-row">
<div class="diet__services-column">
<div class="label">
Описание услуги:
</div>
<textarea wire:model="packet3_options_input.description" name="service" placeholder="Описание услуги"
class="textarea"></textarea>
</div>
</div>
<div class="diet__services-row">
<div class="diet__services-column">
<div class="label">
Содержание услуги
</div>
@isset($packet3_options['items'])
<ul class="mb-3">
@foreach ($packet3_options['items'] as $item)
<li>
<td>{{ $item }}</td>
</li>
@endforeach
</ul>
@endisset
<div class="diet__form-row">
<input wire:model="input_items_3" type="text" name="name"
class="input" placeholder="Содержание услуги" required="">
</div>
<button
wire:click="addPacketOption('packet3_options', 'packet3_options_input')"
type="button" class="btn btn-primary icon-plus"></button>
</div>
</div>
</div>
</div>
</div>
<div class="diet__services-body">
<div class="tabpanel" role="tabpanel" id="tabpanel-1" tabindex="0"
aria-labelledby="tab-1">
<div class="diet__services-form">
<div class="diet__services-row">
<div class="diet__services-column">
<div class="label">
Краткое описание
</div>
<input wire:model="packet3_options_input.short" type="text"
name="desc" class="input"
placeholder="Введите краткое описание">
</div>
<div class="diet__services-column">
<div class="label">
Цена
<span>
3 вариант
</span>
</div>
<input wire:model="packet3_options_input.price" type="num"
name="price" class="input"
placeholder="Введите цену варианта">
</div>
</div>
<div class="diet__services-row">
<div class="diet__services-column">
<div class="label">
Описание услуги:
</div>
<textarea wire:model="packet3_options_input.description" name="service" placeholder="Описание услуги"
class="textarea"></textarea>
</div>
</div>
<div class="diet__services-row">
<div class="diet__services-column">
<div class="label">
Содержание услуги
</div>
@isset($packet3_options['items'])
<ul class="mb-3">
@foreach ($packet3_options['items'] as $item)
<li>
<td>{{ $item }}</td>
</li>
@endforeach
</ul>
@endisset
<div class="row">
<div class="col-12 col-md-10 mb-3">
<input class="input" wire:model="input_items_3"
type="text" class="form-control py-3 w-100"
placeholder="Содержание услуги" required=""></input>
</div>
<div class="col-12 col-md-2 mb-3">
<button
wire:click="addPacketOption('packet3_options', 'packet3_options_input')"
type="button"
class="float-end btn btn-lg btn-primary btn-block px-5 fs-6 --f_bold">+</button>
</div>
</div>
</div>
</div>
</div>
</div>
@endif
@if ($errors)
<div class="">
<ul>
@@ -687,7 +504,6 @@
class="diet__btn btn btn-primary">Опубликовать</button>
</div>
</div>
@endif
</section>
</div>

View File

@@ -28,7 +28,7 @@
</a>
</div>
<a href="" class="settings__person-thumb">
<img src="{{ $authorPhoto }}" alt="thumb">
<img src="{{ $author->profile_photo_url }}" alt="thumb">
</a>
</div>
<a href="" class="settings__action btn btn-md btn-primary icon-message-square">
@@ -86,8 +86,6 @@
{{ $plan->details }}
</p>
{{-- @livewire('plan.like', ['plan' => $plan]) --}}
<div class="announcement__footer">
<button type="button"
class="announcement__footer-action icon-message-square">Комментировать</button>
@@ -96,7 +94,6 @@
</div>
</div>
</div>
@livewire('plan.accordion', ['plan' => $plan])
</div>
@@ -119,8 +116,8 @@
</section>
@endsection
@push('jq_scripts')
{{-- @push('jq_scripts') --}}
{{-- <script src="js/app.min.js"></script> --}}
<script src="/js/bootstrap.min.js"></script>
<script src="/js/bootstrap.bundle.min.js"></script>
@endpush
{{-- <script src="/js/bootstrap.min.js"></script> --}}
{{-- <script src="/js/bootstrap.bundle.min.js"></script> --}}
{{-- @endpush --}}

View File

@@ -1,29 +1,29 @@
<?php
namespace Tests\Feature\Plan;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\Storage;
// use Livewire\WithFileUploads;
use Livewire\Livewire;
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
use Illuminate\Foundation\Testing\RefreshDatabase;
// use Illuminate\Foundation\Testing\DatabaseTransactions;
use App\Livewire\Plan\Create;
use App\Models\Plan;
use App\Models\User;
use App\Livewire\Plan\Create;
use App\Providers\RouteServiceProvider;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
use Livewire\Livewire;
use Tests\TestCase;
class CreateTest extends TestCase
{
// use RefreshDatabase;
use RefreshDatabase;
private $image;
private $plan;
protected User $user;
public function setUp():void
public function setUp(): void
{
parent::setUp();
@@ -32,81 +32,92 @@ class CreateTest extends TestCase
$this->user = User::factory()->create(['is_consultant' => true]);
$this->plan = Plan::factory()->make();
}
public function test_show_form_create_plan()
{
$response = $this->actingAs($this->user)
$response = $this
->actingAs($this->user)
->get('/plan/create');
$response
->assertStatus(302)
->assertRedirect('https://dev2.eatvio.com/ru');
->assertStatus(302);
// ->assertRedirect(route('home'));
}
public function test_publish_new_plan_success(): void
{
$countPlanBeforeCreated = $this->plan->count();
$this->actingAs($this->user);
// $this->assertEquals($this->plan->count(), $count = Plan::count());
Livewire::test(Create::class)
->set('name', $this->plan->name)
->assertSet('name', $this->plan->name)
->set('image', $this->image)
->set('duration', $this->plan->duration)
->assertSet('duration', $this->plan->duration)
->set('state', $this->plan->state)
->assertSet('state', $this->plan->state)
->set('type', $this->plan->type)
->assertSet('type', $this->plan->type)
->set('details', $this->plan->details)
->assertSet('details', $this->plan->details)
->set('packets_count', $this->plan->packets_count)
->assertSet('packets_count', $this->plan->packets_count)
->set('packet1_options', $this->plan->packet1_options)
->assertSet('packet1_options', $this->plan->packet1_options)
->set('packet2_options', $this->plan->packet2_options)
->assertSet('packet2_options', $this->plan->packet2_options)
->set('packet3_options', $this->plan->packet3_options)
->assertSet('packet3_options', $this->plan->packet3_options)
->call('publish')
// ->assertFileDownloaded('plan.png');
->assertStatus(200)
->assertRedirect('plan/'.$this->plan->count());
->assertHasNoErrors(['name', 'image', 'duration', 'details']);
$countPlanAfterCreated = $this->plan->count();
Storage::disk('public')->assertExists($this->plan->image);
$this->assertEquals($countPlanBeforeCreated + 1, $countPlanAfterCreated);
// $this->assertEquals($count + 1, Plan::count());
}
//
public function test_to_draft_new_plan_success(): void
{
$countPlanBeforeCreated = $this->plan->count();
$this->actingAs($this->user);
$id = $this->plan->count();
Livewire::test(Create::class)
->set('name', $this->plan->name)
->assertSet('name', $this->plan->name)
->set('image', $this->image)
->set('duration', $this->plan->duration)
->assertSet('duration', $this->plan->duration)
->set('state', $this->plan->state)
->assertSet('state', $this->plan->state)
->set('type', $this->plan->type)
->assertSet('type', $this->plan->type)
->set('details', $this->plan->details)
->assertSet('details', $this->plan->details)
->set('packets_count', $this->plan->packets_count)
->assertSet('packets_count', $this->plan->packets_count)
->set('packet1_options', $this->plan->packet1_options)
->assertSet('packet1_options', $this->plan->packet1_options)
->set('packet2_options', $this->plan->packet2_options)
->assertSet('packet2_options', $this->plan->packet2_options)
->set('packet3_options', $this->plan->packet3_options)
->assertSet('packet3_options', $this->plan->packet3_options)
->call('addToDrafts')
// ->assertFileDownloaded('plan.png');
->assertStatus(200)
->assertRedirect('plan/'.$this->plan->count());
->assertRedirect('plan/' . $id + 1)
->assertHasNoErrors(['name', 'image', 'duration', 'details']);
$countPlanAfterCreated = $this->plan->count();
$this->assertEquals($countPlanBeforeCreated + 1, $countPlanAfterCreated);
Storage::disk('public')->assertExists($this->plan->image);
}
//
public function test_to_preview_new_plan_success(): void
{
$countPlanBeforeCreated = $this->plan->count();
$this->actingAs($this->user);
Livewire::test(Create::class)
@@ -114,21 +125,44 @@ class CreateTest extends TestCase
->assertSet('name', $this->plan->name)
->set('image', $this->image)
->set('duration', $this->plan->duration)
->assertSet('duration', $this->plan->duration)
->set('state', $this->plan->state)
->assertSet('state', $this->plan->state)
->set('type', $this->plan->type)
->assertSet('type', $this->plan->type)
->set('details', $this->plan->details)
->assertSet('details', $this->plan->details)
->set('packets_count', $this->plan->packets_count)
->assertSet('packets_count', $this->plan->packets_count)
->set('packet1_options', $this->plan->packet1_options)
->assertSet('packet1_options', $this->plan->packet1_options)
->set('packet2_options', $this->plan->packet2_options)
->assertSet('packet2_options', $this->plan->packet2_options)
->set('packet3_options', $this->plan->packet3_options)
->assertSet('packet3_options', $this->plan->packet3_options)
->call('showPreview')
// ->assertFileDownloaded('plan.png');
->assertStatus(200)
->assertRedirect('plan/'.$this->plan->count());
->assertHasNoErrors(['name', 'image', 'duration', 'details']);
$countPlanAfterCreated = $this->plan->count();
$this->assertEquals($countPlanBeforeCreated + 1, $countPlanAfterCreated);
Storage::disk('public')->assertExists($this->plan->image);
}
public function test_set_empty_data(): void
{
$this->actingAs($this->user);
Livewire::test(Create::class)
->set('name', null)
->set('image', null)
->set('duration', null)
->set('state', null)
->set('type', null)
->set('details', null)
->set('packets_count', null)
->set('packet1_options', null)
->set('packet2_options', null)
->set('packet3_options', null)
->call('publish')
->assertHasErrors(['name', 'image', 'duration', 'details']);
}
}

View File

@@ -0,0 +1,61 @@
<?php
namespace Tests\Feature\Plan;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\Storage;
// use Livewire\WithFileUploads;
use Livewire\Livewire;
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
use Illuminate\Foundation\Testing\RefreshDatabase;
// use Illuminate\Foundation\Testing\DatabaseTransactions;
use App\Models\Plan;
use App\Models\User;
use App\Livewire\Plan\Create;
use Tests\TestCase;
class ShowTest extends TestCase
{
// use RefreshDatabase;
use RefreshDatabase;
private $image;
private $plan;
protected User $user;
public function setUp():void
{
parent::setUp();
Storage::fake('plans');
$this->image = UploadedFile::fake()->image('plan.png');
$this->user = User::factory()->create(['is_consultant' => true]);
$this->plan = Plan::factory()->create();
}
public function test_show_form_success()
{
$response = $this->actingAs($this->user)
->get('/plan/'. $this->plan->id);
$response
->assertStatus(302);
// ->assertRedirect(route('home'));
// ->assertRedirect('https://dev2.eatvio.com/ru');
}
// When appear role for user
// public function test_show_form_is_not_consultant()
// {
// $user = User::factory()->create(['is_consultant' => false]);
// $response = $this->actingAs($this->user)
// ->get('/plan/'. $this->plan->id);
// $response
// ->assertStatus(403);
// }
}