我在此代码上遇到“试图获取非对象属性”的问题。请有人检查此代码以使我清楚。 TQ
index.blade.php
<div class="form-group">
<label for="idUnit" class="control-label col-sm-3">Unit :</label>
<div class="col-sm-9">
<select name="idUnit" class="form-control input-sm" id="idUnit" disabled="disabled">
<option value="">Sila Pilih...</option> ---> error on this code!
@foreach ($KodUnit as $unit)
<option value="{{ $unit->id }}"
@if(isset(request()->idUnit) && request()->idUnit == $unit->id)
selected="selected"
@endif
>{{ $unit->nama }}</option>
@endforeach
</select>
</div>
</div>```
kodUnit model:
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class KodUnit extends Model
{
protected $table = 'kod_unit';
protected $primaryKey = 'id';
protected $fillable = ['id', 'kod', 'nama'];
public $timestamps = false;
}