缺少[Route:voluntier.submit.get]所需的参数[URI:voluntier / submit / {id}]

问题描述 投票:0回答:1

我目前正在最后一个项目上,但是出现了这个错误,我试图将html上的route操作更改为{{route('voluntier.submit.get')}},但它仍然显示错误。谁能帮我找到解决方案。

非常感谢

VoluntierController.php] >>

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Event;
use App\City;
use App\User;
use App\VoluntierProfile;
use App\Submission;

class VoluntierController extends Controller
{
    public function index()
    {
        $data = Event::select('events.job_desk', 'events.location', 'events.city', 'events.job_description', 'events.fee', 'cities.name as city', 'job_desks.job_desk')
            ->leftJoin('job_desks', 'events.job_desk', 'job_desks.id')
            ->leftJoin('cities', 'events.city', 'cities.id')
            ->get();

        $data_category_liaison = Event::select('events.job_desk')
            ->where('id' , '=', 2)
            ->count();
        // dd($data_category);

        return view('voluntier.index', compact('data', 'data_category_liaison'));
    }

    public function profile()
    {
        return view('voluntier.profile');
    }

    public function createProfile()
    {
        $city = City::all()->where('id', '!=', '0');
        return view('voluntier.profile-edit', compact('city'));
    }

    public function storeProfile(Request $request)
    {
        $profile = new VoluntierProfile();

        $profile->voluntier_id = $request->input('voluntier_id');
        $profile->about = $request->input('tentang');
        $profile->city_id = $request->input('kota');
        $profile->address = $request->input('alamat');
        $profile->latest_education = $request->input('pendidikan_terakhir');

        $profile->save();
    }

    public function submitCreate($id)
    {
        $event = Event::find($id)->first();
        $voluntier = Voluntier::find(Auth::user()->id)->get();
        // dd($voluntier);
        return view('voluntier.submit', compact('data'));
    }

    public function submitStore($id, Request $request)
    {
        $event = Event::find($id);
        $voluntier = Auth::user();
        $submission = new Submission();

        $submission->event_id = $event->id;
        $submission->voluntier_id = $voluntier->id;
        $submission->status_id = $request->input('status');

        $submission->save();

        return redirect('voluntier/dashboard');
    }
}

index.blade.php

@foreach($data as $row)
              <td><a href="{{ route('voluntier.submit.get', $row->id) }}" class="job-item d-block d-md-flex align-items-center  border-bottom fulltime">
                <div class="company-logo blank-logo text-center text-md-left pl-3">
                  <img src="images/company_logo_blank.png" alt="Image" class="img-fluid mx-auto">
                </div>
                <div class="job-details h-100">
                  <div class="p-3 align-self-center">
                    <h3>{{ $row->job_desk }}</h3>
                    <div class="d-block d-lg-flex">
                      <div class="mr-3"><span class="icon-suitcase mr-1"></span>{{ $row->location }}</div>
                      <div class="mr-3"><span class="icon-room mr-1"></span>{{ $row->city }}</div>
                      <div><span class="icon-money mr-1"></span>Rp. {{ $row->fee }}</div>
                    </div>
                  </div>
                </div>
                <!-- <div class="job-category align-self-center">
                  <div class="p-3">
                    <span class="text-info p-2 rounded border border-info">Full Time</span>
                  </div>
                </div>  --> 
              </a></td>

              @endforeach

submit.blade.php

<form action="{{ route('voluntier.submit.post', $event->id) }}" method="post" class="p-5 bg-white">

我的路线web.php

Route::prefix('voluntier')->group(function() {
    Route::get('/login', 'Auth\LoginController@showVoluntierLoginForm')->name('voluntier.login.get');
    Route::post('/login/post', 'Auth\LoginController@voluntierLogin')->name('voluntier.login.post');
    Route::get('/register', 'Auth\RegisterController@showVoluntierRegisterForm')->name('voluntier.register.get');
    Route::post('/register/post', 'Auth\RegisterController@createVoluntier')->name('voluntier.register.post');
    Route::get('/dashboard', 'VoluntierController@index')->middleware('auth:voluntier')->name('voluntier.dashboard');

    Route::get('/profile', 'VoluntierController@profile')->middleware('auth:voluntier')->name('voluntier.get');
    Route::get('/profile/get', 'VoluntierController@createProfile')->middleware('auth:voluntier')->name('voluntier.profile.get');
    Route::post('/profile/post', 'VoluntierController@storeProfile')->name('voluntier.profile.post');
    Route::get('/submit/{id}', 'VoluntierController@submitCreate')->middleware('auth:voluntier')->name('voluntier.submit.get');
    Route::post('submit/post/{id}', 'VoluntierController@submitStore')->name('voluntier.submit.post');
});

我目前正在最后一个项目上,但是出现了这个错误,我试图将html上的route操作更改为{{route('voluntier.submit.get')}},但它仍然显示错误。可以...

php laravel laravel-5.8 laravel-6
1个回答
-1
投票

您必须使用关联数组才能告诉route该信息意味着什么:

© www.soinside.com 2019 - 2024. All rights reserved.