Skip to content

Commit

Permalink
style: format files
Browse files Browse the repository at this point in the history
  • Loading branch information
zanechua committed Sep 4, 2021
1 parent 0279f67 commit 875b7ed
Show file tree
Hide file tree
Showing 263 changed files with 3,384 additions and 2,715 deletions.
10 changes: 6 additions & 4 deletions app/Console/Commands/GenerateRecurringInvoices.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,12 @@ public function handle()
$template = $invoiceRecurrence->template;
$templateItems = $template->items;

$constraintTime = $now->{$this->getDateAdditionOperator($invoiceRecurrence->time_period)}($invoiceRecurrence->time_interval + 3);
$constraintTime = $now->{$this->getDateAdditionOperator($invoiceRecurrence->time_period)}(
$invoiceRecurrence->time_interval + 3,
);
$constraint = new BeforeConstraint($constraintTime);

// $rrule = Unicorn::generateRrule($invoiceRecurrence->created_at, $timezone, $invoiceRecurrence->time_interval, $invoiceRecurrence->time_period, $invoiceRecurrence->until_type, $invoiceRecurrence->until_meta, true);
// $rrule = Unicorn::generateRrule($invoiceRecurrence->created_at, $timezone, $invoiceRecurrence->time_interval, $invoiceRecurrence->time_period, $invoiceRecurrence->until_type, $invoiceRecurrence->until_meta, true);
$rrule = Rule::createFromString($invoiceRecurrence->rule, $template->date);
$transformer = new ArrayTransformer();

Expand All @@ -73,7 +75,7 @@ public function handle()
break;
}

// $template->date = $template->date->{$this->getDateAdditionOperator($invoiceRecurrence->time_period)}(($invoiceRecurrence->time_interval * ($key + 1) ));
// $template->date = $template->date->{$this->getDateAdditionOperator($invoiceRecurrence->time_period)}(($invoiceRecurrence->time_interval * ($key + 1) ));

$generatedInvoice = new Invoice();
$generatedInvoice->fill($template->toArray());
Expand All @@ -86,7 +88,7 @@ public function handle()

//Generate hash based on the serialized version of the invoice;
//Only retrieve the invoice data without any relations
$hash = hash('sha512', serialize(json_encode($generatedInvoice->getAttributes()).$templateItems));
$hash = hash('sha512', serialize(json_encode($generatedInvoice->getAttributes()) . $templateItems));

