/**
  * Test samples for all models have been seeded.
  */
 public function testModelSeed()
 {
     $message = 'Haven\'t you forgotten to run artisan migrate and db::seed?';
     $this->assertNotEmpty(Author::all(), $message);
     $this->assertNotEmpty(Comment::all(), $message);
     $this->assertNotEmpty(Post::all(), $message);
     $this->assertNotEmpty(Site::all(), $message);
 }
 /**
  * Test samples for all models have been seeded.
  */
 public function testModelSeed()
 {
     $message = 'Haven\'t you forgotten to run artisan migrate and db::seed?';
     $this->assertNotEmpty(Author::all(), $message);
     $this->assertNotEmpty(Comment::all(), $message);
     $this->assertNotEmpty(Post::all(), $message);
     $this->assertNotEmpty(Site::all(), $message);
     $isAuthenticated = Auth::attempt(['email' => UsersTableSeeder::SAMPLE_LOGIN, 'password' => UsersTableSeeder::SAMPLE_PASSWORD]);
     $this->assertTrue($isAuthenticated);
 }
 public function run()
 {
     if (class_exists('Faker\\Factory')) {
         $faker = Faker\Factory::create();
         $specimens = Specimen::all()->all();
         $museums = Museum::all()->all();
         $authors = Author::all()->all();
         $animalGroups = AnimalGroup::all()->all();
         for ($i = 1; $i <= 500; $i++) {
             Scan::create(['scanId' => $faker->randomNumber(5), 'scanQuality' => $faker->randomElement(['low', 'medium', 'high']), 'fileDirectory' => '//scan' . $faker->randomNumber(2), 'location' => $faker->country, 'scanTime' => $faker->dateTime, 'voltage' => $faker->randomFloat(2, 1, 20), 'voxelSize' => $faker->randomFloat(1, 0, 1) . 'mm', 'imageCount' => $faker->randomNumber(4), 'current' => '120v', 'sequence' => $faker->randomNumber(4), 'specimenId' => $faker->randomElement($specimens)->id, 'museumId' => $faker->randomElement($museums)->id, 'authorId' => $faker->randomElement($authors)->id, 'animalGroupId' => $faker->randomElement($animalGroups)->id]);
         }
     }
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $this->checkParametersEmpty();
     return $this->getResponse(Author::all());
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     return $this->getResponse(Author::all());
 }
// --- BOOKS ---
$app->get('/books', function () use($app) {
    $books = Book::all();
    return view('books.index', ['books' => $books]);
});
$app->get('/books/new', function (Request $request) use($app) {
    $authors = Author::all();
    return view('books.new', ['authors' => $authors, 'request' => $request]);
});
$app->post('/books', function (Request $request) use($app) {
    $this->validate($request, Book::VALIDATION_RULES);
    $new_book = new Book($request->all());
    $new_book->save();
    return redirect('books/' . $new_book->id);
});
$app->get('/books/{id}', function ($id, Request $request) use($app) {
    $book = Book::find($id);
    $authors = Author::all();
    return view('books.edit', ['authors' => $authors, 'request' => $request, 'book' => $book, 'id' => $id]);
});
$app->post('/books/{id}/update', function ($id, Request $request) use($app) {
    $this->validate($request, Book::VALIDATION_RULES);
    $book = Book::find($id);
    $book->update($request->all());
    return redirect('books/' . $book->id);
});
$app->get('authors/{id}/books', function ($id, Request $request) use($app) {
    $author = Author::find($id);
    $books = $author->books->all();
    return view('books.by_author', ['author' => $author, 'request' => $request, 'books' => $books, 'id' => $id]);
});