0

I have a problem inserting data into my database and always get the following error.

SQLSTATE[22003]: Numeric value out of range: 1416 Cannot get geometry object from data you send to the GEOMETRY field

I tried to insert data with my Eloquent model using query builder, but it gave me the same error. In the migration file I have:

Schema::create('books', function (Blueprint $table) {
    $table->bigIncrements('id')->autoIncrement()->primary();
    $table->text("name");
    $table->multiLineString("opinion");
    $table->string("post");
    $table->timestamp("date");
});

I've also tried to insert data with this:

$validatedData = $this->validate($request, [
    'name'    => 'required|alpha_dash|max:40|min:3',
    'opinion' => 'required|alpha_dash|max:40|min:3',
]);

$validatedData = Binput::all();

DB::table("books")->insert([
    "name"    => $validatedData["name"],
    "post"    => $url,
    "opinion" => $validatedData["opinion"],
]);
3
  • What is the output of dd($validatedData["opinion"]);? Commented Jul 27, 2019 at 19:05
  • array:3 [▼ "name" => "string" "opinion" => "string" "submit" => "string" ] Commented Jul 27, 2019 at 19:11
  • opinion is string it was "filali" Commented Jul 27, 2019 at 19:27

2 Answers 2

1

I don't know this Binput::all(); came from.

Can you try to delete this line $validatedData = Binput::all();

Should be:

$validatedData = $this->validate($request, [
    'name'    => 'required|alpha_dash|max:40|min:3',
    'opinion' => 'required|alpha_dash|max:40|min:3',
]);

DB::table("books")->insert([
    "name"    => $validatedData["name"],
    "post"    => $url,
    "opinion" => $validatedData["opinion"],
]);
Sign up to request clarification or add additional context in comments.

Comments

0

I solve it by changing the migration instead of string and text i did char and it work

            $table->bigIncrements('id')->autoIncrement()->primary();
            $table->char("name");
            $table->char("opinion");
            $table->char("post");
            $table->timestamps();

when i tried this migration it work thank you all

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.