Skip to content

Commit

Permalink
Bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
elimentz committed Nov 22, 2016
1 parent 7de5585 commit 4f3f30b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ ixudra/imageable

Custom Laravel imaging package for the Laravel 5 framework - developed by [Ixudra](http://ixudra.be).

The ixudra/imageable package provides an easy to use polymorphic image model that can be linked to one or more models in any Laravel PHP application. The package contains an image model class as well as a factory class that will take care of creating and editing the image model. Additionally, the package will also take care of moving and storing the actual files in the correct locations.

This package can be used by anyone at any given time, but keep in mind that it is optimized for my personal custom workflow. It may not suit your project perfectly and modifications may be in order.


Expand Down Expand Up @@ -106,7 +108,6 @@ A full example of a factory class that leverages the package functionality can b
```php

use Ixudra\Imageable\Services\Factories\ImageFactory;
use Ixudra\Imageable\Traits\ImageFactoryTrait;

class CardFactory {

Expand All @@ -122,15 +123,15 @@ A full example of a factory class that leverages the package functionality can b
public function create($input, $prefix = '')
{
$card = Card::create( array( 'name' => $input['name'] ) );
$this->imageFactory->make( $this->extractImageInput( $input ), $card, $prefix );
$this->imageFactory->make( $input, $card, $prefix );

return $card;
}

public function modify($card, $input, $prefix = '')
{
$card = $card->update( array( 'name' => $input['name'] ), $prefix );
$this->imageFactory->modify( $card->image, $this->extractImageInput( $input ), $card );
$card = $card->update( array( 'name' => $input['name'] ) );
$this->imageFactory->modify( $input, $card, $prefix );

return $card;
}
Expand All @@ -148,7 +149,7 @@ Usage example of both cases can be found in the examples below:

```php

{!! Form::open(array('url' => 'cards/', 'method' => 'POST', 'id' => 'createCard', 'class' => 'form-horizontal', 'role' => 'form', 'files' => true)) !!}
{!! Form::open(array('url' => 'cards', 'method' => 'POST', 'id' => 'createCard', 'class' => 'form-horizontal', 'role' => 'form', 'files' => true)) !!}

<div class="well well-large">
<div class='form-group {{ $errors->has('name') ? 'has-error' : '' }}'>
Expand Down Expand Up @@ -201,7 +202,8 @@ The usage of these views is by no means required to take advantage of the functi

## Planning

- Improve support for multiple images per model
- Improve support for multiple images per model
- Add Javascript library to improve user interaction



Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ixudra/imageable",
"description": "Custom Laravel imaging package for the Laravel 5 framework - developed by Ixudra",
"version": "6.0.0",
"version": "6.0.1",
"keywords": ["Ixudra", "image", "Laravel"],
"homepage": "http://ixudra.be",
"license": "MIT",
Expand Down
8 changes: 5 additions & 3 deletions src/Ixudra/Imageable/Services/Factories/ImageFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,17 @@ class ImageFactory extends BaseFactory {

public function make($input, $imageable, $prefix = '')
{
$image = Image::create( $this->preProcessInput( $this->extractInput( $input, Image::getDefaults(), $prefix, true ), $imageable, $prefix ) );
$image->uploadFile( $input[ 'file' ] );
$imageInput = $this->preProcessInput( $this->extractInput($input, Image::getDefaults(), $prefix, true), $imageable );

$image = Image::create( $imageInput );
$image->uploadFile( $imageInput[ 'file' ] );

return $image;
}

public function modify($image, $input, $imageable, $prefix = '')
{
$input = $this->preProcessInput( $this->extractInput( $input, Image::getDefaults(), $prefix ), $imageable, $prefix );
$input = $this->preProcessInput( $this->extractInput( $input, Image::getDefaults(), $prefix ), $imageable );
$image->update( $input );

return $image;
Expand Down

0 comments on commit 4f3f30b

Please sign in to comment.