mardi 23 octobre 2018

Unable to Explode HTTP Request

I have an input in which I intend to write image tags in the following way:

Tag1, Tag2, Tag3

Then create an array which I can loop through by using the explode() PHP function like this:

$tagsRaw = $request['artwork-tags'];
$tags = explode(',', $tagsRaw);

foreach($tags as $tag) {
    $tag = new Tag();
    $tag->name = $tag;
    $tag->save();

    $image->tags()->attach($tag);
}

Sadly I'm getting this error:

Type error: Argument 1 passed to Illuminate\Database\Grammar::parameterize() must be of the type array, string given, called in C:\MAMP\htdocs\Art\vendor\laravel\framework\src\Illuminate\Database\Query\Grammars\Grammar.php on line 681 ◀

I assume that I'm trying to explode() something which can't be exploded and that I'm not passing a string to explode().



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire