Please go to admin panel > Menus > select the menu and add items to it.

Laravel Blog Package

Enjoy the package

Just look at the outstanding features, then continue reading (Jump into the Installation instead):

  • Full Text Search – Searching throughout all blog posts
  • Multi Level Categories – Nested sets pattern using Baum
  • Multi Language Support – Ability to translate each post

If you are looking for a blog solution for your laravel website, I recommend to use a laravel blog package instead. In this article I’ll show you how to install and use a great laravel blog package (laravel 8 blog) which adds blog/cms functionality to your website and is compatible with latest Laravel version (now laravel 8). Firstly let me explain the problem which I encountered when I wanted to have a blog functionality for my laravel project.

My scenario has some requirements for a blog system, for example the blog functionality must support commenting, defining categories for posts (plus multi-level category support), being light-weight, giving front-end, and being flexible for further customization. Also preferably it’s better to use a free solution. I explained my options In “Feasible Solutions” section.

You can check the online demo before you install it yourself. Feel free to start any discussion on Github:

https://github.com/sam-beri/laravel-blog-packages/discussions

New Surprising Feature: Multi-language

Even WordPress and some other CMS platforms does not have multi-language support out-of-box. You may need to do some tricks to to implement that for your blog. For example, in WordPress you can use another instance along with your main WordPress instance for an additional language. Then you must sync databases. So, you have an extra burden to setup your blog system.

Hessam CMS has multi-language feature out-of-box. Easily use common languages and translate your posts.

We were planned to update the package on December first but we completed it sooner. All improvements are possible with your support 🙂

Table of Contents

Feasible Solutions

For the above mentioned requirements you have several solutions. Let’s see the solutions.

  • A package which provides your laravel website with blog functionality
  • Using some platforms which act as a basis for our website – actually they are a complete Laravel setup. Therefor these platforms have their own structure, and you need to learn their coding..
  • Integration with other blogging platforms – in this scenario you have your own models and business logics, and you connect these models to your blogging systems like WordPress. For example: you have access to your WordPress posts and your categories inside your laravel code, you can manipulate in your code and etc.
  • Using a separate blogging system – You have a blogging system (Joomla, Drupal, WordPress) along with your main laravel webasite. So you can link to your blog section (which is a link to your Joomla project) inside your main website (for example a /blog link in nav bar). Keep in mind that in this scenario blog users and your laravel users are separated.

So it’s up to you to choose among these solutions, but I prefer a solution which does not make me dependent to any platform, plus ease of customization. Preferably a Laravel CMS package (laravel 8 blog – laravel blog package). I explained the reasons in more detail in this article.

What others say..

“I was looking for quite a while for a Laravel CMS I could use that allowed me to use _all_ of Laravel’s current features.  Even the big ones like October are limited to operating on v6; I get it – they want the LTS version, but in my specific case it limited the ability to do want I wanted.

A key will be that it’s updated in line with Laravel to always work on the latest version.  None of the other CMSs work on anything above Laravel v6 – and some are stuck on v5.  That’s no good.

The way your system works, I can do exactly that.”

— Andrew Coghlan- Director at FullClarity

Laravel and WordPress CMS

Many websites use wordpress as their publishing platform. Regardless which framework you use for your website or web application (for example Django, Flask, Symfony, CodeIgniter, Spring Boot, MVC .Net, Ruby on Rails and even the most popular Laravel), it’s very common to use wordpress as publishing platform and CMS to have a blog and manage blog posts. In case of Laravel there are many Laravel CMS and publishing platforms like October. CMS platforms like October are very powerful and robust, but it’s not a good idea for existing websites and existing codes. They impose their own structures really they are a blogging frameworks over Laravel frameworks. So when you use them you do not feel comfortable. To work with them correctly you need to read more about them and learn additional concepts.

But easily you can add a Laravel CMS / Laravel Blog, to your website without worry about your models, business logic and existing code. Hessam CMS is a laravel package which provides your website with a blogging system like WordPress.


Hessam CMS Demo Video

In this video the installation process and a quick overview is shown. After following this video you have a nice blog system for your Laravel website.

Laravel Blog Package Demo Video

Preview For Admin Interface

laravel blog package create new post
Create new post
laravel blog package shows all posts in admin
Shows all posts in admin panel
laravl blog system adding a category
Add new category

Minimum Requirements

All of the requirements are installed during package installation.


Benefits

Everyone who use Laravel framework, can get benefit from this package. You can customize it and make any changes to fit your needs. So this works with your existing user and role management too.

