0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Laravel Telescopeのログを直接取得する

Last updated at Posted at 2022-02-22

前提条件

  • laravel/framework v8.83.1
  • laravel/telescope v4.7.3

リクエストのログを5件取得する。

use Laravel\Telescope\Contracts\EntriesRepository;
use Laravel\Telescope\Storage\EntryQueryOptions;

$entries = app(EntriesRepository::class)->get(
    'request',
    (new EntryQueryOptions())->limit(5)
);

ページネーションする場合は beforeSequence() で。

use Laravel\Telescope\Contracts\EntriesRepository;
use Laravel\Telescope\Storage\EntryQueryOptions;

$entries = app(EntriesRepository::class)->get(
    'request',
    (new EntryQueryOptions())->limit(5)->beforeSequence($prevEntries->last()->sequence)
);

コントローラーで使う場合は EntryQueryOptions::fromRequest() で省略できる。

use Laravel\Telescope\Contracts\EntriesRepository;
use Laravel\Telescope\Storage\EntryQueryOptions;
use Illuminate\Http\Request;

public function index(Request $request) {
    $entries = app(EntriesRepository::class)->get(
        'request',
        EntryQueryOptions::fromRequest($request)
    );
    // ...
}

Requestに使えるパラメータは以下。

  • batch_id
  • uuids
  • before (beforeSequence()用)
  • tag
  • family_hash
  • take (limit()用)

参考資料

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?