1
1

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,livewire2.0 TipsAdvent Calendar 2022

Day 3

【Laravel9】いつのまにulidを生成できるようになったんだ

Last updated at Posted at 2022-12-19

概要

Laravel9から文字列ヘルパ項目にulid生成が増えてる(strの上)

  • Laravel8
    スクリーンショット 2022-12-19 18.42.10.png

  • Laravel9
    スクリーンショット 2022-12-19 18.43.13.png

Str::ulid()

Str::ulidメソッドは、ULIDを生成します。


use Illuminate\Support\Str;

return (string) Str::ulid();

// 01gd6r360bp37zj17nxb55yv40

各ユーザーに固有のランダム文字列を与えたい時にuuidだと長すぎるなぁと思ってたので嬉しいです。

ライブラリを使えば主キーにuuidやulidを使える様でしたが、Laravel9から主キーをuuidにできるようになったみたいです

1
1
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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?