type = $type; $this->model = ! empty($model) ? $model : $contact; $this->contact = $this->model; $this->permissionCreate = $this->getPermissionCreate($type, $permissionCreate); $this->permissionUpdate = $this->getPermissionUpdate($type, $permissionUpdate); $this->permissionDelete = $this->getPermissionDelete($type, $permissionDelete); /* -- Main End -- */ /* -- Buttons Start -- */ $this->hideNewDropdown = $hideNewDropdown; $this->hideButtonDocument = $hideButtonDocument; $this->hideButtonTransaction = $hideButtonTransaction; $this->permissionCreateDocument = $this->getPermissionCreateDocument($type, $permissionCreateDocument); $this->permissionCreateTransaction = $this->getPermissionCreateTransaction($type, $permissionCreateTransaction); $this->routeButtonDocument = $this->getCreateDocumentRoute($type, $routeButtonDocument); $this->routeButtonTransaction = $this->getCreateTransactionRoute($type, $routeButtonTransaction); $this->textDocument = $this->getTextDocument($type, $textDocument); $this->textTransaction = $this->getTextTransaction($type, $textTransaction); $this->hideButtonEdit = $hideButtonEdit; $this->routeButtonEdit = $this->getEditRoute($type, $routeButtonEdit); $this->hideActionsDropdown = $hideActionsDropdown; $this->hideButtonDuplicate = $hideButtonDuplicate; $this->routeButtonDuplicate = $this->getDuplicateRoute($type, $routeButtonDuplicate); $this->hideButtonDelete = $hideButtonDelete; $this->routeButtonDelete = $this->getDeleteRoute($type, $routeButtonDelete); $this->textDeleteModal = $this->getTextDeleteModal($type, $textDeleteModal); /* -- Buttons End -- */ /* -- Profile Start -- */ $this->hideProfile = $hideTopLeft; $this->hideAvatar = $hideAvatar; $this->hideEmail = $hideEmail; $this->hidePhone = $hidePhone; $this->hideDetails = $hideTopRight; $this->hideOverdue = $hideOverdue; $this->hideOpen = $hideOpen; $this->hidePaid = $hidePaid; $this->hideSummary = $hideBottomLeft; $this->hideAddress = $hideAddress; $this->hideTaxNumber = $hideTaxNumber; $this->hideWebsite = $hideWebsite; $this->hideReference = $hideReference; $this->hideUser = $hideUser; $this->hideContent = $hideBottomRight; /* -- Profile End -- */ } protected function getPermissionCreateDocument($type, $permissionCreateDocument) { if (! empty($permissionCreateDocument)) { return $permissionCreateDocument; } $document_type = config('type.contact.' . $type . '.document_type', 'invoice'); $permission = ''; $config_key = 'create'; // if set config trasnlation config_key if ($permission = config('type.document.' . $document_type . '.permission.' . $config_key)) { return $permission; } $alias = config('type.document.' . $document_type . '.alias'); $group = config('type.document.' . $document_type . '.group'); $prefix = config('type.document.' . $document_type . '.permission.prefix'); $permission = $config_key . '-'; // if use module set module alias if (! empty($alias)) { $permission .= $alias . '-'; } // if controller in folder it must if (! empty($group)) { $permission .= $group . '-'; } $permission .= $prefix; $permissionCreateDocument = $permission; return $permissionCreateDocument; } protected function getPermissionCreateTransaction($type, $permissionCreateTransaction) { if (! empty($permissionCreateTransaction)) { return $permissionCreateTransaction; } $permissionCreateTransaction = 'create-banking-transactions'; return $permissionCreateTransaction; } protected function getCreateDocumentRoute($type, $routeButtonDocument) { if (! empty($routeButtonDocument)) { return $routeButtonDocument; } $prefix = config('type.contact.' . $type . '.route.prefix'); $document_type = config('type.contact.' . $type . '.document_type'); return $prefix . '.create-' . $document_type; } protected function getCreateTransactionRoute($type, $routeButtonDocument) { if (! empty($routeButtonDocument)) { return $routeButtonDocument; } $prefix = config('type.contact.' . $type . '.route.prefix'); $transaction_type = config('type.contact.' . $type . '.transaction_type'); return $prefix . '.create-' . $transaction_type; } protected function getTextDocument($type, $textDocument) { if (! empty($textDocument)) { return $textDocument; } $document_type = config('type.contact.' . $type . '.document_type'); switch ($document_type) { case 'invoice': $text = 'general.invoices'; break; case 'bill': $text = 'general.bills'; break; default: $text = config('type.contact.' . $type . '.translation.prefix') . '.' . config('type.contact.' . $type . '.route.prefix'); } return $text; } protected function getTextTransaction($type, $textTransaction) { if (! empty($textTransaction)) { return $textTransaction; } $document_type = config('type.contact.' . $type . '.document_type'); switch ($document_type) { case 'invoice': $text = 'general.incomes'; break; case 'bill': $text = 'general.expenses'; break; default: $text = config('type.contact.' . $type . '.translation.prefix') . '.' . config('type.contact.' . $type . '.transaction_type') . 's'; } return $text; } protected function getTextDeleteModal($type, $textDeleteModal) { if (! empty($textDeleteModal)) { return $textDeleteModal; } $document_type = config('type.contact.' . $type . '.document_type'); switch ($document_type) { case 'invoice': $text = 'general.incomes'; break; case 'bill': $text = 'general.expenses'; break; default: $text = config('type.contact.' . $type . '.translation.prefix') . '.' . config('type.contact.' . $type . '.transaction_type') . 's'; } return $text; } }