companyRepo = $repository; $this->plansRepo = $plansRepo; $this->roleRepo = $roleRepo; $this->SettingsHelper = new SettingsHelper(); } /** * Disable Inactive companies (Companies that didny paid for subscription) * */ public function disableInactiveCompanies() { $companies = Company::whereNotNull('subscription_valid_until') ->whereDate('subscription_valid_until', '<', Carbon::now()); foreach ($companies as $company) { $company->is_enabled = false; $company->save(); } } /** * Register Company * * @param $data * @return User */ public function registerCompany($data) { $plan = $this->plansRepo->findWithoutFail(CompanyPlan::ASSIGN_PLAN_ON_REGISTER); $company = new Company(); if (!empty($plan)) { $company->plan()->associate($plan); $company->user_limit = $plan->teams_limit; $company->storage_limit = $plan->storage_limit; } $company->name = 'Company ' . uniqid(); $company->is_enabled = true; $company->save(); //Find Company Manager Role $role = $this->roleRepo->getRolebyNameForCompany(Role::DEFAULT_COMPANY_ADMIN_ROLE, $company->id); $user = new User($data); $user->is_active = true; $user->company()->associate($company); $user->assignRole($role); $user->save(); return $user; } /** * Seed company with default dictionary data * @param Company $company */ public function seedCompany(Company $company) { // Seed with default dictionary data //Roles & Permission $permissionSeeder = new PermissionsSeeder(); $permissionSeeder->dictionary($company->id); //Country $countrySeeder = new CountrySeeder(); $countrySeeder->dictionary($company->id); //Currency $currencySeeder = new CurrencySeeder(); $currencySeeder->dictionary($company->id); //Tax $taxSeeder = new TaxSeeder(); $taxSeeder->dictionary($company->id); //Accounts $accountSeeder = new AccountsDatabaseSeeder(); $accountSeeder->dictionary($company->id); //Assets $assetSeeder = new AssetsDatabaseSeeder(); $assetSeeder->dictionary($company->id); //Calendar $calendarSeeder = new CalendarDatabaseSeeder(); $calendarSeeder->dictionary($company->id); //Calls //Campaings $campaignSeeder = new CampaignsDatabaseSeeder(); $campaignSeeder->dictionary($company->id); //Contacts $contactsSeeder = new ContactsDatabaseSeeder(); $contactsSeeder->dictionary($company->id); //Deals $dealsSeeder = new DealsDatabaseSeeder(); $dealsSeeder->dictionary($company->id); //Documents $documentsSeeder = new DocumentsDatabaseSeeder(); $documentsSeeder->dictionary($company->id); //Invoices $invoicesSeeder = new InvoicesDatabaseSeeder(); $invoicesSeeder->dictionary($company->id); //Leads $leadsSeeder = new LeadsDatabaseSeeder(); $leadsSeeder->dictionary($company->id); //Orders $ordersSeeder = new OrdersDatabaseSeeder(); $ordersSeeder->dictionary($company->id); //Payments $paymentSeeder = new PaymentsDatatableSeeder(); $paymentSeeder->dictionary($company->id); //Products $productsSeeder = new ProductsDatabaseSeeder(); $productsSeeder->dictionary($company->id); //Quotes $quoteSeeder = new QuotesDatabaseSeeder(); $quoteSeeder->dictionary($company->id); //Service Contracts $serviceContractSeeder = new ServiceContractsDatabaseSeeder(); $serviceContractSeeder->dictionary($company->id); //Tickets $ticketsSeeder = new TicketsDatabaseSeeder(); $ticketsSeeder->dictionary($company->id); //Contact Request $contactRequestSeeder = new ContactRequestsDatabaseSeeder(); $contactRequestSeeder->dictionary($company->id); //Calls $callsSeeder = new CallsDatabaseSeeder(); $callsSeeder->dictionary($company->id); //Testimonial $testimonialSeeder = new TestimonialDictDatabaseSeeder(); $testimonialSeeder->dictionary($company->id); //Mailinglist $mailinglistSeeder = new MailinglistDictDatabaseSeeder(); $mailinglistSeeder ->dictionary($company->id); CompanySettings::set('s_invoice_prefix','INV-',$company->id); CompanySettings::set('s_invoice_increment','1',$company->id); CompanySettings::set('s_invoice_use_increment','1',$company->id); CompanySettings::set('s_invoice_due_days','7',$company->id); CompanySettings::set('dashboard_reset_time','00:00',$company->id); CompanySettings::set('reports_reset_time','00:00',$company->id); CompanySettings::set('report_excluded_groups',null,$company->id); CompanySettings::set('service_level_ringe_time','1000',$company->id); CompanySettings::set('lead_settings_phone_required',false,$company->id); CompanySettings::set('s_email_notify_content_welcome',"
{{name}},
Welcome to MultiCRM. You can login here {{app_url}}.
Your login: {{email}}
Your password: {{password}}
Remember to change password after first login!
regards,
Team