PHP code example of msieprawski / eloquent-photos

1. Go to this page and download the library: Download msieprawski/eloquent-photos 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/ */

    

msieprawski / eloquent-photos example snippets


 namespace App;
$user = User::find(1);
$user->addPhoto('/path/to/your/photo.jpg');
$user->addPhotos([
    '/path/to/your/photo1.jpg',
    '/path/to/your/photo2.jpg',
]);

 namespace App;

$photos = request()->file('photos');
$user = User::find(1);
$user->addPhoto($photos);

 namespace App;
$user = User::find(1);
$photos = $user->photos;
foreach ($photos as $photo) {
    /** @var Msieprawski\EloquentPhotos\Photo $photo */
    echo $photo->photo_path;
}

 namespace App;
$user = User::find(1);
$user->destroyPhotos();