/** * */ public function update(Request $request, $id) { $entry = Entry::find($id); $data = array_filter(array_diff_assoc($request->except(['restoration_type_id', 'folders']), $entry->toArray()), 'removeFalseKeepZero'); $entry->update($data); $restorationType = RestorationType::find($request->get('restoration_type_id')); $entry->restorationType()->associate($restorationType); $entry->save(); $entry->folders()->sync($request->get('folder_ids')); return $this->responseOk($entry); }
public function run() { RestorationType::truncate(); RestorationType::create(['name' => 'crown/onlay']); RestorationType::create(['name' => 'occlusal']); RestorationType::create(['name' => 'veneer']); RestorationType::create(['name' => 'implant']); RestorationType::create(['name' => 'composite bridge']); RestorationType::create(['name' => 'maryland bridge']); RestorationType::create(['name' => 'root canal therapy']); RestorationType::create(['name' => 'chip repair']); RestorationType::create(['name' => 'incisal']); }
public function run() { $this->faker = Faker::create(); Entry::truncate(); DB::table('entry_folder')->truncate(); foreach (range(0, 20) as $index) { $originalRestorationDate = $this->faker->dateTimeBetween('-10 years', '-2 years')->format('Y-m-d'); $lastPhotoDate = $this->faker->dateTimeBetween('-2 years', 'now')->format('Y-m-d'); $restorationAge = Carbon::createFromFormat('Y-m-d', $lastPhotoDate)->diffInMonths(Carbon::createFromFormat('Y-m-d', $originalRestorationDate)) / 12; $restorationAge = round($restorationAge * 2) / 2; $entry = new Entry(['first_name' => $this->faker->firstName, 'last_name' => $this->faker->lastName, 'tooth_number' => $this->faker->numberBetween(1, 6), 'original_restoration_date' => $originalRestorationDate, 'last_photo_date' => $lastPhotoDate, 'restoration_age' => $restorationAge, 'note' => $this->faker->sentence()]); $restorationTypeIds = RestorationType::lists('id')->all(); $restorationTypeId = $this->faker->randomElement($restorationTypeIds); $restorationType = RestorationType::find($restorationTypeId); $entry->restorationType()->associate($restorationType); $entry->save(); $folderCount = $this->faker->numberBetween(1, 2); $folder_ids = $this->faker->randomElements(Folder::lists('id')->all(), $folderCount); foreach ($folder_ids as $folder_id) { $entry->folders()->attach($folder_id); } } }
public function index() { return RestorationType::get(); }
public function home() { // return $this->entriesRepository->getEntries(); JavaScript::put(['env' => app()->env, 'restorationTypes' => RestorationType::get(), 'folders' => Folder::get(), 'entries' => $this->entriesRepository->getEntries()]); return view('home'); }