public function testEmailShouldNotBeSent()
 {
     //disable new book email (created eloquent event)
     Book::flushEventListeners();
     factory('App\\Model\\Book', 1)->create(['user_id' => factory(App\Model\User::class)->create()->id, 'taken_at' => new DateTime()]);
     $mock = $this->getMockBuilder('\\Illuminate\\Mail\\Mailer')->disableOriginalConstructor()->getMock();
     $mock->expects($this->never())->method('raw');
     $command = new ReturnBookRemind($mock);
     $command->handle();
 }
 public function showAddBookPage()
 {
     //
     //   \Log::info("in the showAddBookPage method");
     $CategoryName = Book::getCategory();
     $LocationName = Book::getLocations();
     \Log::info($LocationName);
     \Log::info("category name print over");
     return view('book.addbook', ['CategoryName' => $CategoryName, 'LocationName' => $LocationName]);
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $books = Book::with('user')->where('taken_at', '<', date('Y-m-d H:i:s', time() - 2592000))->get();
     /** @var Book[] $books */
     foreach ($books as $book) {
         $this->mailer->raw(sprintf("Hi %s,\nPlease return back %s by %s.\nRegards,\nYour Library", $book->user->first_name, $book->title, $book->author), function ($message) use($book) {
             $message->subject('Reminder');
             $message->from(getenv('EMAIL_FROM'));
             $message->to($book->user->email);
         });
     }
 }
 public static function addToAuthors($AuthorName, $bookId)
 {
     foreach ($AuthorName as $author) {
         if (strlen($author) > 0) {
             $index = Book::getAuthorId($author);
             if ($index < 0) {
                 DB::insert('INSERT INTO authors (AuthorName) ' . ' VALUES (?)', [$author]);
                 $index = DB::getPdo()->lastInsertId();
             }
             Book::addToBookInfoAuthors($bookId, $index);
         }
     }
 }
示例#5
0
文件: Book.php 项目: shafi-/vlibrary
 public static function addToBookInfoAuthors($BookName, $AuthorName)
 {
     \Log::info("in addToBookInfoAuthors method");
     //   \Log::info ($AuthorName);
     $BookId = Book::getBookId($BookName);
     foreach ($AuthorName as $author) {
         if (strlen($author) > 0) {
             //	\Log::info ($author);
             $AuthorId = Book::getAuthorId($author);
             \Log::info("AuthorId");
             \Log::info($AuthorId);
             \Log::info($BookId);
             \Log::info("BookId");
             DB::insert('INSERT INTO bookinfoauthors (BookId, AuthorId) ' . ' VALUES (?, ?)', [$BookId, $AuthorId]);
         }
     }
 }
 public static function getLocations()
 {
     $LocationName = Book::getLocationName();
     //will return an array of objects
     $curUser = Auth::user();
     $userId = $curUser->id;
     $userLocations = Book::getLocationIdFromUserLocations($userId);
     $userLocationId = array();
     for ($i = 0; $i < count($userLocations); $i++) {
         $userLocationId[$i] = $userLocations[$i]->locationId;
     }
     $LocationName2 = array();
     for ($i = 0; $i < count($LocationName); $i++) {
         if (in_array($LocationName[$i]->locationId, $userLocationId)) {
             $temp = array($LocationName[$i]->LocationName, '1');
         } else {
             $temp = array($LocationName[$i]->LocationName, '0');
         }
         $LocationName2[$i] = $temp;
     }
     //     \Log::info($LocationName2);
     //    \Log::info("..........returning complex cat name");
     return $LocationName2;
 }
 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     Book::created(function ($book) {
         $this->dispatch(new SendNewBookEmail($book));
     });
 }
 public function updateUserProfile(Request $request)
 {
     $name = array("alamin");
     $LocationName = $request->input('LocationName', 'LocationName not set');
     $curUser = Auth::user();
     $userId = $curUser->id;
     Book::deleteFromUserLocations($userId);
     Book::addToUserLocations($userId, $LocationName);
     $LocationName = Book::getLocations();
     return view('user.profilePage', ['name' => $name, 'LocationName' => $LocationName]);
     //
 }
 public function showSearchBookPage()
 {
     $CategoryName = Book::getCategory();
     $LocationName = Book::getLocations();
     return view('book.searchbook', ['CategoryName' => $CategoryName, 'LocationName' => $LocationName]);
 }
示例#10
0
    //	\Log::info(Request::input());
    $data = array('value' => 'from post some data returning', 'input' => Request::input());
    // return a JSON response
    return Response::json($data);
});
Route::post('/ajax/postlended', function () {
    $a = Request::input('ownedBookListId');
    $b = Request::input('borrowerId');
    Book::updateBorrowHistoryTable($a, $b);
    \Log::info(Request::input());
    $data = array('value' => 'from post some data returning', 'input' => Request::input());
    // return a JSON response
    return Response::json($data);
});
Route::post('/ajax/postreview', function () {
    // pass back some data, along with the original data, just to prove it was received
    //$CategoryName = $request->input('ownerId', 'CategoryName not set');
    //	\Log::info($CategoryName);
    $a = Request::input('userId');
    $b = Request::input('borrowerId');
    $c = Request::input('point');
    Book::updateReputaionTable($a, $b, $c);
    \Log::info("...........about to log a and b");
    \Log::info($a);
    \Log::info($b);
    \Log::info(Request::input());
    \Log::info("log from ajax over");
    $data = array('value' => 'from post some data returning', 'input' => Request::input());
    // return a JSON response
    return Response::json($data);
});
 private function createWordRef($word)
 {
     if ($word !== null) {
         $wordId = $word->fh;
         $ref['id'] = $wordId;
         $matches = [];
         preg_match("/^(\\d{1,3}?)(\\d{3})(\\d{3})(\\d{5})\$/", $wordId, $matches);
         $ref['bookId'] = (int) $matches[1];
         $ref['bookName'] = Book::findById($ref['bookId'])->nev;
         $ref['chapter'] = (int) $matches[2];
         $ref['verse'] = (int) $matches[3];
         $ref['wordNum'] = (int) $matches[4];
         return $ref;
     } else {
         return null;
     }
 }
示例#12
0
<?php

/**
 * @author: Ali Kenan Yağmur
 * Date: 25.03.2016
 * Time: 16:54
 */
$app->get("/books", function ($request, $response, $args) {
    return \App\Model\Book::all()->toJson();
});
 public function getChapterLength($bookId, $chapter)
 {
     $book = Book::findById($bookId);
     return Response::json(['bookLength' => Book::getBookLength($book->nev), 'chapterLength' => Book::getChapterLength($book->nev, $chapter)]);
 }
示例#14
0
 public function showSearchBookPage()
 {
     $CategoryName = Book::getCategory();
     $LocationName = Book::getLocations();
     //  \Log::info($LocationName);
     //     \Log::info("category name print over");
     return view('book.searchbook', ['CategoryName' => $CategoryName, 'LocationName' => $LocationName]);
     //   return view('book.searchbook');
 }
 /**
  * @param Request $request
  * @param $bookId
  */
 public function unBorrow(Request $request, $bookId)
 {
     $book = Book::find($bookId);
     $book->user()->dissociate();
     $book->taken_at = null;
     $book->save();
     Session::flash('info', 'Successfully');
     return Redirect::to(route('book.index'));
 }