Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 41 additions & 41 deletions database/factories/ActivityFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,22 @@ public function definition(): array
{
return [
'description' => $this->faker->sentence(3),
'details' => $this->faker->paragraph(),
'userType' => $this->faker->randomElement(['Guest', 'Registered', 'Crawler']),
'userId' => $this->faker->numberBetween(1, 100),
'route' => $this->faker->url(),
'ipAddress' => $this->faker->ipv4(),
'userAgent' => $this->faker->userAgent(),
'locale' => $this->faker->locale(),
'referer' => $this->faker->optional()->url(),
'methodType' => $this->faker->randomElement(['GET', 'POST', 'PUT', 'DELETE', 'PATCH']),
'created_at' => $this->faker->dateTimeBetween('-1 year', 'now'),
'updated_at' => $this->faker->dateTimeBetween('-1 year', 'now'),
'details' => $this->faker->paragraph(),
'userType' => $this->faker->randomElement(['Guest', 'Registered', 'Crawler']),
'userId' => $this->faker->numberBetween(1, 100),
'route' => $this->faker->url(),
'ipAddress' => $this->faker->ipv4(),
'userAgent' => $this->faker->userAgent(),
'locale' => $this->faker->locale(),
'referer' => $this->faker->optional()->url(),
'methodType' => $this->faker->randomElement(['GET', 'POST', 'PUT', 'DELETE', 'PATCH']),
'created_at' => $this->faker->dateTimeBetween('-1 year', 'now'),
'updated_at' => $this->faker->dateTimeBetween('-1 year', 'now'),
];
}

/**
* Create an activity for today
* Create an activity for today.
*/
public function today(): static
{
Expand All @@ -41,7 +41,7 @@ public function today(): static
}

/**
* Create an activity for yesterday
* Create an activity for yesterday.
*/
public function yesterday(): static
{
Expand All @@ -54,7 +54,7 @@ public function yesterday(): static
}

/**
* Create an activity for last week
* Create an activity for last week.
*/
public function lastWeek(): static
{
Expand All @@ -67,7 +67,7 @@ public function lastWeek(): static
}

/**
* Create an activity for last month
* Create an activity for last month.
*/
public function lastMonth(): static
{
Expand All @@ -80,7 +80,7 @@ public function lastMonth(): static
}

/**
* Create an activity for last year
* Create an activity for last year.
*/
public function lastYear(): static
{
Expand All @@ -93,40 +93,40 @@ public function lastYear(): static
}

/**
* Create a guest activity
* Create a guest activity.
*/
public function guest(): static
{
return $this->state(function (array $attributes) {
return [
'userType' => 'Guest',
'userId' => null,
'userId' => null,
];
});
}

/**
* Create a registered user activity
* Create a registered user activity.
*/
public function registered(): static
{
return $this->state(function (array $attributes) {
return [
'userType' => 'Registered',
'userId' => $this->faker->numberBetween(1, 100),
'userId' => $this->faker->numberBetween(1, 100),
];
});
}

/**
* Create a crawler activity
* Create a crawler activity.
*/
public function crawler(): static
{
return $this->state(function (array $attributes) {
return [
'userType' => 'Crawler',
'userId' => null,
'userType' => 'Crawler',
'userId' => null,
'userAgent' => $this->faker->randomElement([
'Googlebot/2.1',
'Bingbot/2.0',
Expand All @@ -138,43 +138,43 @@ public function crawler(): static
}

/**
* Create a login activity
* Create a login activity.
*/
public function login(): static
{
return $this->state(function (array $attributes) {
return [
'description' => 'User logged in',
'methodType' => 'POST',
'route' => '/login',
'methodType' => 'POST',
'route' => '/login',
];
});
}

/**
* Create a logout activity
* Create a logout activity.
*/
public function logout(): static
{
return $this->state(function (array $attributes) {
return [
'description' => 'User logged out',
'methodType' => 'POST',
'route' => '/logout',
'methodType' => 'POST',
'route' => '/logout',
];
});
}

/**
* Create a view activity
* Create a view activity.
*/
public function view(): static
{
return $this->state(function (array $attributes) {
return [
'description' => 'User viewed page',
'methodType' => 'GET',
'route' => $this->faker->randomElement([
'methodType' => 'GET',
'route' => $this->faker->randomElement([
'/dashboard',
'/profile',
'/settings',
Expand All @@ -185,15 +185,15 @@ public function view(): static
}

/**
* Create a create activity
* Create a create activity.
*/
public function create(): static
{
return $this->state(function (array $attributes) {
return [
'description' => 'User created resource',
'methodType' => 'POST',
'route' => $this->faker->randomElement([
'methodType' => 'POST',
'route' => $this->faker->randomElement([
'/posts',
'/users',
'/products',
Expand All @@ -204,15 +204,15 @@ public function create(): static
}

/**
* Create an update activity
* Create an update activity.
*/
public function update(): static
{
return $this->state(function (array $attributes) {
return [
'description' => 'User updated resource',
'methodType' => 'PUT',
'route' => $this->faker->randomElement([
'methodType' => 'PUT',
'route' => $this->faker->randomElement([
'/posts/1',
'/users/1',
'/products/1',
Expand All @@ -223,15 +223,15 @@ public function update(): static
}

/**
* Create a delete activity
* Create a delete activity.
*/
public function delete(): static
{
return $this->state(function (array $attributes) {
return [
'description' => 'User deleted resource',
'methodType' => 'DELETE',
'route' => $this->faker->randomElement([
'methodType' => 'DELETE',
'route' => $this->faker->randomElement([
'/posts/1',
'/users/1',
'/products/1',
Expand Down
2 changes: 1 addition & 1 deletion rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->paths([
__DIR__ . '/src',
__DIR__.'/src',
]);

// Define what rule sets will be applied
Expand Down
Loading