コード例 #1
0
 public function run()
 {
     DB::table('loancrops')->delete();
     $collection = [['loan_id' => 1, 'crop_id' => 1, 'market' => 'CropsRUs'], ['loan_id' => 1, 'crop_id' => 2, 'market' => 'CropsRUs'], ['loan_id' => 1, 'crop_id' => 6, 'market' => 'CropsRUs', 'gin_mill' => 'Millers Gin', 'var_harvest' => 0.09, 'rebates' => 0.1], ['loan_id' => 2, 'crop_id' => 1, 'market' => 'Lansing Louisiana'], ['loan_id' => 2, 'crop_id' => 2, 'market' => 'Lansing Louisiana'], ['loan_id' => 2, 'crop_id' => 6, 'market' => 'Lansing Louisiana', 'gin_mill' => 'Millers Gin', 'var_harvest' => 0.09, 'rebates' => 1.2], ['loan_id' => 2, 'crop_id' => 4, 'market' => 'Lansing Louisiana'], ['loan_id' => 2, 'crop_id' => 7, 'market' => 'Lansing Louisiana']];
     foreach ($collection as $record) {
         Loancrop::create($record);
     }
 }
コード例 #2
0
 public function run()
 {
     DB::table('loancrops')->delete();
     $collection = [['loan_id' => 1, 'crop_id' => 1], ['loan_id' => 1, 'crop_id' => 2], ['loan_id' => 1, 'crop_id' => 6, 'var_harvest' => 0.09, 'rebates' => 5], ['loan_id' => 2, 'crop_id' => 1], ['loan_id' => 2, 'crop_id' => 2], ['loan_id' => 2, 'crop_id' => 6, 'var_harvest' => 0.09, 'rebates' => 5], ['loan_id' => 2, 'crop_id' => 4], ['loan_id' => 2, 'crop_id' => 7]];
     foreach ($collection as $record) {
         Loancrop::create($record);
     }
 }
コード例 #3
0
 public function update($id)
 {
     // save updated
     $record = $this->records->find($id);
     if (!$record) {
         Loancrop::create(Input::all());
         return $this->respond($record);
     }
     $record->fill(Input::all())->save();
     return $this->respond($record);
 }