lundi 18 mars 2019

Why Grammar::parameterize adding new setting row

In laravel 5.7 app I got an error on save adding new setting rows I got error :

Argument 1 passed to Illuminate\Database\Grammar::parameterize() must be of the type array, string given, called in /mnt/_work_sdb8/wwwroot/lar/votes/vendor/laravel/framework/src/Illuminate/Database/Query/Grammars/Grammar.php on line 853

In my app I check if there if row in Setting table by name field, if not create it :

                with(new self)->info( $next_votes_key,'$next_votes_key::' );
                $settings = Settings::getByName($next_votes_key)->first();
                with(new self)->info( $settings,'$settings::' );
                if ($settings === null) {
                    with(new self)->info( "INSIDE",'$::' );
                    $settings       = new Settings();
                    $settings->name = $next_votes_key;
                }
                with(new self)->info( $requestData['votes_' . $next_votes_key],'$requestData[\'votes_\' . $next_votes_key]::' );
                $settings->value      = $requestData['votes_' . $next_votes_key];
                $settings->save();

with(new self)->info that is just wrapper for 
            Debugbar::addMessage($info, $label);

My app/Settings.php model is very simple and have only 2 fillable string fields name and value:

<?php

namespace App;

use App\MyAppModel;
use App\Http\Traits\funcsTrait;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Storage;
use DB;

class Settings extends MyAppModel
{
    protected $table      = 'settings';
    protected $primaryKey = 'id';
    public $timestamps = false;


    protected $fillable = [
        'name',
        'value',
    ];
...

Why error and how to fix it ?

Thanks!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire