/** * Run the database seeds. * * @return void */ public function run() { $users = \Birdwatcher\User::all(); foreach ($users as $name => $birds) { $user = \Birdwatcher\User::where('name', 'like', $name)->first(); foreach ($birds as $birdName) { $bird = \Birdwatcher\Bird::where('name', 'LIKE', $birdName)->first(); $user->birds()->save($bird); } } }
public function getEdit($id = null) { # Get this bird and eager load its tags $bird = \Birdwatcher\Bird::with('rarity_id')->find($id); if (is_null($bird)) { \Session::flash('flash_message', 'bird not found.'); return redirect('\\birds'); } # Get all the possible authors so we can build the authors dropdown in the view $raritiesModel = new \Birdwatcher\Rarity(); $authors_for_dropdown = $authorModel->getAuthorsForDropdown(); return view('birds.edit')->with(['bird' => $bird, 'rarities_for_dropdown' => $rarities_for_dropdown]); }
@stop @section('jumbotron') <br> <h3> Welcome to Birdwatcher, where birdwatchers can share information and feel at home. To get started <a href='/login'>log in</a> or <a href='/register'>register</a>. </h3> <br> @stop @section('content') <div class ="container"> <h3>Log in and start creating a log of the birds you have seen ...</h3><br> <p>Birdwatcher allows you to keep a detailed record of the birds that you have seen and where you have seen them.</p> </div> <?php $birds = \Birdwatcher\Bird::orderBy('id', 'ASC')->get(); $output = ''; if (!$birds->isEmpty()) { foreach ($birds as $bird) { $rarity = \Birdwatcher\Rarity::find($bird->rarity_id); $rarity = $rarity->rarity . ' (' . $rarity->rarity_acronym . ')'; if ($rarity == "Least concern (LC)") { $rarity = '<font color="green">' . $rarity . '</font>'; } elseif ($rarity == "Critically endangered (CR)") { $rarity = '<font color="fuscia">' . $rarity . '</font>'; } elseif ($rarity == "Vulnerable (VU)") { $rarity = '<font color="purple">' . $rarity . '</font>'; } $output = $output . '<div class="col-sm-6 col-md-4">' . '<div class="thumbnail">' . '<img src="' . $bird->image . '">' . '<div class="thumbnail">' . '<h3>' . $bird->name . ' (<i> ' . $bird->scientific_name . ' </i>) </h3>' . '<p><b>IUCN Conservation Status: ' . $rarity . '</b></p>' . '<p>' . 'Description: ' . $bird->description . '</p></div></div></div>'; } echo '<div class="row">' . $output . ' ' . '</div><br><br>';