Skip to content

Commit

Permalink
Rename facede method to make
Browse files Browse the repository at this point in the history
  • Loading branch information
ptrckvzn committed Oct 1, 2021
1 parent 3c0d313 commit 29a6ca1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ The `Image` model allows you to interact fluently with a media object.
$image = new A17\Twill\Image\Models\Image($object, $role, $media);

// or using the Facade
$image = TwillImage::image($object, $role, $media);
$image = TwillImage::make($object, $role, $media);
```

|Argument|Type|Default|Description|
Expand Down Expand Up @@ -238,7 +238,7 @@ $image = new Image($page, 'preview');
If you need to split the image generation from the render (exposing the `Image` model data through a REST API for example), use this method to get all attributes as an array.

```php
$previewImage = TwillImage::image($page, 'preview')->preset('art_directed')->toArray();
$previewImage = TwillImage::make($page, 'preview')->preset('art_directed')->toArray();
```

And use the `render` method from the facade to render the view.
Expand All @@ -254,7 +254,7 @@ And use the `render` method from the facade to render the view.
As seen in the previous section, the image element rendering can be separated from the image attributes generation. You can use the `Image` model to set up your image and pass the resulting object (or its `array` format to the `render` method to output the view).

```php
$previewImage = TwillImage::image($page, 'preview')->toArray();
$previewImage = TwillImage::make($page, 'preview')->toArray();
```

```blade
Expand Down Expand Up @@ -288,13 +288,13 @@ or
#### Examples

```blade
{!! TwillImage::image($item, 'preview_image', [
{!! TwillImage::make($item, 'preview_image', [
'sizes' => '(max-width: 767px) 50vw, 100vw',
])->render(); !!}
@php
$heroImage = TwillImage::image($item, 'preview_image');
$listingImage = TwillImage::image($item, 'preview_image')->crop('listing');
$heroImage = TwillImage::make($item, 'preview_image');
$listingImage = TwillImage::make($item, 'preview_image')->crop('listing');
@endphp
{!! TwillImage::render($heroImage) !!}
Expand Down Expand Up @@ -371,7 +371,7 @@ Let's say this is your preset `art_directed` in your config:

```blade
@php
$image = TwillImage::image($page, 'preview')->preset('art_directed');
$image = TwillImage::make($page, 'preview')->preset('art_directed');
@endphp
<div>
Expand Down Expand Up @@ -408,7 +408,7 @@ This is an example when you have multiple medias attached to a single `role`.
```blade
@php
$galleryImages = $item->imageObjects('gallery_image', 'desktop')->map(function ($media) use ($item) {
return TwillImage::image($item, 'gallery_image', $media);
return TwillImage::make($item, 'gallery_image', $media);
})->toArray();
@endphp
Expand Down
5 changes: 3 additions & 2 deletions src/TwillImage.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace A17\Twill\Image;

use A17\Twill\Models\Block;
use A17\Twill\Models\Media;
use A17\Twill\Models\Model;
use A17\Twill\Image\Models\Image;
Expand All @@ -10,12 +11,12 @@
class TwillImage
{
/**
* @param object|Model $object
* @param object|Model|Block $object
* @param string $role
* @param null|Media $media
* @return Image
*/
public function image($object, $role, $media = null)
public function make($object, $role, $media = null)
{
return new Image($object, $role, $media);
}
Expand Down

0 comments on commit 29a6ca1

Please sign in to comment.