Skip to content

Commit e4670b9

Browse files
author
angel cruz
committed
Fixed what needed fixing and squished some bugs. 🐛
1 parent 2e4f2c3 commit e4670b9

File tree

7 files changed

+127
-1
lines changed

7 files changed

+127
-1
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
namespace Tepuilabs\SimpleCrm\Database\Factories;
4+
5+
use Illuminate\Database\Eloquent\Factories\Factory;
6+
7+
class ServiceFactory extends Factory
8+
{
9+
/**
10+
* The name of the factory's corresponding model.
11+
*
12+
* @var string
13+
*/
14+
protected $model = \Tepuilabs\SimpleCrm\Tests\Models\Service::class;
15+
16+
/**
17+
* Define the model's default state.
18+
*
19+
* @return array
20+
*/
21+
public function definition()
22+
{
23+
return [
24+
'name' => $this->faker->sentence($nbWords = 6, $variableNbWords = true),
25+
'description' => $this->faker->sentence($nbWords = 6, $variableNbWords = true),
26+
'status' => $this->faker->randomElement(['published', 'draft']),
27+
];
28+
}
29+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
class CreateServicesTable extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*
12+
* @return void
13+
*/
14+
public function up()
15+
{
16+
Schema::create('services', function (Blueprint $table) {
17+
$table->id();
18+
$table->string('name')->nullable();
19+
$table->text('description')->nullable();
20+
$table->enum('status', ['published', 'draft'])->default('draft');
21+
$table->timestamps();
22+
$table->softDeletes();
23+
});
24+
}
25+
26+
/**
27+
* Reverse the migrations.
28+
*
29+
* @return void
30+
*/
31+
public function down()
32+
{
33+
Schema::dropIfExists('services');
34+
}
35+
}

models/Service.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
namespace App\Models\Tepuilabs\SimpleCrm;
4+
5+
use Illuminate\Database\Eloquent\Factories\HasFactory;
6+
use Illuminate\Database\Eloquent\Model;
7+
8+
class Service extends Model
9+
{
10+
use HasFactory;
11+
12+
/**
13+
* The attributes that are mass assignable.
14+
*
15+
* @var array
16+
*/
17+
protected $fillable = [
18+
'name',
19+
'description',
20+
'status',
21+
];
22+
}

src/SimpleCrmServiceProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ class SimpleCrmServiceProvider extends ServiceProvider
99
public function boot(): void
1010
{
1111
if ($this->app->runningInConsole()) {
12-
1312
$this->publishes([
1413
__DIR__ . '/../models' => app_path('Models/Tepuilabs/SimpleCrm'),
1514
], 'simple-crm-models');
1615

1716
$migrationFileNames = [
1817
'create_leads_table.php',
1918
'create_notes_table.php',
19+
'create_services_table.php',
2020
];
2121

2222
foreach ($migrationFileNames as $key) {

tests/Models/Service.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
namespace Tepuilabs\SimpleCrm\Tests\Models;
4+
5+
use Illuminate\Database\Eloquent\Factories\HasFactory;
6+
use Illuminate\Database\Eloquent\Model;
7+
8+
class Service extends Model
9+
{
10+
use HasFactory;
11+
12+
/**
13+
* The attributes that are mass assignable.
14+
*
15+
* @var array
16+
*/
17+
protected $fillable = [
18+
'name',
19+
'description',
20+
'status',
21+
];
22+
}

tests/TestCase.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,12 @@ public function getEnvironmentSetUp($app)
3636

3737
include_once __DIR__.'/../database/migrations/create_leads_table.php.stub';
3838
include_once __DIR__.'/../database/migrations/create_notes_table.php.stub';
39+
include_once __DIR__.'/../database/migrations/create_services_table.php.stub';
3940
include_once __DIR__.'/database/migrations/create_users_table.php.stub';
4041

4142
(new \CreateUsersTable())->up();
4243
(new \CreateLeadsTable())->up();
4344
(new \CreateNotesTable())->up();
45+
(new \CreateServicesTable())->up();
4446
}
4547
}

tests/Unit/ServiceTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
namespace Tepuilabs\SimpleCrm\Tests\Unit;
4+
5+
use Tepuilabs\SimpleCrm\Tests\TestCase;
6+
7+
class ServiceTest extends TestCase
8+
{
9+
/** @test */
10+
public function test_it_can_create_services()
11+
{
12+
$service = \Tepuilabs\SimpleCrm\Tests\Models\Service::factory()->create();
13+
14+
$this->assertInstanceOf(\Tepuilabs\SimpleCrm\Tests\Models\Service::class, $service);
15+
}
16+
}

0 commit comments

Comments
 (0)