blog api created
This commit is contained in:
1 parent
4f101885a8
commit
d98bc7bbb0
27 files changed
+1022
-44
No files matched your search
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories\Blog;
|
||||
|
||||
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 = $this->faker->unique()->word;
|
||||
return [
|
||||
'name' => ucfirst($name),
|
||||
'slug' => Str::slug($name),
|
||||
'description' => $this->faker->paragraph,
|
||||
'short_description' => $this->faker->sentence,
|
||||
'image' => $this->faker->imageUrl(640, 480, 'business', true),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories\Blog;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use App\Models\Blog\Post;
|
||||
use App\Models\Blog\Category;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Tag>
|
||||
*/
|
||||
class PostFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
|
||||
protected $model = Post::class;
|
||||
|
||||
|
||||
public function definition(): array
|
||||
{
|
||||
$title = $this->faker->sentence;
|
||||
return [
|
||||
'title' => $title,
|
||||
'body' => $this->faker->paragraphs(5, true),
|
||||
'excerpt' => $this->faker->text(200),
|
||||
'slug' => Str::slug($title) . '-' . $this->faker->unique()->numberBetween(1, 1000),
|
||||
'author_id' => User::inRandomOrder()->first()->id ?? User::factory(),
|
||||
'category_id' => Category::inRandomOrder()->first()->id ?? Category::factory(),
|
||||
'featured_image' => $this->faker->imageUrl(800, 600, 'technics', true),
|
||||
'views' => $this->faker->numberBetween(0, 1000),
|
||||
'likes' => $this->faker->numberBetween(0, 500),
|
||||
'published_at' => $this->faker->dateTimeBetween('-1 years', 'now'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories\Blog;
|
||||
|
||||
use App\Models\Blog\Tag;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Tag>
|
||||
*/
|
||||
class TagFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
|
||||
protected $model = Tag::class;
|
||||
|
||||
public function definition(): array
|
||||
{
|
||||
$name = $this->faker->unique()->word;
|
||||
return [
|
||||
'name' => ucfirst($name),
|
||||
'slug' => Str::slug($name),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user