namespace App\Http\Livewire;
use Carbon\Carbon;
use Livewire\Component;
use Illuminate\Support\Facades\DB;
class SkillTrainer extends Component
{
public $skills;
public $selectedSkill;
public $internalTrainers = [];
public $selectedTrainer;
public function render()
{
return view('livewire.skill-trainer', [
//get the skills
'skills' => DB::table('skills')
->whereNull('skills.deleted_at')
->orderBy('skill_name')
->get(),
]);
}
The list of skills shows up correctly in the Skill dropdown, but when I select a give skill nothing happens, even with I have {{ $selectedSkill }} just to see it change.
You have skills as a public property on the Component, and also as data passed to the view; should the public property be the singular skill?
Generally, anything that needs fetching only once (like a list of skills) does not need to be passed using the render method (which will execute the query everytime the component changes); use the mount method to set public state on instance instead.
Okay, looks like I have a series of errors on the console for livewire...
GET http://workbus/livewire/livewire.js?id=25f025805c3c370f7e87 net::ERR_ABORTED 404 (Not Found)
Uncaught ReferenceError: Livewire is not defined
at new:1159
(anonymous) @ new:1159
I have the livewireScripts in my app file like instructed.
Could it be in conflict with other javascript (I read that in some other places)?
I ran the publish command as you recommend and now something crazy happens (a modal of my site pops up?!) when I change the dropdown, but at least I am getting a response... progress!