Add (post manage)

Add (post country viewing)
This commit is contained in:
2023-07-28 02:29:11 +08:00
parent e70195f4f7
commit ded1643e5f
49 changed files with 4484 additions and 3844 deletions

View File

@@ -12,8 +12,8 @@
public function up(): void
{
Schema::table('categories', function (Blueprint $table) {
$table->string('country_locale_slug')->after('country_locale_id')->default('my');
$table->foreign('country_locale_slug')->references('slug')->on('country_locales');
$table->string('country_locale_slug')->after('country_locale_id')->default('my');
$table->foreign('country_locale_slug')->references('slug')->on('country_locales');
});
}

View File

@@ -21,10 +21,10 @@ public function up(): void
$table->string('featured_image');
$table->enum('editor', ['editorjs'])->default('editorjs');
$table->json('body')->nullable();
$table->enum('post_format',['standard'])->default('standard');
$table->enum('post_format', ['standard'])->default('standard');
$table->integer('comment_count')->default(0);
$table->integer('likes_count')->default(0);
$table->enum('status', ['publish','future','draft','private','trash'])->default('draft');
$table->enum('status', ['publish', 'future', 'draft', 'private', 'trash'])->default('draft');
$table->timestamps();
$table->foreign('author_id')->references('id')->on('authors');

View File

