Skip to content

Commit 6ec5239

Browse files
authored
Merge pull request #30 from venturedrake/develop
Develop release 0.6
2 parents c52b2f8 + 89c7544 commit 6ec5239

37 files changed

+461
-46
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2020
### Fixed
2121
### Removed --->
2222

23+
## 0.6.0 - 2021-07-14
24+
### Added
25+
- Support for Jetstream/Spark teams
26+
### Fixed
27+
- Model observers - https://github.com/venturedrake/laravel-crm/issues/29
28+
- Assign role instead of sync - https://github.com/venturedrake/laravel-crm/pull/28
29+
2330
## 0.5.1 - 2021-05-31
2431
### Fixed
2532
- Missing key in lang file

README.md

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ This package will add CRM functionality to your laravel projects
1616
- Build a custom CRM for your business or your clients
1717
- Use as an integrated CRM for your Laravel powered business (Saas, E-commerce, etc)
1818
- Use as a CRM for your Laravel development business
19+
- Run a multi-tenant CRM Saas business
1920

2021
## Features
2122

@@ -27,6 +28,7 @@ This package will add CRM functionality to your laravel projects
2728
- Users & Teams
2829
- Secure registration & login
2930
- Reset forgotten password
31+
- Laravel Jetstream/Spark teams support
3032

3133
## Installation (10-15mins)
3234

@@ -45,7 +47,7 @@ https://spatie.be/docs/laravel-permission/v4/installation-laravel
4547
#### Step 4. Require the current package using composer:
4648

4749
```bash
48-
composer require venturedrake/laravel-crm:^0.5
50+
composer require venturedrake/laravel-crm:^0.6
4951
```
5052

5153
#### Step 5. Publish the migrations, config & assets
@@ -127,12 +129,12 @@ Note if you modified the route_prefix setting from the default the above url wil
127129

128130
## Upgrade
129131

130-
### Upgrading from 0.3
132+
### Upgrading from >= 0.2
131133

132134
#### Step 1. Run the following to the update migrations and publish assets:
133135

134136
```bash
135-
composer require venturedrake/laravel-crm::^0.5
137+
composer require venturedrake/laravel-crm::^0.6
136138
php artisan vendor:publish --provider="VentureDrake\LaravelCrm\LaravelCrmServiceProvider" --tag="migrations"
137139
php artisan vendor:publish --provider="VentureDrake\LaravelCrm\LaravelCrmServiceProvider" --tag="assets" --force
138140
php artisan migrate
@@ -144,26 +146,12 @@ php artisan migrate
144146
php artisan db:seed --class="VentureDrake\LaravelCrm\Database\Seeders\LaravelCrmTablesSeeder"
145147
```
146148

147-
### Upgrading from 0.1 to 0.3
149+
### Upgrading from < 0.2
148150

149-
#### Step 1. Run the following to the update migrations and publish assets:
151+
#### Step 1. Run the following to the update package:
150152

151153
```bash
152-
composer require venturedrake/laravel-crm::^0.3
153-
php artisan vendor:publish --provider="VentureDrake\LaravelCrm\LaravelCrmServiceProvider" --tag="migrations"
154-
php artisan vendor:publish --provider="VentureDrake\LaravelCrm\LaravelCrmServiceProvider" --tag="assets" --force
155-
php artisan migrate
156-
```
157-
158-
### Upgrading from 0.1 to 0.2
159-
160-
#### Step 1. Run the following to the update package, database and add the default roles/permissions:
161-
162-
```bash
163-
composer require venturedrake/laravel-crm::^0.2
164-
php artisan vendor:publish --provider="VentureDrake\LaravelCrm\LaravelCrmServiceProvider" --tag="migrations"
165-
php artisan migrate
166-
php artisan db:seed --class="VentureDrake\LaravelCrm\Database\Seeders\LaravelCrmTablesSeeder"
154+
composer require venturedrake/laravel-crm::^0.6
167155
```
168156

169157
#### Step 2. Delete previously published package views located in <code>resources/views/vendor/laravel-crm/*</code>
@@ -172,18 +160,14 @@ php artisan db:seed --class="VentureDrake\LaravelCrm\Database\Seeders\LaravelCrm
172160

173161
#### Step 4. Add HasCrmAccess, HasCrmTeams & HasRoles traits to App\User model, see installation Step 8.
174162

