我正在尝试通过按下按钮通过隐藏字段将数据发布到数据库但是我面临的错误是419 Page Expired
这是我的观点:-
<div>
<h1> All Posts </h1>
@if(count($user) > 0)
@foreach($user as $post)
<form action="/f" method="POST">
<input type="hidden" id="friends" name="friends" value="{{$post->id}}" />
<button type="submit" class="btn btn-primary">
{{ __('chat') }}
</button>
</form>
<div class="well">
<a href="/profile/1"<button class="button btn-success">chat</button>></a>
<h3>{{$post->title}}</h3>
<h4>{{$post->body}}</h4>
<small>written on {{$post->created_at}}</small>
</div>
@endforeach
@else
<p>No Forms Found</p>
@endif
</div>
这是我的路线:-
Route::post('/f', 'FriendsController@store');
这是我的控制器:-
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class FriendsController extends Controller
{
public function store(Request $request)
{ dd($request->all());
post::create([
'friends' => $request->friends,
]);
return redirect('/profile/' . auth()->user()->id);
}
}
我可能在我的商店方法中犯了错误请检查并让我知道它有什么问题我只是一个初学者 - 谢谢
白猪掌柜的