Find this useful? Enter your email to receive occasional updates for securing PHP code.
Signing you up...
Thank you for signing up!
PHP Decode
<?php namespace App\Jobs\Banking; use App\Abstracts\Job; use App\Events\Banking\AccountU..
Decoded Output download
<?php
namespace App\Jobs\Banking;
use App\Abstracts\Job;
use App\Events\Banking\AccountUpdating;
use App\Events\Banking\AccountUpdated;
use App\Interfaces\Job\ShouldUpdate;
use App\Models\Banking\Account;
class UpdateAccount extends Job implements ShouldUpdate
{
public function handle(): Account
{
$this->authorize();
event(new AccountUpdating($this->model, $this->request));
\DB::transaction(function () {
$this->model->update($this->request->all());
// Set default account
if ($this->request['default_account']) {
setting()->set('default.account', $this->model->id);
setting()->save();
}
});
event(new AccountUpdated($this->model, $this->request));
return $this->model;
}
/**
* Determine if this action is applicable.
*/
public function authorize(): void
{
$relationships = $this->getRelationships();
if (($this->request->has('enabled') && ! $this->request->get('enabled')) && ($this->model->id == setting('default.account'))) {
$relationships[] = strtolower(trans_choice('general.companies', 1));
$message = trans('messages.warning.disabled', ['name' => $this->model->name, 'text' => implode(', ', $relationships)]);
throw new \Exception($message);
}
if (! $relationships) {
return;
}
if ($this->model->currency_code != $this->request->get('currency_code')) {
$message = trans('messages.warning.disable_code', ['name' => $this->model->name, 'text' => implode(', ', $relationships)]);
throw new \Exception($message);
}
}
public function getRelationships(): array
{
$rels = [
'transactions' => 'transactions',
];
return $this->countRelationships($this->model, $rels);
}
}
?>
Did this file decode correctly?
Original Code
<?php
namespace App\Jobs\Banking;
use App\Abstracts\Job;
use App\Events\Banking\AccountUpdating;
use App\Events\Banking\AccountUpdated;
use App\Interfaces\Job\ShouldUpdate;
use App\Models\Banking\Account;
class UpdateAccount extends Job implements ShouldUpdate
{
public function handle(): Account
{
$this->authorize();
event(new AccountUpdating($this->model, $this->request));
\DB::transaction(function () {
$this->model->update($this->request->all());
// Set default account
if ($this->request['default_account']) {
setting()->set('default.account', $this->model->id);
setting()->save();
}
});
event(new AccountUpdated($this->model, $this->request));
return $this->model;
}
/**
* Determine if this action is applicable.
*/
public function authorize(): void
{
$relationships = $this->getRelationships();
if (($this->request->has('enabled') && ! $this->request->get('enabled')) && ($this->model->id == setting('default.account'))) {
$relationships[] = strtolower(trans_choice('general.companies', 1));
$message = trans('messages.warning.disabled', ['name' => $this->model->name, 'text' => implode(', ', $relationships)]);
throw new \Exception($message);
}
if (! $relationships) {
return;
}
if ($this->model->currency_code != $this->request->get('currency_code')) {
$message = trans('messages.warning.disable_code', ['name' => $this->model->name, 'text' => implode(', ', $relationships)]);
throw new \Exception($message);
}
}
public function getRelationships(): array
{
$rels = [
'transactions' => 'transactions',
];
return $this->countRelationships($this->model, $rels);
}
}
Function Calls
None |
Stats
MD5 | 19fba744bcc82212fb28b103bb6f771f |
Eval Count | 0 |
Decode Time | 85 ms |