akaunting/app/Http/Controllers/Common/Import.php

54 lines
1.5 KiB
PHP
Raw Permalink Normal View History

2017-11-30 08:47:56 +00:00
<?php
namespace App\Http\Controllers\Common;
2019-11-16 07:21:14 +00:00
use App\Abstracts\Http\Controller;
use Akaunting\Module\Module;
2017-11-30 08:47:56 +00:00
class Import extends Controller
{
/**
* Show the form for creating a new resource.
*
* @param $group
* @param $type
* @param $route
*
2017-11-30 08:47:56 +00:00
* @return Response
*/
public function create($group, $type, $route = null)
2017-11-30 08:47:56 +00:00
{
2021-04-15 21:59:43 +00:00
$path = company_id() . '/' . $group . '/' . $type;
2017-11-30 08:47:56 +00:00
2021-05-19 06:20:36 +00:00
$module = module($group);
if ($module instanceof Module) {
$title_type = trans_choice($group . '::general.' . str_replace('-', '_', $type), 2);
2021-05-19 06:20:36 +00:00
$sample_file = url('modules/' . $module->getStudlyName() . '/Resources/assets/' . $type . '.xlsx');
} else {
$title_type = trans_choice('general.' . str_replace('-', '_', $type), 2);
2023-01-17 13:10:46 +00:00
$sample_file = url('/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,
2022-06-01 07:15:55 +00:00
'route' => '',
'url' => '',
];
2022-06-01 07:15:55 +00:00
if (! empty($route)) {
$form_params['route'] = $route;
2019-04-04 14:54:03 +00:00
} else {
$form_params['url'] = $path . '/import';
2019-04-04 14:54:03 +00:00
}
return view('common.import.create', compact('group', 'type', 'path', 'route', 'form_params', 'title_type', 'sample_file'));
2017-11-30 08:47:56 +00:00
}
}