本文整理汇总了PHP中app\models\Author::all方法的典型用法代码示例。如果您正苦于以下问题:PHP Author::all方法的具体用法?PHP Author::all怎么用?PHP Author::all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Author
的用法示例。
在下文中一共展示了Author::all方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testModelSeed
/**
* 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);
}
示例2: testModelSeed
/**
* 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);
}
示例3: run
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]);
}
}
}
示例4: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
$this->checkParametersEmpty();
return $this->getResponse(Author::all());
}
示例5: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
return $this->getResponse(Author::all());
}
示例6: function
// --- 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]);
});