Skip to content

Commit

Permalink
feat: added user-seeder for test data
Browse files Browse the repository at this point in the history
  • Loading branch information
stevan06v committed Mar 19, 2024
1 parent 511e857 commit 72d5f33
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 18 deletions.
4 changes: 2 additions & 2 deletions .env.dev.example
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ DB_DATABASE=propromo
DB_USERNAME=postgres
DB_PASSWORD=propromo

GITHUB_CLIENT_ID=b6e2c09ada28dae5186e
GITHUB_CLIENT_SECRET=ff191c19a886b5e159e7882d0511d6e217f37d9a
GITHUB_CLIENT_ID=9d2af66c97afc82f98cf
GITHUB_CLIENT_SECRET=71450e2badc04cc23c114e2d1b8f050377c16873
GITHUB_CALLBACK_URI=http://propromo.test/auth/github/callback

BROADCAST_DRIVER=log
Expand Down
4 changes: 2 additions & 2 deletions .env.docker.example
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ DB_DATABASE=propromo
DB_USERNAME=postgres
DB_PASSWORD=propromo

GITHUB_CLIENT_ID=b6e2c09ada28dae5186e
GITHUB_CLIENT_SECRET=ff191c19a886b5e159e7882d0511d6e217f37d9a
GITHUB_CLIENT_ID=9d2af66c97afc82f98cf
GITHUB_CLIENT_SECRET=71450e2badc04cc23c114e2d1b8f050377c16873
GITHUB_CALLBACK_URI=http://propromo.test/auth/github/callback

BROADCAST_DRIVER=log
Expand Down
4 changes: 2 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ DB_DATABASE=propromo
DB_USERNAME=postgres
DB_PASSWORD=propromo

GITHUB_CLIENT_ID=b6e2c09ada28dae5186e
GITHUB_CLIENT_SECRET=ff191c19a886b5e159e7882d0511d6e217f37d9a
GITHUB_CLIENT_ID=9d2af66c97afc82f98cf
GITHUB_CLIENT_SECRET=71450e2badc04cc23c114e2d1b8f050377c16873
GITHUB_CALLBACK_URI=http://propromo.test/auth/github/callback

BROADCAST_DRIVER=log
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?php

namespace App\Http\Controllers;
namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use App\Models\User;
use Exception;
use Illuminate\Support\Facades\Auth;
Expand Down
4 changes: 4 additions & 0 deletions database/factories/UserFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,15 @@ class UserFactory extends Factory
*/
public function definition(): array
{
$auth_type = $this->faker->randomElement(["GITHUB", "PROPROMO"]);

return [
'name' => fake()->name(),
'email' => fake()->unique()->safeEmail(),
'email_verified_at' => now(),
'password' => static::$password ??= Hash::make('password'),
'auth_type' => $auth_type,
'github_id' => $auth_type == 'GITHUB' ? $this->faker->randomAscii() : null,
'remember_token' => Str::random(10),
];
}
Expand Down
9 changes: 3 additions & 6 deletions database/seeders/DatabaseSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,8 @@ class DatabaseSeeder extends Seeder
*/
public function run(): void
{
// \App\Models\User::factory(10)->create();

// \App\Models\User::factory()->create([
// 'name' => 'Test User',
// 'email' => '[email protected]',
// ]);
$this->call([
UserSeeder::class
]);
}
}
20 changes: 20 additions & 0 deletions database/seeders/UserSeeder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace Database\Seeders;

use App\Models\User;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;

class UserSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
User::factory()
->count(10)
->create();
}
}
1 change: 0 additions & 1 deletion resources/views/livewire/home/join-monitor-form.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ public function submit()
try {
$monitor = $this->join_monitor($this->monitor_hash);
return redirect('/monitors/' . $monitor->id);
} catch (Exception $e) {
$this->join_monitor_error = $e->getMessage();
$this->error_head = "Seems like something went wrong...";
Expand Down
6 changes: 2 additions & 4 deletions routes/web.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

use App\Http\Controllers\GithubController;
use App\Http\Controllers\Auth\GithubController;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Redirect;
use Livewire\Volt\Volt;
use Illuminate\Support\Facades\Route;
use Livewire\Volt\Volt;

Volt::route('/', '/home/index')->name('home.index');

Expand All @@ -18,11 +18,9 @@
Route::get('/auth/github', [GithubController::class,'redirect'])->name('github.login');
Route::get('/auth/github/callback', [GithubController::class,'callback']);


Volt::route('/monitors', 'monitors.index');
Volt::route('/monitors/{monitor}', 'monitors.show');


Volt::route('/create-monitor', 'auth.create-monitor');
Volt::route('/join', 'auth.join-monitor');
Volt::route('/register', 'auth.register');
Expand Down

0 comments on commit 72d5f33

Please sign in to comment.