2020use App \Models \Album as ModelsAlbum ;
2121use App \Models \Extensions \BaseAlbum ;
2222use App \Policies \AlbumPolicy ;
23+ use App \Rules \CopyrightRule ;
2324use App \Rules \TitleRule ;
2425use Illuminate \Contracts \View \View ;
2526use Illuminate \Foundation \Auth \Access \AuthorizesRequests ;
@@ -44,6 +45,7 @@ class Properties extends Component
4445 public string $ album_sorting_order = '' ; // ! wired
4546 public string $ album_aspect_ratio = '' ; // ! wired
4647 public string $ license = 'none ' ; // ! wired
48+ public string $ copyright = '' ; // ! wired
4749
4850 /**
4951 * This is the equivalent of the constructor for Livewire Components.
@@ -63,6 +65,7 @@ public function mount(BaseAlbum $album): void
6365 $ this ->description = $ album ->description ?? '' ;
6466 $ this ->photo_sorting_column = $ album ->photo_sorting ?->column->value ?? '' ;
6567 $ this ->photo_sorting_order = $ album ->photo_sorting ?->order->value ?? '' ;
68+ $ this ->copyright = $ album ->copyright ?? '' ;
6669 if ($ this ->is_model_album ) {
6770 /** @var ModelsAlbum $album */
6871 $ this ->license = $ album ->license ->value ;
@@ -94,6 +97,7 @@ public function submit(AlbumFactory $albumFactory): void
9497 ...SetPhotoSortingRuleSet::rules (),
9598 ...SetAlbumSortingRuleSet::rules (),
9699 RequestAttribute::ALBUM_ASPECT_RATIO_ATTRIBUTE => ['present ' , 'nullable ' , new Enum (AspectRatioType::class)],
100+ RequestAttribute::COPYRIGHT_ATTRIBUTE => ['present ' , 'nullable ' , new CopyrightRule ()],
97101 ];
98102
99103 if (!$ this ->areValid ($ rules )) {
@@ -106,12 +110,17 @@ public function submit(AlbumFactory $albumFactory): void
106110 $ baseAlbum ->title = $ this ->title ;
107111 $ baseAlbum ->description = $ this ->description ;
108112
113+ $ this ->copyright = trim ($ this ->copyright );
114+
109115 // Not super pretty but whatever.
110116 $ column = ColumnSortingPhotoType::tryFrom ($ this ->photo_sorting_column );
111117 $ order = OrderSortingType::tryFrom ($ this ->photo_sorting_order );
112118 $ photoSortingCriterion = $ column === null ? null : new PhotoSortingCriterion ($ column ->toColumnSortingType (), $ order );
113119 $ baseAlbum ->photo_sorting = $ photoSortingCriterion ;
114120
121+ // If left empty, we set to null
122+ $ baseAlbum ->copyright = $ this ->copyright === '' ? null : $ this ->copyright ;
123+
115124 if ($ this ->is_model_album ) {
116125 /** @var ModelsAlbum $baseAlbum */
117126 $ baseAlbum ->license = LicenseType::from ($ this ->license );
0 commit comments