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

Reviewed-on: eatvio/eatvio#3
Reviewed-by: apoloz <anatoliy.poloz@gmail.com>
This commit is contained in:
apoloz
2023-12-11 09:43:21 +00:00
18 changed files with 1056 additions and 369 deletions

View File

@@ -62,9 +62,13 @@ class PlanController extends Controller
->cooldown($expiresAt)
->record();
$options1 = $this->unserializeOptions($plan->packet1_options);
$options2 = $this->unserializeOptions($plan->packet2_options);
$options3 = $this->unserializeOptions($plan->packet2_options);
// $options1 = $this->unserializeOptions($plan->packet1_options);
// $options2 = $this->unserializeOptions($plan->packet2_options);
// $options3 = $this->unserializeOptions($plan->packet2_options);
$options1 = $plan->packet1_options;
$options2 = $plan->packet2_options;
$options3 = $plan->packet2_options;
return view('plan/show',
[
'plan' => $plan,

View File

@@ -27,7 +27,9 @@ class Create extends Component
public $packet2_options_input = [];
public $packet3_options_input = [];
public $input_items = "";
public $input_items_1 = "";
public $input_items_2 = "";
public $input_items_3 = "";
protected function rules()
{
@@ -69,41 +71,46 @@ class Create extends Component
$this->$options_type['short'] = $this->$options_type_input['short'];
$this->$options_type['price'] = $this->$options_type_input['price'];
$this->$options_type['description'] = $this->$options_type_input['description'];
$this->$options_type['items'][] = $this->input_items;
$this->reset('input_items');
$this->$options_type['items'][] = $this->input_items_1;
$this->$options_type['items'][] = $this->input_items_2;
$this->$options_type['items'][] = $this->input_items_3;
$this->reset('input_items_1');
$this->reset('input_items_2');
$this->reset('input_items_3');
}
public function publish()
{
/* dd($this->type); */
$this->validate();
$plan = new Plan();
$plan->name = $this->name;
$plan->image = $this->image->store('plans', 'public');
$plan->duration = $this->duration;
$plan->state = $this->state;
$plan->type = json_encode($this->type);
$plan->details = $this->details;
$plan->packets_count = $this->packets_count;
$plan->type = json_encode($this->type);
$plan->packet1_options = json_encode($this->packet1_options);
$plan->packet2_options = json_encode($this->packet2_options);
$plan->packet3_options = json_encode($this->packet3_options);
$plan->save();
$plan->saveOrFail();
$user = Auth::user();
$user->author_of_plans()->attach($plan->id);
return redirect()->route('plan.show', $plan->id);
}
public function addToDrafts()
{
$this->type = "draft";
$this->state = "draft";
$this->publish();
}
public function showPreview()
{
$this->type = "inactive";
$this->state = "inactive";
$this->publish();
}
}

View File

@@ -1,24 +1,40 @@
<?php
namespace App\Models;
use Laracasts\Presenter\PresentableTrait;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Model;
use App\Models\PlanLike;
use App\Presenters\PlanPresenter;
use Illuminate\Database\Eloquent\Casts\Attribute;
use CyrildeWit\EloquentViewable\InteractsWithViews;
use CyrildeWit\EloquentViewable\Contracts\Viewable;
class Plan extends Model implements Viewable
{
use HasFactory, InteractsWithViews;
use HasFactory;
use InteractsWithViews;
use PresentableTrait;
protected $withCount = [
'likes',
'comments'
];
protected $casts = [
'type' => 'array',
'packet1_options' => 'array',
'packet2_options' => 'array',
'packet3_options' => 'array',
];
protected $presenter = PlanPresenter::class;
public function author()
{
return $this->belongsToMany(User::class, 'plan_author', 'plan_id', 'user_id');
@@ -48,7 +64,9 @@ class Plan extends Model implements Viewable
$result = [];
for ($i = 1; $i <= $this->packets_count; $i++) {
$key = "packet" . $i . "_options";
$data = $this->unserializeOptionsObj($this->$key);
// $data = $this->unserializeOptionsObj($this->$key);
$data = $this->$key;
if (!is_null($data)) {
$result = array_merge($result, data_get($data, "items", []));
}
@@ -59,10 +77,11 @@ class Plan extends Model implements Viewable
public function types(): Attribute
{
$data = $this->unserializeOptionsArr($this->type);
// $data = $this->unserializeOptionsArr($this->type);
$data = $this->type;
return new Attribute(
get: fn() => array_keys($data),
get: fn () => array_keys($data),
);
}
@@ -71,7 +90,9 @@ class Plan extends Model implements Viewable
$result = 0;
for ($i = 1; $i <= $this->packets_count; $i++) {
$key = "packet" . $i . "_options";
$data = $this->unserializeOptionsObj($this->$key);
// dd($this->$key);
// $data = $this->unserializeOptionsObj($this->$key);
$data = $this->$key;
if (!is_null($data)) {
$curPrice = (int)data_get($data, "price", 0);
$result = $curPrice > $result ? $curPrice : $result ;
@@ -79,7 +100,7 @@ class Plan extends Model implements Viewable
}
return new Attribute(
get: fn() => $result,
get: fn () => $result,
);
}

View File

@@ -0,0 +1,22 @@
<?php
namespace App\Presenters;
use Illuminate\Support\Facades\Storage;
use App\Models\Plan;
use Laracasts\Presenter\Presenter;
class PlanPresenter extends Presenter
{
public function getAuthorPhoto()
{
$author = $this->getAuthor();
return Storage::url($author->profile_photo_path);
}
public function getAuthor()
{
return $this->author->first();
}
}

View File

@@ -12,6 +12,8 @@
"doctrine/dbal": "^3.0",
"guzzlehttp/guzzle": "^7.2",
"iben12/laravel-statable": "^1.5",
"jzonta/faker-restaurant": "^2.0",
"laracasts/presenter": "^0.2.6",
"laravel/framework": "^10.0",
"laravel/jetstream": "^4.0",
"laravel/sanctum": "^3.2",
@@ -59,7 +61,9 @@
],
"post-create-project-cmd": [
"@php artisan key:generate --ansi"
]
],
"php-cs-fixer": "php-cs-fixer --config=.php-cs-fixer.php --allow-risky=yes",
"test": "phpunit --colors=always"
},
"extra": {
"laravel": {

234
composer.lock generated
View File

@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "34d1a8c89daa6bffe88d41428ab1f92e",
"content-hash": "2e254ae7b37d7841970bf3a2a4f56d80",
"packages": [
{
"name": "asantibanez/livewire-charts",
@@ -1170,6 +1170,74 @@
],
"time": "2023-01-14T14:17:03+00:00"
},
{
"name": "fakerphp/faker",
"version": "v1.23.0",
"source": {
"type": "git",
"url": "https://github.com/FakerPHP/Faker.git",
"reference": "e3daa170d00fde61ea7719ef47bb09bb8f1d9b01"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/FakerPHP/Faker/zipball/e3daa170d00fde61ea7719ef47bb09bb8f1d9b01",
"reference": "e3daa170d00fde61ea7719ef47bb09bb8f1d9b01",
"shasum": ""
},
"require": {
"php": "^7.4 || ^8.0",
"psr/container": "^1.0 || ^2.0",
"symfony/deprecation-contracts": "^2.2 || ^3.0"
},
"conflict": {
"fzaninotto/faker": "*"
},
"require-dev": {
"bamarni/composer-bin-plugin": "^1.4.1",
"doctrine/persistence": "^1.3 || ^2.0",
"ext-intl": "*",
"phpunit/phpunit": "^9.5.26",
"symfony/phpunit-bridge": "^5.4.16"
},
"suggest": {
"doctrine/orm": "Required to use Faker\\ORM\\Doctrine",
"ext-curl": "Required by Faker\\Provider\\Image to download images.",
"ext-dom": "Required by Faker\\Provider\\HtmlLorem for generating random HTML.",
"ext-iconv": "Required by Faker\\Provider\\ru_RU\\Text::realText() for generating real Russian text.",
"ext-mbstring": "Required for multibyte Unicode string functionality."
},
"type": "library",
"extra": {
"branch-alias": {
"dev-main": "v1.21-dev"
}
},
"autoload": {
"psr-4": {
"Faker\\": "src/Faker/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "François Zaninotto"
}
],
"description": "Faker is a PHP library that generates fake data for you.",
"keywords": [
"data",
"faker",
"fixtures"
],
"support": {
"issues": "https://github.com/FakerPHP/Faker/issues",
"source": "https://github.com/FakerPHP/Faker/tree/v1.23.0"
},
"time": "2023-06-12T08:44:38+00:00"
},
{
"name": "fruitcake/php-cors",
"version": "v1.2.0",
@@ -2022,6 +2090,102 @@
],
"time": "2020-06-13T08:05:20+00:00"
},
{
"name": "jzonta/faker-restaurant",
"version": "2.0.1",
"source": {
"type": "git",
"url": "https://github.com/jzonta/FakerRestaurant.git",
"reference": "4e10ff08dc8ca08603a3daf7abe48d412b013cf4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/jzonta/FakerRestaurant/zipball/4e10ff08dc8ca08603a3daf7abe48d412b013cf4",
"reference": "4e10ff08dc8ca08603a3daf7abe48d412b013cf4",
"shasum": ""
},
"require": {
"fakerphp/faker": "^1.9.1",
"php": ">=7.1"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.17",
"phpstan/phpstan": "^0.12.66",
"phpunit/phpunit": "^9"
},
"type": "library",
"autoload": {
"psr-4": {
"FakerRestaurant\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "João Zonta"
}
],
"description": "Food and Beverage names generate using fakerphp/faker",
"homepage": "https://github.com/jzonta/FakerRestaurant",
"support": {
"issues": "https://github.com/jzonta/FakerRestaurant/issues",
"source": "https://github.com/jzonta/FakerRestaurant/tree/v2.0.1"
},
"time": "2021-11-15T11:21:22+00:00"
},
{
"name": "laracasts/presenter",
"version": "0.2.6",
"source": {
"type": "git",
"url": "https://github.com/laracasts/Presenter.git",
"reference": "4353fb5a1a3b9b9073db66fd823eaaf04c0c5db0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laracasts/Presenter/zipball/4353fb5a1a3b9b9073db66fd823eaaf04c0c5db0",
"reference": "4353fb5a1a3b9b9073db66fd823eaaf04c0c5db0",
"shasum": ""
},
"require": {
"illuminate/support": "~5.0|~6.0|~7.0|~8.0|^9.0|^10.0",
"php": ">=5.4.0"
},
"require-dev": {
"mockery/mockery": "~0.9",
"phpspec/phpspec": "~2.0"
},
"type": "library",
"autoload": {
"psr-0": {
"Laracasts\\Presenter": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Jeffrey Way",
"email": "jeffrey@laracasts.com"
}
],
"description": "Simple view presenters",
"keywords": [
"laravel",
"presenter",
"view"
],
"support": {
"issues": "https://github.com/laracasts/Presenter/issues",
"source": "https://github.com/laracasts/Presenter/tree/0.2.6"
},
"time": "2023-02-21T16:06:10+00:00"
},
{
"name": "laravel/fortify",
"version": "v1.17.5",
@@ -9324,74 +9488,6 @@
}
],
"packages-dev": [
{
"name": "fakerphp/faker",
"version": "v1.23.0",
"source": {
"type": "git",
"url": "https://github.com/FakerPHP/Faker.git",
"reference": "e3daa170d00fde61ea7719ef47bb09bb8f1d9b01"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/FakerPHP/Faker/zipball/e3daa170d00fde61ea7719ef47bb09bb8f1d9b01",
"reference": "e3daa170d00fde61ea7719ef47bb09bb8f1d9b01",
"shasum": ""
},
"require": {
"php": "^7.4 || ^8.0",
"psr/container": "^1.0 || ^2.0",
"symfony/deprecation-contracts": "^2.2 || ^3.0"
},
"conflict": {
"fzaninotto/faker": "*"
},
"require-dev": {
"bamarni/composer-bin-plugin": "^1.4.1",
"doctrine/persistence": "^1.3 || ^2.0",
"ext-intl": "*",
"phpunit/phpunit": "^9.5.26",
"symfony/phpunit-bridge": "^5.4.16"
},
"suggest": {
"doctrine/orm": "Required to use Faker\\ORM\\Doctrine",
"ext-curl": "Required by Faker\\Provider\\Image to download images.",
"ext-dom": "Required by Faker\\Provider\\HtmlLorem for generating random HTML.",
"ext-iconv": "Required by Faker\\Provider\\ru_RU\\Text::realText() for generating real Russian text.",
"ext-mbstring": "Required for multibyte Unicode string functionality."
},
"type": "library",
"extra": {
"branch-alias": {
"dev-main": "v1.21-dev"
}
},
"autoload": {
"psr-4": {
"Faker\\": "src/Faker/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "François Zaninotto"
}
],
"description": "Faker is a PHP library that generates fake data for you.",
"keywords": [
"data",
"faker",
"fixtures"
],
"support": {
"issues": "https://github.com/FakerPHP/Faker/issues",
"source": "https://github.com/FakerPHP/Faker/tree/v1.23.0"
},
"time": "2023-06-12T08:44:38+00:00"
},
{
"name": "filp/whoops",
"version": "2.15.3",

View File

@@ -0,0 +1,58 @@
<?php
namespace Database\Factories;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\Storage;
use FakerRestaurant\Provider\en_US\Restaurant;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Plan>
*/
class PlanFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
$faker = \Faker\Factory::create();
$this->faker->addProvider(new Restaurant($faker));
$typeBody = [
'fit' => $this->faker->boolean(),
'slim' => $this->faker->boolean(),
'behavior' => $this->faker->boolean(),
'wellness' => $this->faker->boolean(),
];
$packetsOptions = [
'items' => [$this->faker->fruitName(), $this->faker->meatName(), $this->faker->sauceName()],
'price' => $this->faker->randomNumber(),
'short' => $this->faker->foodName(),
'description' => $this->faker->text(),
];
Storage::fake('plans');
$file = UploadedFile::fake()->image('plan.png');
$fileLocalPath = $file->store('plans', 'public');
return [
'name' => $this->faker->foodName(),
// 'image' => UploadedFile::fake()->image('plans/Photo_C.png'),
'image' => $fileLocalPath,
'duration' => $this->faker->randomElement([7, 14,21]),
'state' => $this->faker->randomElement(['active', 'draft', 'archived']),
'type' => $typeBody,
'details' => $this->faker->text(),
'packets_count' => $this->faker->randomElement([1, 3]),
'packet1_options' => $packetsOptions,
'packet2_options' => $packetsOptions,
'packet3_options' => $packetsOptions,
];
}
}

View File

@@ -21,7 +21,7 @@ class UserDetailzFactory extends Factory
public function definition()
{
return [
'user_id' => User::factory(),
// 'user_id' => User::factory(),
'first_name' => $this->faker->name(),
'last_name' => $this->faker->name(),
'birthdate' => $this->faker->date('Y-m-d'),
@@ -43,6 +43,8 @@ class UserDetailzFactory extends Factory
'favorite_foods' => $this->faker->text(),
'unfavorite_foods' => $this->faker->text(),
'additional_info' => $this->faker->text(),
'is_mood_fillable' => $this->faker->boolean(),
'is_bedtime_fillable' => $this->faker->boolean(),
];
}
}

