Skip to content

Commit 17fec22

Browse files
committed
Pipeline settings and migrations
1 parent f7cdeb8 commit 17fec22

29 files changed

+939
-100
lines changed
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
return new class extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*
12+
* @return void
13+
*/
14+
public function up()
15+
{
16+
Schema::table(config('laravel-crm.db_table_prefix').'leads', function (Blueprint $table) {
17+
$table->foreignIdFor(\VentureDrake\LaravelCrm\Models\Pipeline::class)->nullable()->after('team_id');
18+
$table->foreignIdFor(\VentureDrake\LaravelCrm\Models\PipelineStage::class)->nullable()->after('pipeline_id');
19+
});
20+
21+
Schema::table(config('laravel-crm.db_table_prefix').'deals', function (Blueprint $table) {
22+
$table->foreignIdFor(\VentureDrake\LaravelCrm\Models\Pipeline::class)->nullable()->after('team_id');
23+
$table->foreignIdFor(\VentureDrake\LaravelCrm\Models\PipelineStage::class)->nullable()->after('pipeline_id');
24+
});
25+
26+
Schema::table(config('laravel-crm.db_table_prefix').'quotes', function (Blueprint $table) {
27+
$table->foreignIdFor(\VentureDrake\LaravelCrm\Models\Pipeline::class)->nullable()->after('team_id');
28+
$table->foreignIdFor(\VentureDrake\LaravelCrm\Models\PipelineStage::class)->nullable()->after('pipeline_id');
29+
});
30+
31+
Schema::table(config('laravel-crm.db_table_prefix').'orders', function (Blueprint $table) {
32+
$table->foreignIdFor(\VentureDrake\LaravelCrm\Models\Pipeline::class)->nullable()->after('team_id');
33+
$table->foreignIdFor(\VentureDrake\LaravelCrm\Models\PipelineStage::class)->nullable()->after('pipeline_id');
34+
});
35+
36+
Schema::table(config('laravel-crm.db_table_prefix').'invoices', function (Blueprint $table) {
37+
$table->foreignIdFor(\VentureDrake\LaravelCrm\Models\Pipeline::class)->nullable()->after('team_id');
38+
$table->foreignIdFor(\VentureDrake\LaravelCrm\Models\PipelineStage::class)->nullable()->after('pipeline_id');
39+
});
40+
41+
Schema::table(config('laravel-crm.db_table_prefix').'deliveries', function (Blueprint $table) {
42+
$table->foreignIdFor(\VentureDrake\LaravelCrm\Models\Pipeline::class)->nullable()->after('team_id');
43+
$table->foreignIdFor(\VentureDrake\LaravelCrm\Models\PipelineStage::class)->nullable()->after('pipeline_id');
44+
});
45+
46+
Schema::table(config('laravel-crm.db_table_prefix').'purchase_orders', function (Blueprint $table) {
47+
$table->foreignIdFor(\VentureDrake\LaravelCrm\Models\Pipeline::class)->nullable()->after('team_id');
48+
$table->foreignIdFor(\VentureDrake\LaravelCrm\Models\PipelineStage::class)->nullable()->after('pipeline_id');
49+
});
50+
}
51+
52+
/**
53+
* Reverse the migrations.
54+
*
55+
* @return void
56+
*/
57+
public function down()
58+
{
59+
Schema::table(config('laravel-crm.db_table_prefix').'leads', function (Blueprint $table) {
60+
$table->dropColumn([
61+
'pipeline_id',
62+
'pipeline_stage_id'
63+
]);
64+
});
65+
66+
Schema::table(config('laravel-crm.db_table_prefix').'deals', function (Blueprint $table) {
67+
$table->dropColumn([
68+
'pipeline_id',
69+
'pipeline_stage_id'
70+
]);
71+
});
72+
73+
Schema::table(config('laravel-crm.db_table_prefix').'quotes', function (Blueprint $table) {
74+
$table->dropColumn([
75+
'pipeline_id',
76+
'pipeline_stage_id'
77+
]);
78+
});
79+
80+
Schema::table(config('laravel-crm.db_table_prefix').'orders', function (Blueprint $table) {
81+
$table->dropColumn([
82+
'pipeline_id',
83+
'pipeline_stage_id'
84+
]);
85+
});
86+
87+
Schema::table(config('laravel-crm.db_table_prefix').'invoices', function (Blueprint $table) {
88+
$table->dropColumn([
89+
'pipeline_id',
90+
'pipeline_stage_id'
91+
]);
92+
});
93+
94+
Schema::table(config('laravel-crm.db_table_prefix').'deliveries', function (Blueprint $table) {
95+
$table->dropColumn([
96+
'pipeline_id',
97+
'pipeline_stage_id'
98+
]);
99+
});
100+
101+
Schema::table(config('laravel-crm.db_table_prefix').'purchase_orders', function (Blueprint $table) {
102+
$table->dropColumn([
103+
'pipeline_id',
104+
'pipeline_stage_id'
105+
]);
106+
});
107+
}
108+
};
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
return new class extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*
12+
* @return void
13+
*/
14+
public function up()
15+
{
16+
Schema::table(config('laravel-crm.db_table_prefix').'settings', function (Blueprint $table) {
17+
$table->unsignedBigInteger('user_id')->nullable()->after('team_id');
18+
$table->foreign('user_id')->references('id')->on('users');
19+
});
20+
}
21+
22+
/**
23+
* Reverse the migrations.
24+
*
25+
* @return void
26+
*/
27+
public function down()
28+
{
29+
Schema::table(config('laravel-crm.db_table_prefix').'settings', function (Blueprint $table) {
30+
$table->dropForeign(['user_id']);
31+
$table->dropColumn('user_id');
32+
});
33+
}
34+
};
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
return new class extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*
12+
* @return void
13+
*/
14+
public function up()
15+
{
16+
Schema::create(config('laravel-crm.db_table_prefix').'pipeline_stage_probabilities', function (Blueprint $table) {
17+
$table->id();
18+
$table->string('external_id');
19+
$table->unsignedBigInteger('team_id')->index()->nullable();
20+
$table->string('name');
21+
$table->unsignedTinyInteger('percent');
22+
$table->tinyInteger('limit')->nullable();
23+
$table->boolean('archive')->default(false);
24+
$table->timestamp('archived_at')->nullable();
25+
$table->timestamps();
26+
$table->softDeletes();
27+
});
28+
}
29+
30+
/**
31+
* Reverse the migrations.
32+
*
33+
* @return void
34+
*/
35+
public function down()
36+
{
37+
Schema::dropIfExists(config('laravel-crm.db_table_prefix').'pipeline_stage_probabilities');
38+
}
39+
};
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
return new class extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*
12+
* @return void
13+
*/
14+
public function up()
15+
{
16+
Schema::create(config('laravel-crm.db_table_prefix').'pipeline_stages', function (Blueprint $table) {
17+
$table->id();
18+
$table->string('external_id');
19+
$table->unsignedBigInteger('team_id')->index()->nullable();
20+
$table->string('name');
21+
$table->text('description')->nullable();
22+
$table->foreignIdFor(\VentureDrake\LaravelCrm\Models\Pipeline::class);
23+
$table->foreignIdFor(\VentureDrake\LaravelCrm\Models\PipelineStageProbability::class)->nullable();
24+
$table->tinyInteger('order')->default(0);
25+
$table->string('color')->nullable();
26+
$table->timestamps();
27+
$table->softDeletes();
28+
});
29+
}
30+
31+
/**
32+
* Reverse the migrations.
33+
*
34+
* @return void
35+
*/
36+
public function down()
37+
{
38+
Schema::dropIfExists(config('laravel-crm.db_table_prefix').'pipeline_stages');
39+
}
40+
};
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
return new class extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*
12+
* @return void
13+
*/
14+
public function up()
15+
{
16+
Schema::create(config('laravel-crm.db_table_prefix').'pipelines', function (Blueprint $table) {
17+
$table->id();
18+
$table->string('external_id');
19+
$table->unsignedBigInteger('team_id')->index()->nullable();
20+
$table->string('name');
21+
$table->string('model');
22+
$table->timestamps();
23+
$table->softDeletes();
24+
});
25+
}
26+
27+
/**
28+
* Reverse the migrations.
29+
*
30+
* @return void
31+
*/
32+
public function down()
33+
{
34+
Schema::dropIfExists(config('laravel-crm.db_table_prefix').'pipelines');
35+
}
36+
};

resources/lang/en/lang.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,4 +494,19 @@
494494
'edit_custom_field_group' => 'edit custom field group',
495495
'back_to_custom_field_groups' => 'back to custom field groups',
496496
'pipelines' => 'pipelines',
497+
'add_pipeline' => 'add pipeline',
498+
'pipeline' => 'pipeline',
499+
'create_pipeline' => 'create pipeline',
500+
'edit_pipeline' => 'edit pipeline',
501+
'back_to_pipelines' => 'back to pipelines',
502+
'pipeline_updated' => 'pipeline updated',
503+
'pipeline_stored' => 'pipeline stored',
504+
'pipeline_deleted' => 'pipeline deleted',
505+
'stages' => 'stages',
506+
'pipeline_stages' => 'pipeline stages',
507+
'add_pipeline_stage' => 'add pipeline stage',
508+
'pipeline_stage' => 'pipeline stage',
509+
'create_pipeline_stage' => 'create pipeline stage',
510+
'back_to_pipeline_stages' => 'back to pipeline stages',
511+
'edit_pipeline_stage' => 'edit pipeline stage',
497512
];

resources/views/layouts/partials/nav-settings.blade.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
<li class="nav-item">
1414
<a class="nav-link {{ (strpos(Route::currentRouteName(), 'laravel-crm.pipelines') === 0) ? 'active' : '' }}" href="{{ url(route('laravel-crm.pipelines.index')) }}" role="tab" aria-controls="pipelines" aria-selected="false">{{ ucwords(__('laravel-crm::lang.pipelines')) }}</a>
1515
</li>
16+
<li class="nav-item">
17+
<a class="nav-link {{ (strpos(Route::currentRouteName(), 'laravel-crm.pipeline-stages') === 0) ? 'active' : '' }}" href="{{ url(route('laravel-crm.pipeline-stages.index')) }}" role="tab" aria-controls="pipeline-stages" aria-selected="false">{{ ucwords(__('laravel-crm::lang.pipeline_stages')) }}</a>
18+
</li>
1619
@endcan
1720
@can('view crm product categories')
1821
<li class="nav-item">

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@
77
@endslot
88

