Add initial Todo items and CalDAV sync
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Todo;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class TodoFactory extends Factory
|
||||
{
|
||||
protected $model = Todo::class;
|
||||
|
||||
public function definition(): array
|
||||
{
|
||||
$now = $this->faker->dateTimeBetween('-1 month', 'now');
|
||||
return [
|
||||
'id' => (string) Str::uuid(),
|
||||
'etag' => null,
|
||||
'title' => $this->faker->sentence(4),
|
||||
'description' => $this->faker->optional()->paragraph(),
|
||||
'type_id' => null,
|
||||
'url' => $this->faker->optional()->url(),
|
||||
'due_date' => $this->faker->optional()->dateTimeBetween('now', '+2 months'),
|
||||
'recurring' => $this->faker->optional()->regexify('RRULE:FREQ=DAILY;COUNT=\d{1,2}'),
|
||||
'priority' => $this->faker->optional()->numberBetween(1, 9),
|
||||
'status' => $this->faker->randomElement(['NEEDS-ACTION','IN-PROCESS','COMPLETED', null]),
|
||||
'created_at' => $now,
|
||||
'last_modified' => $this->faker->dateTimeBetween($now, 'now'),
|
||||
'parent' => null,
|
||||
'object' => null,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -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 {
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('todos', function (Blueprint $table) {
|
||||
$table->string('id')->primary(); // ical UID
|
||||
$table->string('etag')->nullable(); // ical etag
|
||||
$table->string('title');
|
||||
$table->text('description')->nullable();
|
||||
$table->foreignId('type_id')->nullable()->constrained('todo_types')->nullOnDelete();
|
||||
$table->string('url')->nullable();
|
||||
$table->timestamp('due_date')->nullable();
|
||||
$table->text('recurring')->nullable(); // RRULE
|
||||
$table->tinyInteger('priority')->nullable();
|
||||
$table->string('status')->nullable(); // e.g. IN-PROCESS, NEEDS-ACTION
|
||||
$table->timestamp('created_at')->nullable(); // iCal CREATED
|
||||
$table->timestamp('last_modified')->nullable(); // iCal LAST-MODIFIED
|
||||
$table->string('parent')->nullable()->index(); // RELATED-TO (parent UID)
|
||||
$table->string('object')->nullable(); // RELATED-TO (object reference)
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('todos');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration {
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('todo_types', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name')->unique();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('todo_types');
|
||||
}
|
||||
};
|
||||
@@ -19,7 +19,8 @@ public function run(): void
|
||||
{
|
||||
$this->call([
|
||||
PaymentTermsSeeder::class,
|
||||
SettingsTableSeeder::class
|
||||
SettingsTableSeeder::class,
|
||||
TodoTypeSeeder::class,
|
||||
]);
|
||||
|
||||
$user = User::factory()->create([
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use App\Models\TodoType;
|
||||
|
||||
class TodoTypeSeeder extends Seeder
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
$types = ['phoneCall', 'todo', 'email', 'meeting'];
|
||||
|
||||
foreach ($types as $name) {
|
||||
TodoType::firstOrCreate(['name' => $name]);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user