/** * @return Response */ public function index() { Animal::truncate(); $animals = Import::all(); $breeds = Breed::where('species', '=', 'Dog')->orderBy('name')->lists('name', 'id'); $stati = \Config::get('rescue.status'); $no_breed = \Config::get('rescue.select_breed_id'); foreach ($animals as $animal) { $pri_breed_id = array_search($animal->pri_breed, $breeds); if (FALSE != $pri_breed_id) { $sec_breed_id = array_search($animal->sec_breed, $breeds); if (FALSE == $sec_breed_id) { $sec_breed_id = $no_breed; } $status = array_search($animal->status, $stati); if (FALSE == $status) { $status = 0; } Animal::create(array('id' => $animal, 'name' => $animal->name, 'species' => $animal->species, 'pri_breed_id' => $pri_breed_id, 'sec_breed_id' => $sec_breed_id, 'mixed_breed' => $animal->mix == '1' ? TRUE : FALSE, 'date_of_birth' => $animal->date_of_birth, 'gender' => $animal->gender, 'altered' => $animal->altered == 1 ? TRUE : FALSE, 'intake_date' => $animal->intake_date, 'status_id' => $status, 'status_date' => $animal->status_date, 'foster' => $animal->foster, 'picture' => $animal->picture, 'description' => $animal->description)); } } return '<h2>Import Complete: ' . Animal::Count() . ' Records Imported</h2>'; }
/** * Get breed ids of products based from breed filter value * * @param String $breedParameter * @return Array */ private function getBreedIds($breedParameter) { $tempBreedIds = []; foreach (explode(' ', $breedParameter) as $breedName) { if ($breedName == 'crossbreed') { // Get all breed ids that contain '+' in their breed name $crossbreeds = Breed::where('name', 'like', '%+%')->get(); foreach ($crossbreeds as $crossbreed) { array_push($tempBreedIds, $crossbreed->id); } continue; } else { $breedInstance = Breed::where('name', $breedName)->get()->first()->id; } array_push($tempBreedIds, $breedInstance); } return $tempBreedIds; }
/** * GET /breed * Display a listing of the resource. * * @return Response */ public function index() { $breeds = Breed::where('species', '=', 'Dog')->paginate(15); return View::make('pages.breed.index', compact('breeds')); }