first commit from hostslim
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\AnalyticsSession;
|
||||
use App\Models\Visitor;
|
||||
use App\Models\Website;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/** @extends Factory<AnalyticsSession> */
|
||||
class AnalyticsSessionFactory extends Factory
|
||||
{
|
||||
public function definition(): array
|
||||
{
|
||||
$started = now()->subMinutes(fake()->numberBetween(1, 60));
|
||||
|
||||
return [
|
||||
'website_id' => Website::factory(),
|
||||
'visitor_id' => Visitor::factory(),
|
||||
'uid' => Str::random(32),
|
||||
'started_at' => $started,
|
||||
'ended_at' => $started->copy()->addSeconds(fake()->numberBetween(10, 600)),
|
||||
'duration' => fake()->numberBetween(10, 600),
|
||||
'is_bounce' => false,
|
||||
'entry_page' => '/',
|
||||
'exit_page' => '/about',
|
||||
'pages_count' => fake()->numberBetween(1, 10),
|
||||
'ip_address' => fake()->ipv4(),
|
||||
'referrer_url' => null,
|
||||
'referrer_domain' => null,
|
||||
'utm_source' => null,
|
||||
'utm_medium' => null,
|
||||
'utm_campaign' => null,
|
||||
'utm_term' => null,
|
||||
'utm_content' => null,
|
||||
];
|
||||
}
|
||||
|
||||
public function bounce(): static
|
||||
{
|
||||
return $this->state([
|
||||
'is_bounce' => true,
|
||||
'pages_count' => 1,
|
||||
'duration' => 0,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\AnalyticsSession;
|
||||
use App\Models\Event;
|
||||
use App\Models\Visitor;
|
||||
use App\Models\Website;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/** @extends Factory<Event> */
|
||||
class EventFactory extends Factory
|
||||
{
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'website_id' => Website::factory(),
|
||||
'visitor_id' => Visitor::factory(),
|
||||
'analytics_session_id' => AnalyticsSession::factory(),
|
||||
'name' => fake()->randomElement(['click', 'signup', 'purchase', 'download']),
|
||||
'category' => fake()->randomElement(['engagement', 'conversion', 'navigation']),
|
||||
'action' => fake()->word(),
|
||||
'label' => fake()->word(),
|
||||
'value' => fake()->optional(0.5)->randomFloat(2, 1, 100),
|
||||
'properties' => null,
|
||||
'occurred_at' => now(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\AnalyticsSession;
|
||||
use App\Models\Goal;
|
||||
use App\Models\GoalConversion;
|
||||
use App\Models\Visitor;
|
||||
use App\Models\Website;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/** @extends Factory<GoalConversion> */
|
||||
class GoalConversionFactory extends Factory
|
||||
{
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'goal_id' => Goal::factory(),
|
||||
'website_id' => Website::factory(),
|
||||
'visitor_id' => Visitor::factory(),
|
||||
'analytics_session_id' => AnalyticsSession::factory(),
|
||||
'value' => fake()->randomFloat(2, 1, 100),
|
||||
'converted_at' => now(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Goal;
|
||||
use App\Models\Website;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/** @extends Factory<Goal> */
|
||||
class GoalFactory extends Factory
|
||||
{
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'website_id' => Website::factory(),
|
||||
'name' => fake()->sentence(2),
|
||||
'type' => 'url_destination',
|
||||
'conditions' => ['path' => '/thank-you', 'match_type' => 'exact'],
|
||||
'default_value' => fake()->randomFloat(2, 1, 100),
|
||||
'is_active' => true,
|
||||
];
|
||||
}
|
||||
|
||||
public function urlDestination(string $path = '/thank-you', string $matchType = 'exact'): static
|
||||
{
|
||||
return $this->state([
|
||||
'type' => 'url_destination',
|
||||
'conditions' => ['path' => $path, 'match_type' => $matchType],
|
||||
]);
|
||||
}
|
||||
|
||||
public function eventMatch(string $eventName, ?string $category = null): static
|
||||
{
|
||||
return $this->state([
|
||||
'type' => 'event_match',
|
||||
'conditions' => array_filter([
|
||||
'event_name' => $eventName,
|
||||
'event_category' => $category,
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
public function duration(int $seconds): static
|
||||
{
|
||||
return $this->state([
|
||||
'type' => 'duration',
|
||||
'conditions' => ['seconds' => $seconds],
|
||||
]);
|
||||
}
|
||||
|
||||
public function pagesPerSession(int $count): static
|
||||
{
|
||||
return $this->state([
|
||||
'type' => 'pages_per_session',
|
||||
'conditions' => ['page_count' => $count],
|
||||
]);
|
||||
}
|
||||
|
||||
public function inactive(): static
|
||||
{
|
||||
return $this->state(['is_active' => false]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\AnalyticsSession;
|
||||
use App\Models\PageView;
|
||||
use App\Models\Visitor;
|
||||
use App\Models\Website;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/** @extends Factory<PageView> */
|
||||
class PageViewFactory extends Factory
|
||||
{
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'website_id' => Website::factory(),
|
||||
'visitor_id' => Visitor::factory(),
|
||||
'analytics_session_id' => AnalyticsSession::factory(),
|
||||
'url' => fake()->url(),
|
||||
'path' => '/'.fake()->slug(2),
|
||||
'title' => fake()->sentence(3),
|
||||
'referrer' => null,
|
||||
'time_on_page' => fake()->numberBetween(5, 300),
|
||||
'viewed_at' => now(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
<?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),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate that the model's email address should be unverified.
|
||||
*/
|
||||
public function unverified(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'email_verified_at' => null,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Visitor;
|
||||
use App\Models\Website;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/** @extends Factory<Visitor> */
|
||||
class VisitorFactory extends Factory
|
||||
{
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'website_id' => Website::factory(),
|
||||
'uid' => Str::random(32),
|
||||
'first_seen_at' => now(),
|
||||
'last_seen_at' => now(),
|
||||
'device_type' => fake()->randomElement(['desktop', 'mobile', 'tablet']),
|
||||
'browser' => fake()->randomElement(['Chrome', 'Firefox', 'Safari', 'Edge']),
|
||||
'browser_version' => fake()->numerify('##.#'),
|
||||
'os' => fake()->randomElement(['Windows', 'macOS', 'Linux', 'iOS', 'Android']),
|
||||
'os_version' => fake()->numerify('##.#'),
|
||||
'screen_resolution' => fake()->randomElement(['1920x1080', '1366x768', '390x844']),
|
||||
'language' => fake()->randomElement(['en', 'de', 'fr', 'es']),
|
||||
'country' => fake()->countryCode(),
|
||||
'region' => fake()->state(),
|
||||
'city' => fake()->city(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\Website;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/** @extends Factory<Website> */
|
||||
class WebsiteFactory extends Factory
|
||||
{
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'user_id' => User::factory(),
|
||||
'name' => fake()->company(),
|
||||
'domain' => fake()->domainName(),
|
||||
'tracking_id' => 'TA-'.strtoupper(Str::random(10)),
|
||||
'is_active' => true,
|
||||
'settings' => [],
|
||||
];
|
||||
}
|
||||
|
||||
public function inactive(): static
|
||||
{
|
||||
return $this->state(['is_active' => false]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user