customer seeder

pull/25/head
A1Gard 1 year ago
parent eb3d852dae
commit 8cdd2d92b7

@ -2,6 +2,8 @@
namespace Database\Factories; namespace Database\Factories;
use App\Models\Address;
use App\Models\Customer;
use Illuminate\Database\Eloquent\Factories\Factory; use Illuminate\Database\Eloquent\Factories\Factory;
/** /**
@ -16,8 +18,21 @@ class CustomerFactory extends Factory
*/ */
public function definition() public function definition()
{ {
$state = rand(1,31);
$k = array_keys(Address::$cities[$state]);
shuffle($k);
return [ return [
// //
'name' => $this->faker->name,
'address' => $this->faker->address,
'mobile' => '0912'.rand(1111111,9999999),
'email' => $this->faker->unique()->email,
'state' => $state,
'city' => $k[0],
'password' => bcrypt('password'),
'credit' => 0,
]; ];
} }
} }

@ -0,0 +1,21 @@
<?php
namespace Database\Seeders;
use App\Models\Customer;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
class CustomerSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
//
Customer::factory(5)->create();
}
}

@ -2,6 +2,7 @@
namespace Database\Seeders; namespace Database\Seeders;
use App\Models\Customer;
use Illuminate\Database\Console\Seeds\WithoutModelEvents; use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder; use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\Storage;
@ -32,6 +33,7 @@ class DatabaseSeeder extends Seeder
UserSeeder::class, UserSeeder::class,
CategorySeeder::class, CategorySeeder::class,
CatSeeder::class, CatSeeder::class,
CustomerSeeder::class,
PostSeeder::class, PostSeeder::class,
MenuSeeder::class, MenuSeeder::class,
PropSeeder::class, PropSeeder::class,

Loading…
Cancel
Save