尝试在laravel 5.2中的Controller存储方法中分配非对象的属性

时间:2018-08-05 17:05:44

标签: laravel-5

我是laravel的新手,请帮助我。.我遇到

错误
  ShowuserController.php第33行中的

ErrorException:   尝试分配非对象的属性“ ipk”

我在控制器中有一种存储方法,并尝试设置诸如波纹管这样的属性

public function store(Request $request){
        $inputs = Input::all();
        $databeasiswa = new Databeasiswa;
        $databeasiswa->id = $inputs['id'];
        $databeasiswa = DB::table('beasiswas')
                        ->join('databeasiswas', 'beasiswas.id', '=', 'databeasiswas.beasiswa_id')
                        ->get();
        $databeasiswa = DB::table('mahasiswas')
                        ->join('databeasiswas', 'mahasiswas.id', '=', 'databeasiswas.mahasiswa_id')
                        ->get();
        $databeasiswa->ipk = $inputs['ipk'];
        $databeasiswa->kelas = $inputs['kelas'];
        $databeasiswa->prestasi = $inputs['prestasi'];
        $databeasiswa->detail_prestasi = $inputs['detail_prestasi'];
        $databeasiswa->organisasi = $inputs['organisasi'];
        $databeasiswa->jabatan = $inputs['jabatan'];
        $databeasiswa->save(); 
        return redirect(url('databeasiswa'));
    }

而且我也在视图中使用 combobox ,例如波纹管

<form action="{{ url('dashboard') }}" method="post" accept-charset="utf-8" role="form"> {{ csrf_field() }}
  <div class="box-body">
      <div class="form-group">
        <label>NIM Mahasiswa</label>
        <input type="text" name="id" class="form-control" placeholder="{{ trans('NIM tanpa titik') }}">
      </div>

      <div class="form-group">
        <label>IPK</label>
        <select name=ipk class="form-control">
        <option value="">Pilih IPK</option>
        <option value="5">> 3,80</option>    
        <option value="4">3,61 - 3,80</option>    
        <option value="3">3,41 - 3,60</option>    
        <option value="2">3,21 - 3,40</option>
        <option value="1">3,00 - 3,20</option>
        </select>
      </div>

0 个答案:

没有答案