Skip to content

Commit

Permalink
Merge branch 'main' of github.com:statikbe/laravel-filament-flexible-…
Browse files Browse the repository at this point in the history
…content-blocks
  • Loading branch information
sten committed Nov 7, 2023
2 parents fd30542 + 06538c2 commit acf0d8d
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 11 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@

All notable changes to `laravel-filament-flexible-content-blocks` will be documented in this file.

## v0.2.5 - 2023-11-05

### What's Changed

- Fix: HasSlugAttributeTrait referenced `$this` when in a static context by @HelgeSverre in https://github.com/statikbe/laravel-filament-flexible-content-blocks/pull/22
- Fix: Initialize properties to null in Hero component class by @HelgeSverre in https://github.com/statikbe/laravel-filament-flexible-content-blocks/pull/23
- Mention the Table action "ViewAction" in the README. by @HelgeSverre in https://github.com/statikbe/laravel-filament-flexible-content-blocks/pull/24

### New Contributors

- @HelgeSverre made their first contribution in https://github.com/statikbe/laravel-filament-flexible-content-blocks/pull/22

**Full Changelog**: https://github.com/statikbe/laravel-filament-flexible-content-blocks/compare/v0.2.4...v0.2.5

## v0.2.4 - 2023-10-20

- fix bug with spatie image fields in content blocks, where a newly uploaded image gets deleted immediately after a new image is uploaded.
Expand Down
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,24 @@ public static function table(Table $table): Table {
}
```

#### (optional) Adding a ViewAction to your table

If your model uses the [`Linkable`](src%2FModels%2FContracts%2FLinkable.php) interface, you can also use the
provided `ViewAction` in your table.
This action will simply open the url returned by the `getViewUrl()` method on your model.

```php
use Statikbe\FilamentFlexibleContentBlocks\Filament\Table\Actions\ViewAction;

->actions([
Tables\Actions\EditAction::make(),
PublishAction::make(),
ViewAction::make(), // <-- Add this
])
```

#### Setup the form

And then you can implement the `form()` function with Filament fields provided by the package. Below is an example with tabs.
Note that we sometimes make use of `create()` static functions, because we want to set the
names to the fixed variables used in the models. Some fields in the example are bundled in groupings
Expand Down
11 changes: 5 additions & 6 deletions src/ContentBlocks/AbstractContentBlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,16 +136,15 @@ public function replaceParameters(?string $content): ?string

/**
* Sometimes the media UUID is saved as an array instead of a string. This converts array uuids to a string.
* @param string|array|null $uuid
* @return string|null
*/
protected function getMediaUuid(string|array|null $uuid): string|null {
if(!$uuid){
protected function getMediaUuid(string|array|null $uuid): ?string
{
if (! $uuid) {
return null;
}

if(is_array($uuid)){
if(empty($uuid)){
if (is_array($uuid)) {
if (empty($uuid)) {
return null;
}

Expand Down
6 changes: 3 additions & 3 deletions src/Models/Concerns/HasSlugAttributeTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ protected static function bootHasSlugAttributeTrait(): void

if (! empty($changedSlugs)) {
$published = true;
if (method_exists($this, 'isPublishedForDates')) {
$published = $this->isPublishedForDates($this->getOriginal('publishing_begins_at'), $this->getOriginal('publishing_ends_at'));
if (method_exists($record, 'isPublishedForDates')) {
$published = $record->isPublishedForDates($record->getOriginal('publishing_begins_at'), $record->getOriginal('publishing_ends_at'));
}

//dispatch event:
SlugChanged::dispatch($this, $changedSlugs, $published);
SlugChanged::dispatch($record, $changedSlugs, $published);
}
});
}
Expand Down
4 changes: 2 additions & 2 deletions src/View/Components/Hero.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ class Hero extends Component

public ?string $intro = null;

public ?string $heroImageTitle;
public ?string $heroImageTitle = null;

public ?string $heroImageCopyright;
public ?string $heroImageCopyright = null;

public function __construct(HasPageAttributes|HasHeroImageAttributes|HasIntroAttribute $page)
{
Expand Down

0 comments on commit acf0d8d

Please sign in to comment.