175-
### Upgrading from 0.1.x to 0.1.2
176-
177-
#### Step 1. Run the following to update the package & database
178-
163+
#### Step 5. Run the following to the update database and add the default roles/permissions:
179164
```bash
180-
composer require venturedrake/laravel-crm::^0.1
181165
php artisan vendor:publish --provider="VentureDrake\LaravelCrm\LaravelCrmServiceProvider" --tag="migrations"
166+
php artisan vendor:publish --provider="VentureDrake\LaravelCrm\LaravelCrmServiceProvider" --tag="assets" --force
182167
php artisan migrate
168+
php artisan db:seed --class="VentureDrake\LaravelCrm\Database\Seeders\LaravelCrmTablesSeeder"
183169
```
184170

185-
#### Step 2. Delete previously published package views located in folder <code>resources/views/vendor/laravel-crm/*</code>
186-
187171
<!--- ## Usage --->
188172

189173
## Testing

config/laravel-crm.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,29 @@
1616

1717
'crm_owner' => env('LARAVEL_CRM_OWNER', ''),
1818

19+
/*
20+
|--------------------------------------------------------------------------
21+
| Teams Support
22+
|--------------------------------------------------------------------------
23+
|
24+
| This value relates to the "teams" feature in Laravel Jetstream or Spark.
25+
| Only set this to true if you are using this feature as it will break
26+
| your installation if not. It basically allows you to run a multi-tenant
27+
| crm, and the teams can be different "accounts". You can switch between
28+
| different teams/accounts and have different users, contacts, leads, etc
29+
| in each account.
30+
|
31+
| PLEASE NOTE! This has nothing to do with the user teams feature within
32+
| the crm itself, which is simply a way of grouping users within the crm.
33+
|
34+
| For Jetstream see https://jetstream.laravel.com/2.x/features/teams.html
35+
|
36+
| For Spark see https://spark-classic.laravel.com/docs/11.0/teams
37+
|
38+
*/
39+
40+
'teams' => env('LARAVEL_CRM_TEAMS', false),
41+
1942
/*
2043
|--------------------------------------------------------------------------
2144
| Route Prefix

config/package.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@
1313
|
1414
*/
1515

16-
'version' => '0.5.1',
16+
'version' => '0.6.0',
1717

1818
];
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
class AddGlobalToLaravelCrmSettingsTable 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->boolean('global')->after('team_id')->default(false);
18+
});
19+
}
20+
21+
/**
22+
* Reverse the migrations.
23+
*
24+
* @return void
25+
*/
26+
public function down()
27+
{
28+
Schema::table(config('laravel-crm.db_table_prefix').'settings', function (Blueprint $table) {
29+
$table->dropColumn(['global']);
30+
});
31+
}
32+
}

resources/views/updates/index.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<div class="card">
66
<div class="card-header"><h3 class="card-title m-0">Laravel CRM {{ ucfirst(__('laravel-crm::lang.updates')) }}</h3></div>
77
<div class="card-body">
8-
<p class="card-text">{{ ucfirst(__('laravel-crm::lang.current_version')) }} {{ \VentureDrake\LaravelCrm\Models\Setting::where('name','version')->first()->value }} {{ (\VentureDrake\LaravelCrm\Models\Setting::where('name','version')->first()->value == \VentureDrake\LaravelCrm\Models\Setting::where('name','version_latest')->first()->value) ? ucfirst(__('laravel-crm::lang.is_the_latest_version')) : null }}</p>
8+
<p class="card-text">{{ ucfirst(__('laravel-crm::lang.current_version')) }} {{ \VentureDrake\LaravelCrm\Models\Setting::where('name','version')->first()->value }} {{ (\VentureDrake\LaravelCrm\Models\Setting::where('name','version')->first()->value == \VentureDrake\LaravelCrm\Models\Setting::where('name','version_latest')->first()->value) ? __('laravel-crm::lang.is_the_latest_version') : null }}</p>
99
@if(\VentureDrake\LaravelCrm\Models\Setting::where('name','version')->first()->value < \VentureDrake\LaravelCrm\Models\Setting::where('name','version_latest')->first()->value)
1010
<hr />
1111
<h5 class="mb-4">{{ ucfirst(__('laravel-crm::lang.updated_version_of_laravel_crm_is_available')) }}</h5>

src/Http/Controllers/SettingController.php

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

33
namespace VentureDrake\LaravelCrm\Http\Controllers;
44

5+
use DB;
56
use VentureDrake\LaravelCrm\Http\Requests\UpdateSettingRequest;
67
use VentureDrake\LaravelCrm\Services\SettingService;
78

@@ -51,6 +52,12 @@ public function update(UpdateSettingRequest $request)
5152
$this->settingService->set('country', $request->country);
5253
$this->settingService->set('currency', $request->currency);
5354

