first commit;
tests / ci (push) Canceled after 0s

This commit is contained in:
2026-09-17 23:01:26 -07:00
commit 1e8ae3d1e5
137 changed files with 24339 additions and 0 deletions
+1
View File
@@ -0,0 +1 @@
*.sqlite*
+38
View File
@@ -0,0 +1,38 @@
<?php
namespace Database\Factories;
use App\Models\Folder;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends Factory<Folder>
*/
class FolderFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'user_id' => User::factory(),
'name' => fake()->unique()->words(2, true),
'parent_id' => null,
];
}
/**
* Indicate that the folder belongs under the given parent folder.
*/
public function childOf(Folder $folder): static
{
return $this->state(fn (array $attributes) => [
'parent_id' => $folder->id,
'user_id' => $folder->user_id,
]);
}
}
+82
View File
@@ -0,0 +1,82 @@
<?php
namespace Database\Factories;
use App\Models\Folder;
use App\Models\Todo;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends Factory<Todo>
*/
class TodoFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'user_id' => User::factory(),
'folder_id' => Folder::factory(),
'description' => fake()->sentence(6),
'due_date' => today()->addDays(5),
'completed_at' => null,
];
}
/**
* Indicate that the todo has no due date.
*/
public function noDueDate(): static
{
return $this->state(fn (array $attributes) => [
'due_date' => null,
]);
}
/**
* Indicate that the todo has notes.
*/
public function withNotes(): static
{
return $this->state(fn (array $attributes) => [
'notes' => fake()->paragraph(),
]);
}
/**
* Indicate that the todo has been completed.
*/
public function completed(): static
{
return $this->state(fn (array $attributes) => [
'completed_at' => now(),
]);
}
/**
* Indicate that the todo is overdue.
*/
public function overdue(): static
{
return $this->state(fn (array $attributes) => [
'due_date' => today()->subDays(3),
'completed_at' => null,
]);
}
/**
* Indicate that the todo is due today and still open.
*/
public function dueToday(): static
{
return $this->state(fn (array $attributes) => [
'due_date' => today(),
'completed_at' => null,
]);
}
}
+80
View File
@@ -0,0 +1,80 @@
<?php
namespace Database\Factories;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Str;
/**
* @extends Factory<User>
*/
class UserFactory extends Factory
{
/**
* The current password being used by the factory.
*/
protected static ?string $password;
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'name' => fake()->name(),
'email' => fake()->unique()->safeEmail(),
'email_verified_at' => now(),
'password' => static::$password ??= Hash::make('password'),
'remember_token' => Str::random(10),
'two_factor_secret' => null,
'two_factor_recovery_codes' => null,
'two_factor_confirmed_at' => null,
];
}
/**
* Indicate that the model's email address should be unverified.
*/
public function unverified(): static
{
return $this->state(fn (array $attributes) => [
'email_verified_at' => null,
]);
}
/**
* Indicate that the user is an administrator.
*/
public function asAdmin(): static
{
return $this->state(fn (array $attributes) => [
'is_admin' => true,
]);
}
/**
* Set the maximum length allowed for the user's todo notes.
*/
public function withNotesLimit(int $limit): static
{
return $this->state(fn (array $attributes) => [
'notes_limit' => $limit,
]);
}
/**
* Indicate that the model has two-factor authentication configured.
*/
public function withTwoFactor(): static
{
return $this->state(fn (array $attributes) => [
'two_factor_secret' => encrypt('secret'),
'two_factor_recovery_codes' => encrypt(json_encode(['recovery-code-1'])),
'two_factor_confirmed_at' => now(),
]);
}
}
@@ -0,0 +1,49 @@
<?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('users', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->rememberToken();
$table->timestamps();
});
Schema::create('password_reset_tokens', function (Blueprint $table) {
$table->string('email')->primary();
$table->string('token');
$table->timestamp('created_at')->nullable();
});
Schema::create('sessions', function (Blueprint $table) {
$table->string('id')->primary();
$table->foreignId('user_id')->nullable()->index();
$table->string('ip_address', 45)->nullable();
$table->text('user_agent')->nullable();
$table->longText('payload');
$table->integer('last_activity')->index();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('users');
Schema::dropIfExists('password_reset_tokens');
Schema::dropIfExists('sessions');
}
};
@@ -0,0 +1,35 @@
<?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('cache', function (Blueprint $table) {
$table->string('key')->primary();
$table->mediumText('value');
$table->bigInteger('expiration')->index();
});
Schema::create('cache_locks', function (Blueprint $table) {
$table->string('key')->primary();
$table->string('owner');
$table->bigInteger('expiration')->index();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('cache');
Schema::dropIfExists('cache_locks');
}
};
@@ -0,0 +1,59 @@
<?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->id();
$table->string('queue')->index();
$table->longText('payload');
$table->unsignedSmallInteger('attempts');
$table->unsignedInteger('reserved_at')->nullable();
$table->unsignedInteger('available_at');
$table->unsignedInteger('created_at');
});
Schema::create('job_batches', function (Blueprint $table) {
$table->string('id')->primary();
$table->string('name');
$table->integer('total_jobs');
$table->integer('pending_jobs');
$table->integer('failed_jobs');
$table->longText('failed_job_ids');
$table->mediumText('options')->nullable();
$table->integer('cancelled_at')->nullable();
$table->integer('created_at');
$table->integer('finished_at')->nullable();
});
Schema::create('failed_jobs', function (Blueprint $table) {
$table->id();
$table->string('uuid')->unique();
$table->string('connection');
$table->string('queue');
$table->longText('payload');
$table->longText('exception');
$table->timestamp('failed_at')->useCurrent();
$table->index(['connection', 'queue', 'failed_at']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('jobs');
Schema::dropIfExists('job_batches');
Schema::dropIfExists('failed_jobs');
}
};
@@ -0,0 +1,34 @@
<?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('passkeys', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
$table->string('name');
$table->string('credential_id')->unique();
$table->json('credential');
$table->timestamp('last_used_at')->nullable();
$table->timestamps();
$table->index('user_id');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('passkeys');
}
};
@@ -0,0 +1,34 @@
<?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::table('users', function (Blueprint $table) {
$table->text('two_factor_secret')->after('password')->nullable();
$table->text('two_factor_recovery_codes')->after('two_factor_secret')->nullable();
$table->timestamp('two_factor_confirmed_at')->after('two_factor_recovery_codes')->nullable();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn([
'two_factor_secret',
'two_factor_recovery_codes',
'two_factor_confirmed_at',
]);
});
}
};
@@ -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('folders', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
$table->string('name');
$table->foreignId('parent_id')->nullable()->constrained('folders')->cascadeOnDelete();
$table->timestamps();
$table->index(['user_id', 'parent_id']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('folders');
}
};
@@ -0,0 +1,35 @@
<?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('todos', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
$table->foreignId('folder_id')->constrained()->cascadeOnDelete();
$table->string('description');
$table->date('due_date');
$table->timestamp('completed_at')->nullable();
$table->timestamps();
$table->index(['user_id', 'completed_at']);
$table->index(['user_id', 'due_date']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('todos');
}
};
@@ -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::table('todos', function (Blueprint $table) {
$table->date('due_date')->nullable()->change();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('todos', function (Blueprint $table) {
$table->date('due_date')->nullable(false)->change();
});
}
};
@@ -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::table('todos', function (Blueprint $table) {
$table->text('notes')->nullable()->after('description');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('todos', function (Blueprint $table) {
$table->dropColumn('notes');
});
}
};
@@ -0,0 +1,29 @@
<?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::table('users', function (Blueprint $table) {
$table->boolean('is_admin')->default(false);
$table->unsignedInteger('notes_limit')->default(1000);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn(['is_admin', 'notes_limit']);
});
}
};
+24
View File
@@ -0,0 +1,24 @@
<?php
namespace Database\Seeders;
use App\Models\User;
use Illuminate\Database\Seeder;
class BaseDatabaseSeeder extends Seeder
{
/**
* Seed the application's base data.
*/
public function run(): void
{
User::updateOrCreate(
['email' => config('admin.email')],
[
'name' => config('admin.name'),
'password' => config('admin.password'),
'is_admin' => true,
],
);
}
}
+91
View File
@@ -0,0 +1,91 @@
<?php
namespace Database\Seeders;
use App\Models\Folder;
use App\Models\Todo;
use App\Models\User;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
class DatabaseSeeder extends Seeder
{
use WithoutModelEvents;
/**
* Seed the application's database.
*/
public function run(): void
{
$this->call(BaseDatabaseSeeder::class);
$user = User::factory()->create([
'name' => 'Test User',
'email' => 'test@example.com',
'is_admin' => true,
]);
$work = $this->createTopLevelFolder($user, 'Work');
$business = $this->createTopLevelFolder($user, 'Business');
$personal = $this->createTopLevelFolder($user, 'Personal');
$workCompanies = [
$this->createChildFolder($work, 'Acme Corp'),
$this->createChildFolder($work, 'Globex'),
];
$businessTypes = [
$this->createChildFolder($business, 'Invoices'),
$this->createChildFolder($business, 'Prospects'),
];
$personalTypes = [
$this->createChildFolder($personal, 'Health'),
$this->createChildFolder($personal, 'Home'),
];
$folders = collect([$work, $business, $personal])
->merge($workCompanies)
->merge($businessTypes)
->merge($personalTypes);
$samples = [
['Work out the Q4 roadmap', 'Acme Corp', 0, 'open'],
['Review Globex contract', 'Globex', 2, 'overdue'],
['Send invoice for consulting work', 'Invoices', 1, 'due-today'],
['Follow up on new prospect', 'Prospects', 5, 'open'],
['Book dentist appointment', 'Health', -1, 'overdue'],
['Fix the garage door', 'Home', 7, 'open'],
['Plan summer vacation', 'Personal', null, 'open'],
['Consolidate expense reports', 'Business', 10, 'completed'],
];
$foldersByName = $folders->keyBy(fn (Folder $folder) => $folder->name);
foreach ($samples as [$description, $folderName, $daysFromToday, $status]) {
$todo = Todo::factory()->recycle($user)->create([
'folder_id' => $foldersByName[$folderName]->id,
'description' => $description,
'due_date' => $daysFromToday === null ? null : today()->addDays($daysFromToday),
]);
if ($status === 'overdue') {
$todo->update(['due_date' => today()->subDays(3)]);
}
if ($status === 'completed') {
$todo->update(['completed_at' => now()->subDay()]);
}
}
}
private function createTopLevelFolder(User $user, string $name): Folder
{
return Folder::factory()->recycle($user)->create(['name' => $name]);
}
private function createChildFolder(Folder $parent, string $name): Folder
{
return Folder::factory()->childOf($parent)->create(['name' => $name]);
}
}