In this article you’ll learn how to make a Blog module with beyond CRUD functions for admin and shown in the client portal.
my-blog is the alias aka unique identifier of the module.
You can get the ready-to-use files from GitHub or apply the following steps to create the same module.
First of all, generate the scaffold by running the following command:
php artisan module:make my-blog
Before installing the module, create the database tables:
php artisan module:make-migration my_blog_v1 my-blog
The command will create the migration file into
Now you can install the module. Akaunting will also run the migrations.
php artisan module:install my-blog 1
Create the model by using the following command:
php artisan module:make-model Post my-blog --fillable=company_id,name,description,category_id,enabled,created_by
The scaffold comes with 2 route files. Add the controllers for both admin and portal.
By default, a
Main controller is automatically created when you make a module. However, in this case, you need a separate controller for admin and another one for portal. So create them using the following commands:
php artisan module:make-controller Posts my-blog php artisan module:make-controller Portal\Posts my-blog
Akaunting uses the Job kind of action to
Delete records. It makes that code re-usable in other places such as API, console, etc.
php artisan module:make-job CreatePost my-blog --sync php artisan module:make-job UpdatePost my-blog --sync php artisan module:make-job DeletePost my-blog --sync
Akaunting uses the Search String package in the backend to search and filter the records. To make the module compatible, create a
search-string.php config file referring to the model, merge it to the core config in the service provider, and put a couple of lines in the
index.blade.php file, Akaunting will do the frontend magic.
In order to show the blog in the menu (left sidebar), you should listen to the
PortalCreated events, separately.
The language file is