diff --git a/app/Console/Commands/CreateTestData.php b/app/Console/Commands/CreateTestData.php index 554a02f0e49c..36aeee130ef4 100644 --- a/app/Console/Commands/CreateTestData.php +++ b/app/Console/Commands/CreateTestData.php @@ -81,7 +81,6 @@ class CreateTestData extends Command $account = factory(\App\Models\Account::class)->create(); $company = factory(\App\Models\Company::class)->create([ 'account_id' => $account->id, - 'domain' => 'ninja.test:8000', ]); $account->default_company_id = $company->id; @@ -137,7 +136,6 @@ class CreateTestData extends Command $account = factory(\App\Models\Account::class)->create(); $company = factory(\App\Models\Company::class)->create([ 'account_id' => $account->id, - 'domain' => 'ninja.test:8000', ]); $account->default_company_id = $company->id; @@ -194,7 +192,6 @@ class CreateTestData extends Command $account = factory(\App\Models\Account::class)->create(); $company = factory(\App\Models\Company::class)->create([ 'account_id' => $account->id, - 'domain' => 'ninja.test:8000', ]); $account->default_company_id = $company->id; diff --git a/app/Factory/CompanyFactory.php b/app/Factory/CompanyFactory.php index 334d9e048a96..17692af4e071 100644 --- a/app/Factory/CompanyFactory.php +++ b/app/Factory/CompanyFactory.php @@ -32,7 +32,7 @@ class CompanyFactory $company->settings = CompanySettings::defaults(); $company->db = config('database.default'); $company->custom_fields = (object) ['custom1' => '1', 'custom2' => '2', 'custom3'=>'3']; - $company->domain = ''; + $company->subdomain = ''; return $company; } diff --git a/app/Http/Controllers/OpenAPI/CompanySchema.php b/app/Http/Controllers/OpenAPI/CompanySchema.php index 26898a88f53c..c120bc00cebd 100644 --- a/app/Http/Controllers/OpenAPI/CompanySchema.php +++ b/app/Http/Controllers/OpenAPI/CompanySchema.php @@ -7,7 +7,7 @@ * @OA\Property(property="size_id", type="string", example="1", description="The company size ID"), * @OA\Property(property="industry_id", type="string", example="1", description="The company industry ID"), * @OA\Property(property="portal_mode", type="string", example="subdomain", description="Determines the client facing urls ie: subdomain,domain,iframe"), - * @OA\Property(property="domain", type="string", example="http://acmeco.invoicing.co", description="Determines the client facing url "), + * @OA\Property(property="subdomain", type="string", example="aceme", description="Specifies the first part of the company domain ie acme in acme.domain.com"), * @OA\Property(property="portal_domain", type="string", example="https://subdomain.invoicing.co", description="The fully qualified domain for client facing URLS"), * @OA\Property(property="enabled_tax_rates", type="integer", example="1", description="Number of taxes rates used per entity"), * @OA\Property(property="fill_products", type="boolean", example=true, description="Toggles filling a product description based on product key"), diff --git a/app/Jobs/Company/CreateCompany.php b/app/Jobs/Company/CreateCompany.php index b07d5f79292d..b13cb5cd27f3 100644 --- a/app/Jobs/Company/CreateCompany.php +++ b/app/Jobs/Company/CreateCompany.php @@ -59,7 +59,7 @@ class CreateCompany $company->ip = request()->ip(); $company->settings = $settings; $company->db = config('database.default'); - $company->domain = isset($this->request['domain']) ? $this->request['domain'] : config('ninja.site_url'); + $company->subdomain = isset($this->request['subdomain']) ? $this->request['subdomain'] : ''; $company->save(); diff --git a/app/Libraries/MultiDB.php b/app/Libraries/MultiDB.php index 3b6aca633a17..cb8e3137a668 100644 --- a/app/Libraries/MultiDB.php +++ b/app/Libraries/MultiDB.php @@ -53,18 +53,18 @@ class MultiDB } - public static function checkDomainAvailable($domain) : bool + public static function checkDomainAvailable($subdomain) : bool { if (! config('ninja.db.multi_db_enabled')) { - return Company::whereDomain($domain)->get()->count() == 0; + return Company::whereSubdomain($subdomain)->get()->count() == 0; } //multi-db active foreach (self::$dbs as $db) { - if(Company::whereDomain($domain)->get()->count() >=1) + if(Company::whereSubdomain($subdomain)->get()->count() >=1) return false; } @@ -209,14 +209,14 @@ class MultiDB } - public static function findAndSetDbByDomain($domain) :bool + public static function findAndSetDbByDomain($subdomain) :bool { //\Log::error("searching for {$domain}"); foreach (self::$dbs as $db) { - if($company = Company::on($db)->whereDomain($domain)->first()) + if($company = Company::on($db)->whereSubdomain($subdomain)->first()) { self::setDb($company->db); diff --git a/app/Models/Company.php b/app/Models/Company.php index bcfa0e8c4ae4..ba4b23ee3b03 100644 --- a/app/Models/Company.php +++ b/app/Models/Company.php @@ -50,7 +50,7 @@ class Company extends BaseModel protected $fillable = [ 'fill_products', 'industry_id', - 'domain', + 'subdomain', 'size_id', 'custom_fields', 'enable_product_cost', @@ -265,5 +265,9 @@ class Company extends BaseModel ->where('id', $this->decodePrimaryKey($value))->firstOrFail(); } + public function domain() + { + return 'https://' . $this->subdomain . config('ninja.app_domain'); + } } diff --git a/app/PaymentDrivers/PayPalExpressPaymentDriver.php b/app/PaymentDrivers/PayPalExpressPaymentDriver.php index d3be8b23bb84..f7a491168a85 100644 --- a/app/PaymentDrivers/PayPalExpressPaymentDriver.php +++ b/app/PaymentDrivers/PayPalExpressPaymentDriver.php @@ -191,7 +191,7 @@ class PayPalExpressPaymentDriver extends BasePaymentDriver private function buildReturnUrl($input) : string { - $url = $this->client->company->domain . "client/payments/process/response"; + $url = $this->client->company->domain() . "client/payments/process/response"; $url .= "?company_gateway_id={$this->company_gateway->id}&gateway_type_id=".GatewayType::PAYPAL; $url .= "&hashed_ids=" . implode(",", $input['hashed_ids']); $url .= "&amount=".$input['amount']; @@ -202,7 +202,7 @@ class PayPalExpressPaymentDriver extends BasePaymentDriver private function buildCancelUrl($input) : string { - $url = $this->client->company->domain . '/client/invoices'; + $url = $this->client->company->domain() . '/client/invoices'; return $url; } diff --git a/app/Transformers/CompanyTransformer.php b/app/Transformers/CompanyTransformer.php index 0ee15d4be9c4..de0af6c4415b 100644 --- a/app/Transformers/CompanyTransformer.php +++ b/app/Transformers/CompanyTransformer.php @@ -94,7 +94,7 @@ class CompanyTransformer extends EntityTransformer 'industry_id' => (string) $company->industry_id ?: '', 'first_month_of_year' => (string) $company->first_month_of_year ?: '', 'first_day_of_week' => (string) $company->first_day_of_week ?: '', - 'domain' => (string) $company->domain ?: '', + 'subdomain' => (string) $company->subdomain ?: '', 'portal_mode' => (string) $company->portal_mode ?: '', 'portal_domain' => (string) $company->portal_domain ?: '', 'settings' => $company->settings ?: '', diff --git a/app/Utils/Traits/Inviteable.php b/app/Utils/Traits/Inviteable.php index 73951a49a680..1a9988e8096e 100644 --- a/app/Utils/Traits/Inviteable.php +++ b/app/Utils/Traits/Inviteable.php @@ -48,7 +48,7 @@ trait Inviteable //$this->with('company','contact',$this->entity_type); $this->with('company'); - $domain = isset($this->company->portal_domain) ?: $this->company->domain; + $domain = isset($this->company->portal_domain) ?: $this->company->domain(); switch ($this->company->portal_mode) { case 'subdomain': diff --git a/app/Utils/Traits/Uploadable.php b/app/Utils/Traits/Uploadable.php index 33da6860c9d2..685f6778b5e1 100644 --- a/app/Utils/Traits/Uploadable.php +++ b/app/Utils/Traits/Uploadable.php @@ -30,7 +30,7 @@ trait Uploadable if($path){ $settings = $entity->settings; - $settings->company_logo = $company->domain . $path; + $settings->company_logo = $company->domain() . $path; $entity->settings = $settings; $entity->save(); } diff --git a/config/ninja.php b/config/ninja.php index 7be0b08649b9..2b208081e7ef 100644 --- a/config/ninja.php +++ b/config/ninja.php @@ -4,7 +4,7 @@ return [ 'web_url' => 'https://www.invoiceninja.com', 'app_name' => env('APP_NAME'), - 'site_url' => env('APP_URL', 'https://admin.invoiceninja.com'), + 'site_url' => env('APP_URL', ''), 'app_domain' => env('APP_DOMAIN', 'invoiceninja.com'), 'app_version' => '0.0.1', 'api_version' => '0.0.1', diff --git a/database/migrations/2014_10_13_000000_create_users_table.php b/database/migrations/2014_10_13_000000_create_users_table.php index 3457e6399573..ca47e98fb71d 100644 --- a/database/migrations/2014_10_13_000000_create_users_table.php +++ b/database/migrations/2014_10_13_000000_create_users_table.php @@ -162,7 +162,7 @@ class CreateUsersTable extends Migration $table->boolean('enable_product_quantity')->default(1); $table->boolean('default_quantity')->default(1); - $table->string('domain')->nullable(); + $table->string('subdomain')->nullable(); $table->string('db')->nullable(); $table->unsignedInteger('size_id')->nullable(); $table->string('first_day_of_week')->nullable(); diff --git a/database/seeds/RandomDataSeeder.php b/database/seeds/RandomDataSeeder.php index 8bfc090ad70b..b4af16e80d09 100644 --- a/database/seeds/RandomDataSeeder.php +++ b/database/seeds/RandomDataSeeder.php @@ -74,7 +74,6 @@ class RandomDataSeeder extends Seeder $account = factory(\App\Models\Account::class)->create(); $company = factory(\App\Models\Company::class)->create([ 'account_id' => $account->id, - 'domain' => config('ninja.site_url'), ]); $account->default_company_id = $company->id; diff --git a/tests/Browser/ClientPortalTest.php b/tests/Browser/ClientPortalTest.php index ecf107131690..8f4b0c033d5c 100644 --- a/tests/Browser/ClientPortalTest.php +++ b/tests/Browser/ClientPortalTest.php @@ -42,7 +42,6 @@ class ClientPortalTest extends DuskTestCase $account = factory(\App\Models\Account::class)->create(); $company = factory(\App\Models\Company::class)->create([ 'account_id' => $account->id, - 'domain' => 'ninja.test', ]); $account->default_company_id = $company->id; diff --git a/tests/Feature/ClientTest.php b/tests/Feature/ClientTest.php index 6955e95d6d6d..d0552e585b0f 100644 --- a/tests/Feature/ClientTest.php +++ b/tests/Feature/ClientTest.php @@ -191,7 +191,6 @@ class ClientTest extends TestCase $account = factory(\App\Models\Account::class)->create(); $company = factory(\App\Models\Company::class)->create([ 'account_id' => $account->id, - 'domain' => 'ninja.test', ]); $account->default_company_id = $company->id; diff --git a/tests/Feature/InvitationTest.php b/tests/Feature/InvitationTest.php index 594f5d82dd58..bc54775b2ef6 100644 --- a/tests/Feature/InvitationTest.php +++ b/tests/Feature/InvitationTest.php @@ -51,7 +51,6 @@ class InvitationTest extends TestCase $account = factory(\App\Models\Account::class)->create(); $company = factory(\App\Models\Company::class)->create([ 'account_id' => $account->id, - 'domain' => 'ninja.test', ]); $account->default_company_id = $company->id; diff --git a/tests/Feature/LoginTest.php b/tests/Feature/LoginTest.php index 52e0dc7fff76..ff766f5bd342 100644 --- a/tests/Feature/LoginTest.php +++ b/tests/Feature/LoginTest.php @@ -51,8 +51,6 @@ class LoginTest extends TestCase ]); $company = factory(\App\Models\Company::class)->make([ 'account_id' => $account->id, - 'domain' => 'ninja.test', - ]); $user->companies()->attach($company->id, [ @@ -85,8 +83,6 @@ class LoginTest extends TestCase ]); $company = factory(\App\Models\Company::class)->make([ 'account_id' => $account->id, - 'domain' => 'ninja.test', - ]); $user->companies()->attach($company->id, [ @@ -117,8 +113,6 @@ class LoginTest extends TestCase ]); $company = factory(\App\Models\Company::class)->make([ 'account_id' => $account->id, - 'domain' => 'ninja.test', - ]); $user->companies()->attach($company->id, [ @@ -146,8 +140,6 @@ class LoginTest extends TestCase $company = factory(\App\Models\Company::class)->create([ 'account_id' => $account->id, - 'domain' => 'ninja.test', - ]); $account->default_company_id = $account->id; diff --git a/tests/Feature/UserTest.php b/tests/Feature/UserTest.php index 4ec8fb74ba1d..553a2c379473 100644 --- a/tests/Feature/UserTest.php +++ b/tests/Feature/UserTest.php @@ -123,7 +123,6 @@ class UserTest extends TestCase /* Create New Company */ $company2 = factory(\App\Models\Company::class)->create([ 'account_id' => $this->account->id, - 'domain' => 'ninja.test:8000', ]); /* Create New Company Token*/ diff --git a/tests/Integration/MultiDBUserTest.php b/tests/Integration/MultiDBUserTest.php index d17828e2eb91..ee8ef9c2366e 100644 --- a/tests/Integration/MultiDBUserTest.php +++ b/tests/Integration/MultiDBUserTest.php @@ -43,12 +43,10 @@ class MultiDBUserTest extends TestCase $company = factory(\App\Models\Company::class)->make([ 'account_id' => $account->id, - 'domain' => 'ninja.test', ]); $company2 = factory(\App\Models\Company::class)->make([ 'account_id' => $account2->id, - 'domain' => 'ninja.test', ]); diff --git a/tests/Integration/UniqueEmailTest.php b/tests/Integration/UniqueEmailTest.php index bfa4749e5dad..fcb7ea827e1e 100644 --- a/tests/Integration/UniqueEmailTest.php +++ b/tests/Integration/UniqueEmailTest.php @@ -38,7 +38,6 @@ class UniqueEmailTest extends TestCase $company = factory(\App\Models\Company::class)->make([ 'account_id' => $account->id, - 'domain' => 'ninja.test', ]); $company->setHidden(['settings', 'settings_object', 'hashed_id']); @@ -52,8 +51,6 @@ class UniqueEmailTest extends TestCase $company2 = factory(\App\Models\Company::class)->make([ 'account_id' => $account2->id, - 'domain' => 'ninja.test', - ]); $company2->setHidden(['settings', 'settings_object', 'hashed_id']); diff --git a/tests/MockAccountData.php b/tests/MockAccountData.php index 70bb9714b311..f202b702a6b6 100644 --- a/tests/MockAccountData.php +++ b/tests/MockAccountData.php @@ -89,7 +89,6 @@ trait MockAccountData $this->account = factory(\App\Models\Account::class)->create(); $this->company = factory(\App\Models\Company::class)->create([ 'account_id' => $this->account->id, - 'domain' => 'ninja.test:8000', ]); $this->account->default_company_id = $this->company->id;