mirror of
https://github.com/Aviortheking/CA_LARAVEL.git
synced 2025-07-29 22:29:51 +00:00
fix migration && add seeder && add is_admin
This commit is contained in:
@ -1,36 +1,73 @@
|
||||
<?php
|
||||
|
||||
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
|
||||
|
||||
class CreateUsersTable extends Migration
|
||||
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('users', function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->string('name');
|
||||
$table->string('email')->unique();
|
||||
$table->timestamp('email_verified_at')->nullable();
|
||||
$table->string('password');
|
||||
$table->rememberToken();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
|
||||
* Run the migrations.
|
||||
|
||||
*
|
||||
|
||||
* @return void
|
||||
|
||||
*/
|
||||
public function down()
|
||||
|
||||
public function up()
|
||||
|
||||
{
|
||||
Schema::dropIfExists('users');
|
||||
|
||||
Schema::create('users', function (Blueprint $table) {
|
||||
|
||||
$table->bigIncrements('id');
|
||||
|
||||
$table->string('name');
|
||||
|
||||
$table->string('email');
|
||||
|
||||
// $table->timestamp('email_verified_at')->nullable();
|
||||
|
||||
$table->boolean('is_admin')->nullable();
|
||||
|
||||
$table->string('password');
|
||||
|
||||
$table->rememberToken();
|
||||
|
||||
$table->timestamps();
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
* Reverse the migrations.
|
||||
|
||||
*
|
||||
|
||||
* @return void
|
||||
|
||||
*/
|
||||
|
||||
public function down()
|
||||
|
||||
{
|
||||
|
||||
Schema::dropIfExists('users');
|
||||
|
||||
}
|
||||
|
||||
}
|
67
database/seeds/CreateUsersSeeder.php
Normal file
67
database/seeds/CreateUsersSeeder.php
Normal file
@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
use App\User;
|
||||
|
||||
|
||||
|
||||
class CreateUsersSeeder extends Seeder
|
||||
|
||||
{
|
||||
|
||||
/**
|
||||
|
||||
* Run the database seeds.
|
||||
|
||||
*
|
||||
|
||||
* @return void
|
||||
|
||||
*/
|
||||
|
||||
public function run()
|
||||
|
||||
{
|
||||
|
||||
$user = [
|
||||
|
||||
[
|
||||
|
||||
'name'=>'Admin',
|
||||
|
||||
'email'=>'admin@admin.fr',
|
||||
|
||||
'is_admin'=>'1',
|
||||
|
||||
'password'=> bcrypt('123456'),
|
||||
|
||||
],
|
||||
|
||||
[
|
||||
|
||||
'name'=>'User',
|
||||
|
||||
'email'=>'user@itsolutionstuff.com',
|
||||
|
||||
'is_admin'=>'0',
|
||||
|
||||
'password'=> bcrypt('123456'),
|
||||
|
||||
],
|
||||
|
||||
];
|
||||
|
||||
|
||||
|
||||
foreach ($user as $key => $value) {
|
||||
|
||||
User::create($value);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user