我需要解决此问题,当我按下“记录”按钮时,该程序应使我进入刚注册的用户页面,但出现此错误:
错误:
语法错误,意外的'__data'(T_STRING),期望的','或')'(查看:C:\ xampp \ htdocs \ boxe \ resources \ views \ utenteShow.blade.php)
路线:
Route::post('/registrazione/store','RegistrazioniController@store')->name('registrazione.store');
Route::get('/registrazione/{utente}','RegistrazioniController@show')->name('utente.show');
Run Code Online (Sandbox Code Playgroud)
控制器:
public function store(tabella_utenti $utente)
{
$this->validate (request(),[
'email' => 'required',
'password' => 'required',
'NomeUtente' => 'required'
]);
$utente=tabella_utenti::create(request(['email','password','NomeUtente']));
//comando che gli passa l'id
$utente=tabella_utenti::all();
$utenteId=$utente->id;
return redirect(route('utente.show',compact('utenteId')));
}
public function show(tabella_utenti $utente)
{
return view('utenteShow',compact('utente'));
}
Run Code Online (Sandbox Code Playgroud)
视图:
@extends('layouts.layout)
@section('body')
<h1>Pagina Utente</h1>
@foreach($utente as $value)
Nome:{{$value->NomeUtente}}
@endforeach
@endsection
Run Code Online (Sandbox Code Playgroud)