我不知道为什么我得到一张空桌子。过去,它对我有用,但为什么我现在得到这个?我做错了什么?
控制器: AdminServiceController
public function create()
{
return view("admin.service.create");
}
public function store(Request $request)
{
$date = $this->vvalidate($request);
$data['creator'] = auth()->user()->id;
Services::create($data);
}
private function vvalidate($request)
{
$rules = [
'title' => 'required|unique:services',
'description' => 'required|min:100',
];
return $this->validate($request, $rules);
}
型号: Services.php
class Services extends Model
{
use HasFactory;
protected $guarded = [];
}
路由: web.php
Route::prefix('admin')->group(function () {
Route::name('admin.')->group(function () {
Route::middleware('auth')->group(function () {
Route::get('/', function () {
return view('admin');
});
Route::resource('service', 'App\Http\Controllers\AdminServiceController');
});
});
});