99
@slot('actions')
10-
@include('laravel-crm::partials.view-types', [
11-
'model' => 'leads',
12-
'viewSetting' => $viewSetting ?? 'list'
13-
])
10+
@if($pipeline)
11+
@include('laravel-crm::partials.view-types', [
12+
'model' => 'leads',
13+
'viewSetting' => $viewSetting ?? 'list'
14+
])
15+
@endif
1416
@include('laravel-crm::partials.filters', [
1517
'action' => route('laravel-crm.leads.filter'),
1618
'model' => '\VentureDrake\LaravelCrm\Models\Lead'

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

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,20 @@
3535
</div>
3636
</div>
3737

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),
38+
@if($pipeline)
39+
@include('laravel-crm::partials.form.select',[
40+
'name' => 'pipeline_stage_id',
41+
'label' => ucfirst(__('laravel-crm::lang.stage')),
42+
'options' => $pipeline->pipelineStages()
43+
->orderBy('order')
44+
->orderBy('id')
45+
->pluck('name', 'id') ?? [],
46+
'value' => old('pipeline_stage_id', $lead->pipelineStage->id ?? $stage ?? $pipeline->pipelineStages()
47+
->orderBy('order')
48+
->orderBy('id')
49+
->first()->id ?? null),
4950
])
51+
@endif
5052

5153
@include('laravel-crm::partials.form.multiselect',[
5254
'name' => 'labels',
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
@extends('laravel-crm::layouts.app')
2+
3+
@section('content')
4+
5+
<form method="POST" action="{{ url(route('laravel-crm.pipeline-stages.store')) }}">
6+
@csrf
7+
<div class="container-fluid pl-0">
8+
<div class="row">
9+
<div class="col col-md-2">
10+
<div class="card">
11+
<div class="card-body py-3 px-2">
12+
@include('laravel-crm::layouts.partials.nav-settings')
13+
</div>
14+
</div>
15+
</div>
16+
<div class="col col-md-10">
17+
<div class="card">
18+
<div class="card-header">
19+
<h3 class="card-title float-left m-0"> {{ ucfirst(trans('laravel-crm::lang.create_pipeline_stage')) }}</h3>
20+
<span class="float-right"><a type="button" class="btn btn-outline-secondary btn-sm" href="{{ url(route('laravel-crm.pipeline-stages.index')) }}"><span class="fa fa-angle-double-left"></span> {{ ucfirst(trans('laravel-crm::lang.back_to_pipeline_stages')) }}</a></span>
21+
</div>
22+
<div class="card-body">
23+
@include('laravel-crm::pipeline-stages.partials.fields')
24+
</div>
25+
@component('laravel-crm::components.card-footer')
26+
<a href="{{ url(route('laravel-crm.pipeline-stages.index')) }}" class="btn btn-outline-secondary">{{ ucfirst(trans('laravel-crm::lang.cancel')) }}</a>
27+
<button type="submit" class="btn btn-primary">{{ ucwords(trans('laravel-crm::lang.save')) }}</button>
28+
@endcomponent
29+
</div>
30+
</div>
31+
</div>
32+
</div>
33+
</form>
34+
35+
@endsection

0 commit comments

Comments
 (0)