所以我试图制作一个发布表单ckeditor并将其发布到数据库,然后尝试在同一个视图中显示它,但是在我提交表单后,我在我的数据库表中没有看到任何内容,所以很明显它甚至没有存储到数据库,我的控制器或视图中是否有任何错误?
这是我的 GuestbookController.php
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Guestbook;
class GuestbookController extends Controller
{
public function index()
{
$guestbooks = Guestbook::get();
return view('post.post_textarea',[
'guestbooks' => $guestbooks,
]);
}
public function store(Request $request)
{
Guestbook::create([
'name' => $request->name,
'message' => $request->message
]);
return redirect()->back();
}
}
这是我的路线
Route::get('/posting','GuestbookController@index')->name('guestbook');
Route::post('/posting','GuestbookController@store')->name('guestbook.store');
这是我的模型
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Guestbook extends Model
{
protected $fillable = ['name', 'message'];
}
这是我的观点
<section class="games-single-page">
<div class="container">
@foreach ($guestbooks as $guestbook)
<div class="card">
<div class="card-body">
<label>mike</label>
<h3>{{ $guestbok->name }}</h3>
{!! $guestbook->message !!}
</div>
</div>
@endforeach
<div class="card">
<div class="card-body">
<form action="/posting" method "POST">
<div class="form-group">
<label style="color: black;" >Title</label>
<input type="text" class="form-control" name="name">
</div>
<div class="form-group">
<label style="color: black;" >Your Input</label>
<br>
<textarea class="form-control" name="message" id="" rows="10"></textarea>
</div>
月关宝盒