🎉 Acceso anticipado Black Friday: Hasta un 80% de descuento en nuestros cursos

6d: 18h: 23m:2s'
José Manuel Muñoz
José Manuel Muñoz
PHP
Comparte:

TENGO UN ERROR en el query builder a dar guardar en curso de BLOG. AYUDA

Array to string conversion

C:\laragon\www\makenko\vendor\laravel\framework\src\Illuminate\Support\Str.php#449
ErrorException
        $result = array_shift($segments);

        foreach ($segments as $segment) {
            $result .= (array_shift($replace) ?? $search).$segment;
        }

        return $result;



#0 C:\laragon\www\makenko\vendor\laravel\framework\src\Illuminate\Support\Str.php(449): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(8, 'Array to string...', 'C:\\laragon\\www\\...', 449, Array)

#1 C:\laragon\www\makenko\vendor\laravel\framework\src\Illuminate\Database\QueryException.php(57): Illuminate\Support\Str::replaceArray('?', Array, 'insert into `po...')

#2 C:\laragon\www\makenko\vendor\laravel\framework\src\Illuminate\Database\QueryException.php(40): Illuminate\Database\QueryException->formatMessage('insert into `po...', Array, Object(PDOException))

#3 C:\laragon\www\makenko\vendor\laravel\framework\src\Illuminate\Database\Connection.php(672): Illuminate\Database\QueryException->__construct('insert into `po...', Array, Object(PDOException))

#4 C:\laragon\www\makenko\vendor\laravel\framework\src\Illuminate\Database\Connection.php(631): Illuminate\Database\Connection->runQueryCallback('insert into `po...', Array, Object(Closure))

#5 C:\laragon\www\makenko\vendor\laravel\framework\src\Illuminate\Database\Connection.php(465): Illuminate\Database\Connection->run('insert into `po...', Array, Object(Closure))

#6 C:\laragon\www\makenko\vendor\laravel\framework\src\Illuminate\Database\Connection.php(417): Illuminate\Database\Connection->statement('insert into `po...', Array)

#7 C:\laragon\www\makenko\vendor\laravel\framework\src\Illuminate\Database\Query\Processors\Processor.php(32): Illuminate\Database\Connection->insert('insert into `po...', Array)

#8 C:\laragon\www\makenko\vendor\laravel\framework\src\Illuminate\Database\Query\Builder.php(2771): Illuminate\Database\Query\Processors\Processor->processInsertGetId(Object(Illuminate\Database\Query\Builder), 'insert into `po...', Array, 'id')

#9 C:\laragon\www\makenko\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Builder.php(1403): Illuminate\Database\Query\Builder->insertGetId(Array, 'id')

#10 C:\laragon\www\makenko\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.php(900): Illuminate\Database\Eloquent\Builder->__call('insertGetId', Array)

#11 C:\laragon\www\makenko\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.php(865): Illuminate\Database\Eloquent\Model->insertAndSetId(Object(Illuminate\Database\Eloquent\Builder), Array)

#12 C:\laragon\www\makenko\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.php(728): Illuminate\Database\Eloquent\Model->performInsert(Object(Illuminate\Database\Eloquent\Builder))

#13 C:\laragon\www\makenko\app\Http\Controllers\Admin\PostsController.php(39): Illuminate\Database\Eloquent\Model->save()
José Manuel Muñoz
José Manuel Muñoz (1114 xp)
Anteriormente guardaba bien hize un migration:refresh -- seeds y ya no me funciona el metodo save() alquien sabe que podria ser?

José Manuel Muñoz
José Manuel Muñoz (1114 xp)
public function store(SavePostRequest $request)
    {
      $post = new Post($request->validated());
      $post->published_at = $request->filled('published_at') ? Carbon::parse($request->get('published_at')) : null;    
      $post->save();

      //Guardamos la relacion N a N de las eiquetas con los posts
      $post->tags()->attach($request->get('tags'));

      return redirect()->route('posts.index')->with('status', 'La publicacion fue guardada con exito');