@@ -2,20 +2,14 @@
namespace Database\Seeders;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use App\Models\Author;
use App\Models\Category;
use App\Models\Post;
use App\Models\PostCategory;
use Faker\Factory as FakerFactory;
use Illuminate\Database\Seeder;
use Illuminate\Support\Str;
class PostsSeeder extends Seeder
{
/*
@@ -23,48 +17,45 @@ class PostsSeeder extends Seeder
*/
public function run(): void
{
$authors = Author::where('enabled', true)->get();
$authors = Author::where('enabled', true)->get();
$categories = Category::Where('enabled', true)->get();
$categories = Category::where('enabled', true)->get();
$faker = FakerFactory::create();
$faker = FakerFactory::create();
for ($i = 0; $i < 20; $i++) {
$photo_id = (($i + 1) % 16); // placekitten has only 16 photos
for ($i = 0; $i < 20; $i++) {
$post_title = $faker->sentence;
$post_slug = Str::slug($post_title, '-');
$photo_id = (($i + 1) % 16); // placekitten has only 16 photos
$cloned_authors = clone $authors;
$cloned_categories = clone $categories;
$post_title = $faker->sentence;
$post_slug = Str::slug($post_title, "-");
$createdAt = $faker->dateTimeBetween('-1 year', 'now');
$cloned_authors = clone $authors;
$cloned_categories = clone $categories;
$post = Post::create([
'title' => $post_title,
'slug' => $post_slug,
'excerpt' => $faker->paragraph,
'author_id' => $cloned_authors->shuffle()->first()->id,
'featured' => rand(0, 1),
'featured_image' => "https://placekitten.com/1920/1080?image={$photo_id}",
'editor' => 'editorjs',
'post_format' => 'standard',
'comment_count' => rand(0, 100),
'likes_count' => rand(0, 100),
'status' => 'publish',
'body' => "{\"time\":1563816717958,\"blocks\":[{\"data\":{\"text\":\"Editor.js\",\"level\":2},\"type\":\"header\"},{\"data\":{\"text\":\"Hey. Meet the new Editor. On this page you can see it in action \\u2014 try to edit this text.\"},\"type\":\"paragraph\"},{\"data\":{\"text\":\"Key features\",\"level\":3},\"type\":\"header\"},{\"data\":{\"items\":[\"It is a block-styled editor\",\"It returns clean data output in JSON\",\"Designed to be extendable and pluggable with a simple API\"],\"style\":\"unordered\"},\"type\":\"list\"},{\"data\":{\"text\":\"What does it mean \\u00abblock-styled editor\\u00bb\",\"level\":3},\"type\":\"header\"},{\"data\":{\"text\":\"Workspace in classic editors is made of a single contenteditable element, used to create different HTML markups. Editor.js <mark class=\\\"cdx-marker\\\">workspace consists of separate Blocks: paragraphs, headings, images, lists, quotes, etc<\\\/mark>. Each of them is an independent contenteditable element (or more complex structure) provided by Plugin and united by Editor's Core.\"},\"type\":\"paragraph\"},{\"data\":{\"text\":\"There are dozens of <a href=\\\"https:\\\/\\\/github.com\\\/editor-js\\\">ready-to-use Blocks<\\\/a> and the <a href=\\\"https:\\\/\\\/editorjs.io\\\/creating-a-block-tool\\\">simple API<\\\/a> for creation any Block you need. For example, you can implement Blocks for Tweets, Instagram posts, surveys and polls, CTA-buttons and even games.\"},\"type\":\"paragraph\"},{\"data\":{\"text\":\"What does it mean clean data output\",\"level\":3},\"type\":\"header\"},{\"data\":{\"text\":\"Classic WYSIWYG-editors produce raw HTML-markup with both content data and content appearance. On the contrary, Editor.js outputs JSON object with data of each Block. You can see an example below\"},\"type\":\"paragraph\"},{\"data\":{\"text\":\"Given data can be used as you want: render with HTML for <code class=\\\"inline-code\\\">Web clients<\\\/code>, render natively for <code class=\\\"inline-code\\\">mobile apps<\\\/code>, create markup for <code class=\\\"inline-code\\\">Facebook Instant Articles<\\\/code> or <code class=\\\"inline-code\\\">Google AMP<\\\/code>, generate an <code class=\\\"inline-code\\\">audio version<\\\/code> and so on.\"},\"type\":\"paragraph\"},{\"data\":{\"text\":\"Clean data is useful to sanitize, validate and process on the backend.\"},\"type\":\"paragraph\"},{\"data\":[],\"type\":\"delimiter\"},{\"data\":{\"text\":\"We have been working on this project more than three years. Several large media projects help us to test and debug the Editor, to make it's core more stable. At the same time we significantly improved the API. Now, it can be used to create any plugin for any task. Hope you enjoy. \\ud83d\\ude0f\"},\"type\":\"paragraph\"},{\"data\":{\"file\":{\"url\":\"https:\\\/\\\/codex.so\\\/upload\\\/redactor_images\\\/o_e48549d1855c7fc1807308dd14990126.jpg\"},\"caption\":\"Image caption\",\"stretched\":false,\"withBorder\":true,\"withBackground\":false},\"type\":\"image\"}],\"version\":\"2.15.0\"}",
'created_at' => $createdAt,
'updated_at' => $createdAt,
]);
$createdAt = $faker->dateTimeBetween('-1 year', 'now');
$post = Post::create([
"title" => $post_title,
"slug" => $post_slug,
"excerpt" => $faker->paragraph,
"author_id" => $cloned_authors->random()->first()->id,
"featured" => rand(0,1),
"featured_image" => "https://placekitten.com/1920/1080?image={$photo_id}",
"editor" => "editorjs",
"post_format" => "standard",
"comment_count" => rand(0,100),
"likes_count" => rand(0,100),
"status" => "publish",
"body" => "{\"time\":1563816717958,\"blocks\":[{\"data\":{\"text\":\"Editor.js\",\"level\":2},\"type\":\"header\"},{\"data\":{\"text\":\"Hey. Meet the new Editor. On this page you can see it in action \\u2014 try to edit this text.\"},\"type\":\"paragraph\"},{\"data\":{\"text\":\"Key features\",\"level\":3},\"type\":\"header\"},{\"data\":{\"items\":[\"It is a block-styled editor\",\"It returns clean data output in JSON\",\"Designed to be extendable and pluggable with a simple API\"],\"style\":\"unordered\"},\"type\":\"list\"},{\"data\":{\"text\":\"What does it mean \\u00abblock-styled editor\\u00bb\",\"level\":3},\"type\":\"header\"},{\"data\":{\"text\":\"Workspace in classic editors is made of a single contenteditable element, used to create different HTML markups. Editor.js <mark class=\\\"cdx-marker\\\">workspace consists of separate Blocks: paragraphs, headings, images, lists, quotes, etc<\\\/mark>. Each of them is an independent contenteditable element (or more complex structure) provided by Plugin and united by Editor's Core.\"},\"type\":\"paragraph\"},{\"data\":{\"text\":\"There are dozens of <a href=\\\"https:\\\/\\\/github.com\\\/editor-js\\\">ready-to-use Blocks<\\\/a> and the <a href=\\\"https:\\\/\\\/editorjs.io\\\/creating-a-block-tool\\\">simple API<\\\/a> for creation any Block you need. For example, you can implement Blocks for Tweets, Instagram posts, surveys and polls, CTA-buttons and even games.\"},\"type\":\"paragraph\"},{\"data\":{\"text\":\"What does it mean clean data output\",\"level\":3},\"type\":\"header\"},{\"data\":{\"text\":\"Classic WYSIWYG-editors produce raw HTML-markup with both content data and content appearance. On the contrary, Editor.js outputs JSON object with data of each Block. You can see an example below\"},\"type\":\"paragraph\"},{\"data\":{\"text\":\"Given data can be used as you want: render with HTML for <code class=\\\"inline-code\\\">Web clients<\\\/code>, render natively for <code class=\\\"inline-code\\\">mobile apps<\\\/code>, create markup for <code class=\\\"inline-code\\\">Facebook Instant Articles<\\\/code> or <code class=\\\"inline-code\\\">Google AMP<\\\/code>, generate an <code class=\\\"inline-code\\\">audio version<\\\/code> and so on.\"},\"type\":\"paragraph\"},{\"data\":{\"text\":\"Clean data is useful to sanitize, validate and process on the backend.\"},\"type\":\"paragraph\"},{\"data\":[],\"type\":\"delimiter\"},{\"data\":{\"text\":\"We have been working on this project more than three years. Several large media projects help us to test and debug the Editor, to make it's core more stable. At the same time we significantly improved the API. Now, it can be used to create any plugin for any task. Hope you enjoy. \\ud83d\\ude0f\"},\"type\":\"paragraph\"},{\"data\":{\"file\":{\"url\":\"https:\\\/\\\/codex.so\\\/upload\\\/redactor_images\\\/o_e48549d1855c7fc1807308dd14990126.jpg\"},\"caption\":\"Image caption\",\"stretched\":false,\"withBorder\":true,\"withBackground\":false},\"type\":\"image\"}],\"version\":\"2.15.0\"}",
'created_at' => $createdAt,
'updated_at' => $createdAt,
]);
$post_category = PostCategory::create([
'post_id' => $post->id,
'category_id' => $cloned_categories->random()->first()->id,
]);
}
$post_category = PostCategory::create([
'post_id' => $post->id,
'category_id' => $cloned_categories->shuffle()->first()->id,
]);
}
}
}