diff --git a/database/factories/AuthCodeFactory.php b/database/factories/AuthCodeFactory.php new file mode 100644 index 00000000..6dc7d4f6 --- /dev/null +++ b/database/factories/AuthCodeFactory.php @@ -0,0 +1,29 @@ + + */ + protected $model = AuthCode::class; + + /** + * Define the model's default state. + */ + public function definition(): array + { + return [ + 'code' => mt_rand(100000, 999999), + 'expires_at' => Date::now()->addMinutes(5), + ]; + } +} diff --git a/src/Models/AuthCode.php b/src/Models/AuthCode.php index 283a525f..aaaa4cbd 100644 --- a/src/Models/AuthCode.php +++ b/src/Models/AuthCode.php @@ -2,9 +2,11 @@ namespace Cone\Root\Models; +use Cone\Root\Database\Factories\AuthCodeFactory; use Cone\Root\Interfaces\Models\AuthCode as Contract; use Cone\Root\Traits\InteractsWithProxy; use Illuminate\Database\Eloquent\Builder; +use Illuminate\Database\Eloquent\Factories\Factory; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; @@ -47,6 +49,14 @@ public static function getProxiedInterface(): string return Contract::class; } + /** + * Create a new factory instance for the model. + */ + protected static function newFactory(): Factory + { + return AuthCodeFactory::new(); + } + /** * Get the user for the model. */