diff --git a/app/Http/Controllers/ClientPortal/ContactHashLoginController.php b/app/Http/Controllers/ClientPortal/ContactHashLoginController.php index 5f5fc4fb92a6..1f8579ba6f9d 100644 --- a/app/Http/Controllers/ClientPortal/ContactHashLoginController.php +++ b/app/Http/Controllers/ClientPortal/ContactHashLoginController.php @@ -50,9 +50,9 @@ class ContactHashLoginController extends Controller public function errorPage() { return render('generic.error', [ - 'title' => session()->get('title'), - 'notification' => session()->get('notification'), - 'account' => auth()->guard('contact')?->user()?->user?->account, + 'title' => session()->get('title'), + 'notification' => session()->get('notification'), + 'account' => auth()->guard('contact')?->user()?->user?->account, 'company' => auth()->guard('contact')?->user()?->user?->company ]); } diff --git a/app/Http/Controllers/PreviewController.php b/app/Http/Controllers/PreviewController.php index 3ca1ce9ddaac..c9b3830baae3 100644 --- a/app/Http/Controllers/PreviewController.php +++ b/app/Http/Controllers/PreviewController.php @@ -195,12 +195,11 @@ class PreviewController extends BaseController $response->header('Content-Type', 'application/pdf'); return $response; - } public function oldDesign(DesignPreviewRequest $request) { - if(Ninja::isHosted() && !in_array($request->getHost(), ['preview.invoicing.co','staging.invoicing.co'])){ + if (Ninja::isHosted() && !in_array($request->getHost(), ['preview.invoicing.co','staging.invoicing.co'])) { return response()->json(['message' => 'This server cannot handle this request.'], 400); } @@ -238,13 +237,12 @@ class PreviewController extends BaseController ->first(); } - if($request->has('client_id') && strlen($request->client_id) > 4) { + if ($request->has('client_id') && strlen($request->client_id) > 4) { $client = Client::withTrashed()->find($this->decodePrimaryKey($request->client_id)); - if($request->settings_type == 'client' && $client ){ - $client->settings = $request->settings; - $client->save(); - } - + if ($request->settings_type == 'client' && $client) { + $client->settings = $request->settings; + $client->save(); + } } if ($request->has('group_id')) { @@ -340,13 +338,13 @@ class PreviewController extends BaseController $headers = ['Content-Type' => 'application/pdf']; - if(request()->input('inline') == 'true') + if (request()->input('inline') == 'true') { $headers = array_merge($headers, ['Content-Disposition' => 'inline']); + } - return response()->streamDownload(function () use($pdf) { - echo $pdf; - }, "preview.pdf", $headers); - + return response()->streamDownload(function () use ($pdf) { + echo $pdf; + }, "preview.pdf", $headers); } if (config('ninja.invoiceninja_hosted_pdf_generation') || config('ninja.pdf_generator') == 'hosted_ninja') { @@ -354,13 +352,13 @@ class PreviewController extends BaseController $headers = ['Content-Type' => 'application/pdf']; - if(request()->input('inline') == 'true') + if (request()->input('inline') == 'true') { $headers = array_merge($headers, ['Content-Disposition' => 'inline']); + } - return response()->streamDownload(function () use($pdf) { - echo $pdf; - }, "preview.pdf", $headers); - + return response()->streamDownload(function () use ($pdf) { + echo $pdf; + }, "preview.pdf", $headers); } $file_path = (new PreviewPdf($maker->getCompiledHTML(true), $company))->handle(); @@ -372,8 +370,9 @@ class PreviewController extends BaseController public function live(PreviewInvoiceRequest $request) { - if(Ninja::isHosted() && !in_array($request->getHost(), ['preview.invoicing.co','staging.invoicing.co'])) + if (Ninja::isHosted() && !in_array($request->getHost(), ['preview.invoicing.co','staging.invoicing.co'])) { return response()->json(['message' => 'This server cannot handle this request.'], 400); + } $company = auth()->user()->company(); diff --git a/app/Http/Controllers/SetupController.php b/app/Http/Controllers/SetupController.php index 91fc65b19585..e89f75c238f5 100644 --- a/app/Http/Controllers/SetupController.php +++ b/app/Http/Controllers/SetupController.php @@ -208,9 +208,7 @@ class SetupController extends Controller public function checkPdf(Request $request) { try { - return response(['url' => ''], 200); - } catch (Exception $e) { nlog($e->getMessage()); diff --git a/app/Http/Requests/TaskScheduler/UpdateSchedulerRequest.php b/app/Http/Requests/TaskScheduler/UpdateSchedulerRequest.php index a573177b7b5a..0c019e25b0d7 100644 --- a/app/Http/Requests/TaskScheduler/UpdateSchedulerRequest.php +++ b/app/Http/Requests/TaskScheduler/UpdateSchedulerRequest.php @@ -11,8 +11,8 @@ namespace App\Http\Requests\TaskScheduler; use App\Http\Requests\Request; -use Illuminate\Validation\Rule; use App\Http\ValidationRules\Scheduler\ValidClientIds; +use Illuminate\Validation\Rule; class UpdateSchedulerRequest extends Request { diff --git a/app/Http/ValidationRules/Company/ValidCompanyQuantity.php b/app/Http/ValidationRules/Company/ValidCompanyQuantity.php index b9166698e8c5..75796f03eb97 100644 --- a/app/Http/ValidationRules/Company/ValidCompanyQuantity.php +++ b/app/Http/ValidationRules/Company/ValidCompanyQuantity.php @@ -26,8 +26,9 @@ class ValidCompanyQuantity implements Rule */ public function passes($attribute, $value) { - if(config('ninja.testvars.travis')) + if (config('ninja.testvars.travis')) { return true; + } if (Ninja::isSelfHost()) { return auth()->user()->company()->account->companies->count() < 10; diff --git a/app/Jobs/Mail/NinjaMailerJob.php b/app/Jobs/Mail/NinjaMailerJob.php index b6dc286b23df..da3e02d04da8 100644 --- a/app/Jobs/Mail/NinjaMailerJob.php +++ b/app/Jobs/Mail/NinjaMailerJob.php @@ -611,8 +611,9 @@ class NinjaMailerJob implements ShouldQueue public function failed($exception = null) { - if($exception) + if ($exception) { nlog($exception->getMessage()); + } config(['queue.failed.driver' => null]); } diff --git a/app/Jobs/Util/UnlinkFile.php b/app/Jobs/Util/UnlinkFile.php index 2e85675e0fa2..722a489c98c3 100644 --- a/app/Jobs/Util/UnlinkFile.php +++ b/app/Jobs/Util/UnlinkFile.php @@ -22,7 +22,9 @@ class UnlinkFile implements ShouldQueue { use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; - public function __construct(protected string $disk = '', protected ?string $file_path = ''){} + public function __construct(protected string $disk = '', protected ?string $file_path = '') + { + } /** * Execute the job. @@ -32,12 +34,14 @@ class UnlinkFile implements ShouldQueue public function handle() { /* Do not delete files if we are on the sync queue*/ - if (config('queue.default') == 'sync') + if (config('queue.default') == 'sync') { return; + } - if(!$this->file_path) + if (!$this->file_path) { return; + } Storage::disk($this->disk)->delete($this->file_path); } diff --git a/app/Models/BaseModel.php b/app/Models/BaseModel.php index 39c697a8c899..db9e5e9d7f1a 100644 --- a/app/Models/BaseModel.php +++ b/app/Models/BaseModel.php @@ -11,16 +11,16 @@ namespace App\Models; -use Illuminate\Support\Str; -use Illuminate\Support\Carbon; -use App\Utils\Traits\MakesHash; +use App\DataMapper\ClientSettings; use App\Jobs\Util\WebhookHandler; use App\Models\Traits\Excludable; -use App\DataMapper\ClientSettings; -use Illuminate\Database\Eloquent\Model; +use App\Utils\Traits\MakesHash; use App\Utils\Traits\UserSessionAttributes; use Illuminate\Database\Eloquent\Factories\HasFactory; +use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\ModelNotFoundException as ModelNotFoundException; +use Illuminate\Support\Carbon; +use Illuminate\Support\Str; /** * Class BaseModel diff --git a/app/Models/StaticModel.php b/app/Models/StaticModel.php index c2a29fd67ddb..b2c6ccf58506 100644 --- a/app/Models/StaticModel.php +++ b/app/Models/StaticModel.php @@ -11,8 +11,8 @@ namespace App\Models; -use App\Utils\Traits\MakesHash; use App\Models\Traits\Excludable; +use App\Utils\Traits\MakesHash; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\ModelNotFoundException as ModelNotFoundException; diff --git a/app/Models/User.php b/app/Models/User.php index f2211b547158..e952e7f5a9b3 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -486,15 +486,15 @@ class User extends Authenticatable implements MustVerifyEmail /** * Used when we need to filter permissions carefully. - * + * * For instance, users that have view_client permissions should not - * see the client balance, however if they also have + * see the client balance, however if they also have * view_invoice or view_all etc, then they should be able to see the balance. - * + * * First we pass over the excluded permissions and return false if we find a match. - * + * * If those permissions are not hit, then we can iterate through the matched_permissions and search for a hit. - * + * * Note, returning FALSE here means the user does NOT have the permission we want to exclude * * @param array $matched_permission @@ -513,7 +513,7 @@ class User extends Authenticatable implements MustVerifyEmail } } - foreach($matched_permission as $permission) { + foreach ($matched_permission as $permission) { if ($this->hasExactPermission($permission)) { return true; } diff --git a/app/Services/PdfMaker/Design.php b/app/Services/PdfMaker/Design.php index d6c3f249303e..b8a2da23707d 100644 --- a/app/Services/PdfMaker/Design.php +++ b/app/Services/PdfMaker/Design.php @@ -245,28 +245,28 @@ class Design extends BaseDesign { $elements = []; - if(!$this->client) + if (!$this->client) { return $elements; + } - $elements = [ - ['element' => 'p', 'content' => ctrans('texts.shipping_address'), 'properties' => ['data-ref' => 'shipping_address-label', 'style' => 'font-weight: bold; text-transform: uppercase']], - ['element' => 'p', 'content' => $this->client->name, 'show_empty' => false, 'properties' => ['data-ref' => 'shipping_address-client.name']], - ['element' => 'p', 'content' => $this->client->shipping_address1, 'show_empty' => false, 'properties' => ['data-ref' => 'shipping_address-client.shipping_address1']], - ['element' => 'p', 'content' => $this->client->shipping_address2, 'show_empty' => false, 'properties' => ['data-ref' => 'shipping_address-client.shipping_address2']], - ['element' => 'p', 'show_empty' => false, 'elements' => [ - ['element' => 'span', 'content' => "{$this->client->shipping_city} ", 'properties' => ['ref' => 'shipping_address-client.shipping_city']], - ['element' => 'span', 'content' => "{$this->client->shipping_state} ", 'properties' => ['ref' => 'shipping_address-client.shipping_state']], - ['element' => 'span', 'content' => "{$this->client->shipping_postal_code} ", 'properties' => ['ref' => 'shipping_address-client.shipping_postal_code']], - ]], - ['element' => 'p', 'content' => optional($this->client->shipping_country)->name, 'show_empty' => false], - ]; + $elements = [ + ['element' => 'p', 'content' => ctrans('texts.shipping_address'), 'properties' => ['data-ref' => 'shipping_address-label', 'style' => 'font-weight: bold; text-transform: uppercase']], + ['element' => 'p', 'content' => $this->client->name, 'show_empty' => false, 'properties' => ['data-ref' => 'shipping_address-client.name']], + ['element' => 'p', 'content' => $this->client->shipping_address1, 'show_empty' => false, 'properties' => ['data-ref' => 'shipping_address-client.shipping_address1']], + ['element' => 'p', 'content' => $this->client->shipping_address2, 'show_empty' => false, 'properties' => ['data-ref' => 'shipping_address-client.shipping_address2']], + ['element' => 'p', 'show_empty' => false, 'elements' => [ + ['element' => 'span', 'content' => "{$this->client->shipping_city} ", 'properties' => ['ref' => 'shipping_address-client.shipping_city']], + ['element' => 'span', 'content' => "{$this->client->shipping_state} ", 'properties' => ['ref' => 'shipping_address-client.shipping_state']], + ['element' => 'span', 'content' => "{$this->client->shipping_postal_code} ", 'properties' => ['ref' => 'shipping_address-client.shipping_postal_code']], + ]], + ['element' => 'p', 'content' => optional($this->client->shipping_country)->name, 'show_empty' => false], + ]; - // if (!is_null($this->context['contact'])) { + // if (!is_null($this->context['contact'])) { // $elements[] = ['element' => 'p', 'content' => $this->context['contact']->email, 'show_empty' => false, 'properties' => ['data-ref' => 'delivery_note-contact.email']]; - // } + // } - return $elements; - + return $elements; } public function clientDetails(): array @@ -309,22 +309,18 @@ class Design extends BaseDesign public function entityDetailsx(): array { - - if ($this->type === 'statement') { - $s_date = $this->translateDate($this->options['start_date'], $this->client->date_format(), $this->client->locale()) . " - " . $this->translateDate($this->options['end_date'], $this->client->date_format(), $this->client->locale()); - return [ + return [ ['element' => 'p', 'content' => "