error PHP-LARAVEL Undefined variable:

3

I'm doing a project in laravel. But he throws me the next mistake.

In my controller I have this:

public function edit($id)
{
    $lanifComercial = new PlanifComercial();
    $lanifComercial->LABORATORIO = 'LABORATORIO';
   return view('Planif_Comercial.Edit',$lanifComercial);
}

and in my view I have this:

but I get the following error:

  

(2/2) ErrorException Undefined variable: lanifComercial (View:   C: \ xampp \ htdocs \ interface-load-soap \ resources \ views \ Planif_Comercial \ Edit.blade.php)

I already appreciate your answers.

Greetings.

    
asked by Carlos 31.07.2017 в 22:48
source

1 answer

2

Use an array or a compact to pass the data to view:

return view('mi-vista', compact('lanifComercial');

The array:

return view('mi-vista', ['lanifComercial' => $lanifComercial] 
    
answered by 31.07.2017 / 23:11
source