if (Invoice::where('hash', $hash)->count() == 1) {
print_r("Invoice already generated\n");
Expand Down
4 changes: 3 additions & 1 deletion app/Console/Commands/ProcessNotifiableInvoices.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ public function handle()
{
$startDate = Carbon::now()->subDay();
$endDate = Carbon::now()->addDay();
$invoices = Invoice::datebetween($startDate, $endDate)->notifiable()->get();
$invoices = Invoice::datebetween($startDate, $endDate)
->notifiable()
->get();
foreach ($invoices as $invoice) {
$company = $invoice->company;
$localDate = Carbon::now($company->timezone);
Expand Down
2 changes: 1 addition & 1 deletion app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ protected function schedule(Schedule $schedule)
*/
protected function commands()
{
$this->load(__DIR__.'/Commands');
$this->load(__DIR__ . '/Commands');

require base_path('routes/console.php');
}
Expand Down
10 changes: 2 additions & 8 deletions app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,7 @@ class Handler extends ExceptionHandler
*
* @var array
*/
protected $dontFlash = [
'current_password',
'password',
'password_confirmation',
];
protected $dontFlash = ['current_password', 'password', 'password_confirmation'];

/**
* Register the exception handling callbacks for the application.
Expand Down Expand Up @@ -57,8 +53,6 @@ public function register()
*/
protected function unauthenticated($request, AuthenticationException $exception)
{
return $request->expectsJson()
? response()->json(['message' => 'Unauthenticated.'], 401)
: redirect()->guest(route('auth.show'));
return $request->expectsJson() ? response()->json(['message' => 'Unauthenticated.'], 401) : redirect()->guest(route('auth.show'));
}
}
30 changes: 17 additions & 13 deletions app/Http/Controllers/AdhocInvoiceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ public function store(CreateAdhocInvoiceRequest $request, Company $company)
$invoice->notify = $request->has('notify') ? 1 : 0;

$client = [
'companyname' => $request->input('companyname'),
'companyname' => $request->input('companyname'),
'country_code' => $request->input('country_code'),
'block' => $request->input('block'),
'street' => $request->input('street'),
'unitnumber' => $request->input('unitnumber'),
'postalcode' => $request->input('postalcode'),
'block' => $request->input('block'),
'street' => $request->input('street'),
'unitnumber' => $request->input('unitnumber'),
'postalcode' => $request->input('postalcode'),
];
$invoice->client_data = json_encode($client);

Expand All @@ -78,7 +78,9 @@ public function store(CreateAdhocInvoiceRequest $request, Company $company)
foreach ($request->input('item_name') as $key => $item) {
$invoiceitem = new InvoiceItem();
$invoiceitem->name = $item;
$invoiceitem->description = (array_key_exists($key, $request->input('item_description'))) ? $request->input('item_description')[$key] : null;
$invoiceitem->description = array_key_exists($key, $request->input('item_description'))
? $request->input('item_description')[$key]
: null;
$invoiceitem->quantity = $request->input('item_quantity')[$key];
$invoiceitem->price = $request->input('item_price')[$key];
$invoiceitem->invoice_id = $invoice->id;
Expand Down Expand Up @@ -154,7 +156,7 @@ public function update(UpdateAdhocInvoiceRequest $request, Company $company, Inv
$request->input('item_name')[$key],
$request->input('item_description')[$key],
$request->input('item_quantity')[$key],
$request->input('item_price')[$key]
$request->input('item_price')[$key],
);

if ($ismodified) {
Expand Down Expand Up @@ -188,12 +190,12 @@ public function update(UpdateAdhocInvoiceRequest $request, Company $company, Inv
}

$client = [
'companyname' => $request->input('companyname'),
'companyname' => $request->input('companyname'),
'country_code' => $request->input('country_code'),
'block' => $request->input('block'),
'street' => $request->input('street'),
'unitnumber' => $request->input('unitnumber'),
'postalcode' => $request->input('postalcode'),
'block' => $request->input('block'),
'street' => $request->input('street'),
'unitnumber' => $request->input('unitnumber'),
'postalcode' => $request->input('postalcode'),
];

$invoice->client_data = json_encode($client);
Expand All @@ -211,7 +213,9 @@ public function update(UpdateAdhocInvoiceRequest $request, Company $company, Inv
$invoiceitem = new InvoiceItem();
}
$invoiceitem->name = $itemname;
$invoiceitem->description = (array_key_exists($key, $request->input('item_description'))) ? $request->input('item_description')[$key] : null;
$invoiceitem->description = array_key_exists($key, $request->input('item_description'))
? $request->input('item_description')[$key]
: null;
$invoiceitem->quantity = $request->input('item_quantity')[$key];
$invoiceitem->price = $request->input('item_price')[$key];
$invoiceitem->invoice_id = $invoice->id;
Expand Down
28 changes: 16 additions & 12 deletions app/Http/Controllers/AdhocQuoteController.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ public function store(CreateAdhocQuoteRequest $request, Company $company)
$quote->company_id = $company->id;

$client = [
'companyname' => $request->input('companyname'),
'companyname' => $request->input('companyname'),
'country_code' => $request->input('country_code'),
'block' => $request->input('block'),
'street' => $request->input('street'),
'unitnumber' => $request->input('unitnumber'),
'postalcode' => $request->input('postalcode'),
'block' => $request->input('block'),
'street' => $request->input('street'),
'unitnumber' => $request->input('unitnumber'),
'postalcode' => $request->input('postalcode'),
];
$quote->client_data = json_encode($client);

Expand All @@ -75,7 +75,9 @@ public function store(CreateAdhocQuoteRequest $request, Company $company)
foreach ($request->input('item_name') as $key => $item) {
$quoteitem = new QuoteItem();
$quoteitem->name = $item;
$quoteitem->description = (array_key_exists($key, $request->input('item_description'))) ? $request->input('item_description')[$key] : null;
$quoteitem->description = array_key_exists($key, $request->input('item_description'))
? $request->input('item_description')[$key]
: null;
$quoteitem->quantity = $request->input('item_quantity')[$key];
$quoteitem->price = $request->input('item_price')[$key];
$quoteitem->quote_id = $quote->id;
Expand Down Expand Up @@ -131,12 +133,12 @@ public function update(UpdateAdhocQuoteRequest $request, Company $company, Quote
$quote->fill($request->all());

$client = [
'companyname' => $request->input('companyname'),
'companyname' => $request->input('companyname'),
'country_code' => $request->input('country_code'),
'block' => $request->input('block'),
'street' => $request->input('street'),
'unitnumber' => $request->input('unitnumber'),
'postalcode' => $request->input('postalcode'),
'block' => $request->input('block'),
'street' => $request->input('street'),
'unitnumber' => $request->input('unitnumber'),
'postalcode' => $request->input('postalcode'),
];

$quote->client_data = json_encode($client);
Expand All @@ -153,7 +155,9 @@ public function update(UpdateAdhocQuoteRequest $request, Company $company, Quote
$quoteitem = new QuoteItem();
}
$quoteitem->name = $itemname;
$quoteitem->description = (array_key_exists($key, $request->input('item_description'))) ? $request->input('item_description')[$key] : null;
$quoteitem->description = array_key_exists($key, $request->input('item_description'))
? $request->input('item_description')[$key]
: null;
$quoteitem->quantity = $request->input('item_quantity')[$key];
$quoteitem->price = $request->input('item_price')[$key];
$quoteitem->quote_id = $quote->id;
Expand Down
54 changes: 33 additions & 21 deletions app/Http/Controllers/ClientController.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,23 +61,28 @@ public function store(CreateClientRequest $request, Company $company)
$client->company_id = $company->id;
$client->save();

$storedirectory = '/perm_store/company/'.$client->company_id.'/clients/'.$client->id.'/photos/';
$storedirectory = '/perm_store/company/' . $client->company_id . '/clients/' . $client->id . '/photos/';

Storage::makeDirectory($storedirectory);

if ($request->file('logo')) {
$file = $request->file('logo');
$uuid = Str::random(25);
$filename = $uuid.'.png';

if (! Storage::exists($storedirectory.'logo_'.$filename)) {
$image = Image::make($file)->fit(500, 500, function ($constraint) {
$constraint->upsize();
}, 'center');
Storage::put($storedirectory.'logo_'.$filename, $image->stream('jpg')->detach());
$filename = $uuid . '.png';

if (!Storage::exists($storedirectory . 'logo_' . $filename)) {
$image = Image::make($file)->fit(
500,
500,
function ($constraint) {
$constraint->upsize();
},
'center',
);
Storage::put($storedirectory . 'logo_' . $filename, $image->stream('jpg')->detach());
}

$filepath = $storedirectory.'logo_'.$filename;
$filepath = $storedirectory . 'logo_' . $filename;

$client->logo = $filepath;
}
Expand Down Expand Up @@ -143,23 +148,28 @@ public function update(UpdateClientRequest $request, Company $company, Client $c
$client->fill($request->all());
$client->save();

$storedirectory = '/perm_store/company/'.$client->company_id.'/clients/'.$client->id.'/photos/';
$storedirectory = '/perm_store/company/' . $client->company_id . '/clients/' . $client->id . '/photos/';

Storage::makeDirectory($storedirectory);

if ($request->file('logo')) {
$file = $request->file('logo');
$uuid = Str::random(25);
$filename = $uuid.'.png';

if (! Storage::exists($storedirectory.'logo_'.$filename)) {
$image = Image::make($file)->fit(500, 500, function ($constraint) {
$constraint->upsize();
}, 'center');
Storage::put($storedirectory.'logo_'.$filename, $image->stream('jpg')->detach());
$filename = $uuid . '.png';

if (!Storage::exists($storedirectory . 'logo_' . $filename)) {
$image = Image::make($file)->fit(
500,
500,
function ($constraint) {
$constraint->upsize();
},
'center',
);
Storage::put($storedirectory . 'logo_' . $filename, $image->stream('jpg')->detach());
}

$filepath = $storedirectory.'logo_'.$filename;
$filepath = $storedirectory . 'logo_' . $filename;

$client->logo = $filepath;
}
Expand Down Expand Up @@ -198,8 +208,10 @@ public function destroy(Company $company, Client $client)
*/
public function invoicecreate(Company $company, Client $client)
{
return redirect()->route('invoice.create', ['company' => $company])->withInput([
'client_id' => $client->id,
]);
return redirect()
->route('invoice.create', ['company' => $company])
->withInput([
'client_id' => $client->id,
]);
}
}
2 changes: 1 addition & 1 deletion app/Http/Controllers/CompanyAddressController.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function update(UpdateCompanyAddressRequest $request, Company $company)
{
$companyaddress = $company->address;

if (! $companyaddress) {
if (!$companyaddress) {
$companyaddress = new CompanyAddress();
}

Expand Down
Loading

0 comments on commit 875b7ed

Please sign in to comment.