2017 © Pedro Pelรกez
 

library laravel-helpers

a helper library for laravel

image

fei77/laravel-helpers

a helper library for laravel

  • Friday, July 20, 2018
  • by Fei77
  • Repository
  • 0 Watchers
  • 0 Stars
  • 98 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 7 Versions
  • 13 % Grown

The README.md

LaravelHelpers

Latest Version on Packagist ![Software License][ico-license] ![Total Downloads][ico-downloads], (*1)

Install

Via Composer, (*2)

``` bash $ composer require hifisaputra/laravel-helpers, (*3)


## Usage ``` php // Image helpers $image = Helpers::image($request->imagefile) /** * Change directory path using laravel's helper functions * * Parameters: * (string) - default (public_path()) * */ $image->path(storage_path()) /** * Change the folder path * * Parameters: * (string) - default ('images') */ $image->folder('images/profile') /** * Add encoding * * Parameters: * (string) Here's a list of encoding format * supported by [Intervention Image](http://image.intervention.io) * * jpg โ€” return JPEG encoded image data * png โ€” return Portable Network Graphics (PNG) encoded image data * gif โ€” return Graphics Interchange Format (GIF) encoded image data * tif โ€” return Tagged Image File Format (TIFF) encoded image data * bmp โ€” return Bitmap (BMP) encoded image data * ico โ€” return ICO encoded image data * psd โ€” return Photoshop Document (PSD) encoded image data * webp โ€” return WebP encoded image data * data-url โ€” encode current image data in data URI scheme (RFC 2397) * * (integer) Define the quality of the encoded image optionally. * Data ranging from 0 (poor quality, small file) to 100 (best quality, big file). */ $image->encode('jpg', 95) /** * Add prefix to filename * * Parameters: * (string) */ $image->prefix('user-') /** * Save the image * Return the image's name */ $image->save(); dd($image) // '/images/profile/user-5a9d24bb389ae.jpg' /** * Save the image with thumbnail * Return an array of the image's name and the thumbnail's name */ $image->saveWithThumbnail(); dd($image) /** * [ * 'originalName' : '/images/profile/user-5a9d24bb389ae.jpg', * 'thumbnailName' : '/images/profile/user-5a9d24bb389ae_tn.jpg' * ] */ // Delete helpers /** * Delete file from the given path * @param $path can be array of strings or just a string. */ Helpers::delete($path); //Config writer /** * Write laravel config file * * credit: https://github.com/daftspunk/laravel-config-writer * * @param array */ Helpers::config()->write(['app.locale' => 'en']);

Example

public function store(Request $request)
{
  $blog = new Blog();
  $blog->user_id = Auth::user()->id;
  if ($request->image) {

    $image = Helpers::image($request->image)->folder('images/blogs')->encode('jpg', 80)->saveWithThumbnail();
      // the image files will be saved inside public/images/blogs

    $blog->originalUrl = $image['originalName'];
    $blog->previewUrl = $image['thumbnailName'];
  }

  $blog->fill($request->translations);
  $blog->save();
}

Contributing

License

The MIT License (MIT). Please see License File for more information., (*4)

The Versions

20/07 2018

dev-master

9999999-dev https://github.com/fei77/laravel-helpers

a helper library for laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

fei77 laravelhelpers

26/05 2018

1.1.1.1

1.1.1.1 https://github.com/fei77/laravel-helpers

a helper library for laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

fei77 laravelhelpers

25/05 2018

1.1.1

1.1.1.0 https://github.com/fei77/laravel-helpers

a helper library for laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

fei77 laravelhelpers

30/04 2018

1.1.0

1.1.0.0 https://github.com/fei77/laravel-helpers

a helper library for laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

fei77 laravelhelpers

02/04 2018

1.0.2

1.0.2.0 https://github.com/fei77/laravel-helpers

a helper library for laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

fei77 laravelhelpers

30/03 2018

1.0.1

1.0.1.0 https://github.com/fei77/laravel-helpers

a helper library for laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

fei77 laravelhelpers

06/03 2018

1.0

1.0.0.0 https://github.com/fei77/laravel-helpers

a helper library for laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

fei77 laravelhelpers