initial commit
This commit is contained in:
commit
ae93c7e1a6
233 changed files with 20282 additions and 0 deletions
30
backend/database/factories/BrandFactory.php
Normal file
30
backend/database/factories/BrandFactory.php
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Brand>
|
||||
*/
|
||||
class BrandFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
$name = fake()->unique()->company();
|
||||
|
||||
return [
|
||||
'name' => $name,
|
||||
'slug' => Str::slug($name).'-'.fake()->unique()->numberBetween(10, 99),
|
||||
'description' => fake()->optional()->sentence(),
|
||||
'website_url' => fake()->optional()->url(),
|
||||
'active' => fake()->boolean(95),
|
||||
];
|
||||
}
|
||||
}
|
||||
39
backend/database/factories/CategoryFactory.php
Normal file
39
backend/database/factories/CategoryFactory.php
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Category;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Category>
|
||||
*/
|
||||
class CategoryFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
$name = fake()->category;
|
||||
|
||||
return [
|
||||
'parent_id' => null,
|
||||
'name' => Str::title($name),
|
||||
'slug' => Str::slug($name).'-'.fake()->unique()->numberBetween(1, 999),
|
||||
'description' => fake()->optional()->sentence(),
|
||||
'active' => fake()->boolean(90),
|
||||
'sort_order' => fake()->numberBetween(0, 50),
|
||||
];
|
||||
}
|
||||
|
||||
public function childOf(Category $category): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'parent_id' => $category->id,
|
||||
]);
|
||||
}
|
||||
}
|
||||
38
backend/database/factories/ProductFactory.php
Normal file
38
backend/database/factories/ProductFactory.php
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Brand;
|
||||
use App\Models\Category;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Product>
|
||||
*/
|
||||
class ProductFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
$name = Str::title(fake()->words(fake()->numberBetween(2, 5), true));
|
||||
|
||||
return [
|
||||
'category_id' => Category::factory(),
|
||||
'brand_id' => Brand::factory(),
|
||||
'name' => $name,
|
||||
'slug' => Str::slug($name).'-'.fake()->unique()->numberBetween(100, 999),
|
||||
'sku' => strtoupper(fake()->bothify('SKU-#####??')),
|
||||
'short_description' => fake()->optional()->sentence(),
|
||||
'description' => fake()->paragraphs(2, true),
|
||||
'price' => fake()->randomFloat(2, 10, 10000),
|
||||
'stock_quantity' => fake()->numberBetween(0, 5000),
|
||||
'active' => fake()->boolean(90),
|
||||
'published_at' => fake()->optional(0.8)->dateTimeBetween('-1 year', 'now'),
|
||||
];
|
||||
}
|
||||
}
|
||||
44
backend/database/factories/UserFactory.php
Normal file
44
backend/database/factories/UserFactory.php
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\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,
|
||||
]);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue