Skip to content

Commit

Permalink
keep module files under their own folder
Browse files Browse the repository at this point in the history
  • Loading branch information
denisdulici committed May 19, 2021
1 parent 9f1cf98 commit 3b3292f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 25 deletions.
30 changes: 25 additions & 5 deletions app/Http/Controllers/Common/Import.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace App\Http\Controllers\Common;

use App\Abstracts\Http\Controller;
use Illuminate\Http\Request;
use Akaunting\Module\Module;

class Import extends Controller
{
Expand All @@ -12,18 +12,38 @@ class Import extends Controller
*
* @param $group
* @param $type
* @param $route
*
* @return Response
*/
public function create($group, $type, $route = null)
{
$path = company_id() . '/' . $group . '/' . $type;

if (module($group) instanceof \Akaunting\Module\Module) {
$namespace = $group . '::';
if (module($group) instanceof Module) {
$title_type = trans_choice($group . '::general.' . str_replace('-', '_', $type), 2);
$sample_file = url('modules/' . $group . '/Resources/assets/' . $type . '.xlsx');
} else {
$title_type = trans_choice('general.' . str_replace('-', '_', $type), 2);
$sample_file = url('public/files/import/' . $type . '.xlsx');
}

$form_params = [
'id' => 'import',
'@submit.prevent' => 'onSubmit',
'@keydown' => 'form.errors.clear($event.target.name)',
'files' => true,
'role' => 'form',
'class' => 'form-loading-button',
'novalidate' => true,
];

if (!empty($route)) {
$form_params['route'] = $route;
} else {
$namespace = '';
$form_params['url'] = $path . '/import';
}

return view('common.import.create', compact('group', 'type', 'path', 'route', 'namespace'));
return view('common.import.create', compact('group', 'type', 'path', 'route', 'form_params', 'title_type', 'sample_file'));
}
}
24 changes: 4 additions & 20 deletions resources/views/common/import/create.blade.php
Original file line number Diff line number Diff line change
@@ -1,33 +1,16 @@
@extends('layouts.admin')

@section('title', trans('import.title', ['type' => trans_choice($namespace . 'general.' . str_replace('-', '_', $type), 2)]))
@section('title', trans('import.title', ['type' => $title_type]))

@section('content')
<div class="card">
@php
$form_open = [
'id' => 'import',
'@submit.prevent' => 'onSubmit',
'@keydown' => 'form.errors.clear($event.target.name)',
'files' => true,
'role' => 'form',
'class' => 'form-loading-button',
'novalidate' => true
];
if (!empty($route)) {
$form_open['route'] = $route;
} else {
$form_open['url'] = $path . '/import';
}
@endphp
{!! Form::open($form_open) !!}
{!! Form::open($form_params) !!}

<div class="card-body">
<div class="row">
<div class="col-md-12">
<div class="alert alert-info alert-important">
{!! trans('import.message', ['link' => url('public/files/import/' . $type . '.xlsx')]) !!}
{!! trans('import.message', ['link' => $sample_file]) !!}
</div>
</div>

Expand All @@ -54,6 +37,7 @@
</div>
</div>
</div>

{!! Form::close() !!}
</div>
@endsection
Expand Down

0 comments on commit 3b3292f

Please sign in to comment.