admin()->create([ 'name' => 'Alex Morgan', 'email' => 'alex.morgan@example.com', ]); } /** * Eight shares of different ages, sizes and states: one expired, two password-protected, some * with a download limit, some never expiring. */ public static function shares(): void { $shares = [ ['token' => self::DELIVERY_TOKEN, 'daysAgo' => 0, 'expiresAfterDays' => 7, 'downloads' => 3, 'options' => [], 'files' => ['Q3 Report.pdf' => 2400, 'Contract 2026.pdf' => 380, 'Product photos/hero-shot.jpg' => 4800, 'Product photos/detail.jpg' => 3900]], ['token' => self::PROTECTED_TOKEN, 'daysAgo' => 1, 'expiresAfterDays' => 3, 'downloads' => 1, 'options' => ['password' => self::PROTECTED_PASSWORD, 'max_downloads' => 3], 'files' => ['Payroll September.xlsx' => 210, 'Tax statement 2025.pdf' => 640]], ['token' => 'Rt5uV6wX7yZ8aB9c', 'daysAgo' => 2, 'expiresAfterDays' => 30, 'downloads' => 7, 'options' => ['max_downloads' => 10], 'files' => ['Brand guidelines.pdf' => 8600]], ['token' => 'Kc2dE3fG4hJ5kL6m', 'daysAgo' => 5, 'expiresAfterDays' => 14, 'downloads' => 2, 'options' => [], 'files' => ['Site plan rev C.dwg' => 12400, 'Site plan rev C.pdf' => 3100]], ['token' => 'Np7qR8sT9uV1wX2y', 'daysAgo' => 9, 'expiresAfterDays' => null, 'downloads' => 0, 'options' => ['password' => 'demo-interview'], 'files' => ['Interview recording.m4a' => 18300]], ['token' => 'Zb4cD5eF6gH7jK8L', 'daysAgo' => 14, 'expiresAfterDays' => 30, 'downloads' => 0, 'options' => ['max_downloads' => 1], 'files' => ['Invoice 2026-0412.pdf' => 95]], ['token' => 'Mq1rS2tU3vW4xY5z', 'daysAgo' => 21, 'expiresAfterDays' => null, 'downloads' => 4, 'options' => [], 'files' => ['Onboarding/Welcome.pdf' => 520, 'Onboarding/Handbook.pdf' => 2900, 'Onboarding/IT checklist.docx' => 130]], ['token' => 'Ae6fG7hJ8kL9mN1p', 'daysAgo' => 40, 'expiresAfterDays' => 10, 'downloads' => 12, 'options' => [], 'files' => ['Event photos.zip' => 15700]], ]; foreach ($shares as $share) { self::share(...$share); } } /** * @param array{password?: string, max_downloads?: int} $options * @param array $files relative path => size in kilobytes */ private static function share(string $token, int $daysAgo, ?int $expiresAfterDays, int $downloads, array $options, array $files): void { $createdAt = Carbon::now()->subDays($daysAgo)->subHours(2); Str::createRandomStringsUsing(fn (): string => $token); try { $share = app(ShareService::class)->createShare( collect($files)->map(fn (int $kilobytes, string $path): array => [ 'file' => UploadedFile::fake()->create(basename($path), $kilobytes), 'relativePath' => str_contains($path, '/') ? $path : null, ])->values()->all(), [...$options, 'expires_at' => $expiresAfterDays === null ? null : $createdAt->copy()->addDays($expiresAfterDays)], ); } finally { Str::createRandomStringsNormally(); } $share->forceFill(['download_count' => $downloads, 'created_at' => $createdAt, 'updated_at' => $createdAt])->save(); } }