Skip to content

Commit

Permalink
Updated project to follow PSR-12
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewdrake committed Jun 25, 2023
1 parent 92b80e4 commit a336f15
Show file tree
Hide file tree
Showing 150 changed files with 458 additions and 454 deletions.
2 changes: 1 addition & 1 deletion .php-cs-fixer.cache

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
use PhpCsFixer\Finder;

$rules = [
'@PSR2' => true,
'array_syntax' => ['syntax' => 'short'],
'@PSR12' => true,
/*'array_syntax' => ['syntax' => 'short'],
'ordered_imports' => ['sort_algorithm' => 'alpha'],
'no_unused_imports' => true,
'not_operator_with_successor_space' => true,
Expand All @@ -22,7 +22,7 @@
'on_multiline' => 'ensure_fully_multiline',
'keep_multiple_spaces_after_comma' => true,
],
'single_trait_insert_per_statement' => true,
'single_trait_insert_per_statement' => true,*/
];

$finder = Finder::create()
Expand Down
2 changes: 1 addition & 1 deletion .styleci.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
risky: false

preset: psr2
preset: psr12
18 changes: 9 additions & 9 deletions config/laravel-crm.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
| the crm is installed if not already.
|
*/

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

/*
Expand Down Expand Up @@ -53,11 +53,11 @@
| creates a new team when team support is enabled above.
|
*/

'currency' => env('LARAVEL_CRM_CURRENCY', 'USD'),

'country' => env('LARAVEL_CRM_COUNTRY', 'United States'),

'language' => env('LARAVEL_CRM_LANGUAGE', 'english'),

/*
Expand Down Expand Up @@ -90,7 +90,7 @@
| controllers, models, views, etc.
|
*/

'route_prefix' => env('LARAVEL_CRM_ROUTE_PREFIX', 'crm'),

/*
Expand All @@ -101,7 +101,7 @@
| For any custom middleware you have developed to be added to the crm routes
|
*/

'route_middleware' => [],

/*
Expand All @@ -114,7 +114,7 @@
| as the default "crm" to avoid any possible table name conflicts.
|
*/

'db_table_prefix' => env('LARAVEL_CRM_DB_TABLE_PREFIX', 'crm_'),

/*
Expand All @@ -126,7 +126,7 @@
| certain database table fields as an added layer of privacy protection.
|
*/

'encrypt_db_fields' => env('LARAVEL_CRM_ENCRYPT_DB_FIELDS', false),

/*
Expand Down Expand Up @@ -167,5 +167,5 @@
'deliveries',
'teams',
],

];
2 changes: 1 addition & 1 deletion config/package.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
*/

'version' => '0.18.1',

];
16 changes: 8 additions & 8 deletions database/seeders/LaravelCrmTablesSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public function run()
foreach ($items as $item) {
\VentureDrake\LaravelCrm\Models\OrganisationType::firstOrCreate($item[0], $item[1]);
}

// Address types
$items = [
[
Expand Down Expand Up @@ -175,7 +175,7 @@ public function run()
foreach ($items as $item) {
\VentureDrake\LaravelCrm\Models\AddressType::firstOrCreate($item[0], $item[1]);
}

// Contact types
$items = [
[
Expand All @@ -195,7 +195,7 @@ public function run()
],
],
];

foreach ($items as $item) {
\VentureDrake\LaravelCrm\Models\ContactType::firstOrCreate($item[0], $item[1]);
}
Expand Down Expand Up @@ -260,7 +260,7 @@ public function run()
Permission::firstOrCreate(['name' => 'view crm teams', 'crm_permission' => 1]);
Permission::firstOrCreate(['name' => 'edit crm teams', 'crm_permission' => 1]);
Permission::firstOrCreate(['name' => 'delete crm teams', 'crm_permission' => 1]);

Permission::firstOrCreate(['name' => 'view crm settings', 'crm_permission' => 1]);
Permission::firstOrCreate(['name' => 'edit crm settings', 'crm_permission' => 1]);

Expand Down Expand Up @@ -345,7 +345,7 @@ public function run()
Permission::firstOrCreate(['name' => 'view crm clients', 'crm_permission' => 1]);
Permission::firstOrCreate(['name' => 'edit crm clients', 'crm_permission' => 1]);
Permission::firstOrCreate(['name' => 'delete crm clients', 'crm_permission' => 1]);

if (config('permission.teams')) {
$roleArray = ['name' => 'Owner', 'crm_role' => 1, 'team_id' => null];
} else {
Expand All @@ -360,7 +360,7 @@ public function run()
} else {
$roleArray = ['name' => 'Admin', 'crm_role' => 1];
}

$role = Role::firstOrCreate($roleArray)
->givePermissionTo(Permission::all());

Expand All @@ -369,7 +369,7 @@ public function run()
} else {
$roleArray = ['name' => 'Manager', 'crm_role' => 1];
}

