diff --git a/app/Livewire/Plan/Create.php b/app/Livewire/Plan/Create.php index 2371a99..abbff86 100644 --- a/app/Livewire/Plan/Create.php +++ b/app/Livewire/Plan/Create.php @@ -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,42 +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; - // dd($this->options_type_input); - $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->details); $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->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(); + + $this->name = $plan->name; + $this->image = $plan->image->store('plans', 'public'); + $this->duration = $plan->duration; + $this->state = $plan->state; + $this->details = $plan->details; + $this->packets_count = $plan->packets_count; + $this->type = json_encode($plan->type); + $this->packet1_options = json_encode($plan->packet1_options); + $this->packet2_options = json_encode($plan->packet2_options); + $this->packet3_options = json_encode($plan->packet3_options); + $this->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(); } } diff --git a/resources/views/livewire/plan/create.blade.php b/resources/views/livewire/plan/create.blade.php index 3e52006..a3f8d55 100644 --- a/resources/views/livewire/plan/create.blade.php +++ b/resources/views/livewire/plan/create.blade.php @@ -78,8 +78,6 @@ - -
@@ -278,7 +276,7 @@ @endisset
-
@@ -351,7 +349,7 @@ @endisset
-
@@ -420,7 +418,7 @@ @endisset
-
@@ -480,7 +478,7 @@
Содержание услуги
- @isset($packet2_options['items']) + @isset($packet3_options['items'])
    @foreach ($packet3_options['items'] as $item)
  • @@ -491,7 +489,7 @@ @endisset
    -