Skip to content

Commit bbe77d6

Browse files
Merge pull request #2254 from suraj-webkul/issue#2234
issue #2234 fixed.
2 parents 3bda12b + fe2afaa commit bbe77d6

File tree

3 files changed

+43
-26
lines changed

3 files changed

+43
-26
lines changed

packages/Webkul/Admin/src/Http/Controllers/Lead/LeadController.php

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -157,20 +157,24 @@ public function store(LeadForm $request): RedirectResponse
157157
{
158158
Event::dispatch('lead.create.before');
159159

160-
$data = $request->all();
160+
$data = request()->all();
161161

162162
$data['status'] = 1;
163163

164-
if (isset($data['lead_pipeline_stage_id'])) {
164+
if (! empty($data['lead_pipeline_stage_id'])) {
165165
$stage = $this->stageRepository->findOrFail($data['lead_pipeline_stage_id']);
166166

167167
$data['lead_pipeline_id'] = $stage->lead_pipeline_id;
168168
} else {
169-
$pipeline = $this->pipelineRepository->getDefaultPipeline();
169+
if (empty($data['lead_pipeline_id'])) {
170+
$pipeline = $this->pipelineRepository->getDefaultPipeline();
170171

171-
$stage = $pipeline->stages()->first();
172+
$data['lead_pipeline_id'] = $pipeline->id;
173+
} else {
174+
$pipeline = $this->pipelineRepository->findOrFail($data['lead_pipeline_id']);
175+
}
172176

173-
$data['lead_pipeline_id'] = $pipeline->id;
177+
$stage = $pipeline->stages()->first();
174178

175179
$data['lead_pipeline_stage_id'] = $stage->id;
176180
}
@@ -185,7 +189,11 @@ public function store(LeadForm $request): RedirectResponse
185189

186190
session()->flash('success', trans('admin::app.leads.create-success'));
187191

188-
return redirect()->route('admin.leads.index', $data['lead_pipeline_id']);
192+
if (! empty($data['lead_pipeline_id'])) {
193+
$params['pipeline_id'] = $data['lead_pipeline_id'];
194+
}
195+
196+
return redirect()->route('admin.leads.index', $params ?? []);
189197
}
190198

191199
/**

packages/Webkul/Admin/src/Resources/views/leads/create.blade.php

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,20 @@ class="primary-button"
3939
</div>
4040

4141
@if (request('stage_id'))
42-
<input
43-
type="hidden"
44-
id="lead_pipeline_stage_id"
45-
name="lead_pipeline_stage_id"
46-
value="{{ request('stage_id') }}"
42+
<input
43+
type="hidden"
44+
id="lead_pipeline_stage_id"
45+
name="lead_pipeline_stage_id"
46+
value="{{ request('stage_id') }}"
47+
/>
48+
@endif
49+
50+
@if (request('pipeline_id'))
51+
<input
52+
type="hidden"
53+
id="lead_pipeline_id"
54+
name="lead_pipeline_id"
55+
value="{{ request('pipeline_id') }}"
4756
/>
4857
@endif
4958

@@ -57,13 +66,13 @@ class="primary-button"
5766
{!! view_render_event('admin.leads.create.form.after') !!}
5867

5968
@pushOnce('scripts')
60-
<script
69+
<script
6170
type="text/x-template"
6271
id="v-lead-create-template"
6372
>
6473
<div class="box-shadow flex flex-col gap-4 rounded-lg border border-gray-200 bg-white dark:border-gray-800 dark:bg-gray-900">
6574
{!! view_render_event('admin.leads.edit.form_controls.before') !!}
66-
75+
6776
<div class="flex w-full gap-2 border-b border-gray-200 dark:border-gray-800">
6877
<!-- Tabs -->
6978
<template
@@ -93,8 +102,8 @@ class="primary-button"
93102
{!! view_render_event('admin.leads.create.details.before') !!}
94103
95104
<!-- Details section -->
96-
<div
97-
class="flex flex-col gap-4"
105+
<div
106+
class="flex flex-col gap-4"
98107
id="lead-details"
99108
>
100109
<div class="flex flex-col gap-1">
@@ -142,7 +151,7 @@ class="flex flex-col gap-4"
142151
]"
143152
/>
144153
</div>
145-
154+
146155
<div class="w-full">
147156
<x-admin::attributes
148157
:custom-attributes="app('Webkul\Attribute\Repositories\AttributeRepository')->findWhere([
@@ -169,8 +178,8 @@ class="flex flex-col gap-4"
169178
{!! view_render_event('admin.leads.create.contact_person.before') !!}
170179
171180
<!-- Contact Person -->
172-
<div
173-
class="flex flex-col gap-4"
181+
<div
182+
class="flex flex-col gap-4"
174183
id="contact-person"
175184
>
176185
<div class="flex flex-col gap-1">
@@ -192,8 +201,8 @@ class="flex flex-col gap-4"
192201
{!! view_render_event('admin.leads.create.contact_person.after') !!}
193202
194203
<!-- Product Section -->
195-
<div
196-
class="flex flex-col gap-4"
204+
<div
205+
class="flex flex-col gap-4"
197206
id="products"
198207
>
199208
<div class="flex flex-col gap-1">
@@ -212,7 +221,7 @@ class="flex flex-col gap-4"
212221
</div>
213222
</div>
214223
</div>
215-
224+
216225
{!! view_render_event('admin.leads.form_controls.after') !!}
217226
</div>
218227
</script>
@@ -236,9 +245,9 @@ class="flex flex-col gap-4"
236245
methods: {
237246
/**
238247
* Scroll to the section.
239-
*
248+
*
240249
* @param {String} tabId
241-
*
250+
*
242251
* @returns {void}
243252
*/
244253
scrollToSection(tabId) {
@@ -259,5 +268,5 @@ class="flex flex-col gap-4"
259268
scroll-behavior: smooth;
260269
}
261270
</style>
262-
@endPushOnce
263-
</x-admin::layouts>
271+
@endPushOnce
272+
</x-admin::layouts>

packages/Webkul/Admin/src/Resources/views/leads/index.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
<div class="flex items-center gap-x-2.5">
3838
@if (bouncer()->hasPermission('leads.create'))
3939
<a
40-
href="{{ route('admin.leads.create') }}"
40+
href="{{ route('admin.leads.create', request()->query()) }}"
4141
class="primary-button"
4242
>
4343
@lang('admin::app.leads.index.create-btn')

0 commit comments

Comments
 (0)