getAttribute('uuid'))) { $model->setAttribute('uuid', str()->uuid()->toString()); } }); } public function getRouteKeyName(): string { return 'uuid'; } /** * Resolve by UUID instead of BIGINT primary key. */ public function resolveRouteBinding($value, $field = null) { return $this->where('uuid', $value)->firstOrFail(); } /** * Scope: filter by UUID. */ public function scopeWhereUuid($query, string $uuid) { return $query->where('uuid', $uuid); } }