我遇到下拉过滤器在托管后无法工作的问题。这是我的代码
app/Livewire/Matakuliah.php(控制器)
return view('livewire.matakuliah', [
'title' => 'Mata Kuliah',
'matakuliahs' => $matakuliahs,
'jurusans' => Jurusan::all(),
'prodis' => ProgramStudi::where('jurusan_id', $this->jurusan_id)->get(),
]);
资源/视图/livewire/matakuliahModal.blade.php
<div class="form-group mb-3">
<label for="jurusan_id" class="fs_caption4">Jurusan</label>
<select class="form-select @error('jurusan_id') is-invalid @enderror select2-add"
id="jurusan_id" name="jurusan_id" wire:model.live="jurusan_id" style="width: 100%">
<option value="">-Pilih Jurusan-</option>
@if (Auth::user()->role->id == 4)
@foreach ($jurusans as $jurusan)
@if ($jurusan->id == Auth::user()->jurusan_id)
<option value="{{ $jurusan->id }}">{{ $jurusan->nama_jurusan }}</option>
@endif
@endforeach
@else
@foreach ($jurusans as $jurusan)
<option value="{{ $jurusan->id }}">{{ $jurusan->nama_jurusan }}</option>
@endforeach
@endif
</select>
@error('jurusan_id')
<span class="invalid-feedback">{{ $message }}</span>
@enderror
</div>
<div class="form-group">
<label for="program_studi_id" class="fs_caption4">Program Studi</label>
<select class="form-select @error('program_studi_id') is-invalid @enderror select2-add"
id="program_studi_id" name="program_studi_id" wire:model.live="program_studi_id"
style="width: 100%" data-placeholder="-Pilih Program Studi-">
<option value="">-Pilih Program Studi-</option>
@if (Auth::user()->role->id == 4)
@foreach ($prodis as $prodi)
@if ($prodi->id == Auth::user()->program_studi_id)
<option value="{{ $prodi->id }}">{{ $prodi->nama_prodi }}</option>
@endif
@endforeach
@else
@foreach ($prodis as $prodi)
<option value="{{ $prodi->id }}">{{ $prodi->nama_prodi }}</option>
@endforeach
@endif
</select>
@error('program_studi_id')
<span class="invalid-feedback">{{ $message }}</span>
@enderror
</div>
这是托管 Laravel 应用程序后 Program Studi Dropdown 的视图 课程研究下拉列表为空
Program Studi 下拉列表应显示由 Jurusan 过滤的列表。在本地主机中,Program Studi 下拉菜单正在运行
我应该怎么做才能解决这个问题? 非常感谢您的帮助:)
我希望通过 jurusan_id 进行的 Program Studi Dropdown 过滤器将在托管服务器中正常工作
看来您没有充分发挥 Livewire 的潜力,这可能就是原因。
<?php
namespace App\Http\Livewire\Component;
use Livewire\Component;
use App\Models\ProgramStudi;
class YourComponent extends Component
{
public $prodis = [];
public $jurusan_id;
public function updatedJurusanId()
{
$this->prodis = ProgramStudi::where('jurusan_id', $this->jurusan_id)->get();
}
public function updated($key, $value)
{
if ($key === 'jurusan_id')
{
}
}
}