55+
if ($request->organisation_name && config('laravel-crm.teams') && auth()->user()->currentTeam) {
56+
DB::table("teams")
57+
->where("id", auth()->user()->currentTeam->id)
58+
->update(["name" => $request->organisation_name]);
59+
}
60+
5461
flash(ucfirst(trans('laravel-crm::lang.settings_updated')))->success()->important();
5562

5663
return back();

src/LaravelCrmServiceProvider.php

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@
1919
use VentureDrake\LaravelCrm\Models\Organisation;
2020
use VentureDrake\LaravelCrm\Models\Person;
2121
use VentureDrake\LaravelCrm\Models\Phone;
22+
use VentureDrake\LaravelCrm\Models\Setting;
2223
use VentureDrake\LaravelCrm\Observers\EmailObserver;
2324
use VentureDrake\LaravelCrm\Observers\LeadObserver;
2425
use VentureDrake\LaravelCrm\Observers\OrganisationObserver;
2526
use VentureDrake\LaravelCrm\Observers\PersonObserver;
2627
use VentureDrake\LaravelCrm\Observers\PhoneObserver;
28+
use VentureDrake\LaravelCrm\Observers\SettingObserver;
2729

2830
class LaravelCrmServiceProvider extends ServiceProvider
2931
{
@@ -75,6 +77,14 @@ class_alias(config("auth.providers.users.model"), 'App\User');
7577

7678
$this->registerRoutes();
7779

80+
// Register Observers
81+
Lead::observe(LeadObserver::class);
82+
Person::observe(PersonObserver::class);
83+
Organisation::observe(OrganisationObserver::class);
84+
Phone::observe(PhoneObserver::class);
85+
Email::observe(EmailObserver::class);
86+
Setting::observe(SettingObserver::class);
87+
7888
if ($this->app->runningInConsole()) {
7989
$this->publishes([
8090
__DIR__ . '/../config/laravel-crm.php' => config_path('laravel-crm.php'),
@@ -107,6 +117,7 @@ class_alias(config("auth.providers.users.model"), 'App\User');
107117
__DIR__ . '/../database/migrations/create_laravel_crm_product_prices_table.php.stub' => $this->getMigrationFileName($filesystem, 'create_laravel_crm_product_prices_table.php', 8),
108118
__DIR__ . '/../database/migrations/create_laravel_crm_product_variations_table.php.stub' => $this->getMigrationFileName($filesystem, 'create_laravel_crm_product_variations_table.php', 9),
109119
__DIR__ . '/../database/migrations/create_laravel_crm_deal_products_table.php.stub' => $this->getMigrationFileName($filesystem, 'create_laravel_crm_deal_products_table.php', 10),
120+
__DIR__ . '/../database/migrations/add_global_to_laravel_crm_settings_table.php.stub' => $this->getMigrationFileName($filesystem, 'add_global_to_laravel_crm_settings_table.php', 11),
110121
], 'migrations');
111122

112123
// Publishing the seeders
@@ -127,18 +138,9 @@ class_alias(config("auth.providers.users.model"), 'App\User');
127138
}
128139

129140
// Registering package commands.
130-
if ($this->app->runningInConsole()) {
131-
$this->commands([
132-
LaravelCrmInstall::class,
133-
]);
134-
}
135-
136-
// Register Observers
137-
Lead::observe(LeadObserver::class);
138-
Person::observe(PersonObserver::class);
139-
Organisation::observe(OrganisationObserver::class);
140-
Phone::observe(PhoneObserver::class);
141-
Email::observe(EmailObserver::class);
141+
$this->commands([
142+
LaravelCrmInstall::class,
143+
]);
142144

143145
// Register the model factories
144146
if (app()->version() < 8) {

src/Models/Activity.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@
66

77
use Illuminate\Database\Eloquent\Model;
88
use Illuminate\Database\Eloquent\SoftDeletes;
9+
use VentureDrake\LaravelCrm\Traits\BelongsToTeams;
910

1011
class Activity extends Model
1112
{
1213
use SoftDeletes;
14+
use BelongsToTeams;
1315

1416
public function getTable()
1517
{

src/Models/Address.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44

55
use Illuminate\Database\Eloquent\Model;
66
use Illuminate\Database\Eloquent\SoftDeletes;
7+
use VentureDrake\LaravelCrm\Traits\BelongsToTeams;
78
use VentureDrake\LaravelEncryptable\Traits\LaravelEncryptableTrait;
89

910
class Address extends Model
1011
{
1112
use SoftDeletes;
1213
use LaravelEncryptableTrait;
14+
use BelongsToTeams;
1315

1416
protected $guarded = ['id'];
1517

0 commit comments

Comments
 (0)