title: QLSTATE[22007]: Invalid datetime format: 1366 Incorrect integer value laravel
body: <p>I cannot store the company that my client belongs to. The company is a foreign key and when I click register customer I get an error:</p>
  <blockquote>
  <p>SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect integer value: 'Tim' for column <code>customerlist</code>.<code>customers</code>.<code>company</code> at row 1 (SQL:  insert into <code>customers</code> (<code>company</code>, <code>name</code>, <code>document</code>, <code>phone</code>, <code>email</code>, <code>updated_at</code>, <code>created_at</code>) values (Tim, Felix Botta, 04919407939, +55.41984081085,felix.botta@gmail.com, 2021-02-14 20:55:15, 2021-02-14 20:55:15))</p>
  </blockquote>
  <p>CustomerController</p>
  <pre><code>class CustomersController extends Controller
  {
  public function index(){
      $customers = Customer::get();
      return view('customers.list', ['customers' =&gt; $customers]);
  }
  
  public function new(){
      $companies = Company::orderBy('id', 'desc')-&gt;get();
      return view('customers.form', ['companies' =&gt; $companies]);
  }
  
  public function add( Request $request ){
  
      $customers = new Customer;
      $customers = $customers-&gt;create( $request-&gt;all() );
      
      return Redirect::to('/customers');
  }
  
  public function edit( $id ){
      $customers = Customer::findOrFail( $id );
      return view('customers.form', ['customers' =&gt; $customers]);
  }
  
  public function update( $id, Request $request ){
      $customers = Customer::findOrFail( $id );
      $customers-&gt;update( $request-&gt;all() );
      return Redirect::to('/customers');
  }
  
  public function delete( $id ){
      $customers = Customer::findOrFail( $id );
      $customers-&gt;delete();
      return Redirect::to('/customers');
  }}
  </code></pre>
  <p>form.blade</p>
  <blockquote>
  </blockquote>
  <pre><code>                   &lt;form action=&quot;{{ url('customers/add') }}&quot; method=&quot;post&quot;&gt;
                         @csrf
                      
                      &lt;div class=&quot;form-group&quot;&gt;
                          &lt;label for=&quot;&quot;&gt;Empresa:&lt;/label&gt;
                          &lt;select name=&quot;company&quot; class=&quot;form-control&quot;&gt;
  
                          @foreach($companies as $company)
  
                          &lt;option value=&quot;{{ $company-&gt;name }}&quot;&gt;{{ $company-&gt;name }}&lt;/option&gt;
                          
                          @endforeach
                          &lt;/select&gt;
                          
                      &lt;/div&gt;
  
                       &lt;div class=&quot;form-group&quot;&gt;
                          &lt;label for=&quot;exampleInputEmail1&quot;&gt;Nome:&lt;/label&gt;
                          &lt;input type=&quot;text&quot; name=&quot;name&quot; class=&quot;form-control&quot;&gt;
                      &lt;/div&gt;
  
                      &lt;div class=&quot;form-group&quot;&gt;
                          &lt;label for=&quot;exampleInputEmail1&quot;&gt;CPF /  CNPJ:&lt;/label&gt;
                          &lt;input type=&quot;text&quot; name=&quot;document&quot; class=&quot;form-control&quot;&gt;
                      &lt;/div&gt;
  
                      &lt;div class=&quot;form-group&quot;&gt;
                          &lt;label for=&quot;exampleInputEmail1&quot;&gt;Telefone:&lt;/label&gt;
                          &lt;input type=&quot;text&quot; name=&quot;phone&quot; class=&quot;form-control&quot;&gt;
                      &lt;/div&gt;
  
                      &lt;div class=&quot;form-group&quot;&gt;
                          &lt;label for=&quot;exampleInputEmail1&quot;&gt;E-mail:&lt;/label&gt;
                          &lt;input type=&quot;email&quot; name=&quot;email&quot; class=&quot;form-control&quot; id=&quot;exampleInputEmail1&quot; aria-describedby=&quot;emailHelp&quot;&gt;
                      &lt;/div&gt;
  
                      &lt;button type=&quot;submit&quot; class=&quot;btn btn-primary&quot;&gt;Cadastrar&lt;/button&gt;
                      &lt;/form&gt;
                      @endif
               
              &lt;/div&gt;
  </code></pre>
  <blockquote>
  </blockquote>
  <pre><code>class CreateCustomersTable extends Migration
  {
  /**
   * Run the migrations.
   *
   * @return void
   */
  public function up()
  {
      Schema::create('customers', function (Blueprint $table) {
          $table-&gt;id();
          $table-&gt;string('name', 256);
          $table-&gt;string('document', 256);
          $table-&gt;string('phone', 128);
          $table-&gt;string('email', 128);
          $table-&gt;foreignId('company')-&gt;constrained('companies');
          $table-&gt;timestamps();
      });
  }
  
  /**
   * Reverse the migrations.
   *
   * @return void
   */
  public function down()
  {
      Schema::dropIfExists('customers');
  }}
  </code></pre>