keep module files under their own folder

This commit is contained in:
Denis Duliçi
2021-05-19 09:12:01 +03:00
parent 9f1cf98906
commit 3b3292f631
2 changed files with 29 additions and 25 deletions

View File

@ -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
{
@ -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 {
$namespace = '';
$title_type = trans_choice('general.' . str_replace('-', '_', $type), 2);
$sample_file = url('public/files/import/' . $type . '.xlsx');
}
return view('common.import.create', compact('group', 'type', 'path', 'route', 'namespace'));
$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 {
$form_params['url'] = $path . '/import';
}
return view('common.import.create', compact('group', 'type', 'path', 'route', 'form_params', 'title_type', 'sample_file'));
}
}