fix: enable backwards compatibility v1 rendering strategy
Some checks failed
tests / ci (push) Has been cancelled

This commit is contained in:
Benjamin Nussbaum 2026-02-21 11:34:30 +01:00
parent 5eb442d9d6
commit b8b6caba12
4 changed files with 45 additions and 6 deletions

View file

@ -11,6 +11,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
/**
* @property-read array<string, string> $css_variables
* @property-read string|null $css_name
* @property-read DevicePalette|null $palette
*/
final class DeviceModel extends Model
@ -74,6 +75,19 @@ final class DeviceModel extends Model
return null;
}
/**
* Returns css_name for v2 (per-device sizing); for v1 returns 'og' to preserve legacy single-variant behaviour.
*
* @return Attribute<string|null, string|null>
*/
protected function cssName(): Attribute
{
/** @var Attribute<string|null, string|null> */
return Attribute::get(
fn (mixed $value): ?string => config('app.puppeteer_window_size_strategy') === 'v2' ? ($value !== null ? (string) $value : null) : 'og'
);
}
public function palette(): BelongsTo
{
return $this->belongsTo(DevicePalette::class, 'palette_id');