diff --git a/.env.example b/.env.example index 54e388c4fee7..8729acc1dc34 100644 --- a/.env.example +++ b/.env.example @@ -52,6 +52,7 @@ TRUSTED_PROXIES= NINJA_ENVIRONMENT=selfhost +PHANTOMJS_PDF_GENERATION=true PHANTOMJS_KEY='a-demo-key-with-low-quota-per-ip-address' PHANTOMJS_SECRET= diff --git a/app/Http/Controllers/BaseController.php b/app/Http/Controllers/BaseController.php index 6f115f3d78c9..5612705a5bac 100644 --- a/app/Http/Controllers/BaseController.php +++ b/app/Http/Controllers/BaseController.php @@ -65,6 +65,7 @@ class BaseController extends Controller 'company.task_statuses', 'company.expense_categories', 'company.documents', + 'company.users', //'company.users.company_user', 'company.clients.contacts.company', 'company.clients.gateway_tokens', diff --git a/app/Jobs/Entity/CreateEntityPdf.php b/app/Jobs/Entity/CreateEntityPdf.php index 1e552e1ff7d9..9b9027fef718 100644 --- a/app/Jobs/Entity/CreateEntityPdf.php +++ b/app/Jobs/Entity/CreateEntityPdf.php @@ -87,7 +87,7 @@ class CreateEntityPdf implements ShouldQueue public function handle() { - if (config('ninja.phantomjs_key')) { + if (config('ninja.phantomjs_pdf_generation')) { return (new Phantom)->generate($this->invitation); } diff --git a/app/Models/CompanyUser.php b/app/Models/CompanyUser.php index fd0c799adc70..1bd1a7373869 100644 --- a/app/Models/CompanyUser.php +++ b/app/Models/CompanyUser.php @@ -11,6 +11,7 @@ namespace App\Models; +use App\Models\TaxRate; use Illuminate\Database\Eloquent\Relations\Pivot; use Illuminate\Database\Eloquent\SoftDeletes; @@ -55,6 +56,11 @@ class CompanyUser extends Pivot return self::class; } + public function tax_rates() + { + return $this->hasMany(TaxRate::class,'company_id', 'company_id'); + } + public function account() { return $this->belongsTo(Account::class); diff --git a/app/Utils/SystemHealth.php b/app/Utils/SystemHealth.php index 4931fdd2fc3f..3abb9182d4b9 100644 --- a/app/Utils/SystemHealth.php +++ b/app/Utils/SystemHealth.php @@ -78,9 +78,19 @@ class SystemHealth 'simple_db_check' => (bool) self::simpleDbCheck(), 'npm_status' => self::checkNpm(), 'node_status' => self::checkNode(), + 'cache_enabled' => self::checkConfigCache(), + 'phantom_enabled' => (bool) config('ninja.phantomjs_pdf_generation'), ]; } + public static function checkConfigCache() + { + if(env('APP_URL')) + return false; + + return true; + } + public static function checkNode() { try { diff --git a/config/ninja.php b/config/ninja.php index 6edfe78c9e16..b07123bea9bf 100644 --- a/config/ninja.php +++ b/config/ninja.php @@ -29,6 +29,7 @@ return [ 'enabled_modules' => 32767, 'phantomjs_key' => env('PHANTOMJS_KEY', false), 'phantomjs_secret' => env('PHANTOMJS_SECRET', false), + 'phantomjs_pdf_generation' => env('PHANTOMJS_PDF_GENERATION', true), 'trusted_proxies' => env('TRUSTED_PROXIES', false), 'sentry_dsn' => env('SENTRY_LARAVEL_DSN', 'https://9b4e15e575214354a7d666489783904a@sentry.invoicing.co/6'),