$role = Role::firstOrCreate($roleArray)
->givePermissionTo([
'create crm leads',
Expand Down Expand Up @@ -447,7 +447,7 @@ public function run()
} else {
$roleArray = ['name' => 'Employee', 'crm_role' => 1];
}

$role = Role::firstOrCreate($roleArray)
->givePermissionTo([
'create crm leads',
Expand Down
8 changes: 4 additions & 4 deletions src/Console/LaravelCrmAddressTypes.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,19 @@ public function __construct(Composer $composer)
public function handle()
{
$this->info('Updating LaravelCRM Address Types...');

foreach (DB::table('teams')->get() as $team) {
foreach (DB::table('address_types')
->whereNull('team_id')
->get() as $addressType) {
$this->info('Inserting address type '.$addressType->name.' for team '.$team->name);

$teamAddressType = DB::table('address_types')->where([
'name' => $addressType->name,
'description' => $addressType->description,
'team_id' => $team->id,
])->first();

if (! $teamAddressType) {
DB::table('address_types')->insert([
'name' => $addressType->name,
Expand All @@ -73,7 +73,7 @@ public function handle()
}
}
}

$this->info('LaravelCRM Address Types Update Complete.');
}
}
14 changes: 7 additions & 7 deletions src/Console/LaravelCrmInstall.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,12 @@ public function handle()
}

$this->info('Checking user authentication passed.');

// TBC: Check if audits table exists already
// TBC: Check if spatie permissions tables exists already

$this->info('Checking requirements passed.');

$this->info('Installing Laravel CRM...');

$this->info('Publishing configuration...');
Expand All @@ -104,7 +104,7 @@ public function handle()
}

$this->info('Publishing migrations...');

$this->callSilent('vendor:publish', [
'--provider' => 'VentureDrake\LaravelCrm\LaravelCrmServiceProvider',
'--tag' => 'migrations',
Expand All @@ -126,26 +126,26 @@ public function handle()
$this->callSilent('db:seed', [
'--class' => 'VentureDrake\LaravelCrm\Database\Seeders\LaravelCrmTablesSeeder',
]);

if (\App\User::where('crm_access')->count() < 1) {
$this->info('Create your default owner user');

$firstname = $this->ask('Whats your first name?');
$lastname = $this->ask('Whats your last name?');
$email = $this->ask('Whats your email address?');
$password = $this->secret('Enter a password');

if ($user = \App\User::where('email', $email)->first()) {
$this->info('User already exists, granting crm access...');

$user->update([
'crm_access' => 1,
]);

if (! $user->hasRole('Owner')) {
$user->assignRole('Owner');
}

$this->info('User access and role updated.');
} else {
$user = \App\User::forceCreate([
Expand Down
8 changes: 4 additions & 4 deletions src/Console/LaravelCrmLabels.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,20 @@ public function __construct(Composer $composer)
public function handle()
{
$this->info('Updating LaravelCRM Labels...');

foreach (DB::table('teams')->get() as $team) {
foreach (DB::table('labels')
->whereNull('team_id')
->get() as $label) {
$this->info('Inserting label '.$label->name.' for team '.$team->name);

$teamLabel = DB::table('labels')->where([
'name' => $label->name,
'hex' => $label->hex,
'description' => $label->description,
'team_id' => $team->id,
])->first();

if (! $teamLabel) {
DB::table('labels')->insert([
'external_id' => Uuid::uuid4()->toString(),
Expand All @@ -77,7 +77,7 @@ public function handle()
}
}
}

$this->info('LaravelCRM Labels Update Complete.');
}
}
6 changes: 3 additions & 3 deletions src/Console/LaravelCrmOrganisationTypes.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function __construct(Composer $composer)
public function handle()
{
$this->info('Updating LaravelCRM Organisation Types...');

foreach (DB::table('teams')->get() as $team) {
foreach (DB::table('organisation_types')
->whereNull('team_id')
Expand All @@ -61,7 +61,7 @@ public function handle()
'description' => $organisationType->description,
'team_id' => $team->id,
])->first();

if (! $teamOrganisationType) {
DB::table('organisation_types')->insert([
'name' => $organisationType->name,
Expand All @@ -73,7 +73,7 @@ public function handle()
}
}
}

$this->info('LaravelCRM Organisation Types Update Complete.');
}
}
6 changes: 3 additions & 3 deletions src/Console/LaravelCrmPermissions.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ public function handle()
app()[\Spatie\Permission\PermissionRegistrar::class]->forgetCachedPermissions();

$tableNames = config('permission.table_names');

foreach (DB::table('teams')->get() as $team) {
foreach (DB::table($tableNames['roles'])
->where('crm_role', 1)
->whereNull('team_id')
->get() as $role) {
$this->info('Inserting role '.$role->name.' for team '.$team->name);

DB::table($tableNames['roles'])->updateOrInsert([
'name' => $role->name,
'guard_name' => $role->guard_name,
Expand Down Expand Up @@ -95,7 +95,7 @@ public function handle()
}
}
}

$this->info('LaravelCRM Permissions Update Complete.');
}
}
6 changes: 3 additions & 3 deletions src/Console/LaravelCrmUpdate.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class LaravelCrmUpdate extends Command
* @var SettingService
*/
private $settingService;

/**
* The name and signature of the console command.
*
Expand Down Expand Up @@ -57,7 +57,7 @@ public function __construct(Composer $composer, SettingService $settingService)
public function handle()
{
$this->info('Updating Laravel CRM...');

if($this->settingService->get('db_update_0180')->value == 0) {
$this->info('Updating Laravel CRM quote numbers...');

Expand Down Expand Up @@ -107,7 +107,7 @@ public function handle()
$this->settingService->set('db_update_0181', 1);
$this->info('Updating Laravel CRM organisation linked to person complete.');
}

$this->info('Laravel CRM is now updated.');
}
}
Loading

0 comments on commit a336f15

Please sign in to comment.