Init(Core): add project to git and add seeders and factory

This commit is contained in:
2026-04-28 21:29:43 +03:30
commit 15bd23cdd2
101 changed files with 12093 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
<?php
namespace Database\Factories;
use App\Models\Content;
use App\Models\Page;
use Illuminate\Database\Eloquent\Factories\Factory;
class ContentFactory extends Factory
{
protected $model = Content::class;
public function definition(): array
{
$type = fake()->randomElement(['text', 'image', 'video']);
return [
'page_id' => Page::factory(),
'type' => $type,
'body' => $type === 'text' ? fake()->paragraph() : fake()->imageUrl(),
'title' => fake()->optional()->sentence(),
];
}
}

View File

@@ -0,0 +1,22 @@
<?php
namespace Database\Factories;
use App\Models\Image;
use App\Models\Page;
use Illuminate\Database\Eloquent\Factories\Factory;
class ImageFactory extends Factory
{
protected $model = Image::class;
public function definition(): array
{
return [
'path' => fake()->imageUrl(640, 480),
'user_id' => fake()->numberBetween(1, 10),
'page_id' => Page::factory(),
'user_token' => fake()->uuid(),
];
}
}

View File

@@ -0,0 +1,19 @@
<?php
namespace Database\Factories;
use App\Models\Page;
use Illuminate\Database\Eloquent\Factories\Factory;
class PageFactory extends Factory
{
protected $model = Page::class;
public function definition(): array
{
return [
'user_token' => fake()->uuid(),
'url' => fake()->url(),
];
}
}

View File

@@ -0,0 +1,28 @@
<?php
namespace Database\Factories;
use App\Models\Post;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
class PostFactory extends Factory
{
protected $model = Post::class;
public function definition(): array
{
$title = fake()->sentence();
return [
'title' => $title,
'description' => fake()->optional()->text(200),
'content' => fake()->paragraphs(5, true),
'slug' => Str::slug($title),
'image_path' => fake()->imageUrl(800, 600, 'posts'),
'image_thumbnail' => fake()->imageUrl(200, 200, 'posts'),
'image_alt' => fake()->sentence(),
'user_token' => fake()->uuid(),
];
}
}

View File

@@ -0,0 +1,38 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\User>
*/
class UserFactory extends Factory
{
/**
* 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' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // 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,
]);
}
}