Skip to content

Commit

Permalink
feat: Added Admin factory for the seeding
Browse files Browse the repository at this point in the history
* php artisan make:factory Admin
  • Loading branch information
ahmadhuss committed May 10, 2021
1 parent 1913553 commit 28c11e9
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
34 changes: 34 additions & 0 deletions database/factories/AdminFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

namespace Database\Factories;

use App\Models\Admin;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Str;

class AdminFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Admin::class;

/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [
'name' => 'Admin',
'email' => 'admin@admin.com',
'email_verified_at' => now(),
'password' => Hash::make('password'),
'remember_token' => Str::random(10),
];
}
}
3 changes: 2 additions & 1 deletion database/seeders/DatabaseSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Database\Seeders;

use App\Models\Admin;
use Illuminate\Database\Seeder;

class DatabaseSeeder extends Seeder
Expand All @@ -13,6 +14,6 @@ class DatabaseSeeder extends Seeder
*/
public function run()
{
// \App\Models\User::factory(10)->create();
Admin::factory()->create();
}
}

0 comments on commit 28c11e9

Please sign in to comment.