updates for admin area
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class UserFactory extends Factory
|
||||
{
|
||||
protected static ?string $password;
|
||||
|
||||
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),
|
||||
];
|
||||
}
|
||||
|
||||
public function unverified(): static
|
||||
{
|
||||
return $this->state(fn () => ['email_verified_at' => null]);
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,9 @@ return new class extends Migration
|
||||
$table->string('email')->unique();
|
||||
$table->timestamp('email_verified_at')->nullable();
|
||||
$table->string('password');
|
||||
$table->string('phone')->nullable();
|
||||
$table->string('avatar_path')->nullable();
|
||||
$table->boolean('marketing_opt_in')->default(false);
|
||||
$table->rememberToken();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
@@ -8,122 +8,132 @@ return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('businesses', function (Blueprint $t) {
|
||||
$t->ulid('id')->primary();
|
||||
$t->string('name');
|
||||
$t->string('slug')->unique();
|
||||
$t->text('description')->nullable();
|
||||
$t->string('email')->nullable();
|
||||
$t->string('phone')->nullable();
|
||||
$t->string('website')->nullable();
|
||||
$t->string('status')->default('active');
|
||||
$t->timestamp('verified_at')->nullable();
|
||||
$t->timestamps();
|
||||
Schema::create('businesses', function (Blueprint $table) {
|
||||
$table->ulid('id')->primary();
|
||||
$table->string('name');
|
||||
$table->string('slug')->unique();
|
||||
$table->text('description')->nullable();
|
||||
$table->string('email')->nullable();
|
||||
$table->string('phone')->nullable();
|
||||
$table->string('website')->nullable();
|
||||
$table->string('status')->default('active')->index();
|
||||
$table->timestamp('verified_at')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
Schema::create('business_user', function (Blueprint $t) {
|
||||
$t->id();
|
||||
$t->ulid('business_id');
|
||||
$t->foreignId('user_id')->constrained()->cascadeOnDelete();
|
||||
$t->string('role')->default('member');
|
||||
$t->timestamps();
|
||||
$t->unique(['business_id', 'user_id']);
|
||||
|
||||
Schema::create('business_user', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignUlid('business_id')->constrained('businesses')->cascadeOnDelete();
|
||||
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
|
||||
$table->string('role')->default('member');
|
||||
$table->timestamps();
|
||||
$table->unique(['business_id', 'user_id']);
|
||||
});
|
||||
Schema::create('dj_profiles', function (Blueprint $t) {
|
||||
$t->ulid('id')->primary();
|
||||
$t->foreignId('user_id')->constrained()->cascadeOnDelete();
|
||||
$t->ulid('business_id')->nullable();
|
||||
$t->string('stage_name');
|
||||
$t->string('slug')->unique();
|
||||
$t->string('headline')->nullable();
|
||||
$t->text('bio')->nullable();
|
||||
$t->string('city')->index();
|
||||
$t->unsignedSmallInteger('service_radius_miles')->default(30);
|
||||
$t->decimal('price_from', 10, 2)->nullable();
|
||||
$t->string('profile_photo')->nullable();
|
||||
$t->string('cover_photo')->nullable();
|
||||
$t->timestamp('verified_at')->nullable();
|
||||
$t->boolean('is_featured')->default(false);
|
||||
$t->boolean('is_published')->default(false);
|
||||
$t->decimal('average_rating', 3, 2)->default(0);
|
||||
$t->unsignedInteger('review_count')->default(0);
|
||||
$t->timestamps();
|
||||
|
||||
Schema::create('dj_profiles', function (Blueprint $table) {
|
||||
$table->ulid('id')->primary();
|
||||
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignUlid('business_id')->nullable()->constrained('businesses')->nullOnDelete();
|
||||
$table->string('stage_name');
|
||||
$table->string('slug')->unique();
|
||||
$table->string('headline')->nullable();
|
||||
$table->text('bio')->nullable();
|
||||
$table->string('city')->index();
|
||||
$table->unsignedSmallInteger('service_radius_miles')->default(30);
|
||||
$table->decimal('price_from', 10, 2)->nullable();
|
||||
$table->string('profile_photo')->nullable();
|
||||
$table->string('cover_photo')->nullable();
|
||||
$table->timestamp('verified_at')->nullable();
|
||||
$table->boolean('is_featured')->default(false)->index();
|
||||
$table->boolean('is_published')->default(false)->index();
|
||||
$table->decimal('average_rating', 3, 2)->default(0);
|
||||
$table->unsignedInteger('review_count')->default(0);
|
||||
$table->timestamps();
|
||||
});
|
||||
Schema::create('genres', function (Blueprint $t) {
|
||||
$t->id();
|
||||
$t->string('name');
|
||||
$t->string('slug')->unique();
|
||||
$t->timestamps();
|
||||
|
||||
Schema::create('genres', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->string('slug')->unique();
|
||||
$table->timestamps();
|
||||
});
|
||||
Schema::create('dj_profile_genre', function (Blueprint $t) {
|
||||
$t->ulid('dj_profile_id');
|
||||
$t->foreignId('genre_id')->constrained()->cascadeOnDelete();
|
||||
$t->primary(['dj_profile_id', 'genre_id']);
|
||||
|
||||
Schema::create('dj_profile_genre', function (Blueprint $table) {
|
||||
$table->foreignUlid('dj_profile_id')->constrained('dj_profiles')->cascadeOnDelete();
|
||||
$table->foreignId('genre_id')->constrained()->cascadeOnDelete();
|
||||
$table->primary(['dj_profile_id', 'genre_id']);
|
||||
});
|
||||
Schema::create('enquiries', function (Blueprint $t) {
|
||||
$t->ulid('id')->primary();
|
||||
$t->foreignId('user_id')->constrained();
|
||||
$t->ulid('dj_profile_id');
|
||||
$t->string('event_type');
|
||||
$t->date('event_date');
|
||||
$t->time('start_time')->nullable();
|
||||
$t->time('end_time')->nullable();
|
||||
$t->string('venue');
|
||||
$t->string('postcode')->nullable();
|
||||
$t->unsignedInteger('guest_count')->nullable();
|
||||
$t->decimal('budget', 10, 2)->nullable();
|
||||
$t->text('message');
|
||||
$t->string('status')->default('new')->index();
|
||||
$t->timestamps();
|
||||
|
||||
Schema::create('enquiries', function (Blueprint $table) {
|
||||
$table->ulid('id')->primary();
|
||||
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignUlid('dj_profile_id')->constrained('dj_profiles')->cascadeOnDelete();
|
||||
$table->string('event_type');
|
||||
$table->date('event_date')->index();
|
||||
$table->time('start_time')->nullable();
|
||||
$table->time('end_time')->nullable();
|
||||
$table->string('venue');
|
||||
$table->string('postcode')->nullable();
|
||||
$table->unsignedInteger('guest_count')->nullable();
|
||||
$table->decimal('budget', 10, 2)->nullable();
|
||||
$table->text('message');
|
||||
$table->string('status')->default('new')->index();
|
||||
$table->timestamps();
|
||||
});
|
||||
Schema::create('bookings', function (Blueprint $t) {
|
||||
$t->ulid('id')->primary();
|
||||
$t->ulid('enquiry_id')->nullable();
|
||||
$t->foreignId('client_id')->constrained('users');
|
||||
$t->ulid('dj_profile_id');
|
||||
$t->date('event_date');
|
||||
$t->decimal('total', 10, 2);
|
||||
$t->decimal('deposit', 10, 2)->default(0);
|
||||
$t->string('status')->default('pending')->index();
|
||||
$t->timestamp('paid_at')->nullable();
|
||||
$t->timestamps();
|
||||
|
||||
Schema::create('bookings', function (Blueprint $table) {
|
||||
$table->ulid('id')->primary();
|
||||
$table->foreignUlid('enquiry_id')->nullable()->constrained('enquiries')->nullOnDelete();
|
||||
$table->foreignId('client_id')->constrained('users')->cascadeOnDelete();
|
||||
$table->foreignUlid('dj_profile_id')->constrained('dj_profiles')->cascadeOnDelete();
|
||||
$table->date('event_date')->index();
|
||||
$table->decimal('total', 10, 2);
|
||||
$table->decimal('deposit', 10, 2)->default(0);
|
||||
$table->string('status')->default('pending')->index();
|
||||
$table->timestamp('paid_at')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
Schema::create('reviews', function (Blueprint $t) {
|
||||
$t->ulid('id')->primary();
|
||||
$t->ulid('booking_id');
|
||||
$t->foreignId('user_id')->constrained();
|
||||
$t->ulid('dj_profile_id');
|
||||
$t->unsignedTinyInteger('rating');
|
||||
$t->string('title')->nullable();
|
||||
$t->text('body');
|
||||
$t->string('status')->default('pending')->index();
|
||||
$t->text('dj_reply')->nullable();
|
||||
$t->timestamps();
|
||||
|
||||
Schema::create('reviews', function (Blueprint $table) {
|
||||
$table->ulid('id')->primary();
|
||||
$table->foreignUlid('booking_id')->constrained('bookings')->cascadeOnDelete();
|
||||
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignUlid('dj_profile_id')->constrained('dj_profiles')->cascadeOnDelete();
|
||||
$table->unsignedTinyInteger('rating');
|
||||
$table->string('title')->nullable();
|
||||
$table->text('body');
|
||||
$table->string('status')->default('pending')->index();
|
||||
$table->text('dj_reply')->nullable();
|
||||
$table->timestamps();
|
||||
$table->unique(['booking_id', 'user_id']);
|
||||
});
|
||||
Schema::create('cookie_consents', function (Blueprint $t) {
|
||||
$t->id();
|
||||
$t->foreignId('user_id')->nullable()->constrained()->nullOnDelete();
|
||||
$t->string('anonymous_id')->nullable()->index();
|
||||
$t->boolean('analytics')->default(false);
|
||||
$t->boolean('marketing')->default(false);
|
||||
$t->string('policy_version');
|
||||
$t->timestamp('consented_at');
|
||||
$t->timestamps();
|
||||
|
||||
Schema::create('cookie_consents', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('user_id')->nullable()->constrained()->nullOnDelete();
|
||||
$table->string('anonymous_id')->nullable()->index();
|
||||
$table->boolean('analytics')->default(false);
|
||||
$table->boolean('marketing')->default(false);
|
||||
$table->string('policy_version');
|
||||
$table->timestamp('consented_at');
|
||||
$table->timestamps();
|
||||
});
|
||||
Schema::create('audit_logs', function (Blueprint $t) {
|
||||
$t->id();
|
||||
$t->foreignId('user_id')->nullable()->constrained()->nullOnDelete();
|
||||
$t->string('action')->index();
|
||||
$t->nullableMorphs('subject');
|
||||
$t->json('meta')->nullable();
|
||||
$t->string('ip_hash', 64)->nullable();
|
||||
$t->timestamps();
|
||||
|
||||
Schema::create('audit_logs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('user_id')->nullable()->constrained()->nullOnDelete();
|
||||
$table->string('action')->index();
|
||||
$table->nullableMorphs('subject');
|
||||
$table->json('meta')->nullable();
|
||||
$table->string('ip_hash', 64)->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
foreach (['audit_logs', 'cookie_consents', 'reviews', 'bookings', 'enquiries', 'dj_profile_genre', 'genres', 'dj_profiles', 'business_user', 'businesses'] as $x) {
|
||||
Schema::dropIfExists($x);
|
||||
foreach (['audit_logs', 'cookie_consents', 'reviews', 'bookings', 'enquiries', 'dj_profile_genre', 'genres', 'dj_profiles', 'business_user', 'businesses'] as $table) {
|
||||
Schema::dropIfExists($table);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
<?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('permissions', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->string('guard_name');
|
||||
$table->timestamps();
|
||||
$table->unique(['name', 'guard_name']);
|
||||
});
|
||||
|
||||
Schema::create('roles', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->string('guard_name');
|
||||
$table->timestamps();
|
||||
$table->unique(['name', 'guard_name']);
|
||||
});
|
||||
|
||||
Schema::create('model_has_permissions', function (Blueprint $table) {
|
||||
$table->unsignedBigInteger('permission_id');
|
||||
$table->string('model_type');
|
||||
$table->unsignedBigInteger('model_id');
|
||||
$table->index(['model_id', 'model_type']);
|
||||
$table->foreign('permission_id')->references('id')->on('permissions')->cascadeOnDelete();
|
||||
$table->primary(['permission_id', 'model_id', 'model_type']);
|
||||
});
|
||||
|
||||
Schema::create('model_has_roles', function (Blueprint $table) {
|
||||
$table->unsignedBigInteger('role_id');
|
||||
$table->string('model_type');
|
||||
$table->unsignedBigInteger('model_id');
|
||||
$table->index(['model_id', 'model_type']);
|
||||
$table->foreign('role_id')->references('id')->on('roles')->cascadeOnDelete();
|
||||
$table->primary(['role_id', 'model_id', 'model_type']);
|
||||
});
|
||||
|
||||
Schema::create('role_has_permissions', function (Blueprint $table) {
|
||||
$table->unsignedBigInteger('permission_id');
|
||||
$table->unsignedBigInteger('role_id');
|
||||
$table->foreign('permission_id')->references('id')->on('permissions')->cascadeOnDelete();
|
||||
$table->foreign('role_id')->references('id')->on('roles')->cascadeOnDelete();
|
||||
$table->primary(['permission_id', 'role_id']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('role_has_permissions');
|
||||
Schema::dropIfExists('model_has_roles');
|
||||
Schema::dropIfExists('model_has_permissions');
|
||||
Schema::dropIfExists('roles');
|
||||
Schema::dropIfExists('permissions');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,55 @@
|
||||
<?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::table('users', function (Blueprint $table) {
|
||||
$table->string('stripe_id')->nullable()->index();
|
||||
$table->string('pm_type')->nullable();
|
||||
$table->string('pm_last_four', 4)->nullable();
|
||||
$table->timestamp('trial_ends_at')->nullable();
|
||||
});
|
||||
|
||||
Schema::create('subscriptions', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
|
||||
$table->string('type');
|
||||
$table->string('stripe_id')->unique();
|
||||
$table->string('stripe_status');
|
||||
$table->string('stripe_price')->nullable();
|
||||
$table->integer('quantity')->nullable();
|
||||
$table->timestamp('trial_ends_at')->nullable();
|
||||
$table->timestamp('ends_at')->nullable();
|
||||
$table->timestamps();
|
||||
$table->index(['user_id', 'stripe_status']);
|
||||
});
|
||||
|
||||
Schema::create('subscription_items', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('subscription_id')->constrained()->cascadeOnDelete();
|
||||
$table->string('stripe_id')->unique();
|
||||
$table->string('stripe_product');
|
||||
$table->string('stripe_price');
|
||||
$table->integer('quantity')->nullable();
|
||||
$table->string('meter_event_name')->nullable();
|
||||
$table->string('meter_id')->nullable();
|
||||
$table->timestamps();
|
||||
$table->index(['subscription_id', 'stripe_price']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('subscription_items');
|
||||
Schema::dropIfExists('subscriptions');
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->dropIndex(['stripe_id']);
|
||||
$table->dropColumn(['stripe_id', 'pm_type', 'pm_last_four', 'trial_ends_at']);
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -13,7 +13,7 @@ class DatabaseSeeder extends Seeder
|
||||
public function run(): void
|
||||
{
|
||||
foreach (['super-admin', 'admin', 'dj', 'client', 'moderator', 'support'] as $r) {
|
||||
Role::firstOrCreate(['name' => $r]);
|
||||
Role::firstOrCreate(['name' => $r, 'guard_name' => 'web']);
|
||||
} $admin = User::firstOrCreate(['email' => 'admin@beatbook.test'], ['name' => 'BeatBook Admin', 'password' => 'password']);
|
||||
$admin->assignRole('admin');
|
||||
$djUser = User::firstOrCreate(['email' => 'dj@beatbook.test'], ['name' => 'Luna Hart', 'password' => 'password']);
|
||||
|
||||
Reference in New Issue
Block a user