This package gives you a dashboard to manage your blog and posts and a front-end to show your posts. So you can customize the blade templates to be fit with your UI. In other words I try to make admin UI familiar with WordPress admin panel. Actually working with this panel is much easier than working with WordPress admin panel.


Setup Instructions

  1. Install via composer
composer require hessam/laravel-blogger

For a fresh Laravel installation run the following too:

composer require laravel/ui
php artisan ui vue --auth
  1. Run the following two commands to copy config file, migration files, and view files
php artisan vendor:publish --provider="HessamCMS\HessamCMSServiceProvider"
  1. Execute migrations to create tables
php artisan migrate;
  1. 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 canManageHessamCMSPosts()
    {
        // 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;
    }
  1. Create a directory in public/ named blog_images
  2. Login as admin and setup your package: /blog_admin/setup
  3. Congrats! Your blog is ready to use. (URLs are customizable in the config file)
    Admin panel URI: /blog_admin
    Front URI: /en/blog

I work on this package to add more features. I have some to-dos for this that I list it here. You can comment if you see something is missing or is necessary.

Star the package on github:


Full Package Support

I try to add more features and answer issues and fix bugs as soon as possible. Contact me to tell me which features you want, then I plan to create them (You will get response under 3 hour). Moreover I’m online most of the time feel free if you need tips, you can talk to me with online chat or other channels.

So it’s better to create an issue on Github to report a bug fix. Github Issues


Captcha

To enable or disable captcha, check captcha config in config/hessamcms.php file. A simple captcha system is created already, but you can add your logic or your replace the existing. To add your captcha system you have to implement CaptchaInterface and update the class in config/hessamcms.php file.

There are three methods which must be implemented in your class.

  • public function captcha_field_name(): Returns a string for form validation for example “captcha” <input name="..">.
  • public function view(): This returns the related view file which must be added into the appropriate blade file. The default file is hessamcms::captcha.basic.
  • public function rules(): 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. For example for google reCaptcha you must do server-side checking here.
  • Optional: public function runCaptchaBeforeShowingPosts(): 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 HessamCMSReaderController::viewSinglePost method.

Release History / Recent Changes

  • Multi language support – version 9.x
  • Compatibility with Laravel 8 (laravel 8 blog) – version 8.0.x
  • New Admin UI – version 7.3.2
  • Multi-Level Category functionality – version 7.2.x
  • Ability to remove images from posts, updated CKEditor – version 7.1.8
  • Updated Fulltext search package – I added a feature to swisnl/laravel-fulltext package (through a pull request) to fix an issue in search functionality. It’s important to do the config setups to work this search properly, otherwise it returns blogs which are not published in search result – version 7.1.4
  • Support for custom user model – version 7.1.0
  • Made compatible with Laravel 6.x & 7.x – version 7.0.1

Conclusion

In conclusion, as a technical head or as a product owner, you are responsible to choose appropriate solutions for your projects. So, it’s better to use tools and packages which give you flexibility and ease of use. Definitely you do not want to deep dive into complex structures and development process. This CMS package will save your time too much.

Share:

Comments

