implementing crm with laravel documents module

Implementing CRM System With Laravel Part 7: Documents Module

In this part we will implement the documents module that be can selected with contacts or tasks, then we will set the module roles and permissions to allow or disallow access to this module.



Series Topics:


The documents in a CRM system represent images, papers, contracts, or licenses. For example when you create a task, that task may have documents or papers attached to it or when you create a lead, that lead also may have some sort of documents. In the documents module we create the documents first then when create a task or lead we just select those documents.

Generate the views:

Generate the controller:

Next let’s revamp the controller and views to work properly, in the below code i have adjusted the view layout, permissions and others.


Documents Controller

Open app/Http/Controllers/DocumentsController.php and update it as below:

In the above controller this is a modified version of the controller, first i have added the middleware “admin” in the constructorthat we created in previous parts and i passed the permissions as a string in the format “action-permission” separated by “|”.

Next in the index() method i checked to see if the current user is the admin user or not. If this is the admin user then we retrieve and display all documents otherwise we retrieve only the documents assigned to or created by the current user.

In the store() and update() methods i send an email to the user that this document is assigned to.


Documents Views







Update the routes



Update the sidebar


In the above code i have added a new route and added new item in the sidebar to enable the navigation to the documents module, also i checked for the permission to allow or disallow the user to view this module.

Also i have modified the views a little bit by adjusting some fields such as the file upload field and select dropdown for the assigned_user_id field.


Modify app/Helpers/MailerFactory.php add this method at the end of the class:


Now navigate to http://localhost/crm/admin/documents and login check your permissions, add a new user with different permissions and try to add, edit and delete documents.

Updating User Profile

Let’s update the user profile page to show the documents assigned to the currently logged in user




Continue to Part 8: contacts module


Share this: