我正在尝试为家庭作业制作专辑。但是,我遇到了一个错误。我正在尝试使用验证,但它不起作用。
我正在使用逐步的 youtube 教程来帮助我制作这张专辑。然而,没有解释这个具体问题。我还阅读了有关验证的 laravel 网站部分。我也没有真正得到任何答案。最后,我在 StackOverflow 上查找了一些类似的问题,但是,我没有得到我想要的答案。
我收到以下错误:“页面未正确重定向”
我的专辑Controller.php:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class albumController extends Controller
{
public function albums(){
return view("albums");
}
public function create(){
return view("create");
}
/* You have to work on the request later. Make sure that when someone logs in, he returns 123 */
public function store(Request $request){
$this->validate($request, [
'naam' => 'required',
'cover_image' => 'image|max:1999'
]);
}
}
我的相册.blade.php:
@extends('layouts.app')
@section('content')
<h1><b>Ons album</b></h1>
<form method="post" action="/store">
@csrf
<div class="form-group">
<label for="exampleInputPassword1">Naam van Album</label>
<input type="text" class="form-control" id="exampleInputName1" placeholder="Naam" name="naam">
</div>
<div class="form-group">
<label for="exampleTextarea">Omschrijving</label>
<textarea class="form-control" id="exampleTextarea" rows="3" name="omschrijving"></textarea>
</div>
<div class="form-group">
<label for="exampleInputFile">Zoek uw bestand</label>
<input type="file" class="form-control-file" id="exampleInputFile" aria-describedby="fileHelp" name="cover_image">
<small id="fileHelp" class="form-text text-muted">Selecteer uw bestand</small>
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
@endsection
我的 web.php:
Route::GET('/index',('PageController@index'));
Auth::routes();
//Zorg ervoor dat auth verplicht is
Route::get('/albums', 'albumController@albums')->name('albums')->middleware('auth');/*Zorgt ervoor dat je ingelogt moet zijn om naar albums te kunnen gaan*/
Auth::routes();
Route::get('/', 'HomeController@index');
Route::get('/home', 'HomeController@index')->name('home');
Auth::routes();
Route::get('/create', 'albumController@create')->name('create');
Route::post('/store', 'albumController@store');
Route::get('/store', 'albumController@store');
希望我已经为您提供了足够的信息来帮助我找到答案。
问候,
Parsa_237