Add migrations and seeders support

This commit is contained in:
2021-01-14 14:16:52 +03:00
parent d12744296a
commit cb1f3a6bb5
15 changed files with 196 additions and 311 deletions

View File

@@ -1,29 +0,0 @@
<?php
namespace Database\Factories;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
class UserFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = User::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [
'name' => $this->faker->name,
'email' => $this->faker->unique()->safeEmail,
];
}
}

View File

@@ -2,6 +2,7 @@
namespace Database\Seeders;
use App\Helpers\ClassHelper;
use Illuminate\Database\Seeder;
class DatabaseSeeder extends Seeder
@@ -13,6 +14,14 @@ class DatabaseSeeder extends Seeder
*/
public function run()
{
// $this->call('UsersTableSeeder');
$seeders_path = base_path() . '/../database/seeders';
if(file_exists($seeders_path)) {
$files = array_diff(scandir($seeders_path), array('.', '..'));
foreach ($files as $file) {
$this->call(ClassHelper::extract($seeders_path . '/' . $file));
}
}
}
}