Skip to content

Commit 54ae179

Browse files
committed
Updated ui to support lead board
1 parent 015f4eb commit 54ae179

File tree

11 files changed

+73
-7
lines changed

11 files changed

+73
-7
lines changed

resources/views/leads/partials/card-index.blade.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
@slot('actions')
1010
@include('laravel-crm::partials.view-types', [
1111
'model' => 'leads',
12+
'viewSetting' => $viewSetting ?? 'list'
1213
])
1314
@include('laravel-crm::partials.filters', [
1415
'action' => route('laravel-crm.leads.filter'),

resources/views/leads/partials/card-show.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
@component('laravel-crm::components.card-header')
44

55
@slot('title')
6-
{{ $lead->title }}
6+
{{ $lead->title }} @if($lead->pipelineStage) <small><span class="badge badge-secondary">{{ $lead->pipelineStage->name }}</span> @endif</small>
77
@endslot
88

99
@slot('actions')

resources/views/leads/partials/fields.blade.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,20 @@
3434
])
3535
</div>
3636
</div>
37+
38+
@include('laravel-crm::partials.form.select',[
39+
'name' => 'pipeline_stage_id',
40+
'label' => ucfirst(__('laravel-crm::lang.stage')),
41+
'options' => $pipeline->pipelineStages()
42+
->orderBy('order')
43+
->orderBy('id')
44+
->pluck('name', 'id') ?? [],
45+
'value' => old('pipeline_stage_id', $lead->pipelineStage->id ?? $stage ?? $pipeline->pipelineStages()
46+
->orderBy('order')
47+
->orderBy('id')
48+
->first()->id ?? null),
49+
])
50+
3751
@include('laravel-crm::partials.form.multiselect',[
3852
'name' => 'labels',
3953
'label' => ucfirst(__('laravel-crm::lang.labels')),

resources/views/livewire/kanban-board/stage.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
@endforeach
2020
</div>
2121
<div class="card-footer">
22-
<a href="{{ url(route('laravel-crm.leads.create')) }}" class="btn btn-primary btn-block">Add lead</a>
22+
<a href="{{ url(route('laravel-crm.leads.create', ['stage' => $stage['id']])) }}" class="btn btn-primary btn-block">Add lead</a>
2323
</div>
2424
</div>
2525
</div>
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<div class="btn-group" role="group" aria-label="Switch view">
2-
<a href="{{ route('laravel-crm.leads.list') }}" type="button" class="btn btn-sm btn-outline-secondary" data-toggle="tooltip" data-placement="top" title="View {{ $model ?? null }} as list"><i class="fa fa-solid fa-list"></i></a>
3-
<a href="{{ route('laravel-crm.leads.board') }}" type="button" class="btn btn-sm btn-outline-secondary" data-toggle="tooltip" data-placement="top" title="View {{ $model ?? null }} as board"><i class="fa fas fa-th"></i></a>
2+
<a href="{{ route('laravel-crm.leads.list') }}" type="button" class="btn btn-sm btn-outline-secondary {{ ($viewSetting == 'list') ? 'active' : null }}" data-toggle="tooltip" data-placement="top" title="View {{ $model ?? null }} as list"><i class="fa fa-solid fa-list"></i></a>
3+
<a href="{{ route('laravel-crm.leads.board') }}" type="button" class="btn btn-sm btn-outline-secondary {{ ($viewSetting == 'board') ? 'active' : null }}" data-toggle="tooltip" data-placement="top" title="View {{ $model ?? null }} as board"><i class="fa fas fa-th"></i></a>
44
</div>

src/Console/LaravelCrmArchive.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace VentureDrake\LaravelCrm\Console;
44

5-
use Carbon\Carbon;
65
use Illuminate\Console\Command;
76
use Illuminate\Support\Composer;
87
use VentureDrake\LaravelCrm\Services\SettingService;
@@ -56,7 +55,7 @@ public function handle()
5655
{
5756
$this->info('Laravel CRM archiving...');
5857

59-
//
58+
//
6059

6160
$this->info('Archive CRM archiving complete.');
6261
}

src/Http/Controllers/LeadController.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use VentureDrake\LaravelCrm\Models\Lead;
1212
use VentureDrake\LaravelCrm\Models\Organisation;
1313
use VentureDrake\LaravelCrm\Models\Person;
14+
use VentureDrake\LaravelCrm\Models\Pipeline;
1415
use VentureDrake\LaravelCrm\Services\DealService;
1516
use VentureDrake\LaravelCrm\Services\LeadService;
1617
use VentureDrake\LaravelCrm\Services\OrganisationService;
@@ -53,6 +54,17 @@ public function __construct(LeadService $leadService, DealService $dealService,
5354
*/
5455
public function index(Request $request)
5556
{
57+
$viewSetting = auth()->user()->crmSettings()->where('name', 'view_leads')->first();
58+
59+
if(! $viewSetting) {
60+
auth()->user()->crmSettings()->create([
61+
'name' => 'view_leads',
62+
'value' => 'list',
63+
]);
64+
} elseif($viewSetting->value == 'board') {
65+
return redirect(route('laravel-crm.leads.board'));
66+
}
67+
5668
Lead::resetSearchValue($request);
5769
$params = Lead::filters($request);
5870

@@ -62,8 +74,10 @@ public function index(Request $request)
6274
$leads = Lead::filter($params)->whereNull('converted_at')->latest()->paginate(30);
6375
}
6476

77+
6578
return view('laravel-crm::leads.index', [
6679
'leads' => $leads,
80+
'viewSetting' => $viewSetting->value ?? null,
6781
]);
6882
}
6983

@@ -95,6 +109,8 @@ public function create(Request $request)
95109
'client' => $client ?? null,
96110
'organisation' => $organisation ?? null,
97111
'person' => $person ?? null,
112+
'pipeline' => Pipeline::where('model', get_class(new Lead()))->first(),
113+
'stage' => $request->stage ?? null
98114
]);
99115
}
100116

