2021-03-22 21:09:42 +01:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Invoice Ninja (https://invoiceninja.com).
|
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
|
|
|
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
|
|
|
|
*
|
2021-06-16 08:58:16 +02:00
|
|
|
* @license https://www.elastic.co/licensing/elastic-license
|
2021-03-22 21:09:42 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
|
|
|
use App\Libraries\MultiDB;
|
|
|
|
|
|
|
|
class SubdomainController extends BaseController
|
|
|
|
{
|
2021-04-28 05:12:51 +02:00
|
|
|
private $protected = [
|
|
|
|
'www',
|
|
|
|
'app',
|
|
|
|
'ninja',
|
|
|
|
'sentry',
|
|
|
|
'staging',
|
|
|
|
'pdf',
|
|
|
|
'demo',
|
|
|
|
'docs',
|
|
|
|
'client_domain',
|
|
|
|
'custom_domain',
|
|
|
|
];
|
2021-03-22 21:09:42 +01:00
|
|
|
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Display a listing of the resource.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function index()
|
|
|
|
{
|
|
|
|
|
2021-05-18 15:12:03 +02:00
|
|
|
if(in_array(request()->input('subdomain'), $this->protected) || MultiDB::findAndSetDbByDomain(['subdomain' => request()->input('subdomain')]))
|
2021-03-22 21:09:42 +01:00
|
|
|
return response()->json(['message' => 'Domain not available'] , 401);
|
|
|
|
|
|
|
|
return response()->json(['message' => 'Domain available'], 200);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|