本文整理汇总了PHP中app\Book::where方法的典型用法代码示例。如果您正苦于以下问题:PHP Book::where方法的具体用法?PHP Book::where怎么用?PHP Book::where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Book
的用法示例。
在下文中一共展示了Book::where方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getIndex
/**
* Responds to requests to GET /books
*/
public function getIndex(Request $request)
{
// Get all the books "owned" by the current logged in users
// Sort in descending order by id
$books = \App\Book::where('user_id', '=', \Auth::id())->orderBy('id', 'DESC')->get();
return view('books.index')->with('books', $books);
}
示例2: borrow2
public function borrow2()
{
//$user = user::where('email', '=', Input::get('bemail'))->firstOrFail();
$returnData = "";
$name = Input::get("name");
$email = Input::get("email");
if (Request::ajax()) {
$userCount = User::where('email', '=', Input::get('email'))->count();
$bookCount = Book::where('barcode', '=', Input::get('barcode'))->count();
if ($userCount == 1) {
$returnData = $returnData . " user existed ";
$user = User::where('email', '=', Input::get('email'))->find(1);
}
if ($userCount == 0) {
$name = Input::get("name");
$email = Input::get("email");
$user = user::create(array('email' => $email, 'name' => $name));
$returnData = $returnData . " user is created ";
}
if ($bookCount == 1) {
$returnData = $returnData . " book existed ";
$book = Book::where('barcode', '=', Input::get('barcode'))->find(1);
}
if ($bookCount == 0) {
$title = Input::get('title');
$author = Input::get('author');
$barcode = Input::get('barcode');
$book = book::create(array('title' => $title, 'author' => $author, 'barcode' => $barcode));
$returnData = $returnData . " book is created ";
}
$borrow = Borrow::create(array('user_id' => $user->id, 'book_id' => $book->id));
$returnData = $returnData . " borrowing is successful user id =" . $user->id . " book id =" . $book->id;
}
return $returnData;
}
示例3: schoolClicked
public function schoolClicked($id)
{
$schools = School::all();
$programs = Program::where('school_id', '=', $id)->get();
$books = Book::where('school_id', '=', $id)->get();
return view('home')->with('programs', $programs)->with('schools', $schools);
}
示例4: book
public function book($id)
{
$settings = Setting::first();
$books = Book::get();
$currentbook = Book::where('id', $id)->firstOrFail();
return view('front.book', ['books' => $books, 'settings' => $settings, 'currentbook' => $currentbook]);
}
示例5: deleteAllWithBookType
public function deleteAllWithBookType($book_type_id)
{
// Get All Books
$books = Book::where('book_type_id', $book_type_id)->delete();
// Passing data to response service
return $this->responseService->returnMessage($books, 'No Books were Found.');
}
示例6: bookCheckedOutByUser
/**
* @Given 書籍 :bookName 已被 :username 借出
*/
public function bookCheckedOutByUser($bookName, $username)
{
$book = Book::where('name', $bookName)->first();
$user = User::where('username', $username)->first();
$book->available = false;
$book->save();
factory(CheckoutHistory::class)->create(['book_id' => $book->id, 'user_id' => $user->id]);
}
示例7: foreach
function getExample10()
{
$book = \App\Book::where('title', '=', 'The Great Gatsby')->first();
echo $book->title . ' is tagged with : ';
foreach ($book->tags as $tag) {
echo $tag->name . ' ';
}
}
示例8:
function getExample7()
{
$book = \App\Book::where('author', 'LIKE', '%Scott%')->first();
if ($book) {
return $book->title;
} else {
return 'Book not found.';
}
}
示例9: run
/**
* Treat this method as a controller action.
* Return view() or other content to display.
*/
public function run()
{
//
$listItem = Book::where('cate_id', '=', $this->config['id'])->orderBy(DB::raw('RAND()'))->take($this->config['count'])->get();
// return view("widgets.featured_books", [
// 'config' => $this->config,
// 'featuredItem' => $featuredItem
// ]);
return view("widgets.samecategory_books", compact('listItem'));
}
示例10: create
public function create()
{
if (Auth::check()) {
$user = Auth::user();
$count = Book::where('user_id', '=', $user->id)->count();
$mybooks = Book::where('user_id', '=', $user->id)->orderBy('updated_at', 'desc')->take(10)->get();
return view('sell')->with('mybooks', $mybooks)->with('count', $count);
} else {
return redirect()->route('getLogin');
}
}
示例11: Book
function getExample5()
{
//DELETE
$book = new Book();
$harry_potter = Book::where('author', '=', 'J.K.Rowling')->first();
if ($harry_potter != null) {
$harry_potter->delete();
echo 'deleted Harry Potter';
}
return 'example5';
}
示例12: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$books = ['The Great Gatsby' => ['1'], 'A Fire in the Deep' => ['5'], 'Deepness in the Sky' => ['10']];
foreach ($books as $title => $rating) {
$book = \App\Book::where('title', 'like', $title)->first();
foreach ($rating as $ratingName) {
$rating = \App\Rating::where('rating', 'LIKE', $ratingName)->first();
$book->ratings()->save($rating);
}
}
}
示例13: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$books = ['The Great Gatsby' => ['novel', 'fiction', 'classic', 'wealth'], 'The Bell Jar' => ['novel', 'fiction', 'classic', 'women'], 'I Know Why the Caged Bird Sings' => ['autobiography', 'nonfiction', 'classic', 'women']];
foreach ($books as $title => $tags) {
$book = \App\Book::where('title', 'like', $title)->first();
foreach ($tags as $tagName) {
$tag = \App\Tag::where('name', 'LIKE', $tagName)->first();
$book->tags()->save($tag);
}
}
}
示例14: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$books = ['1.mp4' => ['mysql', 'security', 'php', 'model'], '2.mp4' => ['mysql', 'security', 'php', 'controller'], '3.mp4' => ['ui', 'nonfiction', 'js', 'view'], '4.mp4' => ['mysql', 'ui', 'html', 'css']];
foreach ($books as $title => $tags) {
$book = \App\Book::where('title', 'like', $title)->first();
foreach ($tags as $tagName) {
$tag = \App\Tag::where('name', 'LIKE', $tagName)->first();
$book->tags()->save($tag);
}
}
}
示例15: search
public function search(Request $request)
{
if (strlen($request->search) >= 1) {
$books = Book::where('book_title', 'like', "%{$request->search}%")->paginate(3);
if ($books->total() > 1) {
Flash::success('Result');
} else {
Flash::success('Not Found');
}
} else {
$books = Book::where('book_title', 'like', "%aaaaaaaaaaaaaaaaaaaa%")->paginate(3);
}
return view('home', compact('books'));
}