@@ -187,6 +203,7 @@ public function edit(Lead $lead)
187203
'email' => $email ?? null,
188204
'phone' => $phone ?? null,
189205
'address' => $address ?? null,
206+
'pipeline' => Pipeline::where('model', get_class(new Lead()))->first()
190207
]);
191208
}
192209

@@ -355,13 +372,32 @@ public function storeAsDeal(StoreLeadRequest $request, Lead $lead)
355372
return redirect(route('laravel-crm.leads.index'));
356373
}
357374

375+
public function list(Request $request)
376+
{
377+
auth()->user()->crmSettings()->updateOrCreate([
378+
'name' => 'view_leads',
379+
], [
380+
'value' => 'list',
381+
]);
382+
383+
return redirect(route('laravel-crm.leads.index'));
384+
}
385+
358386
/**
359387
* Display a listing of the resource.
360388
*
361389
* @return \Illuminate\Http\Response
362390
*/
363391
public function board(Request $request)
364392
{
393+
$viewSetting = auth()->user()->crmSettings()->where('name', 'view_leads')->first();
394+
395+
auth()->user()->crmSettings()->updateOrCreate([
396+
'name' => 'view_leads',
397+
], [
398+
'value' => 'board',
399+
]);
400+
365401
Lead::resetSearchValue($request);
366402
$params = Lead::filters($request);
367403

@@ -373,6 +409,7 @@ public function board(Request $request)
373409

374410
return view('laravel-crm::leads.board', [
375411
'leads' => $leads,
412+
'viewSetting' => $viewSetting->value ?? null
376413
]);
377414
}
378415
}

src/Http/routes.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292
->name('laravel-crm.leads.index')
9393
->middleware(['can:viewAny,VentureDrake\LaravelCrm\Models\Lead']);
9494

95-
Route::get('list', 'VentureDrake\LaravelCrm\Http\Controllers\LeadController@index')
95+
Route::get('list', 'VentureDrake\LaravelCrm\Http\Controllers\LeadController@list')
9696
->name('laravel-crm.leads.list')
9797
->middleware(['can:viewAny,VentureDrake\LaravelCrm\Models\Lead']);
9898

src/Models/Setting.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ public function getTable()
4141
return config('laravel-crm.db_table_prefix').'settings';
4242
}
4343

44+
public function user()
45+
{
46+
return $this->belongsTo(\App\Models\User::class);
47+
}
48+
4449
public function scopeCurrency($query)
4550
{
4651
return $query->where('name', 'currency')->first();

src/Services/LeadService.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Ramsey\Uuid\Uuid;
66
use VentureDrake\LaravelCrm\Models\Lead;
7+
use VentureDrake\LaravelCrm\Models\PipelineStage;
78
use VentureDrake\LaravelCrm\Repositories\LeadRepository;
89

910
class LeadService
@@ -35,6 +36,8 @@ public function create($request, $person = null, $organisation = null, $client =
3536
'currency' => $request->currency,
3637
'lead_status_id' => 1,
3738
'user_owner_id' => $request->user_owner_id,
39+
'pipeline_id' => PipelineStage::find($request->pipeline_stage_id)->pipeline->id ?? null,
40+
'pipeline_stage_id' => $request->pipeline_stage_id ?? null,
3841
]);
3942

4043
$lead->labels()->sync($request->labels ?? []);
@@ -53,6 +56,8 @@ public function update($request, Lead $lead, $person = null, $organisation = nul
5356
'amount' => $request->amount,
5457
'currency' => $request->currency,
5558
'user_owner_id' => $request->user_owner_id,
59+
'pipeline_id' => PipelineStage::find($request->pipeline_stage_id)->pipeline->id ?? null,
60+
'pipeline_stage_id' => $request->pipeline_stage_id ?? null,
5661
]);
5762

5863
$lead->labels()->sync($request->labels ?? []);

0 commit comments

Comments
 (0)