/** * @param Companionship $companionship * @param Family $family * @param Elder $elder * @param $id * @return $this */ public function edit(Companionship $companionship, Family $family, Elder $elder, $id) { $companionship = $companionship->getCompanionship($id); $families = $family->getFamilies(); $elders = $elder->getElders(); return view('companionships.edit')->with(compact('companionship', 'families', 'elders')); }
/** * @param $comp */ private function addCompanionship($comp) { $seniorName = $this->nameFlip($comp['HT 1']); $juniorName = $this->nameFlip($comp['HT 2']); $senior = $this->elder->where('name', $seniorName)->first(); $junior = $this->elder->where('name', $juniorName)->first(); $junior_id = $junior instanceof Elder ? $junior->id : null; $this->companionship->create(['senior' => $senior->id, 'junior' => $junior_id, 'district' => $comp['District']]); }
/** * Execute the console command. * * @return mixed */ public function handle() { // Setup the things that can't be setup in the constructor (??) $this->setup('csv.elders_csv_path'); // Only static constructors. Fine, fine. $elders = Reader::createFromPath($this->path); $elders = $elders->fetchAssoc(); $count = 0; foreach ($elders as $row) { $this->elder->create(['name' => $this->nameFlip($row['NAME']), 'priesthood' => $row['PRIESTHOOD'], 'endowed' => $row['ENDOWED'] === 'Yes' ? true : false, 'age' => intval($row['AGE']), 'birth_date' => Carbon::createFromFormat('j M Y', $row['BIRTH DATE']), 'phone' => $row['PHONE NUMBER'], 'email' => $row['E-MAIL']]); $count++; } $this->info('All done. ' . $count . ' records were imported into the database.'); }
/** * @param Elder $elder * @param $id */ public function destroy(Elder $elder, $id) { $elder->destroy($id); }