fix create plan content

This commit is contained in:
2023-12-06 12:30:49 +03:00
parent 2a78186a98
commit be80f55dfa
2 changed files with 29 additions and 25 deletions

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,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();
}
}

View File

@@ -78,8 +78,6 @@
</div>
</div>
</div>
<div class="diet__form-row">
<div class="diet__form-checkboxes">
@@ -278,7 +276,7 @@
@endisset
<div class="row">
<div class="col-12 col-md-10 mb-3">
<input class="input" wire:model="input_items" type="text"
<input class="input" wire:model="input_items_1" type="text"
class="form-control py-3 w-100"
placeholder="Содержание услуги" required=""></input>
</div>
@@ -351,7 +349,7 @@
@endisset
<div class="row">
<div class="col-12 col-md-10 mb-3">
<input class="input" wire:model="input_items" type="text"
<input class="input" wire:model="input_items_1" type="text"
class="form-control py-3 w-100" placeholder="Содержание услуги"
required=""></input>
</div>
@@ -420,7 +418,7 @@
@endisset
<div class="row">
<div class="col-12 col-md-10 mb-3">
<input class="input" wire:model="input_items" type="text"
<input class="input" wire:model="input_items_2" type="text"
class="form-control py-3 w-100"
placeholder="Содержание услуги" required=""></input>
</div>
@@ -480,7 +478,7 @@
<div class="label">
Содержание услуги
</div>
@isset($packet2_options['items'])
@isset($packet3_options['items'])
<ul class="mb-3">
@foreach ($packet3_options['items'] as $item)
<li>
@@ -491,7 +489,7 @@
@endisset
<div class="row">
<div class="col-12 col-md-10 mb-3">
<input class="input" wire:model="input_items" type="text"
<input class="input" wire:model="input_items_3" type="text"
class="form-control py-3 w-100"
placeholder="Содержание услуги" required=""></input>
</div>