This commit is contained in:
2023-11-27 08:29:48 +10:00
parent c432b32d08
commit 0772010119
195 changed files with 7153 additions and 9787 deletions

View File

@@ -3,6 +3,7 @@
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Str;
/**
@@ -10,6 +11,8 @@ use Illuminate\Support\Str;
*/
class UserFactory extends Factory
{
protected static ?string $password;
/**
* Define the model's default state.
*
@@ -17,23 +20,13 @@ class UserFactory extends Factory
*/
public function definition(): array
{
$faker = \Faker\Factory::create();
$faker->addProvider(new \Faker\Provider\CustomInternetProvider($faker));
$first_name = $faker->firstName();
$last_name = $faker->lastName();
$display_name = $first_name . ' ' . $last_name;
return [
'first_name' => $first_name,
'last_name' => $last_name,
'email' => $faker->safeEmail(),
'username' => fake()->name(),
'is_under_14' => fake()->randomElement([0, 1]),
'email' => fake()->unique()->safeEmail(),
'email_verified_at' => now(),
'phone' => $faker->phoneNumber(),
'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password
'password' => static::$password ??= Hash::make('password'),
'remember_token' => Str::random(10),
'display_name' => $display_name,
];
}

View File

@@ -0,0 +1,49 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\User>
*/
class UserFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
$faker = \Faker\Factory::create();
$faker->addProvider(new \Faker\Provider\CustomInternetProvider($faker));
$first_name = $faker->firstName();
$last_name = $faker->lastName();
$display_name = $first_name . ' ' . $last_name;
return [
'first_name' => $first_name,
'last_name' => $last_name,
'email' => $faker->safeEmail(),
'email_verified_at' => now(),
'phone' => $faker->phoneNumber(),
'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password
'remember_token' => Str::random(10),
'display_name' => $display_name,
];
}
/**
* Indicate that the model's email address should be unverified.
*/
public function unverified(): static
{
return $this->state(fn (array $attributes) => [
'email_verified_at' => null,
]);
}
}

View File

@@ -0,0 +1,33 @@
<?php
namespace Database\Factories;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Workshop>
*/
class WorkshopFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
$startDate = Carbon::parse($this->faker->dateTimeBetween('now', '+1 year'));
$endDate = Carbon::parse($this->faker->dateTimeBetween($startDate, '+1 year'));
$publishDate = Carbon::parse($this->faker->dateTimeBetween('-1 month', '+1 month'));
return [
'title' => $this->faker->sentence(),
'start_at' => $startDate,
'end_at' => $endDate,
'publish_at' => $publishDate,
'status' => $this->faker->randomElement(['draft', 'soon', 'open', 'closed', 'cancelled']),
'content' => $this->faker->paragraphs(3, true),
];
}
}

View File

@@ -12,15 +12,12 @@ return new class extends Migration
public function up(): void
{
Schema::create('users', function (Blueprint $table) {
$table->uuid('id')->primary();
$table->id();
$table->string('username')->unique();
$table->string('password')->nullable();
$table->boolean('enabled')->default(true);
$table->string('first_name');
$table->string('last_name');
$table->string('email');
$table->string('email')->nullable();
$table->timestamp('email_verified_at')->nullable();
$table->string('phone')->nullable();
$table->boolean('is_under_14')->nullable();
$table->string('password');
$table->rememberToken();
$table->timestamps();
});

View File

@@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('password_reset_tokens', function (Blueprint $table) {
$table->string('email')->primary();
$table->string('token');
$table->timestamp('created_at')->nullable();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('password_reset_tokens');
}
};

View File

@@ -13,7 +13,7 @@ return new class extends Migration
{
Schema::create('personal_access_tokens', function (Blueprint $table) {
$table->id();
$table->uuidMorphs('tokenable');
$table->morphs('tokenable');
$table->string('name');
$table->string('token', 64)->unique();
$table->text('abilities')->nullable();

View File

@@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('workshops', function (Blueprint $table) {
$table->id();
$table->string('title');
$table->timestamp('start_at')->useCurrent();
$table->timestamp('end_at')->useCurrent();
$table->timestamp('publish_at')->useCurrent()->nullable();
$table->string('status')->default('draft');
$table->text('content')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('workshops');
}
};

View File

@@ -0,0 +1,27 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('posts', function (Blueprint $table) {
$table->id();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('posts');
}
};

View File

@@ -0,0 +1,27 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('media', function (Blueprint $table) {
$table->id();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('media');
}
};

View File

@@ -0,0 +1,30 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('verification_codes', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->constrained()->onDelete('cascade');
$table->char('code', 6)->unique();
$table->string('type');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('verification_codes');
}
};

View File

@@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('jobs', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('queue')->index();
$table->longText('payload');
$table->unsignedTinyInteger('attempts');
$table->unsignedInteger('reserved_at')->nullable();
$table->unsignedInteger('available_at');
$table->unsignedInteger('created_at');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('jobs');
}
};

View File

@@ -3,10 +3,7 @@
namespace Database\Seeders;
// use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Carbon\Carbon;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\Hash;
class DatabaseSeeder extends Seeder
{
@@ -15,16 +12,14 @@ class DatabaseSeeder extends Seeder
*/
public function run(): void
{
\App\Models\User::factory(40)->create();
\App\Models\User::factory(10)->create();
\App\Models\User::factory()->create([
'display_name' => 'James Collins',
'first_name' => 'James',
'last_name' => 'Collins',
'email' => 'james@stemmechanics.com.au',
'email_verified_at' => Carbon::now(),
'phone' => '0400 130 190',
'password' => Hash::make('password@12')
'username' => 'admin',
'email' => 'admin@example.com',
'is_under_14' => 0
]);
\App\Models\Workshop::factory(10)->create();
}
}

View File

@@ -0,0 +1,30 @@
<?php
namespace Database\Seeders;
// use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Carbon\Carbon;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\Hash;
class DatabaseSeeder extends Seeder
{
/**
* Seed the application's database.
*/
public function run(): void
{
\App\Models\User::factory(40)->create();
\App\Models\User::factory()->create([
'display_name' => 'James Collins',
'first_name' => 'James',
'last_name' => 'Collins',
'email' => 'james@stemmechanics.com.au',
'email_verified_at' => Carbon::now(),
'phone' => '0400 130 190',
'password' => Hash::make('password@12')
]);
}
}