GithubHelp home page GithubHelp logo

binshops / laravel-blog Goto Github PK

View Code? Open in Web Editor NEW
407.0 19.0 128.0 446 KB

Laravel Blog Package/ Laravel CMS. Easiest way to add a blogging system to your Laravel website. Laravel Blog.

Home Page: https://www.binshops.com

License: MIT License

PHP 65.45% CSS 6.39% JavaScript 0.24% Blade 27.92%
laravel admin blog laravel-application laravel-package laravel7 laravel-framework laravel8x laravelcms cms

laravel-blog's Introduction

Laravel Blog Package

Lightweight and Easy to Install

Incredible features with a lightweight laravel blog package.

  • Quick installation (<3 minutes)
  • It's very easy to extend
  • Included great features out-of-box
  • Its simplicity allows to be easily made compatible with latest laravel
  • No additional concept except laravel knowledge

Outstanding Features

  • Fulltext Search - search throughout all blog posts
  • Multi Level Category - nested sets using Baum
  • Multi Language Support

Quick and easy installation (Multi-lang version)

1- Install via composer

composer require binshops/laravel-blog

For a fresh Laravel installation run the following too:

composer require laravel/ui
php artisan ui vue --auth

2- Scaffold

npm install && npm run build

3- Run the following two commands to copy config file, migration files, and view files

php artisan vendor:publish --provider="BinshopsBlog\BinshopsBlogServiceProvider"

4- Execute migrations to create tables

php artisan migrate;

5- You must add one method to your \App\User (in laravel 8 \App\Models\User) model. As the name of this method shows it determines which user can manage posts. Place your logic there

 /**
     * Enter your own logic (e.g. if ($this->id === 1) to
     *   enable this user to be able to add/edit blog posts
     *
     * @return bool - true = they can edit / manage blog posts,
     *        false = they have no access to the blog admin panel
     */
    public function canManageBinshopsBlogPosts()
    {
        // Enter the logic needed for your app.
        // Maybe you can just hardcode in a user id that you
        //   know is always an admin ID?

        if (       $this->id === 1
             && $this->email === "your_admin_user@your_site.com"
           ){

           // return true so this user CAN edit/post/delete
           // blog posts (and post any HTML/JS)

           return true;
        }

        // otherwise return false, so they have no access
        // to the admin panel (but can still view posts)

        return false;
    }

6- Create a directory in public/ named blog_images

7- Start the server

php artisan serve

8- Login as admin and setup your package: /blog_admin/setup

Congrats! Your blog is ready to use. (URLs are customizable in the config file)

Admin panel URI: /blog_admin Front URI: /en/blog

To see package on Packagist click this Link

Single Language Version

To install the single language version of the package use version v8.1x:

1- composer require binshops/laravel-blog:v8.2.0

2- php artisan vendor:publish --provider="BinshopsBlog\BinshopsBlogServiceProvider"

3- php artisan vendor:publish --tag=laravel-fulltext

4- php artisan migrate;

You can see the single version in "single-lang" branch. The major difference with multi-language version is the database structure.

Important Notes

  • For laravel 8.x's default auth User model, change user model in binshopsblog.php to: \App\Models\User::class

Features

  • Compatible with latest laravel version (laravel 8.x)
  • Backward-compatibility with previous laravel versions
  • Full text search - searching throughout the blog posts
  • Multi-level category support
  • fully configurable via its config/binshopsblog.php config file
  • Ready to use admin panel
  • Full customizability of admin views and front views
  • Paginated views
  • Ability to upload images
  • Managing posts, categories
  • Managing comments and comment approval
  • Other options include using Disqus comments or disabling comments

Recent Changes

  • 9.1.x Multi language support
  • 8.0.x Compatibility with Laravel 8.x

What/who this package is for:

  • For websites running Laravel
  • Anyone, who wants to have a site blog. This laravel blog gives an easy to use interface to write blog posts/assign categories/manage existing posts
  • Where only admin users can edit/manage the blog (this is not suitable for every user on your site to be able to manage posts)
  • For anyone who likes to add a wordpress-like laravel blog to laravel website

How to customise the blog views/templates

After doing the correct vendor:publish, all of the default template files will be found in /resources/views/vendor/binshopsblog/ and are easy to edit to match your needs.

Customizing admin views

