Repository: laravel-shift/blueprint (php)

Issue:
SoftDeletes Issue
<!-- PLEASE COMPLETE THIS TEMPLATE -->

- Laravel Version: 8.0
- PHP Version: 8.0
- Blueprint Version: 2.2
- Platform: Mac

### Issue:
softDeletes issue on model factory still treats it as string.
<img width="814" alt="Screen Shot 2022-02-16 at 11 04 33 AM" src="https://user-images.githubusercontent.com/62448059/154188301-4d913ff1-522c-4c9e-905b-1ee844af3965.png">


### draft.yaml:
```yaml
# PLEASE PASTE THE DRAFT FILE WHICH REPRODUCES THE ISSUE HERE...
```
Address:
    client_id: unsignedBigInteger foreign:clients
    street: string
    region_id: unsignedInteger
    province_id: unsignedInteger
    city_id: unsignedInteger
    barangay_id: unsignedInteger
    zip_code: unsignedInteger min:3 max:4
    user_id: unsignedBigInteger nullable foreign:users
    type: enum:primary,billing,user default:primary
    softDeletes


Pull request description:
Fix literal `softdeletes` field
Closes #546

Patch:
diff --git a/src/Generators/FactoryGenerator.php b/src/Generators/FactoryGenerator.php
index 19cec10..06b719d 100644
--- a/src/Generators/FactoryGenerator.php
+++ b/src/Generators/FactoryGenerator.php
@@ -75,7 +75,7 @@ class FactoryGenerator extends AbstractClassGenerator implements Generator
          * @var \Blueprint\Models\Column $column
          */
         foreach ($fillable as $column) {
-            if ($column->name() === 'id') {
+            if (in_array($column->name(), ['id', 'softdeletes', 'softdeletestz'])) {
                 continue;
             }
 
@@ -185,6 +185,10 @@ class FactoryGenerator extends AbstractClassGenerator implements Generator
             }
         }
 
+        if (empty($definition)) {
+            return '//';
+        }
+
         return trim($definition);
     }
 
@@ -194,10 +198,15 @@ class FactoryGenerator extends AbstractClassGenerator implements Generator
             return $columns;
         }
 
-        return array_filter(
+        $nonNullableColumns = array_filter(
             $columns,
             fn (Column $column) => !in_array('nullable', $column->modifiers())
         );
+
+        return array_filter(
+            $nonNullableColumns,
+            fn (Column $column) => $column->dataType() !== 'softDeletes'
+        );
     }
 
     private function fullyQualifyModelReference(string $model_name)


Test patch:
diff --git a/tests/Feature/Generators/FactoryGeneratorTest.php b/tests/Feature/Generators/FactoryGeneratorTest.php
index 3380c73..f1f93ba 100644
--- a/tests/Feature/Generators/FactoryGeneratorTest.php
+++ b/tests/Feature/Generators/FactoryGeneratorTest.php
@@ -5,7 +5,6 @@ namespace Tests\Feature\Generators;
 use Blueprint\Blueprint;
 use Blueprint\Generators\FactoryGenerator;
 use Blueprint\Tree;
-use Illuminate\Support\Facades\App;
 use Tests\TestCase;
 
 /**
@@ -215,6 +214,7 @@ class FactoryGeneratorTest extends TestCase
             ['drafts/resource-statements.yaml', 'database/factories/UserFactory.php', 'factories/resource-statements.php'],
             ['drafts/factory-smallint-and-tinyint.yaml', 'database/factories/ModelFactory.php', 'factories/factory-smallint-and-tinyint.php'],
             ['drafts/all-column-types.yaml', 'database/factories/AllTypeFactory.php', 'factories/all-column-types.php'],
+            ['drafts/shorthands.yaml', 'database/factories/NameFactory.php', 'factories/shorthands.php'],
         ];
     }
 }
diff --git a/tests/fixtures/factories/shorthands.php b/tests/fixtures/factories/shorthands.php
new file mode 100644
index 0000000..c60a338
--- /dev/null
+++ b/tests/fixtures/factories/shorthands.php
@@ -0,0 +1,29 @@
+<?php
+
+namespace Database\Factories;
+
+use Illuminate\Database\Eloquent\Factories\Factory;
+use Illuminate\Support\Str;
+use App\Models\Name;
+
+class NameFactory extends Factory
+{
+    /**
+     * The name of the factory's corresponding model.
+     *
+     * @var string
+     */
+    protected $model = Name::class;
+
+    /**
+     * Define the model's default state.
+     *
+     * @return array
+     */
+    public function definition()
+    {
+        return [
+            //
+        ];
+    }
+}