QLSTATE [22007]:无效的日期时间格式:1366不正确的整数值laravel

博塔

我无法存储我的客户所属的公司。该公司是外键,当我单击注册客户时出现错误:

SQLSTATE [22007]:无效的日期时间格式:1366不正确的整数值:列的“ Tim” customerlistcustomerscompany在第1行(SQL:INSERT INTO customerscompanynamedocumentphoneemailupdated_atcreated_at)的值(添费利克斯波塔,04919407939,+ 55.41984081085,felix.botta @ gmail.com,2021年2月14日20时55分十五秒,2021-02 -14 20:55:15))

客户控制器

class CustomersController extends Controller
{
public function index(){
    $customers = Customer::get();
    return view('customers.list', ['customers' => $customers]);
}

public function new(){
    $companies = Company::orderBy('id', 'desc')->get();
    return view('customers.form', ['companies' => $companies]);
}

public function add( Request $request ){

    $customers = new Customer;
    $customers = $customers->create( $request->all() );
    
    return Redirect::to('/customers');
}

public function edit( $id ){
    $customers = Customer::findOrFail( $id );
    return view('customers.form', ['customers' => $customers]);
}

public function update( $id, Request $request ){
    $customers = Customer::findOrFail( $id );
    $customers->update( $request->all() );
    return Redirect::to('/customers');
}

public function delete( $id ){
    $customers = Customer::findOrFail( $id );
    $customers->delete();
    return Redirect::to('/customers');
}}

刀片

                   <form action="{{ url('customers/add') }}" method="post">
                       @csrf
                    
                    <div class="form-group">
                        <label for="">Empresa:</label>
                        <select name="company" class="form-control">

                        @foreach($companies as $company)

                        <option value="{{ $company->name }}">{{ $company->name }}</option>
                        
                        @endforeach
                        </select>
                        
                    </div>

                     <div class="form-group">
                        <label for="exampleInputEmail1">Nome:</label>
                        <input type="text" name="name" class="form-control">
                    </div>

                    <div class="form-group">
                        <label for="exampleInputEmail1">CPF /  CNPJ:</label>
                        <input type="text" name="document" class="form-control">
                    </div>

                    <div class="form-group">
                        <label for="exampleInputEmail1">Telefone:</label>
                        <input type="text" name="phone" class="form-control">
                    </div>

                    <div class="form-group">
                        <label for="exampleInputEmail1">E-mail:</label>
                        <input type="email" name="email" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp">
                    </div>

                    <button type="submit" class="btn btn-primary">Cadastrar</button>
                    </form>
                    @endif
             
            </div>
class CreateCustomersTable extends Migration
{
/**
 * Run the migrations.
 *
 * @return void
 */
public function up()
{
    Schema::create('customers', function (Blueprint $table) {
        $table->id();
        $table->string('name', 256);
        $table->string('document', 256);
        $table->string('phone', 128);
        $table->string('email', 128);
        $table->foreignId('company')->constrained('companies');
        $table->timestamps();
    });
}

/**
 * Reverse the migrations.
 *
 * @return void
 */
public function down()
{
    Schema::dropIfExists('customers');
}}
哈里德·朱奈德(M Khalid Junaid)

根据迁移的company列是整数,外键指向公司表,并根据错误你逝去的字符串值Timcompany列。因此,在刀片视图中进行更改

<option value="{{ $company->name }}">{{ $company->name }}</option>

<option value="{{ $company->id }}">{{ $company->name }}</option>

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

SQLSTATE [22007]:无效的日期时间格式:1366不正确的整数值:

SQLSTATE[22007]:无效的日期时间格式:1366 不正确的整数值:Laravel 和 Angular 中列 `myapp`.`employees`.`state_id` 的“null”

laravel 5.7如何解决“无效的日期时间格式:1366不正确的整数值:”错误?

Laravel - SQLSTATE[22007]:无效的日期时间格式:1292 不正确的日期时间值:'1616818311712'

QLSTATE[HY093]: 无效的参数号:未定义参数

Laravel日期时间格式无效:1366错误的整数值:

SQLSTATE[22007]:无效的日期时间格式:1292 不正确的日期时间值

1366不正确的整数值:Laravel 4

SQLSTATE [22007]:无效的日期时间格式:1366错误的整数值:第1行的列'infraction_id'的'[“ 1”,“ 3”,“ 66”,“ 68”]'

一般错误:1366 不正确的整数值

无效的日期时间格式:1366错误的整数值:行“ food_item”列的“ chapati”

不正确的日期格式,带时间

laravel时间遇到一个格式不正确的数值

错误代码:1366。不正确的整数值:第21行的“长度”列的“#N / A”

错误1366(HY000):第1行的'id'列的整数值不正确''

MySql 5.7:一般错误:1366 TinyInt(1)字段的整数值不正确:''

连接失败:SQLSTATE [HY000]:常规错误:1366不正确的整数值

一般错误:1366 不正确的整数值(查询异常)

python mysql脚本:数据错误:(1366,“不正确的整数值:

Symfony-无效的日期时间格式:1292 不正确的日期时间值:'' 列'timestamp' 在第 1 行

在laravel 5.5中遇到的格式不正确的数值

PHPExcel Laravel上遇到的格式不正确的数值

Laravel 中遇到的格式不正确的数值

SQLSTATE [22007]:无效的日期时间格式:1366错误的字符串值,html_entity_decode函数

“ SQLSTATE [HY000]:常规错误:1366不正确的整数值:Laravel第1行的'employee_type_id'列的'Select Employee Type'

日期时间在MySQL中格式不正确

日期和时间格式在iOS上显示不正确

时间计算器的日期格式不正确

不正确的整数值mySQL