forked from ppy/osu-web
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support multiple file upload in single model
- Loading branch information
Showing
24 changed files
with
436 additions
and
474 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the GNU Affero General Public License v3.0. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Casts; | ||
|
||
use Illuminate\Contracts\Database\Eloquent\CastsAttributes; | ||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class LegacyFilename implements CastsAttributes | ||
{ | ||
public static function makeFromAttributes(?array $attributes): ?string | ||
{ | ||
if (!isset($attributes['hash'])) { | ||
return null; | ||
} | ||
|
||
$filename = $attributes['hash']; | ||
if (isset($attributes['ext'])) { | ||
$filename .= ".{$attributes['ext']}"; | ||
} | ||
|
||
return $filename; | ||
} | ||
|
||
public function get(Model $model, string $key, mixed $value, array $attributes) | ||
{ | ||
return static::makeFromAttributes($attributes); | ||
} | ||
|
||
public function set(Model $model, string $key, mixed $value, array $attributes) | ||
{ | ||
return [ | ||
'ext' => null, | ||
'hash' => $value, | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the GNU Affero General Public License v3.0. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Libraries; | ||
|
||
class StorageUrl | ||
{ | ||
public static function make(?string $diskName, string $path): string | ||
{ | ||
$diskName ??= config('filesystems.default'); | ||
$baseUrl = config("filesystems.disks.{$diskName}.base_url"); | ||
|
||
return "{$baseUrl}/{$path}"; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.