|
1 | 1 | # Laravel-Unsplash
|
| 2 | +[](https://styleci.io/repos/116019138) |
2 | 3 |
|
| 4 | +**This package contain pulic actions** |
| 5 | + |
| 6 | +## Install |
| 7 | + |
| 8 | +Via Composer |
| 9 | + |
| 10 | +``` bash |
| 11 | +$ composer require mahdimajidzadeh/laravel-unsplash |
| 12 | +``` |
| 13 | +If you do not run Laravel 5.5 (or higher), then add the service provider in config/app.php: |
| 14 | + |
| 15 | +``` |
| 16 | +MahdiMajidzadeh\LaravelUnsplash\LaravelUnsplashServiceProvider:class |
| 17 | +``` |
| 18 | + |
| 19 | +If you do run the package on Laravel 5.5+, package auto-discovery takes care of the magic of adding the service provider. |
| 20 | + |
| 21 | +You must publish the configuration to provide an own service provider stub. |
| 22 | + |
| 23 | +``` bash |
| 24 | +$ php artisan vendor:publish --provider="MahdiMajidzadeh\LaravelUnsplash\LaravelUnsplashServiceProvider" |
| 25 | +``` |
| 26 | + |
| 27 | +## Usage |
| 28 | +See documention for params and others at [unsplash docs](https://unsplash.com/documentation) |
| 29 | + |
| 30 | +List of methods: |
| 31 | + |
| 32 | +### Photos |
| 33 | + |
| 34 | +``` php |
| 35 | +$unsplash = new MahdiMajidzadeh\LaravelUnsplash\Photo(); |
| 36 | +$photos = $unsplash->photos($params)->get(); // list of all photos |
| 37 | +$photo = $unsplash->single($id, $params)->get(); // single photo |
| 38 | +$statistic = $unsplash->statistic($id, $params)->get(); // single photo statistics |
| 39 | +$link = $unsplash->download($id); // single photo download link |
| 40 | +$photos = $unsplash->curated($params)->get(); // list of curated photos |
| 41 | +$photo = $unsplash->random($params)->get(); // random photo |
| 42 | +``` |
| 43 | + |
| 44 | +**notice**: you can use `getArray()` instead of `get()` to get array of result. |
| 45 | + |
| 46 | +**notice**: `single($id, $params)` and `random($params)` have `getID()` and `getURL()` methods to get ID and URL for using in `<img>` tag. |
| 47 | +``` php |
| 48 | +$photos = $unsplash->random($params)->getURL(); // return https://source.unsplash.com/WLUHO9A_xik/1600x900 |
| 49 | +``` |
| 50 | + |
| 51 | +### Users |
| 52 | + |
| 53 | +``` php |
| 54 | +$unsplash = new MahdiMajidzadeh\LaravelUnsplash\User(); |
| 55 | +$user = $unsplash->single($username, $params)->get(); // single user |
| 56 | +$portfolio = $unsplash->portfolio($username); // single user's portfolio |
| 57 | +$photos = $unsplash->photos($username, $params)->get(); // single user's photos |
| 58 | +$photos = $unsplash->likes($username, $params)->get(); // single user's likes |
| 59 | +$collections = $unsplash->collections($username, $params)->get(); // single user's collections |
| 60 | +$statistics = $unsplash->statistics($username, $params)->get(); // single user's statistics |
| 61 | +``` |
| 62 | + |
| 63 | +**notice**: you can use `getArray()` instead of `get()` to get array of result. |
| 64 | + |
| 65 | +### Collections |
| 66 | + |
| 67 | +``` php |
| 68 | +$unsplash = new MahdiMajidzadeh\LaravelUnsplash\Collection(); |
| 69 | +$collection = $unsplash->collections($params)->get(); // list of all collections |
| 70 | +$collection = $unsplash->single($id)->get(); // single collections |
| 71 | +$photos = $unsplash->photos($id, $params)->get(); // collection photos |
| 72 | +$statistic = $unsplash->statistic($id, $params)->get(); // single collections statistics |
| 73 | +$collection = $unsplash->curated($params)->get(); // list of curated collections |
| 74 | +$collection = $unsplash->related($id)->get(); // list of related collections |
| 75 | +$collection = $unsplash->featured($params)->get(); // list of featured collections |
| 76 | +``` |
| 77 | + |
| 78 | +**notice**: you can use `getArray()` instead of `get()` to get array of result. |
| 79 | + |
| 80 | +### Search |
| 81 | + |
| 82 | +``` php |
| 83 | +$unsplash = new MahdiMajidzadeh\LaravelUnsplash\Search(); |
| 84 | +$photos = $unsplash->photo($query, $params)->get(); |
| 85 | +$collection = $unsplash->collection($query, $params)->get(); |
| 86 | +$user = $unsplash->user($query, $params)->get(); |
| 87 | +``` |
| 88 | +**notice**: you can use `getArray()` instead of `get()` to get array of result. |
0 commit comments