-1
Good morning programmers , I have a problem passing two variables from one function to another, I think. Below follows the Code
class pdfController extends Controller
{
public function index($id)
{
$service = $this->get_service_data($id);
return view('services.pdf')->with('service',$service);
}
public function get_service_data($id)
{
$service = Service::find($id);
$materials=$service->mats_por_servicos = DB::table('mats_por_servicos as mats_serv')
->join('materials as material','mats_serv.mat_id','=','material.id')
->where('serv_id',$id)
->get();
return [$service,$materials];
}
public function pdf()
{
$pdf =\App::make('dompdf.wrapper');
$pdf->loadHTML($this->convert_service_to_html());
}
public function convert_service_to_html($id)
{
$service = $this->get_service_data($id);
}
}
error:
You are passing an array to your view, but you are trying to access it as if it were an object. Its variable
service
in view will be[$service, $materials]
, then you probably need to doservice[0]
to access the object you want.– Woss