This is my file with array for seeding DataBase:
<?php
namespace App\MyFolder;
return [
[
'name' => 'manufacturing firm',
'values' => [
'test1',
'test 2',
'test 3',
],
],
];
Then I try to use it inside my controller:
<?php
namespace App\Http\Controllers;
use App\MyFolder;
class UserController extends Controller
{
public function index() {
//.... error class not found
return MyFolder;
}
}
How can I use arrays, but non-class based files?
Error: Undefined constant 'App\MyFolder'
You can load the file like this:
class UserController extends Controller
{
public function index()
{
return File::getRequire(base_path().'/app/MyFolder/yourfile.php'); // path to your file
}
}