У меня есть миграция с несколькими таблицами: Status, Status_project, Status_task. Могу ли я вызвать их всех только с моей моделью состояния, которая была создана с помощью команды миграции?
php artisan make:model Status -m
Я читаю в нескольких местах, что мне нужно сделать модель для каждой таблицы, но другого пути нет? За исключением DB :: table («статусы»). Из-за моих отношений я не предпочитаю несколько моделей
Пример:
Schema::create('statuses', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('name')->unique();
$table->string('display_name')->nullable();
$table->string('description')->nullable();
$table->timestamps();
});
Schema::create('status_task', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('user_id')->nullable();
$table->unsignedBigInteger('task_id');
$table->unsignedBigInteger('status_id');
$table->foreign('user_id')->references('id')->on('users')
->onUpdate('cascade')->onDelete('cascade');
$table->foreign('task_id')->references('id')->on('ongoing_tasks')
->onUpdate('cascade')->onDelete('cascade');
$table->foreign('status_id')->references('id')->on('statuses')
->onUpdate('cascade')->onDelete('cascade');
});
Schema::create('status_project', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('user_id')->nullable();
$table->string('project_id');
$table->unsignedBigInteger('status_id');
$table->foreign('user_id')->references('id')->on('users')
->onUpdate('cascade')->onDelete('cascade');
$table->foreign('project_id')->references('id')->on('ongoing_projects')
->onUpdate('cascade')->onDelete('cascade');
$table->foreign('status_id')->references('id')->on('statuses')
->onUpdate('cascade')->onDelete('cascade');
});
DB::commit();