本文整理汇总了PHP中app\Book::author方法的典型用法代码示例。如果您正苦于以下问题:PHP Book::author方法的具体用法?PHP Book::author怎么用?PHP Book::author使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Book
的用法示例。
在下文中一共展示了Book::author方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: foreach
function getExample7()
{
/*$book = new Book();
$results = $book->where('published', '>', 1950)->get();
foreach($results as $result)
{
echo $result->title.'<br/>';
}
echo 'Number found is '.count($results).'<br/>';
return 'example7';*/
$author = new \App\Author();
$author->first_name = 'J.K';
$author->last_name = 'Rowling';
$author->bio_url = 'https://en.wikipedia.org/wiki/J._K._Rowling';
$author->birth_year = '1965';
$author->save();
dump($author->toArray());
$book = new \App\Book();
$book->title = "Harry Potter and the Philosopher's Stone";
$book->published = 1997;
$book->cover = 'http://prodimage.images-bn.com/pimages/9781582348254_p0_v1_s118x184.jpg';
$book->purchase_link = 'http://www.barnesandnoble.com/w/harrius-potter-et-philosophi-lapis-j-k-rowling/1102662272?ean=9781582348254';
$book->author()->associate($author);
# <--- Associate the author with this book
$book->save();
dump($book->toArray());
return 'Example 7';
}