View File

@@ -20,6 +20,8 @@ class UserFactory extends Factory
*/
public function definition(): array
{
return [
'name' => $this->faker->name(),
'email' => $this->faker->unique()->safeEmail(),

View File

@@ -16,7 +16,7 @@ return new class extends Migration
{
Schema::create('user_detailzs', function (Blueprint $table) {
$table->id();
$table->bigInteger('user_id');
$table->bigInteger('user_id')->nullable();
$table->string('first_name', 256)->default('');
$table->string('last_name', 256)->default('');
$table->date('birthdate')->default('1980-01-01')->nullable(false);

View File

@@ -14,6 +14,8 @@ class DatabaseSeeder extends Seeder
*/
public function run()
{
$this->call(PlanSeeder::class);
$this->call(UserSeeder::class);
// \App\Models\User::factory(10)->create();
}
}

View File

@@ -0,0 +1,27 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use App\Models\User;
use App\Models\Plan;
class PlanAuthor extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
if (User::count() > 0 && Plan::count() > 0) {
Plan::each( function ($plan) {
User::inRandomOrder()
->first()
->author_of_plans()
->attach($plan->id);
});
}
}
}

19
database/seeders/PlanSeeder.php Executable file
View File

@@ -0,0 +1,19 @@
<?php
namespace Database\Seeders;
use Illuminate\Support\Facades\Storage;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use App\Models\Plan;
class PlanSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
Plan::factory()->count(10)->create();
}
}

