Can’t understand why there is a syntax error – laravel syntax error

I haven’t changed anything to the 1st route. I only added the form submission routes then the error occurred, yet it’s pointing to the first route?

The error points to line 17 with the following, yet I can’t understand why.

syntax error, unexpected token "::", expecting "," or ";"

17> Route::get('/', function () {
      return view('welcome');
    });


// AiFx - This route allows the guests to view the page - //
Route::get('/guests', function () {
    return view('guests');
});

// AiFx - This route allows the completed form to be submitted to DB - this one didnt populate the DB!!??- //
Route::post('/guests', function () {
    $GuestController::create([
        'fname' => request.query->get('fname'),
        'lname' => request.query->get('lname'),
        'id_number' => request.query->get('id_number'),
        'mobile' => request.query->get('mobile'),
        'sqsymptoms' => request.query->get('sqsymptoms'),
        'sqtravel' => request.query->get('sqtravel'),
        'sqcontact' => request.query->get('sqcontact'),
    ])
    public function getRouteKey() {
        return $this->submit;
    }
});

Route::get('/dashboard', function () {
    return view('dashboard');
})->middleware(['auth'])->name('dashboard');

require __DIR__.'/auth.php';

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

You have a missing semicolon.

$GuestController::create([
    'fname' => request.query->get('fname'),
    'lname' => request.query->get('lname'),
    'id_number' => request.query->get('id_number'),
    'mobile' => request.query->get('mobile'),
    'sqsymptoms' => request.query->get('sqsymptoms'),
    'sqtravel' => request.query->get('sqtravel'),
    'sqcontact' => request.query->get('sqcontact'),
]);

Also,
public function getRouteKey() {
    return $this->submit;
}

Is not working within the route, its a function to Override the Route Key name within a model when using Route Model Binding. I dont know what you are trying to achieve, but im pretty sure it does nothing for you here.
Check Docs here


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x