import not compatible with modules
This commit is contained in:
@ -8,12 +8,12 @@ use Illuminate\Validation\ValidationException;
|
||||
class Import
|
||||
{
|
||||
|
||||
public static function createFromFile($import, $slug)
|
||||
public static function createFromFile($import, $slug, $namespace = 'App')
|
||||
{
|
||||
$success = true;
|
||||
|
||||
// Loop through all sheets
|
||||
$import->each(function ($sheet) use (&$success, $slug) {
|
||||
$import->each(function ($sheet) use (&$success, $slug, $namespace) {
|
||||
if (!static::isValidSheetName($sheet, $slug)) {
|
||||
$message = trans('messages.error.import_sheet');
|
||||
|
||||
@ -22,7 +22,7 @@ class Import
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$success = static::createFromSheet($sheet, $slug)) {
|
||||
if (!$success = static::createFromSheet($sheet, $slug, $namespace)) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
@ -30,12 +30,12 @@ class Import
|
||||
return $success;
|
||||
}
|
||||
|
||||
public static function createFromSheet($sheet, $slug)
|
||||
public static function createFromSheet($sheet, $slug, $namespace = 'App')
|
||||
{
|
||||
$success = true;
|
||||
|
||||
$model = '\App\Models\\' . $slug;
|
||||
$request = '\App\Http\Requests\\' . $slug;
|
||||
$model = '\\' . $namespace . '\Models\\' . $slug;
|
||||
$request = '\\' . $namespace . '\Http\Requests\\' . $slug;
|
||||
|
||||
if (!class_exists($model) || !class_exists($request)) {
|
||||
return false;
|
||||
@ -82,11 +82,17 @@ class Import
|
||||
{
|
||||
$t = explode('\\', $slug);
|
||||
|
||||
if (empty($t[1])) {
|
||||
return false;
|
||||
if (count($t) == 1) {
|
||||
$title = $slug;
|
||||
} else {
|
||||
if (empty($t[1])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$title = $t[1];
|
||||
}
|
||||
|
||||
if ($sheet->getTitle() != str_plural(snake_case($t[1]))) {
|
||||
if ($sheet->getTitle() != str_plural(snake_case($title))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user