From 4a63ffb5175c3a37b3c57937146614e3fec48419 Mon Sep 17 00:00:00 2001 From: Hessam Date: Fri, 16 Oct 2020 18:12:23 +0330 Subject: [PATCH 001/118] refactors and adds new tables for translation --- ..._28_224023_create_blog_etc_posts_table.php | 92 ------------------- ...dd_author_and_url_blog_etc_posts_table.php | 37 -------- ...711_add_short_desc_textrea_to_blog_etc.php | 34 ------- ...d_parameters_blog_etc_categories_table.php | 35 ------- ..._005400_create_hessam_categories_table.php | 51 ++++++++++ ...ate_hessam_category_translations_table.php | 39 ++++++++ ...10_16_010039_create_hessam_posts_table.php | 36 ++++++++ ..._create_hessam_post_translations_table.php | 49 ++++++++++ ...16_121230_create_hessam_comments_table.php | 46 ++++++++++ ...8_create_hessam_uploaded_photos_table.php} | 17 +--- ...6_124241_create_hessam_languages_table.php | 38 ++++++++ 11 files changed, 264 insertions(+), 210 deletions(-) delete mode 100755 migrations/2018_05_28_224023_create_blog_etc_posts_table.php delete mode 100644 migrations/2018_09_16_224023_add_author_and_url_blog_etc_posts_table.php delete mode 100644 migrations/2018_09_26_085711_add_short_desc_textrea_to_blog_etc.php delete mode 100644 migrations/2020_05_27_104123_add_parameters_blog_etc_categories_table.php create mode 100644 migrations/2020_10_16_005400_create_hessam_categories_table.php create mode 100644 migrations/2020_10_16_005425_create_hessam_category_translations_table.php create mode 100644 migrations/2020_10_16_010039_create_hessam_posts_table.php create mode 100644 migrations/2020_10_16_010049_create_hessam_post_translations_table.php create mode 100644 migrations/2020_10_16_121230_create_hessam_comments_table.php rename migrations/{2018_09_27_122627_create_blog_etc_uploaded_photos_table.php => 2020_10_16_121728_create_hessam_uploaded_photos_table.php} (60%) create mode 100644 migrations/2020_10_16_124241_create_hessam_languages_table.php diff --git a/migrations/2018_05_28_224023_create_blog_etc_posts_table.php b/migrations/2018_05_28_224023_create_blog_etc_posts_table.php deleted file mode 100755 index 683a076..0000000 --- a/migrations/2018_05_28_224023_create_blog_etc_posts_table.php +++ /dev/null @@ -1,92 +0,0 @@ -increments('id'); - $table->unsignedInteger("user_id")->index()->nullable(); - $table->string("slug")->unique(); - - $table->string("title")->nullable()->default("New blog post"); - $table->string("subtitle")->nullable()->default(""); - $table->text("meta_desc")->nullable(); - $table->mediumText("post_body")->nullable(); - - $table->string("use_view_file")->nullable()->comment("should refer to a blade file in /views/"); - - $table->dateTime("posted_at")->index()->nullable()->comment("Public posted at time, if this is in future then it wont appear yet"); - $table->boolean("is_published")->default(true); - - $table->string('image_large')->nullable(); - $table->string('image_medium')->nullable(); - $table->string('image_thumbnail')->nullable(); - - $table->timestamps(); - }); - - Schema::create('blog_etc_categories', function (Blueprint $table) { - $table->increments('id'); - - $table->string("category_name")->nullable(); - $table->string("slug")->unique(); - $table->mediumText("category_description")->nullable(); - - $table->unsignedInteger("created_by")->nullable()->index()->comment("user id"); - - $table->timestamps(); - }); - - Schema::create('blog_etc_post_categories', function (Blueprint $table) { - $table->increments('id'); - - $table->unsignedInteger("blog_etc_post_id")->index(); - $table->foreign('blog_etc_post_id')->references('id')->on('blog_etc_posts')->onDelete("cascade"); - - $table->unsignedInteger("blog_etc_category_id")->index(); - $table->foreign('blog_etc_category_id')->references('id')->on('blog_etc_categories')->onDelete("cascade"); - }); - - - Schema::create('blog_etc_comments', function (Blueprint $table) { - $table->increments('id'); - - $table->unsignedInteger("blog_etc_post_id")->index(); - $table->foreign('blog_etc_post_id')->references('id')->on('blog_etc_posts')->onDelete("cascade"); - $table->unsignedInteger("user_id")->nullable()->index()->comment("if user was logged in"); - - $table->string("ip")->nullable()->comment("if enabled in the config file"); - $table->string("author_name")->nullable()->comment("if not logged in"); - - $table->text("comment")->comment("the comment body"); - - $table->boolean("approved")->default(true); - - $table->timestamps(); - }); - - - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('blog_etc_post_categories'); - Schema::dropIfExists('blog_etc_categories'); - Schema::dropIfExists('blog_etc_posts'); - } -} diff --git a/migrations/2018_09_16_224023_add_author_and_url_blog_etc_posts_table.php b/migrations/2018_09_16_224023_add_author_and_url_blog_etc_posts_table.php deleted file mode 100644 index 67cec73..0000000 --- a/migrations/2018_09_16_224023_add_author_and_url_blog_etc_posts_table.php +++ /dev/null @@ -1,37 +0,0 @@ -string("author_email")->nullable(); - $table->string("author_website")->nullable(); - }); - - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - - Schema::table('blog_etc_comments', function (Blueprint $table) { - $table->dropColumn("author_email"); - $table->dropColumn("author_website"); - }); - } -} - diff --git a/migrations/2018_09_26_085711_add_short_desc_textrea_to_blog_etc.php b/migrations/2018_09_26_085711_add_short_desc_textrea_to_blog_etc.php deleted file mode 100644 index e24feed..0000000 --- a/migrations/2018_09_26_085711_add_short_desc_textrea_to_blog_etc.php +++ /dev/null @@ -1,34 +0,0 @@ -text("short_description")->nullable(); - }); - - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - - Schema::table('blog_etc_posts', function (Blueprint $table) { - $table->dropColumn("short_description"); - }); - } -} diff --git a/migrations/2020_05_27_104123_add_parameters_blog_etc_categories_table.php b/migrations/2020_05_27_104123_add_parameters_blog_etc_categories_table.php deleted file mode 100644 index 1fc8255..0000000 --- a/migrations/2020_05_27_104123_add_parameters_blog_etc_categories_table.php +++ /dev/null @@ -1,35 +0,0 @@ -integer('parent_id')->nullable()->default(0); - $table->integer('lft')->nullable(); - $table->integer('rgt')->nullable(); - $table->integer('depth')->nullable(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('blog_etc_categories', function (Blueprint $table) { - // - }); - } -} diff --git a/migrations/2020_10_16_005400_create_hessam_categories_table.php b/migrations/2020_10_16_005400_create_hessam_categories_table.php new file mode 100644 index 0000000..c4776e7 --- /dev/null +++ b/migrations/2020_10_16_005400_create_hessam_categories_table.php @@ -0,0 +1,51 @@ +increments('category_id'); + + $table->unsignedInteger("created_by")->nullable()->index()->comment("user id"); + + //columns related to multi-level categories + $table->integer('parent_id')->nullable()->default(0); + $table->integer('lft')->nullable(); + $table->integer('rgt')->nullable(); + $table->integer('depth')->nullable(); + + $table->timestamps(); + }); + + Schema::create('hessam_post_categories', function (Blueprint $table) { + $table->increments('id'); + + $table->unsignedInteger("post_id")->index(); + $table->foreign('post_id')->references('post_id')->on('hessam_posts')->onDelete("cascade"); + + $table->unsignedInteger("category_id")->index(); + $table->foreign('category_id')->references('category_id')->on('hessam_categories')->onDelete("cascade"); + }); + + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('hessam_categories'); + } +} diff --git a/migrations/2020_10_16_005425_create_hessam_category_translations_table.php b/migrations/2020_10_16_005425_create_hessam_category_translations_table.php new file mode 100644 index 0000000..8ff802a --- /dev/null +++ b/migrations/2020_10_16_005425_create_hessam_category_translations_table.php @@ -0,0 +1,39 @@ +increments('category_id'); + + $table->string("category_name")->nullable(); + $table->string("slug")->unique(); + $table->mediumText("category_description")->nullable(); + + $table->unsignedInteger("lang_id")->index(); + $table->foreign('lang_id')->references('lang_id')->on('hessam_languages'); + + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('hessam_category_translations'); + } +} diff --git a/migrations/2020_10_16_010039_create_hessam_posts_table.php b/migrations/2020_10_16_010039_create_hessam_posts_table.php new file mode 100644 index 0000000..0565aa6 --- /dev/null +++ b/migrations/2020_10_16_010039_create_hessam_posts_table.php @@ -0,0 +1,36 @@ +increments('post_id'); + $table->unsignedInteger("user_id")->index()->nullable(); + + $table->dateTime("posted_at")->index()->nullable()->comment("Public posted at time, if this is in future then it wont appear yet"); + $table->boolean("is_published")->default(true); + + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('hessam_posts'); + } +} diff --git a/migrations/2020_10_16_010049_create_hessam_post_translations_table.php b/migrations/2020_10_16_010049_create_hessam_post_translations_table.php new file mode 100644 index 0000000..fd5d295 --- /dev/null +++ b/migrations/2020_10_16_010049_create_hessam_post_translations_table.php @@ -0,0 +1,49 @@ +increments('post_id'); + + $table->string("slug")->unique(); + $table->string("title")->nullable()->default("New blog post"); + $table->string("subtitle")->nullable()->default(""); + $table->text("meta_desc")->nullable(); + $table->string("seo_title")->nullable(); + $table->mediumText("post_body")->nullable(); + $table->text("short_description")->nullable(); + + $table->string("use_view_file")->nullable()->comment("should refer to a blade file in /views/"); + + $table->string('image_large')->nullable(); + $table->string('image_medium')->nullable(); + $table->string('image_thumbnail')->nullable(); + + $table->unsignedInteger("lang_id")->index(); + $table->foreign('lang_id')->references('lang_id')->on('hessam_languages'); + + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('hessam_post_translations'); + } +} diff --git a/migrations/2020_10_16_121230_create_hessam_comments_table.php b/migrations/2020_10_16_121230_create_hessam_comments_table.php new file mode 100644 index 0000000..297b5b6 --- /dev/null +++ b/migrations/2020_10_16_121230_create_hessam_comments_table.php @@ -0,0 +1,46 @@ +increments('id'); + + $table->unsignedInteger("post_id")->index(); + $table->foreign('post_id')->references('post_id')->on('hessam_posts'); + $table->unsignedInteger("user_id")->nullable()->index()->comment("if user was logged in"); + + $table->string("ip")->nullable()->comment("if enabled in the config file"); + $table->string("author_name")->nullable()->comment("if not logged in"); + + $table->text("comment")->comment("the comment body"); + + $table->boolean("approved")->default(true); + + $table->string("author_email")->nullable(); + $table->string("author_website")->nullable(); + + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('hessam_comments'); + } +} diff --git a/migrations/2018_09_27_122627_create_blog_etc_uploaded_photos_table.php b/migrations/2020_10_16_121728_create_hessam_uploaded_photos_table.php similarity index 60% rename from migrations/2018_09_27_122627_create_blog_etc_uploaded_photos_table.php rename to migrations/2020_10_16_121728_create_hessam_uploaded_photos_table.php index 5098b13..66a1d5c 100644 --- a/migrations/2018_09_27_122627_create_blog_etc_uploaded_photos_table.php +++ b/migrations/2020_10_16_121728_create_hessam_uploaded_photos_table.php @@ -1,10 +1,10 @@ increments('id'); $table->text("uploaded_images")->nullable(); $table->string("image_title")->nullable(); @@ -21,9 +21,6 @@ public function up() $table->unsignedInteger("uploader_id")->nullable()->index(); $table->timestamps(); }); - Schema::table("blog_etc_posts",function(Blueprint $table) { - $table->string("seo_title")->nullable(); - }); } /** @@ -33,10 +30,6 @@ public function up() */ public function down() { - Schema::dropIfExists('blog_etc_uploaded_photos'); - - Schema::table("blog_etc_posts",function(Blueprint $table) { - $table->dropColumn("seo_title"); - }); + Schema::dropIfExists('hessam_uploaded_photos'); } } diff --git a/migrations/2020_10_16_124241_create_hessam_languages_table.php b/migrations/2020_10_16_124241_create_hessam_languages_table.php new file mode 100644 index 0000000..b9894e8 --- /dev/null +++ b/migrations/2020_10_16_124241_create_hessam_languages_table.php @@ -0,0 +1,38 @@ +increments('lang_id'); + + $table->string("name")->unique(); + $table->string("locale")->unique(); + $table->string("iso_code")->unique(); + $table->string("date_format")->unique(); + $table->boolean("active")->default(true); + + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('hessam_languages'); + } +} From 2c6c8ad0dff44b75512515a9065026285027ab2a Mon Sep 17 00:00:00 2001 From: Hessam Date: Fri, 16 Oct 2020 18:34:36 +0330 Subject: [PATCH 002/118] model classes refactor --- src/BlogEtcServiceProvider.php | 16 ++++++++------ src/Captcha/CaptchaAbstract.php | 10 ++++----- src/Controllers/BlogEtcAdminController.php | 22 +++++++++---------- .../BlogEtcCategoryAdminController.php | 20 ++++++++--------- .../BlogEtcCommentWriterController.php | 10 ++++----- .../BlogEtcCommentsAdminController.php | 8 +++---- .../BlogEtcImageUploadController.php | 6 ++--- src/Controllers/BlogEtcReaderController.php | 14 ++++++------ src/Controllers/BlogEtcRssFeedController.php | 6 ++--- src/Events/BlogPostAdded.php | 8 +++---- src/Events/BlogPostEdited.php | 8 +++---- src/Events/BlogPostWillBeDeleted.php | 8 +++---- src/Events/CategoryAdded.php | 8 +++---- src/Events/CategoryEdited.php | 8 +++---- src/Events/CategoryWillBeDeleted.php | 8 +++---- src/Events/CommentAdded.php | 14 ++++++------ src/Events/CommentApproved.php | 8 +++---- src/Events/CommentWillBeDeleted.php | 8 +++---- src/Events/UploadedImage.php | 8 +++---- ...BlogEtcCategory.php => HessamCategory.php} | 8 +++---- .../{BlogEtcComment.php => HessamComment.php} | 6 ++--- .../{BlogEtcPost.php => HessamPost.php} | 12 +++++----- ...oadedPhoto.php => HessamUploadedPhoto.php} | 2 +- src/Requests/Traits/HasCategoriesTrait.php | 4 ++-- src/Requests/UpdateBlogEtcCategoryRequest.php | 2 +- src/Requests/UpdateBlogEtcPostRequest.php | 2 +- src/Traits/UploadFileTrait.php | 6 ++--- src/Views/blogetc/search.blade.php | 2 +- .../blogetc/sitewide/random_posts.blade.php | 2 +- .../blogetc/sitewide/recent_posts.blade.php | 2 +- .../sitewide/show_all_categories.blade.php | 2 +- .../blogetc_admin/layouts/sidebar.blade.php | 8 +++---- .../blogetc_admin/posts/add_post.blade.php | 2 +- src/Views/blogetc_admin/posts/form.blade.php | 2 +- tests/MainTest.php | 20 ++++++++--------- 35 files changed, 141 insertions(+), 139 deletions(-) rename src/Models/{BlogEtcCategory.php => HessamCategory.php} (84%) rename src/Models/{BlogEtcComment.php => HessamComment.php} (91%) rename src/Models/{BlogEtcPost.php => HessamPost.php} (93%) rename src/Models/{BlogEtcUploadedPhoto.php => HessamUploadedPhoto.php} (88%) diff --git a/src/BlogEtcServiceProvider.php b/src/BlogEtcServiceProvider.php index a8ed524..9b92d6f 100755 --- a/src/BlogEtcServiceProvider.php +++ b/src/BlogEtcServiceProvider.php @@ -4,7 +4,7 @@ use Illuminate\Support\ServiceProvider; use Swis\Laravel\Fulltext\ModelObserver; -use WebDevEtc\BlogEtc\Models\BlogEtcPost; +use WebDevEtc\BlogEtc\Models\HessamPost; class BlogEtcServiceProvider extends ServiceProvider { @@ -18,7 +18,7 @@ public function boot() if (config("blogetc.search.search_enabled") == false) { // if search is disabled, don't allow it to sync. - ModelObserver::disableSyncingFor(BlogEtcPost::class); + ModelObserver::disableSyncingFor(HessamPost::class); } if (config("blogetc.include_default_routes", true)) { @@ -27,11 +27,13 @@ public function boot() foreach ([ - '2018_05_28_224023_create_blog_etc_posts_table.php', - '2018_09_16_224023_add_author_and_url_blog_etc_posts_table.php', - '2018_09_26_085711_add_short_desc_textrea_to_blog_etc.php', - '2018_09_27_122627_create_blog_etc_uploaded_photos_table.php', - '2020_05_27_104123_add_parameters_blog_etc_categories_table.php' + '2020_10_16_005400_create_hessam_categories_table.php', + '2020_10_16_005425_create_hessam_category_translations_table.php', + '2020_10_16_010039_create_hessam_posts_table.php', + '2020_10_16_010049_create_hessam_post_translations_table.php', + '2020_10_16_121230_create_hessam_comments_table.php', + '2020_10_16_121728_create_hessam_uploaded_photos_table.php', + '2020_10_16_124241_create_hessam_languages_table.php' ] as $file) { $this->publishes([ diff --git a/src/Captcha/CaptchaAbstract.php b/src/Captcha/CaptchaAbstract.php index c11dcf1..bfacc6a 100644 --- a/src/Captcha/CaptchaAbstract.php +++ b/src/Captcha/CaptchaAbstract.php @@ -2,7 +2,7 @@ use Illuminate\Http\Request; use WebDevEtc\BlogEtc\Interfaces\CaptchaInterface; -use WebDevEtc\BlogEtc\Models\BlogEtcPost; +use WebDevEtc\BlogEtc\Models\HessamPost; abstract class CaptchaAbstract implements CaptchaInterface { @@ -12,11 +12,11 @@ abstract class CaptchaAbstract implements CaptchaInterface * executed when viewing single post * * @param Request $request - * @param BlogEtcPost $blogEtcPost + * @param HessamPost $blogEtcPost * * @return void */ - public function runCaptchaBeforeShowingPosts(Request $request, BlogEtcPost $blogEtcPost) + public function runCaptchaBeforeShowingPosts(Request $request, HessamPost $blogEtcPost) { // no code here to run! Maybe in your subclass you can make use of this? /* @@ -37,11 +37,11 @@ public function runCaptchaBeforeShowingPosts(Request $request, BlogEtcPost $blog * executed when posting new comment * * @param Request $request - * @param BlogEtcPost $blogEtcPost + * @param HessamPost $blogEtcPost * * @return void */ - public function runCaptchaBeforeAddingComment(Request $request, BlogEtcPost $blogEtcPost) + public function runCaptchaBeforeAddingComment(Request $request, HessamPost $blogEtcPost) { // no code here to run! Maybe in your subclass you can make use of this? } diff --git a/src/Controllers/BlogEtcAdminController.php b/src/Controllers/BlogEtcAdminController.php index 9f93a30..891d3c4 100755 --- a/src/Controllers/BlogEtcAdminController.php +++ b/src/Controllers/BlogEtcAdminController.php @@ -11,8 +11,8 @@ use WebDevEtc\BlogEtc\Events\BlogPostWillBeDeleted; use WebDevEtc\BlogEtc\Helpers; use WebDevEtc\BlogEtc\Middleware\UserCanManageBlogPosts; -use WebDevEtc\BlogEtc\Models\BlogEtcPost; -use WebDevEtc\BlogEtc\Models\BlogEtcUploadedPhoto; +use WebDevEtc\BlogEtc\Models\HessamPost; +use WebDevEtc\BlogEtc\Models\HessamUploadedPhoto; use WebDevEtc\BlogEtc\Requests\CreateBlogEtcPostRequest; use WebDevEtc\BlogEtc\Requests\DeleteBlogEtcPostRequest; use WebDevEtc\BlogEtc\Requests\UpdateBlogEtcPostRequest; @@ -46,7 +46,7 @@ public function __construct() */ public function index() { - $posts = BlogEtcPost::orderBy("posted_at", "desc") + $posts = HessamPost::orderBy("posted_at", "desc") ->paginate(10); return view("blogetc_admin::index", ['posts'=>$posts]); @@ -70,7 +70,7 @@ public function create_post() */ public function store_post(CreateBlogEtcPostRequest $request) { - $new_blog_post = new BlogEtcPost($request->all()); + $new_blog_post = new HessamPost($request->all()); $this->processUploadedImages($request, $new_blog_post); @@ -96,7 +96,7 @@ public function store_post(CreateBlogEtcPostRequest $request) */ public function edit_post( $blogPostId) { - $post = BlogEtcPost::findOrFail($blogPostId); + $post = HessamPost::findOrFail($blogPostId); return view("blogetc_admin::posts.edit_post")->withPost($post); } @@ -110,8 +110,8 @@ public function edit_post( $blogPostId) */ public function update_post(UpdateBlogEtcPostRequest $request, $blogPostId) { - /** @var BlogEtcPost $post */ - $post = BlogEtcPost::findOrFail($blogPostId); + /** @var HessamPost $post */ + $post = HessamPost::findOrFail($blogPostId); $post->fill($request->all()); $this->processUploadedImages($request, $post); @@ -128,7 +128,7 @@ public function update_post(UpdateBlogEtcPostRequest $request, $blogPostId) public function remove_photo($postSlug) { - $post = BlogEtcPost::where("slug", $postSlug)->firstOrFail(); + $post = HessamPost::where("slug", $postSlug)->firstOrFail(); $path = public_path('/' . config("blogetc.blog_upload_dir")); if (!$this->checked_blog_image_dir_is_writable) { @@ -171,7 +171,7 @@ public function remove_photo($postSlug) public function destroy_post(DeleteBlogEtcPostRequest $request, $blogPostId) { - $post = BlogEtcPost::findOrFail($blogPostId); + $post = HessamPost::findOrFail($blogPostId); event(new BlogPostWillBeDeleted($post)); $post->delete(); @@ -192,7 +192,7 @@ public function destroy_post(DeleteBlogEtcPostRequest $request, $blogPostId) * @throws \Exception * @todo - next full release, tidy this up! */ - protected function processUploadedImages(BaseRequestInterface $request, BlogEtcPost $new_blog_post) + protected function processUploadedImages(BaseRequestInterface $request, HessamPost $new_blog_post) { if (!config("blogetc.image_upload_enabled")) { // image upload was disabled @@ -221,7 +221,7 @@ protected function processUploadedImages(BaseRequestInterface $request, BlogEtcP // store the image upload. // todo: link this to the blogetc_post row. if (count(array_filter($uploaded_image_details))>0) { - BlogEtcUploadedPhoto::create([ + HessamUploadedPhoto::create([ 'source' => "BlogFeaturedImage", 'uploaded_images' => $uploaded_image_details, ]); diff --git a/src/Controllers/BlogEtcCategoryAdminController.php b/src/Controllers/BlogEtcCategoryAdminController.php index 827222c..2ea8d58 100755 --- a/src/Controllers/BlogEtcCategoryAdminController.php +++ b/src/Controllers/BlogEtcCategoryAdminController.php @@ -8,7 +8,7 @@ use WebDevEtc\BlogEtc\Events\CategoryWillBeDeleted; use WebDevEtc\BlogEtc\Helpers; use WebDevEtc\BlogEtc\Middleware\UserCanManageBlogPosts; -use WebDevEtc\BlogEtc\Models\BlogEtcCategory; +use WebDevEtc\BlogEtc\Models\HessamCategory; use WebDevEtc\BlogEtc\Requests\DeleteBlogEtcCategoryRequest; use WebDevEtc\BlogEtc\Requests\StoreBlogEtcCategoryRequest; use WebDevEtc\BlogEtc\Requests\UpdateBlogEtcCategoryRequest; @@ -34,7 +34,7 @@ public function __construct() */ public function index(){ - $categories = BlogEtcCategory::orderBy("category_name")->paginate(25); + $categories = HessamCategory::orderBy("category_name")->paginate(25); return view("blogetc_admin::categories.index")->withCategories($categories); } @@ -45,8 +45,8 @@ public function index(){ public function create_category(){ return view("blogetc_admin::categories.add_category",[ - 'category' => new \WebDevEtc\BlogEtc\Models\BlogEtcCategory(), - 'categories_list' => BlogEtcCategory::orderBy("category_name")->get() + 'category' => new \WebDevEtc\BlogEtc\Models\HessamCategory(), + 'categories_list' => HessamCategory::orderBy("category_name")->get() ]); } @@ -61,7 +61,7 @@ public function store_category(StoreBlogEtcCategoryRequest $request){ if ($request['parent_id']== 0){ $request['parent_id'] = null; } - $new_category = BlogEtcCategory::create($request->all()); + $new_category = HessamCategory::create($request->all()); Helpers::flash_message("Saved new category"); @@ -75,9 +75,9 @@ public function store_category(StoreBlogEtcCategoryRequest $request){ * @return mixed */ public function edit_category($categoryId){ - $category = BlogEtcCategory::findOrFail($categoryId); + $category = HessamCategory::findOrFail($categoryId); return view("blogetc_admin::categories.edit_category",[ - 'categories_list' => BlogEtcCategory::orderBy("category_name")->get() + 'categories_list' => HessamCategory::orderBy("category_name")->get() ])->withCategory($category); } @@ -89,8 +89,8 @@ public function edit_category($categoryId){ * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector */ public function update_category(UpdateBlogEtcCategoryRequest $request, $categoryId){ - /** @var BlogEtcCategory $category */ - $category = BlogEtcCategory::findOrFail($categoryId); + /** @var HessamCategory $category */ + $category = HessamCategory::findOrFail($categoryId); $category->fill($request->all()); $category->save(); @@ -111,7 +111,7 @@ public function destroy_category(DeleteBlogEtcCategoryRequest $request, $categor /* Please keep this in, so code inspections don't say $request was unused. Of course it might now get marked as left/right parts are equal */ $request=$request; - $category = BlogEtcCategory::findOrFail($categoryId); + $category = HessamCategory::findOrFail($categoryId); event(new CategoryWillBeDeleted($category)); $category->delete(); diff --git a/src/Controllers/BlogEtcCommentWriterController.php b/src/Controllers/BlogEtcCommentWriterController.php index d033439..a1ba079 100755 --- a/src/Controllers/BlogEtcCommentWriterController.php +++ b/src/Controllers/BlogEtcCommentWriterController.php @@ -7,8 +7,8 @@ use WebDevEtc\BlogEtc\Captcha\CaptchaAbstract; use WebDevEtc\BlogEtc\Captcha\UsesCaptcha; use WebDevEtc\BlogEtc\Events\CommentAdded; -use WebDevEtc\BlogEtc\Models\BlogEtcComment; -use WebDevEtc\BlogEtc\Models\BlogEtcPost; +use WebDevEtc\BlogEtc\Models\HessamComment; +use WebDevEtc\BlogEtc\Models\HessamPost; use WebDevEtc\BlogEtc\Requests\AddNewCommentRequest; /** @@ -35,7 +35,7 @@ public function addNewComment(AddNewCommentRequest $request, $blog_post_slug) throw new \RuntimeException("Built in comments are disabled"); } - $blog_post = BlogEtcPost::where("slug", $blog_post_slug) + $blog_post = HessamPost::where("slug", $blog_post_slug) ->firstOrFail(); /** @var CaptchaAbstract $captcha */ @@ -57,11 +57,11 @@ public function addNewComment(AddNewCommentRequest $request, $blog_post_slug) /** * @param AddNewCommentRequest $request * @param $blog_post - * @return BlogEtcComment + * @return HessamComment */ protected function createNewComment(AddNewCommentRequest $request, $blog_post) { - $new_comment = new BlogEtcComment($request->all()); + $new_comment = new HessamComment($request->all()); if (config("blogetc.comments.save_ip_address")) { $new_comment->ip = $request->ip(); diff --git a/src/Controllers/BlogEtcCommentsAdminController.php b/src/Controllers/BlogEtcCommentsAdminController.php index 3557aed..de3a638 100755 --- a/src/Controllers/BlogEtcCommentsAdminController.php +++ b/src/Controllers/BlogEtcCommentsAdminController.php @@ -8,7 +8,7 @@ use WebDevEtc\BlogEtc\Events\CommentWillBeDeleted; use WebDevEtc\BlogEtc\Helpers; use WebDevEtc\BlogEtc\Middleware\UserCanManageBlogPosts; -use WebDevEtc\BlogEtc\Models\BlogEtcComment; +use WebDevEtc\BlogEtc\Models\HessamComment; /** * Class BlogEtcCommentsAdminController @@ -32,7 +32,7 @@ public function __construct() */ public function index(Request $request) { - $comments = BlogEtcComment::withoutGlobalScopes()->orderBy("created_at", "desc") + $comments = HessamComment::withoutGlobalScopes()->orderBy("created_at", "desc") ->with("post"); if ($request->get("waiting_for_approval")) { @@ -54,7 +54,7 @@ public function index(Request $request) */ public function approve($blogCommentId) { - $comment = BlogEtcComment::withoutGlobalScopes()->findOrFail($blogCommentId); + $comment = HessamComment::withoutGlobalScopes()->findOrFail($blogCommentId); $comment->approved = true; $comment->save(); @@ -73,7 +73,7 @@ public function approve($blogCommentId) */ public function destroy($blogCommentId) { - $comment = BlogEtcComment::withoutGlobalScopes()->findOrFail($blogCommentId); + $comment = HessamComment::withoutGlobalScopes()->findOrFail($blogCommentId); event(new CommentWillBeDeleted($comment)); $comment->delete(); diff --git a/src/Controllers/BlogEtcImageUploadController.php b/src/Controllers/BlogEtcImageUploadController.php index de80e75..72a2295 100755 --- a/src/Controllers/BlogEtcImageUploadController.php +++ b/src/Controllers/BlogEtcImageUploadController.php @@ -5,7 +5,7 @@ use App\Http\Controllers\Controller; use Illuminate\Http\Request; use WebDevEtc\BlogEtc\Middleware\UserCanManageBlogPosts; -use WebDevEtc\BlogEtc\Models\BlogEtcUploadedPhoto; +use WebDevEtc\BlogEtc\Models\HessamUploadedPhoto; use File; use WebDevEtc\BlogEtc\Requests\UploadImageRequest; use WebDevEtc\BlogEtc\Traits\UploadFileTrait; @@ -46,7 +46,7 @@ public function __construct() public function index() { - return view("blogetc_admin::imageupload.index", ['uploaded_photos' => BlogEtcUploadedPhoto::orderBy("id", "desc")->paginate(10)]); + return view("blogetc_admin::imageupload.index", ['uploaded_photos' => HessamUploadedPhoto::orderBy("id", "desc")->paginate(10)]); } /** @@ -112,7 +112,7 @@ protected function processUploadedImages(UploadImageRequest $request) // store the image upload. - BlogEtcUploadedPhoto::create([ + HessamUploadedPhoto::create([ 'image_title' => $request->get("image_title"), 'source' => "ImageUpload", 'uploader_id' => optional(\Auth::user())->id, diff --git a/src/Controllers/BlogEtcReaderController.php b/src/Controllers/BlogEtcReaderController.php index 242a437..8482430 100755 --- a/src/Controllers/BlogEtcReaderController.php +++ b/src/Controllers/BlogEtcReaderController.php @@ -7,8 +7,8 @@ use Illuminate\Http\Request; use Swis\Laravel\Fulltext\Search; use WebDevEtc\BlogEtc\Captcha\UsesCaptcha; -use WebDevEtc\BlogEtc\Models\BlogEtcCategory; -use WebDevEtc\BlogEtc\Models\BlogEtcPost; +use WebDevEtc\BlogEtc\Models\HessamCategory; +use WebDevEtc\BlogEtc\Models\HessamPost; /** * Class BlogEtcReaderController @@ -33,7 +33,7 @@ public function index($category_slug = null) $categoryChain = null; if ($category_slug) { - $category = BlogEtcCategory::where("slug", $category_slug)->firstOrFail(); + $category = HessamCategory::where("slug", $category_slug)->firstOrFail(); $categoryChain = $category->getAncestorsAndSelf(); $posts = $category->posts()->where("blog_etc_post_categories.blog_etc_category_id", $category->id); @@ -42,13 +42,13 @@ public function index($category_slug = null) \View::share('blogetc_category', $category); // so the view can say "You are viewing $CATEGORYNAME category posts" $title = 'Posts in ' . $category->category_name . " category"; // hardcode title here... } else { - $posts = BlogEtcPost::query(); + $posts = HessamPost::query(); } $posts = $posts->where('is_published', '=', 1)->where('posted_at', '<', Carbon::now()->format('Y-m-d H:i:s'))->orderBy("posted_at", "desc")->paginate(config("blogetc.per_page", 10)); //load categories in 3 levels - $rootList = BlogEtcCategory::where('parent_id' ,'=' , null)->get(); + $rootList = HessamCategory::where('parent_id' ,'=' , null)->get(); for($i = 0 ; sizeof($rootList) > $i ; $i++){ $rootList[$i]->loadSiblings(); for ($j = 0 ; sizeof($rootList[$i]->siblings) > $j; $j++){ @@ -82,7 +82,7 @@ public function search(Request $request) \View::share("title", "Search results for " . e($query)); - $categories = BlogEtcCategory::all(); + $categories = HessamCategory::all(); return view("blogetc::search", [ 'categories' => $categories, @@ -115,7 +115,7 @@ public function view_category($hierarchy) public function viewSinglePost(Request $request, $blogPostSlug) { // the published_at + is_published are handled by BlogEtcPublishedScope, and don't take effect if the logged in user can manage log posts - $blog_post = BlogEtcPost::where("slug", $blogPostSlug) + $blog_post = HessamPost::where("slug", $blogPostSlug) ->firstOrFail(); if ($captcha = $this->getCaptchaObject()) { diff --git a/src/Controllers/BlogEtcRssFeedController.php b/src/Controllers/BlogEtcRssFeedController.php index 2b0ada9..c361f18 100755 --- a/src/Controllers/BlogEtcRssFeedController.php +++ b/src/Controllers/BlogEtcRssFeedController.php @@ -5,7 +5,7 @@ use App\Http\Controllers\Controller; use Carbon\Carbon; use Laravelium\Feed\Feed; -use WebDevEtc\BlogEtc\Models\BlogEtcPost; +use WebDevEtc\BlogEtc\Models\HessamPost; use WebDevEtc\BlogEtc\Requests\FeedRequest; /** @@ -38,14 +38,14 @@ protected function setupFeed(Feed $feed, $posts) */ protected function makeFreshFeed(Feed $feed) { - $posts = BlogEtcPost::orderBy("posted_at", "desc") + $posts = HessamPost::orderBy("posted_at", "desc") ->limit(config("blogetc.rssfeed.posts_to_show_in_rss_feed", 10)) ->with("author") ->get(); $this->setupFeed($feed, $posts); - /** @var BlogEtcPost $post */ + /** @var HessamPost $post */ foreach ($posts as $post) { $feed->add($post->title, $post->author_string(), diff --git a/src/Events/BlogPostAdded.php b/src/Events/BlogPostAdded.php index d0bfb21..081a6fc 100644 --- a/src/Events/BlogPostAdded.php +++ b/src/Events/BlogPostAdded.php @@ -5,7 +5,7 @@ use Illuminate\Queue\SerializesModels; use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Broadcasting\InteractsWithSockets; -use WebDevEtc\BlogEtc\Models\BlogEtcPost; +use WebDevEtc\BlogEtc\Models\HessamPost; /** * Class BlogPostAdded @@ -15,14 +15,14 @@ class BlogPostAdded { use Dispatchable, InteractsWithSockets, SerializesModels; - /** @var BlogEtcPost */ + /** @var HessamPost */ public $blogEtcPost; /** * BlogPostAdded constructor. - * @param BlogEtcPost $blogEtcPost + * @param HessamPost $blogEtcPost */ - public function __construct(BlogEtcPost $blogEtcPost) + public function __construct(HessamPost $blogEtcPost) { $this->blogEtcPost=$blogEtcPost; } diff --git a/src/Events/BlogPostEdited.php b/src/Events/BlogPostEdited.php index 3bade22..c19f366 100644 --- a/src/Events/BlogPostEdited.php +++ b/src/Events/BlogPostEdited.php @@ -5,7 +5,7 @@ use Illuminate\Queue\SerializesModels; use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Broadcasting\InteractsWithSockets; -use WebDevEtc\BlogEtc\Models\BlogEtcPost; +use WebDevEtc\BlogEtc\Models\HessamPost; /** * Class BlogPostEdited @@ -15,14 +15,14 @@ class BlogPostEdited { use Dispatchable, InteractsWithSockets, SerializesModels; - /** @var BlogEtcPost */ + /** @var HessamPost */ public $blogEtcPost; /** * BlogPostEdited constructor. - * @param BlogEtcPost $blogEtcPost + * @param HessamPost $blogEtcPost */ - public function __construct(BlogEtcPost $blogEtcPost) + public function __construct(HessamPost $blogEtcPost) { $this->blogEtcPost=$blogEtcPost; } diff --git a/src/Events/BlogPostWillBeDeleted.php b/src/Events/BlogPostWillBeDeleted.php index 3e1f332..3770200 100644 --- a/src/Events/BlogPostWillBeDeleted.php +++ b/src/Events/BlogPostWillBeDeleted.php @@ -5,7 +5,7 @@ use Illuminate\Queue\SerializesModels; use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Broadcasting\InteractsWithSockets; -use WebDevEtc\BlogEtc\Models\BlogEtcPost; +use WebDevEtc\BlogEtc\Models\HessamPost; /** * Class BlogPostWillBeDeleted @@ -15,14 +15,14 @@ class BlogPostWillBeDeleted { use Dispatchable, InteractsWithSockets, SerializesModels; - /** @var BlogEtcPost */ + /** @var HessamPost */ public $blogEtcPost; /** * BlogPostWillBeDeleted constructor. - * @param BlogEtcPost $blogEtcPost + * @param HessamPost $blogEtcPost */ - public function __construct(BlogEtcPost $blogEtcPost) + public function __construct(HessamPost $blogEtcPost) { $this->blogEtcPost=$blogEtcPost; } diff --git a/src/Events/CategoryAdded.php b/src/Events/CategoryAdded.php index 825339e..b5b23e3 100644 --- a/src/Events/CategoryAdded.php +++ b/src/Events/CategoryAdded.php @@ -5,7 +5,7 @@ use Illuminate\Queue\SerializesModels; use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Broadcasting\InteractsWithSockets; -use WebDevEtc\BlogEtc\Models\BlogEtcCategory; +use WebDevEtc\BlogEtc\Models\HessamCategory; /** * Class CategoryAdded @@ -15,14 +15,14 @@ class CategoryAdded { use Dispatchable, InteractsWithSockets, SerializesModels; - /** @var BlogEtcCategory */ + /** @var HessamCategory */ public $blogEtcCategory; /** * CategoryAdded constructor. - * @param BlogEtcCategory $blogEtcCategory + * @param HessamCategory $blogEtcCategory */ - public function __construct(BlogEtcCategory $blogEtcCategory) + public function __construct(HessamCategory $blogEtcCategory) { $this->blogEtcCategory=$blogEtcCategory; } diff --git a/src/Events/CategoryEdited.php b/src/Events/CategoryEdited.php index 9fe3ef6..e175397 100644 --- a/src/Events/CategoryEdited.php +++ b/src/Events/CategoryEdited.php @@ -5,7 +5,7 @@ use Illuminate\Queue\SerializesModels; use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Broadcasting\InteractsWithSockets; -use WebDevEtc\BlogEtc\Models\BlogEtcCategory; +use WebDevEtc\BlogEtc\Models\HessamCategory; /** * Class CategoryEdited @@ -15,14 +15,14 @@ class CategoryEdited { use Dispatchable, InteractsWithSockets, SerializesModels; - /** @var BlogEtcCategory */ + /** @var HessamCategory */ public $blogEtcCategory; /** * CategoryEdited constructor. - * @param BlogEtcCategory $blogEtcCategory + * @param HessamCategory $blogEtcCategory */ - public function __construct(BlogEtcCategory $blogEtcCategory) + public function __construct(HessamCategory $blogEtcCategory) { $this->blogEtcCategory=$blogEtcCategory; } diff --git a/src/Events/CategoryWillBeDeleted.php b/src/Events/CategoryWillBeDeleted.php index 980d233..299297c 100644 --- a/src/Events/CategoryWillBeDeleted.php +++ b/src/Events/CategoryWillBeDeleted.php @@ -5,7 +5,7 @@ use Illuminate\Queue\SerializesModels; use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Broadcasting\InteractsWithSockets; -use WebDevEtc\BlogEtc\Models\BlogEtcCategory; +use WebDevEtc\BlogEtc\Models\HessamCategory; /** * Class CategoryWillBeDeleted @@ -15,14 +15,14 @@ class CategoryWillBeDeleted { use Dispatchable, InteractsWithSockets, SerializesModels; - /** @var BlogEtcCategory */ + /** @var HessamCategory */ public $blogEtcCategory; /** * CategoryWillBeDeleted constructor. - * @param BlogEtcCategory $blogEtcCategory + * @param HessamCategory $blogEtcCategory */ - public function __construct(BlogEtcCategory $blogEtcCategory) + public function __construct(HessamCategory $blogEtcCategory) { $this->blogEtcCategory=$blogEtcCategory; } diff --git a/src/Events/CommentAdded.php b/src/Events/CommentAdded.php index dcb383c..60b196e 100644 --- a/src/Events/CommentAdded.php +++ b/src/Events/CommentAdded.php @@ -5,8 +5,8 @@ use Illuminate\Queue\SerializesModels; use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Broadcasting\InteractsWithSockets; -use WebDevEtc\BlogEtc\Models\BlogEtcComment; -use WebDevEtc\BlogEtc\Models\BlogEtcPost; +use WebDevEtc\BlogEtc\Models\HessamComment; +use WebDevEtc\BlogEtc\Models\HessamPost; /** * Class CommentAdded @@ -16,17 +16,17 @@ class CommentAdded { use Dispatchable, InteractsWithSockets, SerializesModels; - /** @var BlogEtcPost */ + /** @var HessamPost */ public $blogEtcPost; - /** @var BlogEtcComment */ + /** @var HessamComment */ public $newComment; /** * CommentAdded constructor. - * @param BlogEtcPost $blogEtcPost - * @param BlogEtcComment $newComment + * @param HessamPost $blogEtcPost + * @param HessamComment $newComment */ - public function __construct(BlogEtcPost $blogEtcPost, BlogEtcComment $newComment) + public function __construct(HessamPost $blogEtcPost, HessamComment $newComment) { $this->blogEtcPost=$blogEtcPost; $this->newComment=$newComment; diff --git a/src/Events/CommentApproved.php b/src/Events/CommentApproved.php index 43c9351..e712028 100644 --- a/src/Events/CommentApproved.php +++ b/src/Events/CommentApproved.php @@ -5,7 +5,7 @@ use Illuminate\Queue\SerializesModels; use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Broadcasting\InteractsWithSockets; -use WebDevEtc\BlogEtc\Models\BlogEtcComment; +use WebDevEtc\BlogEtc\Models\HessamComment; /** * Class CommentApproved @@ -15,14 +15,14 @@ class CommentApproved { use Dispatchable, InteractsWithSockets, SerializesModels; - /** @var BlogEtcComment */ + /** @var HessamComment */ public $comment; /** * CommentApproved constructor. - * @param BlogEtcComment $comment + * @param HessamComment $comment */ - public function __construct(BlogEtcComment $comment) + public function __construct(HessamComment $comment) { $this->comment=$comment; // you can get the blog post via $comment->post diff --git a/src/Events/CommentWillBeDeleted.php b/src/Events/CommentWillBeDeleted.php index 7947eb5..fd41e19 100644 --- a/src/Events/CommentWillBeDeleted.php +++ b/src/Events/CommentWillBeDeleted.php @@ -5,7 +5,7 @@ use Illuminate\Queue\SerializesModels; use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Broadcasting\InteractsWithSockets; -use WebDevEtc\BlogEtc\Models\BlogEtcComment; +use WebDevEtc\BlogEtc\Models\HessamComment; /** * Class CommentWillBeDeleted @@ -15,14 +15,14 @@ class CommentWillBeDeleted { use Dispatchable, InteractsWithSockets, SerializesModels; - /** @var BlogEtcComment */ + /** @var HessamComment */ public $comment; /** * CommentWillBeDeleted constructor. - * @param BlogEtcComment $comment + * @param HessamComment $comment */ - public function __construct(BlogEtcComment $comment) + public function __construct(HessamComment $comment) { $this->comment=$comment; } diff --git a/src/Events/UploadedImage.php b/src/Events/UploadedImage.php index 1feb61d..333f2a1 100644 --- a/src/Events/UploadedImage.php +++ b/src/Events/UploadedImage.php @@ -5,7 +5,7 @@ use Illuminate\Queue\SerializesModels; use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Broadcasting\InteractsWithSockets; -use WebDevEtc\BlogEtc\Models\BlogEtcPost; +use WebDevEtc\BlogEtc\Models\HessamPost; /** * Class UploadedImage @@ -15,7 +15,7 @@ class UploadedImage { use Dispatchable, InteractsWithSockets, SerializesModels; - /** @var BlogEtcPost|null */ + /** @var HessamPost|null */ public $blogEtcPost; /** * @var @@ -29,11 +29,11 @@ class UploadedImage * UploadedImage constructor. * * @param $image_filename - the new filename - * @param BlogEtcPost $blogEtcPost + * @param HessamPost $blogEtcPost * @param $image * @param $source string|null the __METHOD__ firing this event (or other string) */ - public function __construct(string $image_filename, $image,BlogEtcPost $blogEtcPost=null,string $source='other') + public function __construct(string $image_filename, $image, HessamPost $blogEtcPost=null, string $source='other') { $this->image_filename = $image_filename; $this->blogEtcPost=$blogEtcPost; diff --git a/src/Models/BlogEtcCategory.php b/src/Models/HessamCategory.php similarity index 84% rename from src/Models/BlogEtcCategory.php rename to src/Models/HessamCategory.php index af32277..c5a1d66 100755 --- a/src/Models/BlogEtcCategory.php +++ b/src/Models/HessamCategory.php @@ -5,7 +5,7 @@ use Illuminate\Database\Eloquent\Model; use WebDevEtc\BlogEtc\Baum\Node; -class BlogEtcCategory extends Node +class HessamCategory extends Node { protected $parentColumn = 'parent_id'; public $siblings = array(); @@ -22,7 +22,7 @@ class BlogEtcCategory extends Node */ public function posts() { - return $this->belongsToMany(BlogEtcPost::class, 'blog_etc_post_categories'); + return $this->belongsToMany(HessamPost::class, 'blog_etc_post_categories'); } /** @@ -54,12 +54,12 @@ public function loadSiblings(){ // public function parent() // { -// return $this->belongsTo('WebDevEtc\BlogEtc\Models\BlogEtcCategory', 'parent_id'); +// return $this->belongsTo('WebDevEtc\BlogEtc\Models\HessamCategory', 'parent_id'); // } // // public function children() // { -// return $this->hasMany('WebDevEtc\BlogEtc\Models\BlogEtcCategory', 'parent_id'); +// return $this->hasMany('WebDevEtc\BlogEtc\Models\HessamCategory', 'parent_id'); // } // // // recursive, loads all descendants diff --git a/src/Models/BlogEtcComment.php b/src/Models/HessamComment.php similarity index 91% rename from src/Models/BlogEtcComment.php rename to src/Models/HessamComment.php index 680bb1c..2096f18 100755 --- a/src/Models/BlogEtcComment.php +++ b/src/Models/HessamComment.php @@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model; use WebDevEtc\BlogEtc\Scopes\BlogCommentApprovedAndDefaultOrderScope; -class BlogEtcComment extends Model +class HessamComment extends Model { public $casts = [ 'approved' => 'boolean', @@ -37,12 +37,12 @@ protected static function boot() /** - * The associated BlogEtcPost + * The associated HessamPost * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ public function post() { - return $this->belongsTo(BlogEtcPost::class,"blog_etc_post_id"); + return $this->belongsTo(HessamPost::class,"blog_etc_post_id"); } /** diff --git a/src/Models/BlogEtcPost.php b/src/Models/HessamPost.php similarity index 93% rename from src/Models/BlogEtcPost.php rename to src/Models/HessamPost.php index 12d97f5..fbcfb11 100755 --- a/src/Models/BlogEtcPost.php +++ b/src/Models/HessamPost.php @@ -9,10 +9,10 @@ use WebDevEtc\BlogEtc\Scopes\BlogEtcPublishedScope; /** - * Class BlogEtcPost + * Class HessamPost * @package WebDevEtc\BlogEtc\Models */ -class BlogEtcPost extends Model implements SearchResultInterface +class HessamPost extends Model implements SearchResultInterface { use Sluggable; @@ -121,7 +121,7 @@ public function author_string() */ public function categories() { - return $this->belongsToMany(BlogEtcCategory::class, 'blog_etc_post_categories'); + return $this->belongsToMany(HessamCategory::class, 'blog_etc_post_categories'); } /** @@ -131,7 +131,7 @@ public function categories() */ public function comments() { - return $this->hasMany(BlogEtcComment::class); + return $this->hasMany(HessamComment::class); } /** @@ -281,11 +281,11 @@ protected function check_valid_image_size(string $size = 'medium') in the database table: : blogetc_posts.image_medium when calling image_url() : image_url("medium") */ - throw new \InvalidArgumentException("Invalid image size ($size). BlogEtcPost image size should not begin with 'image_'. Remove this from the start of $size. It *should* be in the blogetc.image_sizes config though!"); + throw new \InvalidArgumentException("Invalid image size ($size). HessamPost image size should not begin with 'image_'. Remove this from the start of $size. It *should* be in the blogetc.image_sizes config though!"); } - throw new \InvalidArgumentException("BlogEtcPost image size should be 'large','medium','thumbnail' or another field as defined in config/blogetc.php. Provided size ($size) is not valid"); + throw new \InvalidArgumentException("HessamPost image size should be 'large','medium','thumbnail' or another field as defined in config/blogetc.php. Provided size ($size) is not valid"); } diff --git a/src/Models/BlogEtcUploadedPhoto.php b/src/Models/HessamUploadedPhoto.php similarity index 88% rename from src/Models/BlogEtcUploadedPhoto.php rename to src/Models/HessamUploadedPhoto.php index 50aa787..38b7c84 100644 --- a/src/Models/BlogEtcUploadedPhoto.php +++ b/src/Models/HessamUploadedPhoto.php @@ -4,7 +4,7 @@ use Illuminate\Database\Eloquent\Model; -class BlogEtcUploadedPhoto extends Model +class HessamUploadedPhoto extends Model { public $table = 'blog_etc_uploaded_photos'; public $casts = [ diff --git a/src/Requests/Traits/HasCategoriesTrait.php b/src/Requests/Traits/HasCategoriesTrait.php index 40e280d..84eb7cd 100755 --- a/src/Requests/Traits/HasCategoriesTrait.php +++ b/src/Requests/Traits/HasCategoriesTrait.php @@ -1,6 +1,6 @@ get("category")))->select("id")->limit(1000)->get(); + $vals = HessamCategory::whereIn("id", array_keys($this->get("category")))->select("id")->limit(1000)->get(); $vals = array_values($vals->pluck("id")->toArray()); return $vals; diff --git a/src/Requests/UpdateBlogEtcCategoryRequest.php b/src/Requests/UpdateBlogEtcCategoryRequest.php index 45af4d0..cc512df 100755 --- a/src/Requests/UpdateBlogEtcCategoryRequest.php +++ b/src/Requests/UpdateBlogEtcCategoryRequest.php @@ -4,7 +4,7 @@ use Illuminate\Validation\Rule; -use WebDevEtc\BlogEtc\Models\BlogEtcCategory; +use WebDevEtc\BlogEtc\Models\HessamCategory; class UpdateBlogEtcCategoryRequest extends BaseBlogEtcCategoryRequest { diff --git a/src/Requests/UpdateBlogEtcPostRequest.php b/src/Requests/UpdateBlogEtcPostRequest.php index d59ed70..5cef8eb 100755 --- a/src/Requests/UpdateBlogEtcPostRequest.php +++ b/src/Requests/UpdateBlogEtcPostRequest.php @@ -4,7 +4,7 @@ use Illuminate\Validation\Rule; -use WebDevEtc\BlogEtc\Models\BlogEtcPost; +use WebDevEtc\BlogEtc\Models\HessamPost; use WebDevEtc\BlogEtc\Requests\Traits\HasCategoriesTrait; use WebDevEtc\BlogEtc\Requests\Traits\HasImageUploadTrait; diff --git a/src/Traits/UploadFileTrait.php b/src/Traits/UploadFileTrait.php index 1b11f28..3a4befc 100644 --- a/src/Traits/UploadFileTrait.php +++ b/src/Traits/UploadFileTrait.php @@ -4,7 +4,7 @@ use Illuminate\Http\UploadedFile; use WebDevEtc\BlogEtc\Events\UploadedImage; -use WebDevEtc\BlogEtc\Models\BlogEtcPost; +use WebDevEtc\BlogEtc\Models\HessamPost; use File; trait UploadFileTrait @@ -83,14 +83,14 @@ protected function image_destination_path() /** - * @param BlogEtcPost $new_blog_post + * @param HessamPost $new_blog_post * @param $suggested_title - used to help generate the filename * @param $image_size_details - either an array (with 'w' and 'h') or a string (and it'll be uploaded at full size, no size reduction, but will use this string to generate the filename) * @param $photo * @return array * @throws \Exception */ - protected function UploadAndResize(BlogEtcPost $new_blog_post = null, $suggested_title, $image_size_details, $photo) + protected function UploadAndResize(HessamPost $new_blog_post = null, $suggested_title, $image_size_details, $photo) { // get the filename/filepath $image_filename = $this->getImageFilename($suggested_title, $image_size_details, $photo); diff --git a/src/Views/blogetc/search.blade.php b/src/Views/blogetc/search.blade.php index 98abe55..8bfbdfd 100755 --- a/src/Views/blogetc/search.blade.php +++ b/src/Views/blogetc/search.blade.php @@ -12,7 +12,7 @@ @if(isset($result->indexable)) @php $search_count += $search_count + 1; @endphp indexable; ?> - @if($post && is_a($post,\WebDevEtc\BlogEtc\Models\BlogEtcPost::class)) + @if($post && is_a($post,\WebDevEtc\BlogEtc\Models\HessamPost::class))

Search result #{{$search_count}}

@include("blogetc::partials.index_loop") @else diff --git a/src/Views/blogetc/sitewide/random_posts.blade.php b/src/Views/blogetc/sitewide/random_posts.blade.php index 505781b..650ac7a 100644 --- a/src/Views/blogetc/sitewide/random_posts.blade.php +++ b/src/Views/blogetc/sitewide/random_posts.blade.php @@ -1,6 +1,6 @@
Random Posts