嗨,我正在尝试将数据插入 db,但它说:
SQLSTATE [HY000]:常规错误:1364字段'标题'不具有默认值(SQL:插入到
projects(owner_id,updated_at,created_at)的值(1,2019年6月28日13点17分11秒,2019年6月28日13 :17:11))
控制器:
public function store()
{
$attributes = $this->validateProject();
$attributes['owner_id'] = auth()->id();
$project = Project::create($attributes);
//Project::create($attributes);
//Project::create(request(['title', 'description']));
Mail::to($project->owner->email)->send(
new ProjectCreated($project)
);
return redirect('/projects');
}
Run Code Online (Sandbox Code Playgroud)
模型:
protected $guarded = [];
Run Code Online (Sandbox Code Playgroud)
桌子:
Schema::create('projects', function (Blueprint $table) {
$table->increments('id');
$table->unsignedInteger('owner_id');
$table->string('title');
$table->text('description');
$table->timestamps();
$table->foreign('owner_id')->references('id')->on('users')->onDelete('cascade');
});
Run Code Online (Sandbox Code Playgroud)
刀片文件:
<form method="POST" action="/projects">
@csrf
<div class="field">
<label class="label" for="title">Title</label>
<div class="control">
<input type="text" class="input {{ $errors->has('title') ? 'is-danger' …Run Code Online (Sandbox Code Playgroud) 我正在使用用户login_register进行注册,然后将数据插入数据库(也可以登录),但是浏览器显示:
maximum execution time of 30 seconds exceeded
Run Code Online (Sandbox Code Playgroud)
在\ vendor \ phpunit \ phpunit \ appveyor.yml中:它已经是1200
- IF NOT EXIST php-installed.txt echo max_execution_time=1200 >> php.ini
Run Code Online (Sandbox Code Playgroud)
当我注册时,数据已提交到数据库,但显示此https://ibb.co/YLv6N5g 解决此问题的任何解决方案
我是 Laravel 的新手,并试图将产品从管理面板添加到索引页面,首先它运行良好,但现在显示错误SQLSTATE[HY000]: General error: 1364 Field 'care' doesn't have a default value,是否有解决此问题的方法?
SQLSTATE[HY000]: General error: 1364 Field 'care' doesn't have a
default value (SQL: insert into `products` (`product_name`,
`product_code`, `product_color`, `description`, `price`, `image`,
`updated_at`, `created_at`) values (Filter, ASD111, CLR, ASDF, 1000,
85525.png, 2019-01-10 17:18:33, 2019-01-10 17:18:33))
Run Code Online (Sandbox Code Playgroud)
这是 ProductsController:
public function addProduct(Request $request){
if($request->isMethod('post')){
$data = $request->all();
//echo "<pre>"; print_r($data); die;
$product = new Product;
$product->product_name = $data['product_name'];
$product->product_code = $data['product_code'];
$product->product_color = $data['product_color'];
if(!empty($data['description'])){
$product->description = $data['description']; …Run Code Online (Sandbox Code Playgroud) 当管理员登录时,他将重定向到仪表板页面,但通过单击其主按钮(如主页按钮)显示错误,我<a href="{{route('dashboard')}}">在其中添加了以下代码:
路线[仪表板]未定义
这是我的路线:
Route::get('/admin/dashboard','AdminController@dashboard');
Run Code Online (Sandbox Code Playgroud)
解决此问题的任何解决方案