|
9 | 9 | use Backstage\Fields\Fields\Base; |
10 | 10 | use Backstage\Fields\Models\Field; |
11 | 11 | use Backstage\Media\Forms\Components\MediaGridPicker; |
| 12 | +use Backstage\Models\ContentFieldValue; |
12 | 13 | use Backstage\Uploadcare\Enums\Style; |
13 | 14 | use Backstage\Uploadcare\Forms\Components\Uploadcare as Input; |
14 | 15 | use Filament\Actions\Action; |
15 | 16 | use Filament\Facades\Filament; |
| 17 | +use Filament\Forms\Components\Hidden; |
16 | 18 | use Filament\Forms\Components\Select; |
17 | 19 | use Filament\Forms\Components\TextInput; |
18 | 20 | use Filament\Forms\Components\Toggle; |
|
22 | 24 | use Filament\Support\Icons\Heroicon; |
23 | 25 | use Illuminate\Database\Eloquent\Model; |
24 | 26 | use Illuminate\Support\Arr; |
| 27 | +use Illuminate\Support\Collection; |
25 | 28 | use Illuminate\Support\Facades\Auth; |
26 | 29 |
|
27 | 30 | class Uploadcare extends Base implements FieldContract, HydratesValues, HydratesValuesForFilament, HydratesValuesForFrontend |
@@ -138,7 +141,7 @@ public static function make(string $name, Field $field): Input |
138 | 141 | } |
139 | 142 | } |
140 | 143 |
|
141 | | - $fieldValue = \Backstage\Models\ContentFieldValue::where('content_ulid', $record->getKey()) |
| 144 | + $fieldValue = ContentFieldValue::where('content_ulid', $record->getKey()) |
142 | 145 | ->where(function ($query) use ($fieldUlid) { |
143 | 146 | $query->where('field_ulid', $fieldUlid) |
144 | 147 | ->orWhere('ulid', $fieldUlid); |
@@ -173,7 +176,7 @@ public static function make(string $name, Field $field): Input |
173 | 176 | if ($m->relationLoaded('pivot') && $m->pivot) { |
174 | 177 | $contextModel->setRelation('pivot', $m->pivot); |
175 | 178 | } else { |
176 | | - $dummyPivot = new \Backstage\Models\ContentFieldValue; |
| 179 | + $dummyPivot = new ContentFieldValue; |
177 | 180 | $dummyPivot->setAttribute('meta', null); |
178 | 181 | $contextModel->setRelation('pivot', $dummyPivot); |
179 | 182 | } |
@@ -300,7 +303,7 @@ public static function make(string $name, Field $field): Input |
300 | 303 | ->perPage(12) |
301 | 304 | ->multiple($isMultiple) |
302 | 305 | ->acceptedFileTypes($acceptedFileTypes), |
303 | | - \Filament\Forms\Components\Hidden::make('selected_media_uuid') |
| 306 | + Hidden::make('selected_media_uuid') |
304 | 307 | ->default(null) |
305 | 308 | ->dehydrated() |
306 | 309 | ->live(), |
@@ -457,15 +460,15 @@ public static function mutateFormDataCallback(Model $record, Field $field, array |
457 | 460 | if (self::isMediaUlidArray($values)) { |
458 | 461 | $mediaData = null; |
459 | 462 |
|
460 | | - if ($record->exists && class_exists(\Backstage\Models\ContentFieldValue::class)) { |
| 463 | + if ($record->exists && class_exists(ContentFieldValue::class)) { |
461 | 464 | try { |
462 | | - $cfv = \Backstage\Models\ContentFieldValue::where('content_ulid', $record->ulid) |
| 465 | + $cfv = ContentFieldValue::where('content_ulid', $record->ulid) |
463 | 466 | ->where('field_ulid', $field->ulid) |
464 | 467 | ->first(); |
465 | 468 |
|
466 | 469 | if ($cfv) { |
467 | 470 | $models = self::hydrateFromModel($cfv, $values, true); |
468 | | - if ($models && $models instanceof \Illuminate\Support\Collection) { |
| 471 | + if ($models && $models instanceof Collection) { |
469 | 472 | $mediaData = $models->map(fn ($m) => self::mapMediaToValue($m))->values()->all(); |
470 | 473 | } |
471 | 474 | } |
|
0 commit comments