国产+高潮+在线,国产 av 仑乱内谢,www国产亚洲精品久久,51国产偷自视频区视频,成人午夜精品网站在线观看

使用eloquent分頁(yè)時(shí),用模型得到的items是對(duì)象而不是數(shù)組,怎么解

ghjkg546

問(wèn)題描述

這里寫問(wèn)題描述

這種寫法打印的items是對(duì)象

 $WebUsers = MovieBasic::when(is_numeric($request->input('status')) , function ($query) use ($request) {
                return $query->where('status', $request->input('status'));
            })->when($request->input('type'), function ($query) use ($request) {
                return $query->where('type', $request->input('type'));
            })
            ->paginate($request->get('pageSize'));
        $items = $WebUsers->items();
        print_r($items);

這種寫法打印的items正常,是數(shù)組

 $WebUsers =Db::table('movie_basic)->when(is_numeric($request->input('status')) , function ($query) use ($request) {
                return $query->where('status', $request->input('status'));
            })->when($request->input('type'), function ($query) use ($request) {
                return $query->where('type', $request->input('type'));
            })
            ->paginate($request->get('pageSize'));
        $items = $WebUsers->items();
        print_r($items);

model代碼

class MovieBasic extends Model
{

    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'movie_basic';

    /**
     * The primary key associated with the table.
     *
     * @var string
     */
    protected $primaryKey = 'id';

    /**
     * Indicates if the model should be timestamped.
     *
     * @var bool
     */
    public $timestamps = false;
}
534 1 0
1個(gè)回答

不敗少龍

toArray()

  • ghjkg546 2024-05-16

    謝謝,用model時(shí),我是把整個(gè)數(shù)組拿去toArray,所以一直不行,其實(shí)是要把 數(shù)組的每個(gè)子項(xiàng)去toArray, 用model和Db::table,返回的東西不同,卡住我好久了

年代過(guò)于久遠(yuǎn),無(wú)法發(fā)表回答
??