[8] ErrorException in Chapters.php line 24

Trying to get property 'book' of non-object

  1. class Chapters extends Base
  2. {
  3. public function index($id)
  4. {
  5. $chapter = Chapter::with(['photos' => function ($query) {
  6. $query->order('pic_order');
  7. }], 'book')->cache('chapter:' . $id, 600, 'redis')->find($id);
  8. $flag = true;
  9. if ($chapter->book->start_pay >= 0) {
  10. if ($chapter->chapter_order >= $chapter->book->start_pay) { //如果本章序大于起始付费章节,则是付费章节
  11. $flag = false;
  12. }
  13. } else { //如果是倒序付费设置
  14. $abs = abs($chapter->book->start_pay) - 1; //取得倒序的绝对值,比如-2,则是倒数第2章开始付费
  15. $max_chapter_order = cache('max_chapter_order:' . $chapter->book_id);
  16. if (!$max_chapter_order) {
  17. $max_chapter_order = Db::query("SELECT MAX(chapter_order) as max FROM " . $this->prefix . "chapter WHERE book_id=:id",
  18. ['id' => $chapter->book_id])[0]['max'];

Call Stack

  1. in Chapters.php line 24
  2. at Error::appError(8, 'Trying to get proper...', '/www/wwwroot/main.co...', 24, ['id' => '22616', 'chapter' => null, 'flag' => true]) in Chapters.php line 24
  3. at Chapters->index('22616')
  4. at ReflectionMethod->invokeArgs(object(Chapters), ['22616']) in Container.php line 395
  5. at Container->invokeReflectMethod(object(Chapters), object(ReflectionMethod), ['id' => '22616', 'convert' => false]) in Module.php line 132
  6. at Module->think\route\dispatch\{closure}(object(Request), object(Closure), null)
  7. at call_user_func_array(object(Closure), [object(Request), object(Closure), null]) in Middleware.php line 185
  8. at Middleware->think\{closure}(object(Request))
  9. at call_user_func(object(Closure), object(Request)) in Middleware.php line 130
  10. at Middleware->dispatch(object(Request), 'controller') in Module.php line 137
  11. at Module->exec() in Dispatch.php line 168
  12. at Dispatch->run() in App.php line 432
  13. at App->think\{closure}(object(Request), object(Closure), null)
  14. at call_user_func_array(object(Closure), [object(Request), object(Closure), null]) in Middleware.php line 185
  15. at Middleware->think\{closure}(object(Request))
  16. at call_user_func(object(Closure), object(Request)) in Middleware.php line 130
  17. at Middleware->dispatch(object(Request)) in App.php line 435
  18. at App->run() in index.php line 18

Environment Variables

GET Dataempty
POST Dataempty
Filesempty
Cookiesempty
Sessionempty
Server/Request Data
USER www
HOME /home/www
HTTP_CF_CONNECTING_IP 3.88.60.5
HTTP_REFERER http://jjmhw.cc/chapter/22616
HTTP_USER_AGENT claudebot
HTTP_ACCEPT */*
HTTP_CF_VISITOR {"scheme":"https"}
HTTP_X_FORWARDED_PROTO https
HTTP_CF_RAY 86b8edf35aa082e6-IAD
HTTP_X_FORWARDED_FOR 3.88.60.5
HTTP_ACCEPT_ENCODING gzip, br
HTTP_CF_IPCOUNTRY US
HTTP_CDN_LOOP cloudflare
HTTP_HOST jjmhw.cc
PATH_INFO
REDIRECT_STATUS 200
SERVER_NAME jjmhw.cc
SERVER_PORT 443
SERVER_ADDR 192.151.146.2
REMOTE_PORT 23306
REMOTE_ADDR 172.70.175.147
SERVER_SOFTWARE nginx/1.22.1
GATEWAY_INTERFACE CGI/1.1
HTTPS on
REQUEST_SCHEME https
SERVER_PROTOCOL HTTP/2.0
DOCUMENT_ROOT /www/wwwroot/main.com/public
DOCUMENT_URI /index.php
REQUEST_URI /chapter/22616
SCRIPT_NAME /index.php
CONTENT_LENGTH
CONTENT_TYPE
REQUEST_METHOD GET
QUERY_STRING s=//chapter/22616
SCRIPT_FILENAME /www/wwwroot/main.com/public/index.php
FCGI_ROLE RESPONDER
PHP_SELF /index.php
REQUEST_TIME_FLOAT 1711642637.4311
REQUEST_TIME 1711642637
Environment Variablesempty
ThinkPHP Constants
spider_db_conn xxx