Too few arguments to function Illuminate \ Database \ Eloquent \ Model :: setAttribute ()

1

I am making a store to my database in this way:

 public function store(DocumentoAutorFormRequest $request)
{
// Se crea un objeto vinculo
$vinculo = new DocumentoAutor;
//EL ORDEN ES EL MAXIMO ORDEN +1
$orden=DB::table('cntrl_autor')->max('orden');
$vinculo->orden = $orden+1;
$vinculo->extra=" ";
//Se crea la relacion
$vinculo->fk_doc = $request->get('fk_doc');
$vinculo->fk_autor = $request->get('fk_autor');
//cuando se inserta, va regresar a esta misma ruta
$ruta = "/cntrl_autor/ligar/".$request->get('id_documento');
//Extra no se como se maneja, pero se coloca como espacio vacio mientras
    Session::flash('flash_message', 'Vinculación Exitosa!');
    $vinculo->save();
    return Redirect::to($ruta);
}

and it throws me the following error:

Too few arguments to function Illuminate\Database\Eloquent\Model::setAttribute(). .. and exactly 2 expected

My request is like this

class DocumentoAutor extends Model
{
protected $table='cntrl_autor';

protected $primaryKey=null;
public $timestamps=false;


protected $fillable =[
    'orden',
    'fk_doc',
    'fk_autor',
    'extra'
]; 

protected $guarded =[

];

the error I get, however the insertion is doing well in the database I would like to know what I'm doing wrong or why that error comes out.

    
asked by Ccin 29.03.2018 в 02:14
source

1 answer

-1

In the part of your request, like the following

class DocumentoAutor extends Model
{
protected $table='cntrl_autor';

protected $primaryKey=null;
public $timestamps=false;


protected $fillable =[
    'orden',
    'fk_doc',
    'fk_autor',
    'extra'
]; 

protected $guarded =[

];

The primaryKey line does not send it as null; there you can be generating the problem

class DocumentoAutor extends Model
{
protected $table='cntrl_autor';

/*protected $primaryKey=null; comenta o quita esta línea*/
public $timestamps=false;


protected $fillable =[
    'orden',
    'fk_doc',
    'fk_autor',
    'extra'
]; 

protected $guarded =[

];

Or declare which order is the primary key

    
answered by 29.03.2018 / 02:28
source