Код: Выделить всё
select * from entities;
+----+------+-------+-----------+---------------------+---------------------+
| id | name | order | is_active | created_at | updated_at |
+----+------+-------+-----------+---------------------+---------------------+
| 1 | jobs | 0 | 1 | 2024-05-23 11:51:51 | 2024-05-23 11:51:51 |
+----+------+-------+-----------+---------------------+---------------------+
Пока все хорошо. . Проблема возникает, когда я пытаюсь добавить маршруты для этого объекта, и на практике я делаю что-то вроде этого:
Код: Выделить всё
// tenant.php
Route::middleware([
'web',
InitializeTenancyByDomain::class,
PreventAccessFromCentralDomains::class,
InitializeTenancy::class,
])->group(function () {
....
$tenant->get('entity', $baseViewController);
$tenant->get('fields', $baseViewController);
// Include custom web entity routes
require __DIR__.'/tenant/entities/entityRoutesWEB.php';
....
});
// .../entityRoures/php
$entities = Entities::all();
// dd($entities);
foreach ($entities as $entity) {
$entityName = strtolower($entity->name);
$controllerName = 'App\Http\Controllers\API\Tenant\\' . ucfirst($entityName) . 'Controller';
// Define routes for this entity
Route::get("/{$entityName}", [BaseViewController::class, 'index']); // Fetch data for the entity
}
So my problem is here: `$entities = Entities::all();
// dd($entities);` this is getting the entities from the central db.
Код: Выделить всё
// /Tenant/EntitiesModel.php
namespace App\Models\Tenant\Entities;
// /Central/EntitiesModel.php
namespace App\Models\Central\Entities;
Подробнее здесь: https://stackoverflow.com/questions/785 ... -db-system