implementing crm with laravel users module

Implementing CRM System With Laravel Part 5: Users Module CRUD

In this part we will begin the first steps of creating the CRM modules and we will start by creating the users module CRUD.



Series Topics:


CRM systems usually contain long forms with many many fields, so to manipulate those forms using the classic ways of creating the forms manually is a tedious task.

So to make the development easy i will use a CRUD generator to generate form fields easily and then i will modify those fields later, for the purpose of this tutorial i will use a widely used package which is appzcoder/crud-generator.



After that, publish its assets using the vendor:publish Artisan command:

Once executed this command the package created a configuration file in config/crudgenerator.php and some other files in resources/crud-generator. we will update those files in the next section.


Modifying CRUD Generator

The crud generator uses the default laravel layout but we need to update that to be suited with the current theme so you have to do the below modifications:






As shown above i instructed the package to use custom template by specifying ‘custom_template’ => true in the config file next we updated the files of the crud generator template located in resources/crud-generator.


Generating CRM Modules

I will start by running the commands of create the modules views and controllers, i will start with the users and roles modules because the other modules depend on them.


Users CRUD

Run the following crud command in terminal to generate the views:

This command will create the views of (Create, Read, Update, Delete) of the users table in resources/views/pages folder.

Next create the Users controller using the crud:

This command create a resource controller similar to laravel native command instead it will populate it with code ready. Everything is working fine but we need to some code modifications.


Modifying users module

Make the following modifications to the below files:















In the above code i have modified the users Controller code. At first i created a new class MailerFactory, this class contain the methods for sending emails to the user.

In that case the class contain only one method which sends email when ever the user activated or banned, we will add other methods later when create the contacts and tasks modules.

Also i added another file General inside of the /Helpers folder, this file will contain helper methods to use throughout the system. Note that i update the composer.json file to autoload that file so you need to run this command after you update composer.json

For sending the emails i use a virtual email service which simulates the sending of emails which is the you need to create an account there then create a new inbox. After that go to inbox configuration page and grap the email settings and update your .env file like this:

You need to add your valid mailtrap username and password.


Update sidebar

Now to update the sidebar to add the new item we just created so

Open resources/views/layout/sidebar.blade.php


Continue to Part 6: The Roles and Permissions Module

Share this: