Initial PHP rebuild of the app
This commit is contained in:
690 files changed
+33944
-12046
No files matched your search
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Enums\Permission;
|
||||
use App\Models\BookingRule;
|
||||
use App\Models\Business;
|
||||
use App\Models\BusinessDomain;
|
||||
use App\Models\BusinessHours;
|
||||
use App\Models\BusinessLocation;
|
||||
use App\Models\BusinessSettings;
|
||||
use App\Models\Role;
|
||||
use App\Models\RolePermission;
|
||||
use App\Models\Service;
|
||||
use App\Models\ServiceCategory;
|
||||
use App\Models\StaffProfile;
|
||||
use App\Models\StaffService;
|
||||
use App\Models\WorkingHours;
|
||||
use App\Models\ApplicationInstallation;
|
||||
use App\Models\LoyaltyProgramme;
|
||||
use App\Enums\InstallationStatus;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
|
||||
class DatabaseSeeder extends Seeder
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
$business = Business::updateOrCreate(
|
||||
['slug' => 'demo-barbershop'],
|
||||
['name' => 'Blake Heritage Barbershop', 'shortName' => 'Blake Heritage', 'description' => 'Classic cuts, modern service, and a simple way to book your next visit.', 'phone' => '+44 20 7946 0000', 'email' => 'hello@blakeheritage.test', 'timezone' => 'Europe/London', 'currency' => 'GBP', 'locale' => 'en-GB'],
|
||||
);
|
||||
|
||||
foreach (['localhost', '127.0.0.1'] as $hostname) {
|
||||
BusinessDomain::updateOrCreate(['hostname' => $hostname], ['businessId' => $business->id, 'isPrimary' => $hostname === 'localhost', 'isActive' => true]);
|
||||
}
|
||||
BusinessLocation::updateOrCreate(['businessId' => $business->id], ['name' => 'Main Location', 'addressLine1' => '14 Heritage Lane', 'city' => 'London', 'postalCode' => 'SW1A 1AA', 'country' => 'GB', 'isPrimary' => true]);
|
||||
BusinessSettings::updateOrCreate(['businessId' => $business->id], ['cancellationPolicy' => 'Please give us 24 hours notice if you need to cancel.']);
|
||||
BookingRule::updateOrCreate(['businessId' => $business->id], ['minNoticeMinutes' => 120, 'maxAdvanceDays' => 60, 'allowGuestBooking' => true]);
|
||||
|
||||
foreach (['MONDAY' => [600, 1140], 'TUESDAY' => [600, 1140], 'WEDNESDAY' => [600, 1140], 'THURSDAY' => [600, 1140], 'FRIDAY' => [600, 1200], 'SATURDAY' => [540, 1020], 'SUNDAY' => [null, null]] as $day => [$opens, $closes]) {
|
||||
BusinessHours::updateOrCreate(['businessId' => $business->id, 'dayOfWeek' => $day], ['isClosed' => $opens === null, 'opensAtMinutes' => $opens, 'closesAtMinutes' => $closes]);
|
||||
}
|
||||
|
||||
$ownerRole = Role::updateOrCreate(['businessId' => $business->id, 'name' => 'Owner'], ['isSystem' => true]);
|
||||
foreach (Permission::cases() as $permission) {
|
||||
RolePermission::firstOrCreate(['roleId' => $ownerRole->id, 'permission' => $permission->value]);
|
||||
}
|
||||
|
||||
$owner = User::updateOrCreate(['email' => 'owner@blakeheritage.test'], ['name' => 'Alex Blake', 'passwordHash' => Hash::make('password123'), 'emailVerified' => now()]);
|
||||
$staff = StaffProfile::updateOrCreate(['businessId' => $business->id, 'userId' => $owner->id], ['roleId' => $ownerRole->id, 'status' => 'ACTIVE', 'isBookableOnline' => true]);
|
||||
|
||||
$category = ServiceCategory::updateOrCreate(['businessId' => $business->id, 'name' => 'Cuts'], ['displayOrder' => 0, 'isActive' => true]);
|
||||
$services = [
|
||||
Service::updateOrCreate(['businessId' => $business->id, 'categoryId' => $category->id, 'name' => 'Classic Haircut'], ['description' => 'A tailored cut finished with a clean style.', 'durationMinutes' => 45, 'price' => 28.00, 'allowOnlineBooking' => true, 'isActive' => true]),
|
||||
Service::updateOrCreate(['businessId' => $business->id, 'categoryId' => $category->id, 'name' => 'Skin Fade'], ['description' => 'A precise fade with a sharp finish.', 'durationMinutes' => 60, 'price' => 34.00, 'allowOnlineBooking' => true, 'isActive' => true]),
|
||||
];
|
||||
foreach ($services as $service) {
|
||||
StaffService::updateOrCreate(['staffId' => $staff->id, 'serviceId' => $service->id], []);
|
||||
}
|
||||
LoyaltyProgramme::updateOrCreate(['businessId' => $business->id], ['isEnabled' => true, 'stampsRequired' => 10, 'rewardPosition' => 'AFTER_ALL_STAMPS', 'rewardType' => 'PERCENTAGE', 'rewardValue' => 10, 'rewardLabel' => '10% off', 'autoApplyReward' => true, 'requiresStaffApproval' => false, 'cardTitleText' => 'Blake Rewards', 'cardTitleTextSize' => 'MD', 'cardFont' => 'SANS']);
|
||||
foreach (['MONDAY', 'TUESDAY', 'WEDNESDAY', 'THURSDAY', 'FRIDAY', 'SATURDAY', 'SUNDAY'] as $day) {
|
||||
WorkingHours::updateOrCreate(['staffId' => $staff->id, 'dayOfWeek' => $day], ['isOff' => $day === 'SUNDAY', 'startMinutes' => 600, 'endMinutes' => 1140]);
|
||||
}
|
||||
|
||||
ApplicationInstallation::updateOrCreate(['id' => 'singleton'], ['status' => InstallationStatus::Installed, 'installedAt' => now(), 'installedVersion' => 'laravel-1', 'initialAdminUserId' => $owner->id, 'primaryBusinessId' => $business->id, 'metadata' => ['seeded' => true]]);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user