Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
mansoorkhan96 committed Mar 21, 2024
1 parent 4f87fe9 commit 244f1de
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,32 @@ Forms\Components\FileUpload::make('featured_image')

The `UnsplashPickerAction` is simple Filament Form Action and you append all the available methods. The Image picker component is a livewire component, you can extend and override the methods.

Here is a very cool example that shows how to get other data for selected unsplash image:

```php
use Filament\Forms\Components\Actions\Action;
use Livewire\Component;
use Filament\Forms\Components\FileUpload;
use Filament\Forms\Set;
use Illuminate\Support\Arr;

UnsplashPickerAction::make()
->regular()
->action(function (Action $action, $arguments, Component $livewire, FileUpload $component, Set $set) {
$action->uploadImage($arguments, $livewire, $component);

$creatorName = Arr::get($arguments, 'user.name');

$altText = Arr::get($arguments, 'alt_description');
$creditText = "Photo by {$creatorName}, from unsplash.com";
$creditUrl = Arr::get($arguments, 'user.links.html');

$set('featured_image_alt', $altText);
$set('featured_image_credit.text', $creditText);
$set('featured_image_credit.url', $creditUrl);
})
```

You dont need to but you can publish the config file with:

```bash
Expand Down

0 comments on commit 244f1de

Please sign in to comment.