コード例 #1
0
 function autoComplete($term)
 {
     //        DB::table('medication')
     //            ->where('name', 'LIKE', '%'.$term.'%')
     //            ->take(5)->get();
     return Medication::where('name', 'LIKE', '%' . $term . '%')->take(5) - get();
 }
コード例 #2
0
 function saveMedications($name, $quantity)
 {
     $list = ['name' => $name, 'quantity' => $quantity];
     try {
         $medication = Medication::where('name', '=', $name)->firstOrFail();
         $medication->quantity += $quantity;
         $medication->save();
     } catch (\Illuminate\Database\Eloquent\ModelNotFoundException $e) {
         $medication = Medication::firstOrCreate($list);
     }
 }
コード例 #3
0
 /**
  * test for deleting
  *
  * @return void
  */
 public function testDelete()
 {
     Medication::where('name', 'test1')->delete();
     Medication::where('name', 'test2')->delete();
     Medication::where('name', 'test3')->delete();
 }