implementing crm with laravel contacts module

Implementing CRM System With Laravel Part 8: Contacts Module

In this part we will implement the most important module in a CRM system which is the contacts module which can be used to create a leads, opportunity or customer.



Series Topics:


As usual we will use crud generator to generate the module controller and views, then we will modify those files to make them work properly.

Generate the views:

Run this command in terminal:

Generate the controller:

Now i have made the the following updates to the below files:


Contacts Controller


Contacts Views









Update the sidebar



Update the routes


Modify app/Helpers/MailerFactory.php add these functions at the end of the class




In the above code we have a lot of stuff, so at first in the listing page we make a check to list the contacts according to whether the user is super admin or not. If the user is super admin we display all contacts.

Otherwise if the user is not a super admin we list the contacts created by or assigned to the currently logged in user.

I have created a new function getFormData() to retrieve the form data for the contacts such as the documents and users to be used in case of creation and update. Note that for documents i retrieved the documents also according to whether the user is a super admin or not.

Next we updated the contacts creation form completely and separate it into sections, allso i added some javascript code to manipulate emails, phones and documents. The javascript code located in theme/views/contacts/form.js.

The store() and update() functions first do a simple validation then filters the phones, documents and emails from the main request array, save the data and finally we send some notification emails to the user.

Also we added the contacts module to the sidebar.blade.php and adjusted the permissions and the other related files to show the contacts to the authorized users only.



Continue to Part 9: tasks module


Share this: