the browser-facing portion of osu!
at master 37 lines 963 B view raw
1<?php 2 3// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the GNU Affero General Public License v3.0. 4// See the LICENCE file in the repository root for full licence text. 5 6namespace App\Models; 7 8use App\Libraries\Uploader; 9use App\Libraries\User\Cover; 10use Illuminate\Database\Eloquent\Builder; 11 12/** 13 * @property bool $active 14 * @property \Carbon\Carbon|null $created_at 15 * @property string|null $filename 16 * @property int $id 17 * @property \Carbon\Carbon|null $updated_at 18 */ 19class UserCoverPreset extends Model 20{ 21 private Uploader $file; 22 23 public function scopeActive(Builder $query): Builder 24 { 25 return $query->where('active', true)->whereNotNull('filename'); 26 } 27 28 public function file(): Uploader 29 { 30 return $this->file ??= new Uploader( 31 'user-cover-presets', 32 $this, 33 'filename', 34 ['image' => ['maxDimensions' => Cover::CUSTOM_COVER_MAX_DIMENSIONS]], 35 ); 36 } 37}