「Too few arguments to function, 0 passed in」 Laravel-9で開発中のアプリで発生したエラーを解決したい
「Too few arguments to function, 0 passed in」 Laravel-9で開発中のアプリで発生したエラーを解決したい
引数が不足している事は分かっているのですが、
以下のコードにて一体全体、どこが不足しているのかが分かりません。
似たような開発済のアプリでは、このようなエラーは発生しなかったので。
諸先輩方、宜しくお願いいたします。
発生している問題・エラー
Too few arguments to function App\Http\Controllers\ResultController::create(), 0 passed in C:\xampp\htdocs\pointmaster\vendor\laravel\framework\src\Illuminate\Routing\Controller.php on line 54 and exactly 1 expected
app\Http\Controllers\ResultController.php
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use illuminate\Support\Facades\Auth;
use Illuminate\Validation\Rule;
use Symfony\Component\HttpFoundation\StreamedResponse;
use App\Http\Controllers\GroupController;
use App\Models\User;
use App\Models\Group;
use App\Models\Result;
class ResultController extends Controller
{
~省略~
public function create($id)
{
$group = Group::findOrFail($id);
$owner = $group->user_id;
$user = Auth::user()->id;
if ($owner != $user) {
return redirect('/');
}
$result = new Result;
return view('results.create', [
'result' => $result,
'group' => $group,
]);
}
~省略~
routes\web.php
<?php
use App\Http\Controllers\ProfileController;
use App\Http\Controllers\ResultController;
use App\Http\Controllers\RankController;
use App\Http\Controllers\GroupController;
use Illuminate\Support\Facades\Route;
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider and all of them will
| be assigned to the "web" middleware group. Make something great!
|
*/
Route::get('/', function () {
return view('welcome');
});
Route::get('/dashboard', [GroupController::class, 'index'])->middleware(['auth', 'verified'])->name('dashboard');
Route::middleware('auth')->group(function () {
Route::get('/profile', [ProfileController::class, 'edit'])->name('profile.edit');
Route::patch('/profile', [ProfileController::class, 'update'])->name('profile.update');
Route::delete('/profile', [ProfileController::class, 'destroy'])->name('profile.destroy');
});
require __DIR__.'/auth.php';
Route::group(['middleware' => ['auth']], function () {
Route::group(['prefix' => 'users/{id}'], function() {
Route::post('store', [GroupController::class, 'store'])->name('groups.store');
Route::delete('destroy', [GroupController::class, 'destroy'])->name('groups.destroy');
});
Route::group(['prefix' => 'groups/{id}'], function() {
Route::get('index', [ResultController::class, 'index'])->name('results.index');
Route::get('create', [ResultController::class, 'create'])->name('results.create');
Route::post('store', [ResultController::class, 'store'])->name('results.store');
Route::delete('destroy', [ResultController::class, 'destroy'])->name('results.destroy');
});
Route::resource('groups', GroupController::class, [ 'only' => ['create', 'show', 'edit', 'update']]);
Route::resource('results', ResultController::class, [ 'only' => ['create', 'show', 'edit', 'update']]);
});
resources\views\results\index.blade.php
~省略~
<button type="button" class="btn btn-primary mt-3" onclick="window.location='{{ route('results.create', $group->id) }}'">出場者登録 </button>
~省略~
resources\views\results\index.blade.phpの
上記ボタンをクリック時に該当のエラーが発生してしまいます。
色々と調べましたが、お手上げ状態です。
簡単なことで解決はできそうなのですが。。。
0