/** * 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); }); } }
/** * Display a listing of the resource. * * @return Response */ public function index(Request $request) { //pagination doesn't work //@see http://laravel.io/forum/06-18-2015-pagination-always-returns-the-first-page //I spent one hour, but not success so I leave it as is //The issues causes by symfony http request //Illuminate\Http\Request::capture //SymfonyRequest::createFromGlobals()->query //the parameters bag is always empty when requested not root path //e.g. //http://192.168.59.104/book/?page=4 - DOESN'T //http://192.168.59.104/?page=4 - WORKS //I hope that is not a part of home task :) $books = Book::with('user')->where('user_id', $request->user()->id)->paginate(10); return view('book.index', ['books' => $books]); }