View File

@@ -0,0 +1,62 @@
<?php
namespace Database\Seeders;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Storage;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use App\Models\User;
use App\Models\UserDetailz;
class UserSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
array_map(function ($user) {
$user = User::factory($user)->create();
$userDetailz = UserDetailz::factory()->make();
$userDetailz->user()->associate($user);
$userDetailz->saveOrFail();
}, $this->getListUsers());
}
private function getListUsers(): array
{
$allUsersHash = Hash::make('1234567890');
return [
['id' => 3, 'name' => 'Анчоус Альф', 'email' => 'reshetnick.mike+user1@gmail.com', 'password' => $allUsersHash, 'is_consultant' => true],
['id' => 4, 'name' => 'Чена Сибаину', 'email' => 'reshetnik.n+user1@gmail.com', 'password' => $allUsersHash, 'is_consultant' => true],
['id' => 5, 'name' => 'Бруно Бармалей', 'email' => 'reshetnick.mike+user2@gmail.com', 'password' => $allUsersHash, 'is_consultant' => true],
['id' => 6, 'name' => 'Варенник Васаби', 'email' => 'reshetnick.mike+user3@gmail.com', 'password' => $allUsersHash, 'is_consultant' => true],
['id' => 7, 'name' => 'Денди Дуглас', 'email' => 'reshetnick.mike+user4@gmail.com', 'password' => $allUsersHash, 'is_consultant' => true],
['id' => 8, 'name' => 'Ник Радченков', 'email' => 'reshetnik.n+user2@gmail.com', 'password' => $allUsersHash],
['id' => 9, 'name' => 'Миса Кошка', 'email' => 'reshetnik.n+user3@gmail.com', 'password' => $allUsersHash],
['id' => 10, 'name' => 'Ерошка Есаул', 'email' => 'reshetnick.mike+user5@gmail.com', 'password' => $allUsersHash],
['id' => 11, 'name' => 'Жмурка Живчик', 'email' => 'reshetnick.mike+user6@gmail.com', 'password' => $allUsersHash],
['id' => 12, 'name' => 'Гошка Картошка', 'email' => 'reshetnik.n+user4@gmail.com', 'password' => $allUsersHash],
['id' => 13, 'name' => 'Зефир Забияка', 'email' => 'reshetnick.mike+user7@gmail.com', 'password' => $allUsersHash],
['id' => 14, 'name' => 'Антоша Одуван', 'email' => 'reshetnik.n+user5@gmail.com', 'password' => $allUsersHash],
['id' => 15, 'name' => 'Кусик Кукусик', 'email' => 'reshetnik.n+user6@gmail.com', 'password' => $allUsersHash],
['id' => 16, 'name' => 'Косик Кокосик', 'email' => 'reshetnik.n+user7@gmail.com', 'password' => $allUsersHash],
['id' => 17, 'name' => 'Хинкалька Вкусная', 'email' => 'reshetnik.n+user8@gmail.com', 'password' => $allUsersHash],
['id' => 18, 'name' => 'Импульс Йети', 'email' => 'reshetnick.mike+user8@gmail.com', 'password' => $allUsersHash],
['id' => 19, 'name' => 'Квики Кекс', 'email' => 'reshetnick.mike+user9@gmail.com', 'password' => $allUsersHash],
['id' => 20, 'name' => 'Чебурек Сочный', 'email' => 'reshetnik.n+user9@gmail.com', 'password' => $allUsersHash],
['id' => 21, 'name' => 'Клубника Дикая', 'email' => 'reshetnik.n+user10@gmail.com', 'password' => $allUsersHash],
['id' => 22, 'name' => 'Ляпис Лапша', 'email' => 'reshetnick.mike+user10@gmail.com', 'password' => $allUsersHash],
['id' => 23, 'name' => 'Друг Парадоксов', 'email' => 'reshetnick.mike+user11@gmail.com', 'password' => $allUsersHash],
];
}
}

