本文整理匯總了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';
}