File tree Expand file tree Collapse file tree 2 files changed +7
-3
lines changed
Expand file tree Collapse file tree 2 files changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ protected function initializeHasSqids(): void
1818 $ this ->append (['sqid ' ]);
1919 }
2020
21- public function getSqidAttribute (): string
21+ public function getSqidAttribute (): ? string
2222 {
2323 return Sqids::forModel (model: $ this );
2424 }
Original file line number Diff line number Diff line change 1010
1111class Sqids
1212{
13- public static function forModel (Model $ model ): string
13+ public static function forModel (Model $ model ): ? string
1414 {
15- /** @var int $id */
15+ /** @var int|null $id */
1616 $ id = $ model ->getKey ();
1717
18+ if ($ id === null ) {
19+ return null ;
20+ }
21+
1822 $ prefix = static ::prefixForModel (model: $ model ::class);
1923 $ separator = $ prefix ? Config::separator () : null ;
2024 $ sqid = static ::encodeId (model: $ model ::class, id: $ id );
You can’t perform that action at this time.
0 commit comments