Skip to content

Commit e1cb17a

Browse files
committed
database tables ready and getting token auth/login route
1 parent cc1015d commit e1cb17a

5 files changed

Lines changed: 44 additions & 2 deletions

File tree

app/Providers/AppServiceProvider.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace App\Providers;
44

55
use Illuminate\Support\ServiceProvider;
6+
use Illuminate\Support\Facades\Schema;
67

78
class AppServiceProvider extends ServiceProvider
89
{
@@ -15,4 +16,8 @@ public function register()
1516
{
1617
$this->app->register(\Tymon\JWTAuth\Providers\LumenServiceProvider::class);
1718
}
19+
public function boot()
20+
{
21+
Schema::defaultStringLength(191);
22+
}
1823
}

database/factories/UserFactory.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
/*
4+
|--------------------------------------------------------------------------
5+
| Model Factories
6+
|--------------------------------------------------------------------------
7+
|
8+
| Here you may define all of your model factories. Model factories give
9+
| you a convenient way to create models for testing and seeding your
10+
| database. Just tell the factory how a default model should look.
11+
|
12+
*/
13+
14+
$factory->define(App\User::class, function (Faker\Generator $faker) {
15+
return [
16+
'name' => $faker->name,
17+
'email' => $faker->safeEmail,
18+
'password' => app('hash')->make(123456)
19+
];
20+
});

database/migrations/2018_06_21_000223_create_users_table.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ public function up()
1515
{
1616
Schema::create('users', function (Blueprint $table) {
1717
$table->increments('id');
18+
$table->string('name');
19+
$table->string('email')->unique();
20+
$table->string('password');
1821
$table->timestamps();
1922
});
2023
}

database/seeds/DatabaseSeeder.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22

33
use Illuminate\Database\Seeder;
4-
4+
use Illuminate\Database\Eloquent\Model;
55
class DatabaseSeeder extends Seeder
66
{
77
/**
@@ -11,6 +11,8 @@ class DatabaseSeeder extends Seeder
1111
*/
1212
public function run()
1313
{
14-
// $this->call('UsersTableSeeder');
14+
Model::unguard();
15+
$this->call('UsersTableSeeder');
16+
Model::reguard();
1517
}
1618
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
use App\User;
4+
use Illuminate\Database\Seeder;
5+
6+
Class UsersTableSeeder extends Seeder {
7+
8+
9+
public function run() {
10+
factory(User::class, 10)->create();
11+
}
12+
}

0 commit comments

Comments
 (0)