If you need to customize the admin view, just copy the files from vendor/binshopsblog/src/Views/binshopsblog_admin to resources/views/vendor/binshopsblog_admin Then you can modify them just like any other view file.

Routes

It will auto set all required routes (both public facing, and admin backend). There are some config options (such as changing the /blog/ url to something else), which can be done in the binshopsblog.php file.

Config options

All config options have comments which describe what they do. Please just refer to the binshopsblog.php file in your /config/ dir.

Custom User Model

You can change the default user model through the config file.

Events

You can find all the events that are fired by looking in the /src/Events directory.

Add these (and an Event Listener) to your EventServiceProvider.php file to make use of these events when they fire.

Built in CAPTCHA / anti spam

There is a built-in captcha (anti-spam comment) system built in, which will be easy for you to replace with your own implementation.

There is a basic anti-spam captcha function built-in.

See the config/binshops.php captcha section. There is a built in system (basic!) that will prevent most automated spam attempts. Writing your own captcha system:

I wrote the captcha system simple on purpose, so you can add your own captcha options. It should be easy to add any other captcha system to this.

If you want to write your own implementation then create your own class that implements \BinshopsBlog\Interfaces\CaptchaInterface, then update the config/binshopsblog.php file (change the captcha_type option).

There are three methods you need to implement: public function captcha_field_name() : string

Return a string such as "captcha". It is used for the form validation and . public function view() : string

What view file should the binshops::partials.add_comment_form view include? You can set this to whatever you need, and then create your own view file. The default included basic captcha class will return "binshops::captcha.basic". public function rules() : array

Return an array for the rules (which are just the standard Laravel validation rules. This is where you can check if the captcha was successful or not. Optional: public function runCaptchaBeforeShowingPosts() : null

This isn't part of the interface, it isn't required. By default it does nothing. But you can put some code in this method and it'll be run in the BinshopsReaderController::viewSinglePost method.

Image upload errors

Try adding this to config/app.php:

'Image' => Intervention\Image\Facades\Image::class
  • Also make sure that /tmp is writable. If you have open_basedir enabled, be sure to add :/tmp to its value.
  • Ensure that /public/blog_images (or whatever directory you set it to in the config) is writable by the server
  • You might need to set a higher memory limit, or upload smaller image files. This will depend on your server. I've used it to upload huge (10mb+) jpg images without problem, once the server was set up correctly to handle larger file uploads.

Version History

  • 9.3.x Stable version of package
  • 9.0.x Multi-language support beta release
  • 8.0.x Compatibility with Laravel 8
  • 7.3.0 New Admin UI
  • 3.0.1 - replaced all short tags (<?) with full opening ones (<?php)
  • 2.0 - added full text search (enable it via the config file - it is disabled by default).
  • 1.1.1 - added basic captcha
  • 1.0.5 - composer.json changes.
  • 1.0 - First release
  • 0.1 - Initial release

laravel-blog's People

Contributors

edbrk avatar harmjan1990 avatar justanotherfalseprophet avatar musmanikram avatar nebucaz avatar pravnkay avatar samberrry avatar scs-ben avatar usman-xs4arabia-dev avatar wast avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

laravel-blog's Issues

404 and 401 Unauthorized

I installed the package and setup everything as required. The frontend url - /en/blog returns 404. I also changed 'user_model' in the binshopsblog.php file to my admin model and added the method necessary to the model. Attempts to access the blog admin returns 401 unauthorised, even when I have an admin logged in already

Not showing en/blog , corrected HessamPostTranslation.php line 129

Too few arguments to function HessamCMS\Models\HessamPostTranslation::url(), 0 passed ... on get en/blog or search result,

So changed HessamPostTranslation.php:129 from

return $auto_link ? "<a class='" . e($anchor_class) . "' href='" . e($this->url( )) . "'>$img</a>" : $img;
to
return $auto_link ? "<a class='" . e($anchor_class) . "' href='" . e($this->url( app()->getLocale() )) . "'>$img</a>" : $img;

Issue during setup

Hi :)

thank you for the amazing package.

i am trying to install it. After accessing the url /blog_admin/setup and making the English language as default language and clicking on setup package button, i am getting the following error:

SQLSTATE[42703]: Undefined column: 7 ERROR: column "id" does not exist LINE 1: ...ed_at", "created_at") values ($1, $2, $3, $4) returning "id" ^ (SQL: insert into "hessam_configurations" ("key", "value", "updated_at", "created_at") values (INITIAL_SETUP, 1, 2021-01-21 08:17:56, 2021-01-21 08:17:56) returning "id")

Missing Step On Installation

While running the installation it looks like we need to definet he default system language.
Thsi is not mentionned on the installation guide for the version v9.

image

Running the migration does't create that default language so, this means it has to be created manually, otherwise we end on something like this.

image

Improving the installation

Hi,
The step on the installation that suggest to add a method to a model. This can be made using Trait isn't ?

Issue when listing all blogs

i can add the posts successfully but now i am facing another issue when showing all the blog posts on homepage on this url en/blog. i can see the below error:

Too few arguments to function HessamCMS\Models\HessamPostTranslation::url(), 0 passed in /var/www/html/ski_pro_web/vendor/hessam/laravel-blogger/src/Models/HessamPostTranslation.php on line 129 and exactly 1 expected (View: /var/www/html/ski_pro_web/resources/views/vendor/hessamcms/partials/index_loop.blade.php)

compenents give me an errors after blog_admin/setup

After visit "blog_admin/setup", thats show me:
immagine
i click the buttun "setup package" and he tries to redirect me to "/blog_admin"
but instead is showed to me this error:

Symfony\Component\ErrorHandler\Error\FatalError
Declaration of BinshopsBlog\Models\BinshopsPostTranslation::sluggable() must be compatible with Cviebrock\EloquentSluggable\Sluggable::sluggable(): array

If I try to visit others page of the blog stack same error.

How to show english posts for all language codes & link without language code?

My website uses 3 languages.
Default: www.domainname (calls the english version)
English: www.domainname/en
German: www.domainname/de
French: www.domainname/fr

I want my blog to display only english posts, no matter what language the user uses.

I created German and French languages in the blog admin panel.
Default: www.domainname/blog (404 error)
English: www.domainname/en/blog
German: www.domainname/de/blog
French: www.domainname/fr/blog

How can I always show english posts for all language codes and also for the link without a language code (www.domainname/blog)?

Recent Post to fix

Hi @vhessam

in laravel-blogger/src/Views/blogetc/sitewide/recent_posts.blade.php

@forelse(\WebDevEtc\BlogEtc\Models\BlogEtcPost::orderBy("posted_at","desc")->limit(3)->get() as $post)

you have to change it to

@forelse(\WebDevEtc\BlogEtc\Models\BlogEtcPost::where('is_published', '=', 1)->where('posted_at', '<', Carbon\Carbon::now()->format('Y-m-d H:i:s'))->orderBy("posted_at","desc")->limit(3)->get() as $post)

to only post the last one supposed to be posted =)

Cheers

Image title can be added when create/edit a post

Hi @vhessam ,

I would like to suggest two functions:
(1) Adding a function which image title can be added when create/edit a post at the same time.
If I create a post with an image, then the image would become "Untitled Photo", and it can not be edited.
(2) Adding a function which image can also be deleted in imageupload/index.blade.php.

Thank you very much! :-)

Laravel 9 composer file issue

Hello, thank you for this great package. I am having a problem with the installation.
the command: composer require binshops/laravel-blog
generates an error because I am using a later version of eloquent-sluggable.
my composer file contains "cviebrock/eloquent-sluggable": "^9.0",
Your composer file restricts the latest version to 8: "cviebrock/eloquent-sluggable": "~8.0|~7.0|~6.0|~4.8|~4.7|~4.6|~4.5",
Please updade this so that I can automate the deployment

Kind thanks
Dale

Editing Category Error

Can not edit the category. It works if you change the name of the category.

Results in this error:

[2021-12-23 13:42:05] production.ERROR: Could not resolve target node. {"userId":1,"exception":"[object] (BinshopsBlog\\Baum\\MoveNotPossibleException(code: 0): Could not resolve target node. at /.../vendor/binshops/laravel-blog/src/Baum/Move.php:208)
[stacktrace]
#0 /.../vendor/binshops/laravel-blog/src/Baum/Move.php(96): BinshopsBlog\\Baum\\Move->guardAgainstImpossibleMove()
#1 /.../vendor/binshops/laravel-blog/src/Baum/Move.php(87): BinshopsBlog\\Baum\\Move->perform()
#2 /.../vendor/binshops/laravel-blog/src/Baum/Node.php(1240): BinshopsBlog\\Baum\\Move::to()
#3 /.../vendor/binshops/laravel-blog/src/Baum/Node.php(956): BinshopsBlog\\Baum\\Node->moveTo()
#4 /.../vendor/binshops/laravel-blog/src/Baum/Node.php(1068): BinshopsBlog\\Baum\\Node->makeChildOf()
#5 /.../vendor/binshops/laravel-blog/src/Baum/Node.php(122): BinshopsBlog\\Baum\\Node->moveToNewParent()
#6 /.../vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php(404): BinshopsBlog\\Baum\\Node::BinshopsBlog\\Baum\\{closure}()
#7 /.../vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php(249): Illuminate\\Events\\Dispatcher->Illuminate\\Events\\{closure}()
#8 /.../vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasEvents.php(189): Illuminate\\Events\\Dispatcher->dispatch()
#9 /.../vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(1027): Illuminate\\Database\\Eloquent\\Model->fireModelEvent()
#10 /.../vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(998): Illuminate\\Database\\Eloquent\\Model->finishSave()
#11 /.../vendor/binshops/laravel-blog/src/Controllers/BinshopsCategoryAdminController.php(170): Illuminate\\Database\\Eloquent\\Model->save()
#12 /.../vendor/laravel/framework/src/Illuminate/Routing/Controller.php(54): BinshopsBlog\\Controllers\\BinshopsCategoryAdminController->update_category()
#13 /.../vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(45): Illuminate\\Routing\\Controller->callAction()
#14 /.../vendor/laravel/framework/src/Illuminate/Routing/Route.php(262): Illuminate\\Routing\\ControllerDispatcher->dispatch()
#15 /.../vendor/laravel/framework/src/Illuminate/Routing/Route.php(205): Illuminate\\Routing\\Route->runController()
#16 /.../vendor/laravel/framework/src/Illuminate/Routing/Router.php(695): Illuminate\\Routing\\Route->run()
#17 /.../vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(128): Illuminate\\Routing\\Router->Illuminate\\Routing\\{closure}()
#18 /.../vendor/binshops/laravel-blog/src/Middleware/LoadLanguage.php(23): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#19 /.../vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): BinshopsBlog\\Middleware\\LoadLanguage->handle()
#20 /.../vendor/binshops/laravel-blog/src/Middleware/UserCanManageBlogPosts.php(29): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#21 /.../vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): BinshopsBlog\\Middleware\\UserCanManageBlogPosts->handle()
#22 /.../vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(50): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#23 /.../vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Routing\\Middleware\\SubstituteBindings->handle()
#24 /.../vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(78): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#25 /.../vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\VerifyCsrfToken->handle()
#26 /.../vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#27 /.../vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\View\\Middleware\\ShareErrorsFromSession->handle()
#28 /.../vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(121): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#29 /.../vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(64): Illuminate\\Session\\Middleware\\StartSession->handleStatefulRequest()
#30 /.../vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Session\\Middleware\\StartSession->handle()
#31 /.../vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#32 /.../vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Cookie\\Middleware\\AddQueuedCookiesToResponse->handle()
#33 /.../vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(67): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#34 /.../vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Cookie\\Middleware\\EncryptCookies->handle()
#35 /.../vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#36 /.../vendor/laravel/framework/src/Illuminate/Routing/Router.php(697): Illuminate\\Pipeline\\Pipeline->then()
#37 /.../vendor/laravel/framework/src/Illuminate/Routing/Router.php(672): Illuminate\\Routing\\Router->runRouteWithinStack()
#38 /.../vendor/laravel/framework/src/Illuminate/Routing/Router.php(636): Illuminate\\Routing\\Router->runRoute()
#39 /.../vendor/laravel/framework/src/Illuminate/Routing/Router.php(625): Illuminate\\Routing\\Router->dispatchToRoute()
#40 /.../vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(166): Illuminate\\Routing\\Router->dispatch()
#41 /.../vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(128): Illuminate\\Foundation\\Http\\Kernel->Illuminate\\Foundation\\Http\\{closure}()
#42 /.../vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#43 /.../vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ConvertEmptyStringsToNull.php(31): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle()
#44 /.../vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\ConvertEmptyStringsToNull->handle()
#45 /.../vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#46 /.../vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TrimStrings.php(40): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle()
#47 /.../vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\TrimStrings->handle()
#48 /.../vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#49 /.../vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize->handle()
#50 /.../vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php(86): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#51 /.../vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\PreventRequestsDuringMaintenance->handle()
#52 /.../vendor/fruitcake/laravel-cors/src/HandleCors.php(38): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#53 /.../vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Fruitcake\\Cors\\HandleCors->handle()
#54 /.../vendor/laravel/framework/src/Illuminate/Http/Middleware/TrustProxies.php(39): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#55 /.../vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Http\\Middleware\\TrustProxies->handle()
#56 /.../vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#57 /.../vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(141): Illuminate\\Pipeline\\Pipeline->then()
#58 /.../vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(110): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter()
#59 /.../public/index.php(55): Illuminate\\Foundation\\Http\\Kernel->handle()
#60 {main}
"} ```

Lazy Loading issues across the package

There are a number of lazy loading issues across the package that start to arise once I have added more than one post, you are calling model relationships within views which is not ideal, it should be called with a YourModel::with('relation')->get() before passing into the view. I know I could turn off lazy loading but that is not ideal for performance.

An example is line 58 of your NinshopsAdmin Controller. looks like this:
$posts = BinshopsPostTranslation::orderBy("post_id", "desc")->where('lang_id', $language_id) ->paginate(10);

should be this:

$posts = BinshopsPostTranslation::with(['post'])->orderBy("post_id", "desc")->where('lang_id', $language_id) ->paginate(10);

as you are calling $post->post->name in the view, there are a number of other instances as well.

Screenshot 2022-07-15 at 15 07 17

Trying to get property 'category' of non-object

Hi,
I added second language(Chinese(Mandarin) for laravel blog, then add a category under the second language. Then save category, i got Trying to get property 'category' of non-object. The categories only show english categories. Can be a bug, thx.

Trying to get property 'category_name' of non-object (View: vendor/hessam/laravel-blogger/src/Views/hessamcms_admin/categories/_category_partial.blade.php)

The bug only happen when create category under non-english language.

error while trying to upload an image on add post

TypeError
Argument 1 passed to WebDevEtc\BlogEtc\Controllers\BlogEtcAdminController::getImageFilename() must be of the type string, null given, called in /windows10/Users/Pichan/Documents/Project/blog/vendor/hessam/laravel-blogger/src/Traits/UploadFileTrait.php on line 96

post detail not show the style as created

Thanks much for package, I was create a post with different style like h1, h2, bold italic etc as ckeeditor provided but once published no style shown in output/front end and when go back to the backend editor the style change itself no style existing. Please find the image attached. will you please provide the code which will help to solve the problem
blog

Category Not Displayed Properly

Trying to get the categories for a post to display is not currently possible.

If I dump out the categories I get this data blob:
[{"id":2,"created_by":null,"parent_id":null,"lft":1,"rgt":2,"depth":0,"created_at":"2021-12-23T17:32:11.000000Z","updated_at":"2021-12-23T17:32:11.000000Z","pivot":{"post_id":1,"category_id":2}}]

but if I try to iterate over, there is no relationship available to get the category name.

The provided code in categories.blade.php also does not work:

    @foreach($post->categories as $category)
        <a class='btn btn-outline-secondary btn-sm m-1' href='{{$category->url()}}'>
            {{$category->category_name}}
        </a>
    @endforeach```

viewSinglePost fails when a post is unpublished

When I unpublish a post and try to access it via url, the code breaks on
$categories = $blogPost->post->categories()->with([ 'categoryTranslations' => function ($query) use ($request) { $query->where("lang_id", '=', $request->get("lang_id")); } ])->get();
because $blogPost->post is null. Would be nice if this was handled and an exception was thrown or a 404 page was returned.

Trying to get property 'locale' of non-object

namespace BinshopsBlog\Middleware;

use Closure;

use BinshopsBlog\Models\BinshopsConfiguration;

use BinshopsBlog\Models\BinshopsLanguage;

class LoadLanguage

{

public function handle($request, Closure $next)

{

    $default_locale = BinshopsConfiguration::get('DEFAULT_LANGUAGE_LOCALE');

    $lang = BinshopsLanguage::where('locale', $default_locale)

        ->first();



    $request->attributes->add([

        **'locale' => $lang->locale,**

        'language_id' => $lang->id

    ]);



    return $next($request);

}

}

Database seeder uses MySQL injection

CreateLaravelFulltextTable-class contains direct DB::Connection injection which creates columns for text search which uses however MySQL specific column type. Of course this works only when used DB engine is actually MySQL and perhaps MariaSQL.

However, before knew of this, I l already selected Postgresql so did have to commented out two lines that specific class before it went trough.

And you should suggest npm commands anyway since if took code via composer it does not contains predefined web files.

"Auth::check()" 401 error while logged in

I try to get laravel-blog running on an already existing laravel project.

Everything seems fine except of the auth part.
I'm logged in as admin but "\Auth::check()" in "UserCanManageBlogPosts" results in "error evaluating code" when debugging.

I changed 'user_model' to \App\Admin::class which is my user/admin model.
This is how my model looks like:

<?php

namespace App;

use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;

class Admin extends Authenticatable
{
    use Notifiable;
	// The authentication guard for admin
    protected $guard = 'admin';
     /**
      * The attributes that are mass assignable.
      *
      * @var array
      */
    protected $fillable = [
        'username', 'password',
    ];
     /**
      * The attributes that should be hidden for arrays.
      *
      * @var array
      */
    protected $hidden = [
        'password', 'remember_token',
    ];

    /**
     * Enter your own logic (e.g. if ($this->id === 1) to
     *   enable this user to be able to add/edit blog posts
     *
     * @return bool - true = they can edit / manage blog posts,
     *        false = they have no access to the blog admin panel
     */
    public function canManageBinshopsBlogPosts()
    {
        // Enter the logic needed for your app.
        // Maybe you can just hardcode in a user id that you
        //   know is always an admin ID?

        if($this->username === "testadmin")
        {
            // return true so this user CAN edit/post/delete
            // blog posts (and post any HTML/JS)
            return true;
        }
        // otherwise return false, so they have no access
        // to the admin panel (but can still view posts)
        return false;
    }
}

I tried to add "use Illuminate\Support\Facades\Auth;" to "UserCanManageBlogPosts" and changed "\Auth::check()" to "Auth::check()" which doesn't result in an error anymore, but that for in a false, although I'm logged in as admin.

I'm not sure how to get the auth running correctly here, what could be the problem and what could solve it?

errors when add recent posts and categories list in detail post

  1. I as try to add categories list in post detail page I put the @include('binshopsblog::sitewide.show_all_categories') in singel post file then I get error:

Illuminate\Database\QueryException
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'category_name' in 'order clause' (SQL: select * from binshops_categories order by category_name asc limit 200) (View: C:\xampp\htdocs\career\resources\views\vendor\binshopsblog\sitewide\show_all_categories.blade.php)

I get this error and I see the category_name is found in BinshopsCategoryTranslation I try to change that model I get more errors

  1. Also I try to add Recent post in detail post I add @include('binshopsblog::sitewide.recent_posts)
    I get the error
    BadMethodCallException
    Call to undefined method BinshopsBlog\Models\BinshopsPost::url() (View: C:\xampp\htdocs\career\resources\views\vendor\binshopsblog\sitewide\recent_posts.blade.php)
    http://career.localhost/en/blog/how-to-pass-interview-at-utumishi

installation failed

Hello
i'm facing this error while runing composer require hessam/laravel-blogger

 Error

  Class 'HessamCMS\Laravel\Fulltext\ModelObserver' not found

  at vendor/hessam/laravel-blogger/src/HessamCMSServiceProvider.php:33
     29▕     {
     30▕
     31▕         if (config("hessamcms.search.search_enabled") == false) {
     32▕             // if search is disabled, don't allow it to sync.
  ➜  33▕             ModelObserver::disableSyncingFor(HessamPostTranslation::class);
     34▕         }
     35▕
     36▕         if (config("hessamcms.include_default_routes", true)) {
     37▕             include(__DIR__ . "/routes.php");

      +7 vendor frames
  8   [internal]:0
      Illuminate\Foundation\Application::Illuminate\Foundation\{closure}(Object(HessamCMS\HessamCMSServiceProvider))

      +5 vendor frames
  14  artisan:37
      Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1

Installation failed, reverting ./composer.json and ./composer.lock to their original content.

Categories parent_id not found

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'parent_id' in 'where clause' (SQL: select * from blog_etc_categories where parent_id is null)

Command php artisan vendor:publish --provider="WebDevEtc\BlogEtc\BlogEtcServiceProvider" doesn't copy migrations.

php artisan vendor:publish --provider="WebDevEtc\BlogEtc\BlogEtcServiceProvider"
Copied Directory [/vendor/hessam/laravel-blogger/src/Views/blogetc] To [/resources/views/vendor/blogetc]
Publishing complete.

Url Length Exceeded

You guys are using patch method while editing post. When you change the language the whole content of the post is coming with the url which can be problematic for server because we can not specify the length of the url. If the content of the blog will increase it will cause Url too long, length exceeded error.
I would recommend instead of get use post method. Because I'm facing this issue on our live server.
Thanks

404 After updating blog prefix.

When I try to update the blog prefix in config file then after updating I'm getting 404 against some urls like add blog post etc.

Searching not working

I install and config the package as document for an existing laravel project, but i get Sorry, but there were no results!
any help for the fulltext search? thanks.

`
php artisan laravel-fulltext:all 'HessamCMS\Models\HessamPost'

There are no commands defined in the "laravel-fulltext" namespace.
`

Error in sluggable function

I tried to add laravel-blog into my laravel project

Laravel version 8.49.0
laravel-blog version: 8.1.2

but I got this error
Declaration of BinshopsBlog\Models\BinshopsBlogPost::sluggable() must be compatible with Cviebrock\EloquentSluggable\Sluggable::sluggable(): array

I found solution here

I think the solution is to change vendor/binshops/laravel-blog/src/Models/BinshopsBlogPost.php (line 61)

public function sluggable(): array
{
 ... ...
}

I used DO app for server

unfortunately, DO app doesn't support editing package files

routes

maybe is not an issue, but ive not any route of the blog, just auth, after a fresh installation on laravel 8.

Laravel 8 installation

I'm a bit confused. I'm on laravel 8 and have some issue with installation:

Installation request for hessam/laravel-blogger ^8.0 -> satisfiable by hessam/laravel-blogger[v8.0.0].

  • Installation request for laravel/framework (locked at v8.5.0, required as ^8.0) -> satisfiable by laravel/framework[v8.5.0].
  • hessam/laravel-blogger v8.0.0 requires laravel/framework ~5.8|~6.0|~7.0|~8.0 -> satisfiable by laravel/framework[v8.5.0, 5.8.x-dev, 6.x-dev, 7.x-dev, 8.x-dev, v8.0.0, v8.0.1, v8.0.2, v8.0.3, v8.0.4, v8.1.0, v8.2.0, v8.3.0, v8.4.0].
  • Can only install one of: laravel/framework[6.x-dev, 5.7.x-dev].
  • Can only install one of: laravel/framework[7.x-dev, 5.7.x-dev].
  • Can only install one of: laravel/framework[8.x-dev, 5.7.x-dev].
  • Can only install one of: laravel/framework[v8.0.0, 5.7.x-dev].
  • Can only install one of: laravel/framework[v8.0.1, 5.7.x-dev].
  • Can only install one of: laravel/framework[v8.0.2, 5.7.x-dev].
  • Can only install one of: laravel/framework[v8.0.3, 5.7.x-dev].
  • Can only install one of: laravel/framework[v8.0.4, 5.7.x-dev].
  • Can only install one of: laravel/framework[v8.1.0, 5.7.x-dev].
  • Can only install one of: laravel/framework[v8.2.0, 5.7.x-dev].
  • Can only install one of: laravel/framework[v8.3.0, 5.7.x-dev].
  • Can only install one of: laravel/framework[v8.4.0, 5.7.x-dev].
  • Can only install one of: laravel/framework[v8.5.0, 5.7.x-dev].
  • Can only install one of: laravel/framework[5.7.x-dev, v8.5.0].
  • Can only install one of: laravel/framework[5.7.x-dev, v8.5.0].
  • Can only install one of: laravel/framework[5.8.x-dev, 5.7.x-dev].
  • Conclusion: install laravel/framework 5.7.x-dev

Why I can't install it?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.