View File

@@ -1,92 +1,190 @@
<section class="py-5" id="main">
<div class="container d-flex justify-content-between align-items-center mb-4 px-4 py-3 --bg_white --shadow --radius --mw-1000">
<a href="#" class="d-flex align-items-center --f_bold --f_main"><svg width="17" height="16" class="me-2"><use xlink:href="#GoBack"></use></svg><span class="d-none d-md-inline">Мои планы</span></a>
<div class="fs-5 text-center">
<div class="--f_bolder">Добавление плана</div>
</div>
<div class="col-1 col-md-2"></div>
</div>
<section class="diet" id="main">
<div class="diet__container">
<div class="diet__header">
<button class="diet__back icon-arrow-short-left">
<span>Мои планы</span>
</button>
<h1 class="diet__title">
Мои планы
</h1>
</div>
<form>
<div class="diet__form">
<div class="diet__form-row">
<div class="label">
Название
</div>
<input wire:model="name" type="text" name="name" class="input"
placeholder="Введите название плана">
</div>
<div class="container mb-5 py-3 overflow-hidden --bg_white --shadow --radius --mw-1000">
<div class="fs-4_5">
<label for="form-title">Название</label>
<input wire:model="name" type="text" id="form-title" class="form-control mt-3 py-3 w-100" placeholder="Введите название плана" required="" autocomplete="off" role="presentation" />
</div>
<div class="diet__form-row">
<div class="diet__form-columns ">
<div class="diet__form-column">
<div class="label">
Изображение
</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="row fs-4_5">
<div class="col-12 col-sm-12 col-xl-4 my-4 dnd_file">
<label for="form-image">Изображение</label>
<div class="form__item mt-3 p-3 --radius --bordered text-center --f_grey">
<input wire:model="image" type="file" name="form-image" id="form-image">
@error('image') <span class="error">{{ $message }}</span> @enderror
@if (is_null($image))
<span class="file__content">
<span class="file__formats">
<img src="/img/formats-2.svg" alt="formats">
</span>
<span class="file__title">
Нажмите для&nbsp;выбора или&nbsp;перетащите изображание
</span>
</span>
@else
{{-- @php dd($image) @endphp --}}
<span class="file__content">
<span class="file__formats">
<img src="{{ $image->temporaryUrl() }}" alt="formats">
</span>
</span>
@endif
</label>
</div>
<label for="form-image" class="file-label">
@if(is_null($image))
<p><svg width="88" height="88"><use xlink:href="#dndFileIcon"></use></svg></p>
<div class="px-3">Нажмите для выбора или перетащите изображение</div>
<div id="file-name"></div>
@else
{{-- @php dd($image) @endphp --}}
<p><img src="{{ $image->temporaryUrl() }}" /> </p>
@endif
</label>
</div>
</div>
<div class="diet__form-column">
<div class="diet__form-row">
<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>
</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>
<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"> -->
Slim
</span>
</label>
<label class="checkbox-btn">
<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>
Fit
</span>
</label>
</div>
</div>
</div>
<div class="diet__form-column">
<div class="diet__form-row">
<div class="label">
Статус
</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>
<div class="col-12 col-sm-12 col-xl-8 my-4">
<div class="row mb-3">
<div class="col-12 col-sm-6 d-flex flex-column">
<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="14">14 дней</option>
<option value="21">21 дней</option>
</select>
</div>
<div class="col-12 col-sm-6 d-flex flex-column">
<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>
</div>
</div>
</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"
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>
Wellness
</span>
</label>
<label class="checkbox-btn">
<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>
Behavior
</span>
</label>
</div>
</div>
</div>
<div class="row">
<div class="col-12 col-sm-6 d-flex flex-column">
<div class="btn-group --radio">
<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><div>Slim</div></label>
<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><div>Fit</div></label>
</div>
</div>
<div class="col-12 col-sm-6 d-flex flex-column">
<div class="btn-group --radio">
<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><div>Wellness</div></label>
<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><div>Behavior</div></label>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="mb-4 fs-4_5" wire:ignore>
<label for="details" class="mb-3">Описание </label>
<div
class="form-textarea w-full"
x-data="{}"
x-init="ClassicEditor.create($refs.myIdentifierHere,
{
<div wire:ignore class="diet__form-row">
<div class="label">
Описание
</div>
<!-- <label for="details" class="mb-3">Описание </label> -->
<div class="wysiwyg">
<div class="wysiwyg__caption">
<textarea class="w-full" x-data="{}" x-init="ClassicEditor.create($refs.myIdentifierHere, {
toolbar: {
items: [
'heading', '|',
@@ -98,209 +196,335 @@
shouldNotGroupWhenFull: true
}
})
.then( function(editor){
.then(function(editor) {
editor.model.document.on('change:data', () => {
$dispatch('input', editor.getData())
})
})
.catch( error => {
console.error( error );
});"
wire:ignore
wire:key="myIdentifierHere"
x-ref="myIdentifierHere"
wire:model.live.debounce.9999999ms="details"></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 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>
@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>
.catch(error => {
console.error(error);
});" wire:key="myIdentifierHere"
x-ref="myIdentifierHere" wire:model="details"></textarea>
<!-- x-ref="myIdentifierHere" wire:model="details"></textarea> -->
</div>
</div>
</div>
</div>
</form>
<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>
@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)
<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">
Цена
<span>
1 вариант
</span>
</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>
<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 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>
</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
</div>
@if($errors)
<div class="container p-0 --mw-1000 --bg_white --shadow --radius">
<ul>
@foreach($errors->all() as $message)
<li> {{ $message }}</li>
@endforeach
</ul>
@if ($errors)
<div class="">
<ul>
@foreach ($errors->all() as $message)
<li> {{ $message }}</li>
@endforeach
</ul>
</div>
@endif
<div class="diet__btns">
<button wire:click="addToDrafts" type="button" class="diet__btn btn btn-gray">В
черновик</button>
<button wire:click="showPreview"type="button" class="diet__btn btn btn-gray">Превью</button>
<button wire:click.prevent="publish" type="button"
class="diet__btn btn btn-primary">Опубликовать</button>
</div>
</div>
@endif
<div class="container p-0 --mw-1000">
<div class="row gx-3 gx-lg-4 gy-3 gy-lg-4">
<div class="col">
<a wire:click="addToDrafts" href="#" class="btn btn-lg btn-secondary btn-block w-100 --f_bolder --no_wrap">В ЧЕРНОВИК</a>
</div>
<div class="col">
<a wire:click="showPreview" href="#" class="btn btn-lg btn-secondary btn-block w-100 --f_bolder --no_wrap">ПРЕВЬЮ</a>
</div>
<div class="col">
<button wire:click.prevent="publish" class="btn btn-lg btn-primary btn-block w-100 --f_bolder --no_wrap" type="submit">ОПУБЛИКОВАТЬ</button>
</div>
</div>
</div>
</form>
</section>

View File

@@ -49,7 +49,7 @@
<a href="#"><svg width="24" height="21"><use xlink:href="#HeartPath"></use></svg></a>
</div>
@php
$author = $plan->author()->first();
$author = $plan->present()->getAuthor;
@endphp
<a href="{{ route('profile.show', $author) }}" style="color:var(--main_fcolor)">

View File

@@ -1,7 +1,10 @@
@extends('layouts/eatvio')
@php
$author = $plan->author()->first();
$authorPhoto = Storage::url($author->profile_photo_path);
$author = $plan->present()->getAuthor;
$authorPhoto = $plan->present()->getAuthorPhoto;
$image = Storage::url($plan->image);
$planViewsCount = views($plan)->unique()->count();
@endphp

View File

@@ -0,0 +1,134 @@
<?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 CreateTest 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()->make();
}
public function test_show_form_create_plan()
{
$response = $this->actingAs($this->user)
->get('/plan/create');
$response
->assertStatus(302)
->assertRedirect('https://dev2.eatvio.com/ru');
}
public function test_publish_new_plan_success(): void
{
$countPlanBeforeCreated = $this->plan->count();
$this->actingAs($this->user);
Livewire::test(Create::class)
->set('name', $this->plan->name)
->assertSet('name', $this->plan->name)
->set('image', $this->image)
->set('duration', $this->plan->duration)
->set('state', $this->plan->state)
->set('type', $this->plan->type)
->set('details', $this->plan->details)
->set('packets_count', $this->plan->packets_count)
->set('packet1_options', $this->plan->packet1_options)
->set('packet2_options', $this->plan->packet2_options)
->set('packet3_options', $this->plan->packet3_options)
->call('publish')
// ->assertFileDownloaded('plan.png');
->assertStatus(200)
->assertRedirect('plan/'.$this->plan->count());
$countPlanAfterCreated = $this->plan->count();
$this->assertEquals($countPlanBeforeCreated + 1, $countPlanAfterCreated);
}
//
public function test_to_draft_new_plan_success(): void
{
$countPlanBeforeCreated = $this->plan->count();
$this->actingAs($this->user);
Livewire::test(Create::class)
->set('name', $this->plan->name)
->assertSet('name', $this->plan->name)
->set('image', $this->image)
->set('duration', $this->plan->duration)
->set('state', $this->plan->state)
->set('type', $this->plan->type)
->set('details', $this->plan->details)
->set('packets_count', $this->plan->packets_count)
->set('packet1_options', $this->plan->packet1_options)
->set('packet2_options', $this->plan->packet2_options)
->set('packet3_options', $this->plan->packet3_options)
->call('addToDrafts')
// ->assertFileDownloaded('plan.png');
->assertStatus(200)
->assertRedirect('plan/'.$this->plan->count());
$countPlanAfterCreated = $this->plan->count();
$this->assertEquals($countPlanBeforeCreated + 1, $countPlanAfterCreated);
}
//
public function test_to_preview_new_plan_success(): void
{
$countPlanBeforeCreated = $this->plan->count();
$this->actingAs($this->user);
Livewire::test(Create::class)
->set('name', $this->plan->name)
->assertSet('name', $this->plan->name)
->set('image', $this->image)
->set('duration', $this->plan->duration)
->set('state', $this->plan->state)
->set('type', $this->plan->type)
->set('details', $this->plan->details)
->set('packets_count', $this->plan->packets_count)
->set('packet1_options', $this->plan->packet1_options)
->set('packet2_options', $this->plan->packet2_options)
->set('packet3_options', $this->plan->packet3_options)
->call('showPreview')
// ->assertFileDownloaded('plan.png');
->assertStatus(200)
->assertRedirect('plan/'.$this->plan->count());
$countPlanAfterCreated = $this->plan->count();
$this->assertEquals($countPlanBeforeCreated + 1, $countPlanAfterCreated);
}
}