-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b243b3f
commit 3dde3af
Showing
3 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\Modals; | ||
|
||
use App\Abstracts\Http\Controller; | ||
use App\Http\Requests\Banking\Account as Request; | ||
use App\Jobs\Banking\CreateAccount; | ||
use App\Models\Banking\Account; | ||
use App\Models\Setting\Currency; | ||
|
||
class Accounts extends Controller | ||
{ | ||
/** | ||
* Instantiate a new controller instance. | ||
*/ | ||
public function __construct() | ||
{ | ||
// Add CRUD permission check | ||
$this->middleware('permission:create-banking-accounts')->only(['create', 'store', 'duplicate', 'import']); | ||
$this->middleware('permission:read-banking-accounts')->only(['index', 'show', 'edit', 'export']); | ||
$this->middleware('permission:update-banking-accounts')->only(['update', 'enable', 'disable']); | ||
$this->middleware('permission:delete-banking-accounts')->only('destroy'); | ||
} | ||
|
||
/** | ||
* Show the form for creating a new resource. | ||
* | ||
* @return Response | ||
*/ | ||
public function create() | ||
{ | ||
$currencies = Currency::enabled()->pluck('name', 'code'); | ||
|
||
$currency = Currency::where('code', '=', setting('default.currency'))->first(); | ||
|
||
$html = view('modals.accounts.create', compact('currencies', 'currency'))->render(); | ||
|
||
return response()->json([ | ||
'success' => true, | ||
'error' => false, | ||
'message' => 'null', | ||
'html' => $html, | ||
]); | ||
} | ||
|
||
/** | ||
* Store a newly created resource in storage. | ||
* | ||
* @param Request $request | ||
* | ||
* @return Response | ||
*/ | ||
public function store(Request $request) | ||
{ | ||
$request['enabled'] = 1; | ||
|
||
$response = $this->ajaxDispatch(new CreateAccount($request)); | ||
|
||
if ($response['success']) { | ||
$response['message'] = trans('messages.success.added', ['type' => trans_choice('general.accounts', 1)]); | ||
} | ||
|
||
return response()->json($response); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{!! Form::open([ | ||
'id' => 'form-create-account', | ||
'@submit.prevent' => 'onSubmit', | ||
'@keydown' => 'form.errors.clear($event.target.name)', | ||
'role' => 'form', | ||
'class' => 'form-loading-button', | ||
'route' => 'accounts.store', | ||
'novalidate' => true | ||
]) !!} | ||
<div class="row"> | ||
{{ Form::textGroup('name', trans('general.name'), 'font') }} | ||
|
||
{{ Form::textGroup('number', trans('accounts.number'), 'pencil-alt') }} | ||
|
||
{{ Form::selectGroup('currency_code', trans_choice('general.currencies', 1), 'exchange-alt', $currencies, setting('default.currency'), ['required' => 'required', 'change' => 'onChangeCurrency']) }} | ||
|
||
{{ Form::moneyGroup('opening_balance', trans('accounts.opening_balance'), 'balance-scale', ['required' => 'required', 'currency' => $currency], 0.00) }} | ||
|
||
{!! Form::hidden('enabled', '1', []) !!} | ||
</div> | ||
{!! Form::close() !!} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters