У меня есть эти таблицы:
Schema::create('users', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('name');
$table->string('email')->unique();
$table->string('password');
});
Schema::create('periods', function (Blueprint $table) {
$table->bigIncrements('id');
$table->datetime('start_time');
$table->datetime('end_time');
$table->datetime('payout_time');
});
Schema::create('payouts', function (Blueprint $table) {
$table->bigIncrements('id');
$table->unsignedBigInteger('user_id');
$table->unsignedBigInteger('period_id');
$table->foreign('user_id')->references('id')->on('users');
$table->foreign('period_id')->references('id')->on('periods');
});
Я пытаюсь перечислить все периоды с общим числом пользователей , имеющих записи выплат , и общее количество пользователей, у которых нет записей выплат за каждый период.
Period::paginate();
Я пытался настроить отношение HasMany в таблице периодов, но Я уверен, что делаю это неправильно. Как я могу решить это?