PHP code example of marksitko / laravel-unsplash

1. Go to this page and download the library: Download marksitko/laravel-unsplash library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

marksitko / laravel-unsplash example snippets

 php
'providers' => [
    //...
    MarkSitko\LaravelUnsplash\UnsplashServiceProvider::class,
];
 php
'aliases' => [
    //...
    'Unsplash' => MarkSitko\LaravelUnsplash\Facades\Unsplash::class,
];
 bash
$ php artisan vendor:publish --tag=config
 bash
$ php artisan vendor:publish --tag=migrations
 php
// Returns the http response body.
$twoRandomPhotosOfSomePeoples = Unsplash::randomPhoto()
    ->orientation('portrait')
    ->term('people')
    ->count(2)
    ->toJson();

// Store the image in on your provided disc
$theNameFromTheStoredPhoto = Unsplash::randomPhoto()
    ->orientation('landscape')
    ->term('music')
    ->randomPhoto()
    ->store();
];
 php
$photos = Unsplash::photos()->toJson();
$photo = Unsplash::photo($id)->toJson();
$photosStatistics = Unsplash::photosStatistics($id)->toJson();
$trackPhotoDownload = Unsplash::trackPhotoDownload($id)->toJson();
 php
$user = Unsplash::user($username)->toJson();
$userPortfolio = Unsplash::userPortfolio($username)->toJson();
$userPhotos = Unsplash::userPhotos($username)->toJson();
$userLikes = Unsplash::userLikes($username)->toJson();
$userCollections = Unsplash::userCollections($username)->toJson();
$userStatistics = Unsplash::userStatistics($username)->toJson();
 php
$collectionsList = Unsplash::collectionsList()
    ->page($pageNumber)
    ->perPage($itemsPerPage)
    ->toJson();

$featuredCollection = Unsplash::featuredCollection()
    ->page($pageNumber)
    ->perPage($itemsPerPage)
    ->toJson();

$showCollection = Unsplash::showCollection()
    ->id($collectionId)
    ->toJson();

$showCollectionPhotos = Unsplash::showCollectionPhotos()
    ->id($collectionId)
    ->toJson();

$showCollectionRelatedCollections = Unsplash::showCollectionRelatedCollections()
    ->id($collectionId)
    ->toJson();
 php
$topicsList = Unsplash::topicsList()
    ->page($pageNumber)
    ->perPage($itemsPerPage)
    ->toJson();

$showTopic = Unsplash::showTopic()
    ->id($topicIdOrSlug)
    ->toJson();

$showTopicPhotos = Unsplash::showTopicPhotos()
    ->id($topicIdOrSlug)
    ->toJson();
 php
$totalStats = Unsplash::totalStats()->toJson();
$monthlyStats = Unsplash::monthlyStats()->toJson();
 bash
$ php artisan vendor:publish --tag=migrations
 bash
$ php artisan migrate
 php
// Returns the created unsplash asset record
$databaseRecord = Unsplash::randomPhoto()->store();
 php
// Returns the created unsplash asset record
$databaseRecord = UnsplashAsset::api()->randomPhoto()->store();

// Get an stored unsplash asset
$unsplashAsset = UnsplashAsset::find($id);