Undefined variable in component
P粉709307865
P粉709307865 2023-09-06 10:48:25
0
1
842

My server works in Linux via apache2, but works fine in development environment via artisan service on a Windows machine.

The error isUndefined variable $washProgram

  • resources/views/components/expedition-data.blade.php
<div>
   Programa {{ $washProgram->name }}
</div>
  • app/View/Components/expeditionData.php
<?php

namespace App\View\Components;

use Illuminate\View\Component;

class expeditionData extends Component
{

    public $op;
    public $washProgram;

    /**
     * Create a new component instance.
     *
     * @return void
     */
    public function __construct($op)
    {
        $this->op = $op;
        $this->washProgram = $op->getSelectedWashProgram();
    }

    /**
     * Get the view / contents that represent the component.
     *
     * @return \Illuminate\View\View|string
     */
    public function render()
    {
        return view('components.expedition-data');
    }
}
  • Calling components in Blade
<x-expedition-data :op="$op" />

I want to generate a view using this component but it gives me this error.

P粉709307865
P粉709307865

reply all(1)
P粉384366923

Thank you so much. Linux is case sensitive. The component's file names have been changed so that they all begin with a capital letter:

expeditionData.php -> ExpeditionData.php
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template