diff --git a/app/Livewire/Plan/Comment/Create.php b/app/Livewire/Plan/Comment/Create.php index 16fdf52..770b3ef 100644 --- a/app/Livewire/Plan/Comment/Create.php +++ b/app/Livewire/Plan/Comment/Create.php @@ -26,7 +26,7 @@ class Create extends Component public function toggle() { - $this->isChecked = !$this->isChecked; + $this->isChecked = ! $this->isChecked; } public function save() diff --git a/app/Livewire/Plan/Create.php b/app/Livewire/Plan/Create.php index b9e7795..9864e6e 100644 --- a/app/Livewire/Plan/Create.php +++ b/app/Livewire/Plan/Create.php @@ -12,12 +12,17 @@ class Create extends Component { use WithFileUploads; - public $name = ""; + public $name = ''; + public $image = null; - public $duration = "7"; - public $state = "draft"; + + public $duration = '7'; + + public $state = 'draft'; + public $type = ['fit' => false, 'slim' => false, 'behavior' => false, 'wellness' => false]; - public $details = ""; + + public $details = ''; public $packets_count = 1; @@ -59,7 +64,7 @@ class Create extends Component 'packet1_options.items' => 'required|array|min:1', ]; - if($this->packets_count === 3) { + if ($this->packets_count === 3) { $rules['packet2_options.short'] = 'required|string|min:3'; $rules['packet2_options.price'] = 'required|numeric|min:1'; $rules['packet2_options.description'] = 'required|string|min:3'; @@ -135,7 +140,6 @@ class Create extends Component $plan->saveOrFail(); - $user = Auth::user(); $user->author_of_plans()->attach($plan->id); diff --git a/app/Livewire/Plan/Edit.php b/app/Livewire/Plan/Edit.php index 7bd15f3..6779057 100644 --- a/app/Livewire/Plan/Edit.php +++ b/app/Livewire/Plan/Edit.php @@ -11,23 +11,41 @@ class Edit extends Component use WithFileUploads; public Plan $plan; + public $name = ''; + public $image = null; + public $duration = '7'; + public $state = 'draft'; + public $type = ['fit' => false, 'slim' => false, 'behavior' => false, 'wellness' => false]; + public $details = ''; + public $packets_count = 1; + public $packet1_options = []; + public $packet2_options = []; + public $packet3_options = []; + public $packet1_options_input = []; + public $packet2_options_input = []; + public $packet3_options_input = []; + public $input_items_1 = ''; + public $input_items_2 = ''; + public $input_items_3 = ''; + public $isVisibleDuration = false; + public $isVisibleState = false; public function mount(Plan $plan) @@ -111,12 +129,12 @@ class Edit extends Component public function showListDuration() { - $this->isVisibleDuration = !$this->isVisibleDuration; + $this->isVisibleDuration = ! $this->isVisibleDuration; } public function showListState() { - $this->isVisibleState = !$this->isVisibleState; + $this->isVisibleState = ! $this->isVisibleState; } public function toggleDuration($duration) @@ -142,7 +160,7 @@ class Edit extends Component $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->$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'); @@ -153,7 +171,7 @@ class Edit extends Component $this->validate(); $this->plan->name = $this->name; - $this->plan->image = !is_string($this->image) ? $this->image->store('plans', 'public') : $this->image; + $this->plan->image = ! is_string($this->image) ? $this->image->store('plans', 'public') : $this->image; $this->plan->duration = $this->duration; $this->plan->state = $this->state; $this->plan->details = $this->details; diff --git a/app/Models/Plan.php b/app/Models/Plan.php index 1e159d4..c9b3bf1 100644 --- a/app/Models/Plan.php +++ b/app/Models/Plan.php @@ -24,12 +24,12 @@ class Plan extends Model implements Viewable public function getSlugOptions(): SlugOptions { return SlugOptions::create() - ->generateSlugsFrom(['name'] ) + ->generateSlugsFrom(['name']) ->saveSlugsTo('slug') // ->slugsShouldBeNoLongerThan(20) ->usingSeparator('_'); - // ->usingLanguage('ru') - // ->doNotGenerateSlugsOnUpdate(); + // ->usingLanguage('ru') + // ->doNotGenerateSlugsOnUpdate(); } /** diff --git a/database/factories/PlanFactory.php b/database/factories/PlanFactory.php index e8e8082..14c1346 100755 --- a/database/factories/PlanFactory.php +++ b/database/factories/PlanFactory.php @@ -47,7 +47,7 @@ class PlanFactory extends Factory 'name' => $this->faker->foodName(), // 'image' => UploadedFile::fake()->image('plans/Photo_C.png'), 'image' => $fileLocalPath, - 'duration' => $this->faker->randomElement([7, 14,21]), + 'duration' => $this->faker->randomElement([7, 14, 21]), 'state' => $this->faker->randomElement(['active', 'draft', 'unactive']), //'type' => $this->faker->randomElement([$typeBody, $wrongTypeBody]), 'type' => $typeBody, diff --git a/eatvio_tmpls/index.php b/eatvio_tmpls/index.php index bd0b6c7..0540160 100644 --- a/eatvio_tmpls/index.php +++ b/eatvio_tmpls/index.php @@ -1 +1,3 @@ -only('show'); - Route::resource('finance', FinanceController::class)->only(['index','show']); + Route::resource('finance', FinanceController::class)->only(['index', 'show']); Route::resource('plan', PlanController::class)->only(['create', 'show', 'index', 'edit']); Route::resource('diet', DietController::class)->only(['create', 'show', 'index', 'edit']); Route::resource('consultants', ConsultantController::class)->only(['index']); diff --git a/tests/Feature/Plan/CreateTest.php b/tests/Feature/Plan/CreateTest.php index 4f28ade..c96d2c1 100644 --- a/tests/Feature/Plan/CreateTest.php +++ b/tests/Feature/Plan/CreateTest.php @@ -42,7 +42,7 @@ class CreateTest extends TestCase ->get(route('plan.create')); $response->assertSuccessful(); - // ->assertRedirect(route('home')); + // ->assertRedirect(route('home')); } public function test_publish_new_plan_success(): void @@ -50,7 +50,7 @@ class CreateTest extends TestCase $this->actingAs($this->user); // $this->assertEquals($this->plan->count(), $count = Plan::count()); - $planCountAtStart = Plan::count(); + $planCountAtStart = Plan::count(); Livewire::test(Create::class) ->set('name', $this->plan->name) @@ -84,7 +84,6 @@ class CreateTest extends TestCase $response->assertSuccessful(); - // $this->assertEquals($count + 1, Plan::count()); } @@ -92,7 +91,7 @@ class CreateTest extends TestCase { $this->actingAs($this->user); - $planCountAtStart = Plan::count(); + $planCountAtStart = Plan::count(); // $planLastId = $this->plan->latest()->first()->id; // $expectedRedirectRoute = route('plan.show', ['plan' => $planLastId + 1]); @@ -130,7 +129,7 @@ class CreateTest extends TestCase { $this->actingAs($this->user); - $planCountAtStart = Plan::count(); + $planCountAtStart = Plan::count(); Livewire::test(Create::class) ->set('name', $this->plan->name) @@ -165,7 +164,7 @@ class CreateTest extends TestCase { $this->actingAs($this->user); - $planCountAtStart = Plan::count(); + $planCountAtStart = Plan::count(); Livewire::test(Create::class) ->set('name', null)