Organisations
Intro
Organisations are the primary accounts within a Flowcode App. If a user isn't associated with an organisation they will not be able to do anything on the front-end of the application. Organisations are stored in the Organisation model.
Template Organisation
Organisations need departments, divisions, roles and catalogues. However, to build from scratch will create a lot of work for every organisation. The organisation template adds the ability to build a template structure of an organisation which all new organisations will replicate.
When the app was created, a migration created the first organisation in the 2022_08_24_125010_create_template_organisation.php migrations. This organisation is used as the Template organisation on which admins can build organisation elements the following organisation elements:
- Divisions
- Departments
- Organisation Roles
- Organisation Catalogues
The organisation template is created progrmatically using the migration 2022_08_24_125010_create_template_organisation.php and has ID 1. You can access the organisation template on the backend using the constant config('flowcode.org_template_id')
Excluding template organisation from Organisation index
The template organisation is excluded from the organisation index page using the excludeTemplate() local scope.
Get the organisation template
The template organisation can be retrieved using the local scope scopeGetTemplate() which returns the template object.
Editing the organisation template elements
The organisation template elements can be adjusted by clicking the Edit template button on the organisation index page in the admin dashboard.
Building organisations off of the template
When the organisation store route is used the organisation is created and then the action BuildOrganisationElementsFromTemplate is called to build the organisation elements off of the template.
The BuildOrganisationElementsFromTemplate action build() method uses the organisation template to do the following:
1. Build roles: replicates all template roles and assigns to the new organisation
2. Build divisions: replicates all template divisions and assigns to the new organisation
3. Build departments: replicates all template departments and assigns to the new organisation
4. Build catalogues: replicates all template organisation catalogues and assigns to the new organisation