72 Comments

  • Hello,
    Thank you for this package which looks really good.
    For me the installation worked well and I was able to access “Blog” and “blog_admin”. I created categories and uploaded images, so far so good. But as soon as I create a Post, it saves itself well in the database, but if I go to “blog” or “blog_admin” I get the following message:
    Error
    Class ‘App\User’ not found (View: D:\wamp64\wwww\blog\resources\views\vendor\blogetc\partials\index_loop.blade.php)

    Do you know why I have this error?
    Thank you in advance for your help.
    stephane

  • hi,
    I solve the problem.
    In the file \configetc.php I had :
    ‘user_model’=>\App\User::class,

    I replaced with :
    ‘user_model’=>\App\Models\User::class,

    and everything now works perfectly.
    Stéphane

    • Hi Stéphane, happy that you found the solution for this issue.
      Yes this issue is for laravel 8, in latest laravel version the user model is relocated to \App\Models\.. . I try to keep package more compatible with LTS version of laravel.
      Many thanks for your consideration Stéphane.

  • Hi hessam,
    Is it possible to communicate with you directly by email?
    I tried several times to redo an installation of your package from scratch and each time I have the same concern when I want to go on blog_admin – 401 UNAUTHORIZED, then I am well connected, on the home page I have : Dashboard
    You are logged in!
    Thank you in advance for your response.
    Sincerely
    stephane

    • Hi Stephane,
      yes feel free to communicate with me by email, I’m available to ask everything you need.(hessam.modaberi@gmail.com)

      If you get this error.. it seems that you did not set the appropriate method in User model.
      You must add this method to your user model:

      public function canManageBlogEtcPosts()
          {
              // 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;
          }
      

      Many thanks

  • I have a custom guard and model called Admin

    How do I make my admin access blog admin?

    I added this code into my Admin model and when I am logged in as admin, I hot a Unauthorized when I access the blog admin

    “`
    public function canManageHessamCMSPosts()
    {
    return true;
    }
    “`

    • Hi John,
      1- be sure that you are logging in as admin user
      2- if you have another user model except the default in: \App\User\Models change the “user_model” config in hessamcms.php config file

  • I’m still hitting a 401, any ideas?

    In the hessamconfig I have
    //Change it to \App\User::class for previous laravel versions
    ‘user_model’=>\App\Admin::class,

    And in my Admin class I have

    public function canManageHessamCMSPosts()
    {
    if(1){
    return true;
    }

    }

  • Auth::guard(‘admin’)->user()

    This is the line to access my logged in user….do I need to replace all Auth::user() in your code?

  • I have replaced Auth user with my custom guard, now I am getting this error of:

    Trying to get property ‘locale’ of non-object

    in vendor\hessam\laravel-blogger\src\Middleware\LoadLanguage.php:19

  • Excellent. I am nearly there.

    I can now see the dashboard for blog.

    I can add a new category.

    But I can’t create a post or upload a new image – I get a 403 Error : Forbidden

    Any tips?

  • Hi Hessam,

    When I run command composer require hessam/laravel-blogger I am getting the following error

    Package fzaninotto/faker is abandoned, you should avoid using it. No replacement was suggested.
    Generating optimized autoload files
    Class HessamCMS\Laravel\Fulltext\IndexedRecord located in ./vendor/hessam/laravel-blogger/src/FulltextSearch/src/IndexedRecord.php does not comply with psr-4 autoloading standard. Skipping.
    Class HessamCMS\Laravel\Fulltext\Indexable located in ./vendor/hessam/laravel-blogger/src/FulltextSearch/src/Indexable.php does not comply with psr-4 autoloading standard. Skipping.
    Class HessamCMS\Laravel\Fulltext\SearchInterface located in ./vendor/hessam/laravel-blogger/src/FulltextSearch/src/SearchInterface.php does not comply with psr-4 autoloading standard. Skipping.
    Class HessamCMS\Laravel\Fulltext\Commands\UnindexOne located in ./vendor/hessam/laravel-blogger/src/FulltextSearch/src/Commands/UnindexOne.php does not comply with psr-4 autoloading standard. Skipping.
    Class HessamCMS\Laravel\Fulltext\Commands\IndexOne located in ./vendor/hessam/laravel-blogger/src/FulltextSearch/src/Commands/IndexOne.php does not comply with psr-4 autoloading standard. Skipping.
    Class HessamCMS\Laravel\Fulltext\Commands\Index located in ./vendor/hessam/laravel-blogger/src/FulltextSearch/src/Commands/Index.php does not comply with psr-4 autoloading standard. Skipping.
    Class HessamCMS\Laravel\Fulltext\ModelObserver located in ./vendor/hessam/laravel-blogger/src/FulltextSearch/src/ModelObserver.php does not comply with psr-4 autoloading standard. Skipping.
    Class HessamCMS\Laravel\Fulltext\Indexer located in ./vendor/hessam/laravel-blogger/src/FulltextSearch/src/Indexer.php does not comply with psr-4 autoloading standard. Skipping.
    Class HessamCMS\Laravel\Fulltext\Search located in ./vendor/hessam/laravel-blogger/src/FulltextSearch/src/Search.php does not comply with psr-4 autoloading standard. Skipping.
    Class HessamCMS\Laravel\Fulltext\TermBuilder located in ./vendor/hessam/laravel-blogger/src/FulltextSearch/src/TermBuilder.php does not comply with psr-4 autoloading standard. Skipping.
    > Illuminate\Foundation\ComposerScripts::postAutoloadDump
    > @php artisan package:discover

    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}()

    +5 vendor frames
    14 artisan:37
    Illuminate\Foundation\Console\Kernel::handle()
    Script @php artisan package:discover handling the post-autoload-dump event returned with error code 1

  • ArgumentCountError
    Too few arguments to function HessamCMS\Models\HessamPostTranslation::url(), 0 passed in D:\xampp\htdocs\promos-maroc\vendor\hessam\laravel-blogger\src\Models\HessamPostTranslation.php on line 129 and exactly 1 expected (View: D:\xampp\htdocs\promos-maroc\resources\views\vendor\hessamcms\partials\index_loop.blade.php)
    http://localhost/promos-maroc/public/en/blog

    • would you please add this line:
      echo $lang->locale;

      at the end of handle method in “DetectLanguage.php” file within ‘Middelware’ dir , before return.. and check your url again.
      then give me a screenshot please.
      I want to know why the $locale is empty..
      many thanks

  • C:\Users\ajesh\Desktop\Projects\example-app\vendor\hessam\laravel-blogger\src\Middleware\LoadLanguage.php:19

    Trying to get property ‘locale’ of non-object

    HessamLanguage no any language therein the database

    • Hi my friend,
      the category of a product is not accessible in index_loop by default and is not loaded for each product. You can change the controller to have this data. The controller: "HessamReaderController" , index method.

    • add these routes manually at the top of routes in “routes.php” file in hessamcms package.

      Route::get('login', 'Auth\LoginController@showLoginForm')->name('login');
      Route::post('login', 'Auth\LoginController@login');
      Route::post('logout', 'Auth\LoginController@logout')->name('logout');

      // Registration Routes...
      Route::get('register', 'Auth\RegisterController@showRegistrationForm')->name('register');
      Route::post('register', 'Auth\RegisterController@register');

      // Password Reset Routes...
      Route::get('password/reset', 'Auth\ForgotPasswordController@showLinkRequestForm');
      Route::post('password/email', 'Auth\ForgotPasswordController@sendResetLinkEmail');
      Route::get('password/reset/{token}', 'Auth\ResetPasswordController@showResetForm');
      Route::post('password/reset', 'Auth\ResetPasswordController@reset');

  • Hello my friend, a have this erreur this time :

    Illuminate\Routing\Exceptions\UrlGenerationException
    Missing required parameters for [Route: hessamcms.search] [URI: {locale}/search]. (View: D:\xampp\htdocs\promos-text\resources\views\vendor\hessamcms\sitewide\search_form.blade.php)

    http://localhost/promos-text/public/login

  • a have a error :

    BadMethodCallException
    Call to undefined method Illuminate\Database\Eloquent\Relations\BelongsTo::sortBy()

  • Hey Hessam,

    Really nice CMS. However, I am getting the following error when trying to remove a “Featured Image” from a post:

    `SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘0’ in ‘where clause’ (SQL: select * from `hessam_post_translations` where (`0` = slug and `1` = = and `2` = some-test-article and `3` = lang_id and `4` = = and `5` = 1) limit 1)`

    The query doesn’t look correct!

    • Hi dear Abdul. According to your request we made a bagisto-compatible version of this package. You must do the following:
      1- install the package and follow the installation instructions
      2- copy the code from github at branch bagisto-compatible : https://github.com/vhessam/laravel-blog-package
      3- copy the following routes above the routes in: /bagisto-installtion/packages/Webkul/API/Http/routes.php :
      Route::group([‘prefix’ => “/{locale}/”.config(‘hessamcms.blog_prefix’, ‘blog’)], function () {

      Route::get(‘/’, ‘\HessamCMS\Controllers\HessamReaderController@index’)
      ->name(‘hessamcms.index’);

      Route::get(‘/search’, ‘\HessamCMS\Controllers\HessamReaderController@search’)
      ->name(‘hessamcms.search’);

      Route::get(‘/feed’, ‘\HessamCMS\Controllers\HessamRssFeedController@feed’)
      ->name(‘hessamcms.feed’); //RSS feed

      Route::get(‘/category{subcategories}’, ‘\HessamCMS\Controllers\HessamReaderController@view_category’)->where(‘subcategories’, ‘^[a-zA-Z0-9-_\/]+$’)->name(‘hessamcms.view_category’);

      // Route::get(‘/category/{categorySlug}’,
      // ‘HessamReaderController@view_category’)
      // ->name(‘hessamcms.view_category’);

      Route::get(‘/{blogPostSlug}’,
      ‘\HessamCMS\Controllers\HessamReaderController@viewSinglePost’)
      ->name(‘hessamcms.single’);

      // throttle to a max of 10 attempts in 3 minutes:
      Route::group([‘middleware’ => ‘throttle:10,3’], function () {

      Route::post(‘save_comment/{blogPostSlug}’,
      ‘\HessamCMS\Controllers\HessamCommentWriterController@addNewComment’)
      ->name(‘hessamcms.comments.add_new_comment’);
      });
      });

      4- add the canManageHessamCMSPosts() to admin model at: /bagisto-installtion/packages/Webkul/User/Admin.php
      5- create your layouts.app view file to render your views.

  • Dear, thank you for that. It’s a very nice package.

    When i write a post, if i go to “view post” i receive this error.

    Someone have ideas how to fix it?

    ErrorException
    Required parameter $request follows optional parameter $category_slug
    http://127.0.0.1:8000/en/blog/hello-world

    Illuminate\Foundation\Bootstrap\HandleExceptions::handleError
    C:\laragon\www\spagnuolo-blog\vendor\hessam\laravel-blogger\src\Controllers\HessamReaderController.php:37
    Stack trace -> public function index($locale, $category_slug = null, Request $request)

    • Hi dear Rista, thanks for reporting this issue.
      When did you get this error? Would you please tell us the flow of your actions?
      How many posts have you added?

      thanks

  • Yes. I just followed yesterday your setup instructions. After that i tested the application creating a new post. That has been created with no problem. But if i click to the button “view post” i get this error. No other changes has been made for exception to the update of the mail address $this->email === “your_admin_user@your_site.com” with mine (at ID n, 1 of the table database as per instructions).

  • BadMethodCallException
    Call to undefined method App\Models\User::canManageHessamCMSPosts()

  • Hello Hessam,

    I’m not sure if you received my last email, because I had a messaging problem.

    I have the same problem (error 401 when I want to put a comment on a blog post, without being logged in), when I make a fresh installation of Laravel. See what I’m doing :

    1- Laravel new myproject
    1.1 Creation BDD myBDD
    2 – compose require hessam/laravel-blogger
    3- compose require laravel/ui
    4- php artisan ui vue –auth
    4.1 – update .env and config/database to indicate the name of the DBB + user + password
    5- php craftsman vendor:publish –provider=”HessamCMS\HessamCMSServiceProvider
    6-php artisan migrates
    7- added public function canManageHessamCMSPosts() in App\Models\User
    7.1 modification of the email
    8- Create a directory in public/ named blog_images
    9- Localhost:8000/blog_admin/setup
    10- connection with the mail registered in canManageHessamCMSPosts for id=1 of the Users table
    11- creation of a new article :Localhost:8000/blog_admin/
    12-disconnection
    13- Localhost:8000/in/blog/ and click on “edit Post” button
    14- when I fill in the comment input fields and I submit, then I get the error 401
    I hope that with this you will be able to reproduce the case.

    Thank you in advance for your help
    stephane

  • For some reason posts were not being sorted correctly, despite the following line in `HessamReaderController`: `$query->orderBy(“posted_at”, “desc”);`

    I had to add this to line 71: `->orderBy(“post_id”, “desc”)` so that it was sorted on the `hessam_post_translations` table.

  • Hi there! How can i implement single language blog with simple route site.com/blog/ ?
    Thanks in advance!

  • Hi thanks for nice package, I want to add blag section in my job board web but I get the error InvalidArgumentException
    View [layouts.app] not found. (View: C:\xampp\htdocs\career\resources\views\vendor\binshopsblog\saved_comment.blade.php)
    How to make the post with read more

  • ErrorException
    Undefined variable: og (View: C:\xampp\htdocs\career\resources\views\layouts\master.blade.php)
    Here is part of my code for job post comment in master blade
    @if (config(‘services.facebook.client_id’))

    @endif

    {!! $og->renderTags() !!}

    {!! MetaTag::twitterCard() !!}

    @endif

    @else

    @if (config(‘services.facebook.client_id’))

    @endif

    {!! $og->renderTags() !!}

    {!! MetaTag::twitterCard() !!}

    @endif

  • Hello,
    if you encounter a 401 error when creating a comment on a blog post, without being logged in, this is what you have to change in HessamCommentWriterController :
    replace:
    public function __construct()
    {
    $this->middleware(UserCanManageBlogPosts::class);
    $this->middleware(LoadLanguage::class);
    }
    by
    public function __construct()
    {
    if(Auth::check()){
    $this->middleware(UserCanManageBlogPosts::class);
    }

    $this->middleware(LoadLanguage::class);

    }

    here you go, if it can help someone.
    Stéphane

    Translated with http://www.DeepL.com/Translator (free version)

Leave a reply

Your email address will not be published. Required fields are marked *

Posts History