hi everyone I'm Richard and today we are going to discuss about how to create a custom package in creen so this is the official repository of crane you can download it from here or you can clone it as well and this is the admin panel of our crane as I have already downloaded it and this is the official blog presented over here of how to create a custom package in crane so before starting I would like to highlight that what is CRM CRM is a system used to manage customer interaction throughout the customer life cycle between the customer and sales department through the different channels so directly moving for the setup so firstly you need to open it in your code editor as I have already opened it from here and this is the directory structures of trade and now now in this package we have a scenario like uh whenever the admin lead follow the pipeline it get automatically updated and email goes to the admin like if I update this from here uh from here automatically a mail goes to the admin right now the mail is not going so our module is like this whenever we need need to whenever the follow pipeline get updated it will automatically mail to the admin so this is the structure so firstly you need to create a step one that is module setup so in this you have to create a custom uh package by the name of custom workflow or whatever you want to create it in the web pool folder so in the packages directory there is a folder by the name of web pool and in this all the modules are been registered over here so you need to create a new module in this directory so I am creating by the name of custom workflow done and now create a SRC folder inside it so now our directory structure look like this inside the packages there is a folder by the name of web cool and there is a uh module Name by the name of custom workflow and inside that there is a SRC folder as you can see over here so before uh moving further uh firstly make sure you have entered the credentials of email sntv WR in EnV file this EnV file is presented in the root directory so these are the credentials right now I'm using um mhog so these are the credentials of my eail smnp so now moving further and now we need to register our package so for that we need to make registration in two files one is composer. Json and another one is app. php now the question arise where is these file located so these files are located in the root directory so firstly that is composer.
Json composer. Json file is presented over here now click onto that uh you need to make an entry of that inside the autoload psr4 section these are all the registers modules have been presented over here so we need to make a new entry here by the name of custom workflow save this file now moving further uh we need to make an entry in the config inside that there is a file by the name of m. PHP and this file is located app config and app.
php file there is a providers array over here scrolling down you will able to see that this these are all the registered service providers the CRM packages so we have to make entry of this over here now right now it is giving an error because uh providers is not being created yet so our next step is to create a providers see the step two copy from here then create a providers folder inside the packages custom SRC means and done and now create a file by the name of custom workflow service provable so this file is resembl with your module name as like I am creating by the name of XYZ so the service provider file will be XYZ service provider right now we have created a module by the name of custom workflow so uh accordingly uh custom work uh file name is custom workflow service provider so these both are relevant with each other just a second yeah down now a structure look like this that this is the file in this file we have two methods one one is register method and another one is boot method so these both methods are responsible inside our service provider save this file and now hit this command of composer dump autoload done so now our package is ready to use moving further now we need to create a one event service provider uh we need to create this file because uh there is a event fire over here that is by the name of lead update after so we need to listen that event so this event is for in the lead controller yeah see lead update after so we need to listen that event in our respective module so again I'm opening my module and creating a file by the name of event service provider. ehp inside the providers see we have listen the event of lead update after and this is the a module name and this is update is the method that is been called inside that lead controller now save this file moving further now we need to load this from our boot method so this boot method is presented in the custom workflow service provider here make an entry to listen that file now now it's time to create listeners listeners and crane are way to imp uh implement the Observer pattern when listener respond to events that occurs in the application so for that you need to create a listener's folder now inside the SRC and now create a file by the name of e. then in this file we use the functionality of sending an email from here this is giving an error because we haven't created this class of mail custom flow now it's trying to create one more folder by the name of real okay this I create a folder by the name of mail and a file by the name of custom workow that we just called it over here in this we uh use the user we have a data of that admin you can apply DT to check stay with this cash said check hear see po up l a d the data is invisible this is the user data and now we need to call the email to s to the entr going further now I'm reming DD from there save test file now we are creating resource resources we need to create resources because uh we need to show a template file that whatever will be visible in that me so we need to create inside the SRC folder by the name of resources in the resources folder we need to create another folder by the name of VI inside the views again create a folder by the name of mail and now that view file by the name of customer.
l.