Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #420
    dan
    Participant

    I am trying to store data to a database but I get Array to string conversion error

    public function submit() {
    Post::create([
    ‘title’ => $this -> title,
    ‘description’ => $this -> description,
    ‘price’ => $this -> price,
    ‘file_path’ => $this-> attachment,
    ‘due_date’ => $this -> due_date
    ]);

    }

    #421

    It means of to the data you wanted to store is an array but you specified a string in your migration. Die dump each of the data and see which one is actually an array

    For example

    check if dd($this->attachment) is actually an array

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.