Skip to content

Commit 1f5ac39

Browse files
authored
Merge pull request #4 from TepuiLABS/upgrade-package-service-provider-from-spatie
Fixed what needed fixing and squished some bugs.
2 parents ba7749d + dfccc13 commit 1f5ac39

File tree

18 files changed

+218
-136
lines changed

18 files changed

+218
-136
lines changed

.github/workflows/phpstan.yml

Lines changed: 0 additions & 26 deletions
This file was deleted.

.php-cs-fixer.cache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"php":"8.1.3","version":"3.7.0","indent":" ","lineEnding":"\n","rules":{"blank_line_after_opening_tag":true,"braces":{"allow_single_line_anonymous_class_with_empty_body":true},"class_definition":{"inline_constructor_arguments":false,"space_before_parenthesis":true},"compact_nullable_typehint":true,"declare_equal_normalize":true,"lowercase_cast":true,"lowercase_static_reference":true,"new_with_braces":true,"no_blank_lines_after_class_opening":true,"no_leading_import_slash":true,"no_whitespace_in_blank_line":true,"ordered_class_elements":{"order":["use_trait"]},"ordered_imports":{"sort_algorithm":"alpha"},"return_type_declaration":true,"short_scalar_cast":true,"single_blank_line_before_namespace":true,"single_trait_insert_per_statement":true,"ternary_operator_spaces":true,"visibility_required":true,"blank_line_after_namespace":true,"constant_case":true,"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_keywords":true,"method_argument_space":{"on_multiline":"ensure_fully_multiline","keep_multiple_spaces_after_comma":true},"no_break_comment":true,"no_closing_tag":true,"no_space_around_double_colon":true,"no_spaces_after_function_name":true,"no_spaces_inside_parenthesis":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_class_element_per_statement":{"elements":["property"]},"single_import_per_statement":true,"single_line_after_imports":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"encoding":true,"full_opening_tag":true,"array_syntax":{"syntax":"short"},"no_unused_imports":true,"not_operator_with_successor_space":true,"trailing_comma_in_multiline":true,"phpdoc_scalar":true,"unary_operator_spaces":true,"binary_operator_spaces":true,"blank_line_before_statement":{"statements":["break","continue","declare","return","throw","try"]},"phpdoc_single_line_var_spacing":true,"phpdoc_var_without_name":true,"class_attributes_separation":{"elements":{"method":"one"}}},"hashes":{"src\/Models\/Note.php":576988369,"src\/Models\/Service.php":589425630,"src\/Models\/Lead.php":1420902803,"src\/SimpleCrmServiceProvider.php":3677119947,"tests\/Unit\/LeadTest.php":820572205,"tests\/Unit\/ServiceTest.php":303507015,"tests\/Unit\/NoteTest.php":3367683590,"tests\/Models\/User.php":546769323,"tests\/TestCase.php":610046076,"tests\/Pest.php":2378833050,"src\/Models\/Enums\/ProjectStatus.php":240630045,"src\/Models\/Enums\/NoteStatus.php":780172828,"src\/Models\/Enums\/LeadStatus.php":2060495691,"src\/Models\/Project.php":705501016}}
1+
{"php":"8.1.8","version":"3.9.5","indent":" ","lineEnding":"\n","rules":{"blank_line_after_opening_tag":true,"blank_line_between_import_groups":true,"braces":{"allow_single_line_anonymous_class_with_empty_body":true},"class_definition":{"inline_constructor_arguments":false,"space_before_parenthesis":true},"compact_nullable_typehint":true,"declare_equal_normalize":true,"lowercase_cast":true,"lowercase_static_reference":true,"new_with_braces":true,"no_blank_lines_after_class_opening":true,"no_leading_import_slash":true,"no_whitespace_in_blank_line":true,"ordered_class_elements":{"order":["use_trait"]},"ordered_imports":{"sort_algorithm":"alpha"},"return_type_declaration":true,"short_scalar_cast":true,"single_blank_line_before_namespace":true,"single_import_per_statement":{"group_to_single_imports":false},"single_trait_insert_per_statement":true,"ternary_operator_spaces":true,"visibility_required":true,"blank_line_after_namespace":true,"constant_case":true,"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_keywords":true,"method_argument_space":{"on_multiline":"ensure_fully_multiline","keep_multiple_spaces_after_comma":true},"no_break_comment":true,"no_closing_tag":true,"no_space_around_double_colon":true,"no_spaces_after_function_name":true,"no_spaces_inside_parenthesis":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_class_element_per_statement":{"elements":["property"]},"single_line_after_imports":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"encoding":true,"full_opening_tag":true,"array_syntax":{"syntax":"short"},"no_unused_imports":true,"not_operator_with_successor_space":true,"trailing_comma_in_multiline":true,"phpdoc_scalar":true,"unary_operator_spaces":true,"binary_operator_spaces":true,"blank_line_before_statement":{"statements":["break","continue","declare","return","throw","try"]},"phpdoc_single_line_var_spacing":true,"phpdoc_var_without_name":true,"class_attributes_separation":{"elements":{"method":"one"}}},"hashes":{"src\/SimpleCrmServiceProvider.php":3677119947,"src\/Models\/Enums\/Lead\/LeadStatus.php":3241539491,"src\/Models\/Enums\/Lead\/LeadType.php":853698985,"src\/Models\/Enums\/NoteStatus.php":780172828,"src\/Models\/Enums\/LeadStatus.php":2060495691,"src\/Models\/Enums\/StatusEnum.php":3285058312,"src\/Models\/Enums\/ProjectStatus.php":240630045,"src\/Models\/Enums\/Note\/NotePriority.php":2745883000,"src\/Models\/Service.php":2530960531,"src\/Models\/Note.php":1930907653,"src\/Models\/Lead.php":491474045,"src\/Models\/Project.php":2605385879,"tests\/Pest.php":2378833050,"tests\/Unit\/ServiceTest.php":303507015,"tests\/Models\/User.php":2929405912,"tests\/TestCase.php":610046076}}

database/factories/LeadFactory.php

Lines changed: 14 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,71 +2,58 @@
22

33
namespace Tepuilabs\SimpleCrm\Database\Factories;
44

5-
use Illuminate\Database\Eloquent\Model;
6-
use Tepuilabs\SimpleCrm\Models\Enums\LeadStatus;
75
use Illuminate\Database\Eloquent\Factories\Factory;
6+
use Tepuilabs\SimpleCrm\Models\Enums\Lead\LeadStatus;
7+
use Tepuilabs\SimpleCrm\Models\Enums\Lead\LeadType;
88
use Tepuilabs\SimpleCrm\Models\Lead;
99

1010
class LeadFactory extends Factory
1111
{
1212
/**
13-
* The name of the factory's corresponding model.
14-
*
15-
* @var class-string<Model>
13+
* {@inheritdoc}
1614
*/
1715
protected $model = Lead::class;
1816

1917
/**
20-
* Define the model's default state.
21-
*
22-
* @return array
18+
* {@inheritdoc}
2319
*/
24-
public function definition(): array
20+
public function definition()
2521
{
2622
return [
2723
'name' => $this->faker->name,
2824
'email' => $this->faker->email,
29-
'type' => $this->faker->randomElement([
30-
LeadStatus::ORGANIC_TYPE(),
31-
LeadStatus::USER_SUBMITTED_TYPE(),
32-
]),
33-
'status' => $this->faker->randomElement([
34-
LeadStatus::PROSPECT_STATUS(),
35-
LeadStatus::LEAD_STATUS(),
36-
LeadStatus::CUSTOMER_STATUS(),
37-
]),
3825
];
3926
}
4027

41-
public function typeOrganic()
28+
public function organicType(): LeadFactory
4229
{
4330
return $this->state([
44-
'type' => LeadStatus::ORGANIC_TYPE()
31+
'type' => LeadType::ORGANIC_TYPE(),
4532
]);
4633
}
4734

48-
public function typeUserSubmitted()
35+
public function userSubmittedType(): LeadFactory
4936
{
5037
return $this->state([
51-
'type' => LeadStatus::USER_SUBMITTED_TYPE()
38+
'type' => LeadType::USER_SUBMITTED_TYPE(),
5239
]);
5340
}
5441

55-
public function statusProspect()
42+
public function leadStatus(): LeadFactory
5643
{
5744
return $this->state([
58-
'status' => LeadStatus::PROSPECT_STATUS()
45+
'status' => LeadStatus::LEAD_STATUS()
5946
]);
6047
}
6148

62-
public function statusLead()
49+
public function prospectStatus(): LeadFactory
6350
{
6451
return $this->state([
65-
'status' => LeadStatus::LEAD_STATUS()
52+
'status' => LeadStatus::PROSPECT_STATUS()
6653
]);
6754
}
6855

69-
public function statusCustomer()
56+
public function customerStatus(): LeadFactory
7057
{
7158
return $this->state([
7259
'status' => LeadStatus::CUSTOMER_STATUS()

database/factories/NoteFactory.php

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,61 +3,53 @@
33
namespace Tepuilabs\SimpleCrm\Database\Factories;
44

55
use Illuminate\Database\Eloquent\Factories\Factory;
6-
use Illuminate\Database\Eloquent\Model;
7-
use Tepuilabs\SimpleCrm\Models\Enums\NoteStatus;
6+
use Tepuilabs\SimpleCrm\Models\Enums\Note\NotePriority;
7+
use Tepuilabs\SimpleCrm\Models\Lead;
8+
use Tepuilabs\SimpleCrm\Models\Note;
9+
use Tepuilabs\SimpleCrm\Tests\Models\User;
810

911
class NoteFactory extends Factory
1012
{
1113
/**
12-
* The name of the factory's corresponding model.
13-
*
14-
* @var class-string<Model>
14+
* {@inheritdoc}
1515
*/
16-
protected $model = \Tepuilabs\SimpleCrm\Models\Note::class;
17-
16+
protected $model = Note::class;
1817

1918
/**
20-
* Define the model's default state.
21-
*
22-
* @return array
19+
* {@inheritdoc}
2320
*/
2421
public function definition()
2522
{
26-
$author = \Tepuilabs\SimpleCrm\Tests\Models\User::factory()->create();
27-
$lead = \Tepuilabs\SimpleCrm\Models\Lead::factory()->create();
23+
$author = User::factory()->create();
24+
$lead = Lead::factory()->create();
2825

2926
return [
30-
'title' => $this->faker->word,
31-
'body' => $this->faker->paragraphs(),
32-
'priority' => $this->faker->randomElement([
33-
NoteStatus::LOW_PRIORITY(),
34-
NoteStatus::MEDIUM_PRIORITY(),
35-
NoteStatus::HIGH_PRIORITY(),
36-
]),
27+
'title' => $this->faker->sentence($nbWords = 6, $variableNbWords = true),
28+
'body' => $this->faker->paragraphs($nb = 3, $asText = false),
3729
'lead_id' => $lead->id,
3830
'author_id' => $author->id,
3931
'author_type' => \Tepuilabs\SimpleCrm\Tests\Models\User::class,
4032
];
4133
}
4234

43-
public function priorityLow()
35+
public function lowPriority(): NoteFactory
4436
{
4537
return $this->state([
46-
'priority' => NoteStatus::LOW_PRIORITY()
38+
'priority' => NotePriority::LOW_PRIORITY()
4739
]);
4840
}
4941

50-
public function priorityMedium()
42+
public function mediumPriority(): NoteFactory
5143
{
5244
return $this->state([
53-
'priority' => NoteStatus::MEDIUM_PRIORITY()
45+
'priority' => NotePriority::MEDIUM_PRIORITY()
5446
]);
5547
}
5648

57-
public function priorityHigh()
49+
public function highPriority(): NoteFactory
5850
{
5951
return $this->state([
60-
'priority' => NoteStatus::HIGH_PRIORITY()
52+
'priority' => NotePriority::HIGH_PRIORITY()
6153
]);
6254
}
6355
}

database/factories/ServiceFactory.php

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,28 @@
33
namespace Tepuilabs\SimpleCrm\Database\Factories;
44

55
use Illuminate\Database\Eloquent\Factories\Factory;
6-
use Illuminate\Database\Eloquent\Model;
6+
use Tepuilabs\SimpleCrm\Models\Enums\StatusEnum;
77
use Tepuilabs\SimpleCrm\Models\Service;
88

99
class ServiceFactory extends Factory
1010
{
1111
/**
12-
* The name of the factory's corresponding model.
13-
*
14-
* @var class-string<Model>
12+
* {@inheritdoc}
1513
*/
16-
protected $model = Service::class;
14+
protected $model = Service::class;
1715

1816
/**
19-
* Define the model's default state.
20-
*
21-
* @return array
17+
* {@inheritdoc}
2218
*/
2319
public function definition(): array
2420
{
2521
return [
26-
'name' => $this->faker->sentence(),
27-
'description' => $this->faker->sentence(),
28-
'status' => $this->faker->randomElement(['published', 'draft']),
22+
'name' => $this->faker->sentence(6, true),
23+
'description' => $this->faker->sentence(6, true),
24+
'status' => $this->faker->randomElement([
25+
StatusEnum::PUBLISHED(),
26+
StatusEnum::DRAFT()
27+
]),
2928
];
3029
}
3130
}

database/migrations/create_notes_table.php.stub

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ class CreateNotesTable extends Migration
2020
$table->text('priority');
2121
$table->nullableMorphs('commentable');
2222
$table->nullableMorphs('author');
23+
$table->foreignId('parent_id')
24+
->nullable()
25+
->constrained('comments')
26+
->onDelete('cascade');
2327
$table->timestamps();
2428
$table->softDeletes();
2529
});

database/migrations/create_services_table.php.stub

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class CreateServicesTable extends Migration
1717
$table->id();
1818
$table->string('name')->nullable();
1919
$table->text('description')->nullable();
20-
$table->enum('status', ['published', 'draft'])->default('draft');
20+
$table->enum('status', ['PUBLISHED', 'DRAFT'])->default('DRAFT');
2121
$table->timestamps();
2222
$table->softDeletes();
2323
});
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
namespace Tepuilabs\SimpleCrm\Models\Enums\Lead;
4+
5+
use Spatie\Enum\Laravel\Enum;
6+
7+
/**
8+
* @method static self PROSPECT_STATUS()
9+
* @method static self LEAD_STATUS()
10+
* @method static self CUSTOMER_STATUS()
11+
*/
12+
class LeadStatus extends Enum
13+
{
14+
/**
15+
* @return string
16+
*/
17+
public function label(): string
18+
{
19+
return match ($this->value) {
20+
self::PROSPECT_STATUS()->value => 'prospect',
21+
self::LEAD_STATUS()->value => 'lead',
22+
self::CUSTOMER_STATUS()->value => 'customer',
23+
};
24+
}
25+
}

src/Models/Enums/Lead/LeadType.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
namespace Tepuilabs\SimpleCrm\Models\Enums\Lead;
4+
5+
use Spatie\Enum\Laravel\Enum;
6+
7+
/**
8+
* @method static self ORGANIC_TYPE()
9+
* @method static self USER_SUBMITTED_TYPE()
10+
*/
11+
class LeadType extends Enum
12+
{
13+
/**
14+
* @return string
15+
*/
16+
public function label(): string
17+
{
18+
return match ($this->value) {
19+
self::ORGANIC_TYPE()->value => 'organic',
20+
self::USER_SUBMITTED_TYPE()->value => 'user submitted',
21+
};
22+
}
23+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
namespace Tepuilabs\SimpleCrm\Models\Enums\Note;
4+
5+
use Spatie\Enum\Laravel\Enum;
6+
7+
/**
8+
* @method static self LOW_PRIORITY()
9+
* @method static self MEDIUM_PRIORITY()
10+
* @method static self HIGH_PRIORITY()
11+
*/
12+
class NotePriority extends Enum
13+
{
14+
/**
15+
* @return string
16+
*/
17+
public function label(): string
18+
{
19+
return match ($this->value) {
20+
self::LOW_PRIORITY()->value => 'low',
21+
self::MEDIUM_PRIORITY()->value => 'medium',
22+
self::HIGH_PRIORITY()->value => 'high',
23+
};
24+
}
25+
}

0 commit comments

Comments
 (0)