PHPackages                             morrelinko/laravel-simple-photo - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Image &amp; Media](/categories/media)
4. /
5. morrelinko/laravel-simple-photo

AbandonedArchivedLibrary[Image &amp; Media](/categories/media)

morrelinko/laravel-simple-photo
===============================

5322PHP

Since Jun 22Pushed 12y ago1 watchersCompare

[ Source](https://github.com/morrelinko/laravel-simple-photo)[ Packagist](https://packagist.org/packages/morrelinko/laravel-simple-photo)[ RSS](/packages/morrelinko-laravel-simple-photo/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependenciesVersions (1)Used By (0)

Simple Photo
============

[](#simple-photo)

Simple Photo Wrapper for Laravel 4. Simple photo is a library that simplifies handling of photos in your application.

\##Installation

Add `morrelinko/laravel-simple-photo` to your `composer.json` dependencies:

```
{
  "require": {
    "morrelinko/laravel-simple-photo": "dev-master"
  }
}
```

Afterwards, run `composer update` to update your dependencies or `composer install` to install them.

Add an entry for the service provider by editing `app/config/app.php` config file.

```
	'providers' => array(

		// ...

		'Morrelinko\LaravelSimplePhoto\SimplePhotoServiceProvider',
	);
```

Add an entry in your 'aliases' for the `SimplePhoto` facade

```
    'aliases' => array(

        // ...

        'SimplePhoto' => 'Morrelinko\LaravelSimplePhoto\SimplePhotoFacade'
    );
```

Run `php artisan config:publish morrelinko/laravel-simple-photo` to copy the default config file.

Copy the migration from `vendor/morrelinko/laravel-simple-photo/src/migrations to your migrations directory.

And run `php artisan migrate` to run the migration that will create the 'photos' table.

SimplePhoto
-----------

[](#simplephoto)

```
// ...

$source = new LaravelUploadSource($request->file('photo'));
$photoId = SimplePhoto::upload($source);

$user->photo_id = $photoId;
$user->save();
```

And to retrieve the photo later

```
$user = User::find(1);
$photo = SimplePhoto::get($user->photo_id);

echo $photo->url();
echo $photo->fileSize();
echo $photo->fileExtension();
```

SimplePhoto &amp; Eloquent Models
---------------------------------

[](#simplephoto--eloquent-models)

If you are using php 5.4+, you should use the `SimplePhotoTrait`. 'Makes things easy!!' (o\_o ).

Example:::

```
use Morrelinko\LaravelSimplePhoto\SimplePhotoTrait;
use Illuminate\Database\Eloquent\Model;

class User extends Model
{
    protected $photos = array(
        'photo' => array('column' => 'photo_id')
    );

    use SimplePhotoTrait;

    public function photo()
    {
        return $this->belongsTo('Morrelinko\LaravelSimplePhoto\Photo', 'photo_id', 'id');
    }
}
```

Of course, what this will do is that it will add a 'photo' property to this model. And whenever you try to get

this property, it will retrieve the photo just the same way as the above example shows.

The value is a set of options which the trait uses to build the photo of which the 'column' is the most important

as it is the field which contains the ID of the photo you wish to retrieve.

Using the Class
---------------

[](#using-the-class)

```
$user = User::find(1);

echo $user->photo->url();
echo $user->photo->fileSize();
echo $user->photo->fileExtension();

// .....
```

Extra
-----

[](#extra)

If your entity has more than one photo, you can specify all of em like so:::

```
use Morrelinko\LaravelSimplePhoto\SimplePhotoTrait;
use Illuminate\Database\Eloquent\Model;

class User extends Model
{
    protected $photos = array(
        'photo' => array('column' => 'photo_id'),
        'coverPhoto' => array('column' => 'cover_photo_id'),
        'profileBg' => array('column' => 'profile_bg_id')
    );

    use SimplePhotoTrait;

    public function photo()
    {
        return $this->belongsTo('Morrelinko\LaravelSimplePhoto\Photo', 'photo_id', 'id');
    }

    public function coverPhoto()
    {
        return $this->belongsTo('Morrelinko\LaravelSimplePhoto\Photo', 'cover_photo_id', 'id');
    }

    public function profileBg()
    {
        return $this->belongsTo('Morrelinko\LaravelSimplePhoto\Photo', 'profile_bg_id', 'id');
    }
}

$user = User::find(1);
echo $user->photo->url();
echo $user->coverPhoto->url();
echo $user->profileBg->url();
```

Options such as transformations and fallback can be added.

```
use Morrelinko\LaravelSimplePhoto\SimplePhotoTrait;
use Illuminate\Database\Eloquent\Model;

class User extends Model
{
    protected $photos = array(
        'photo' => array(
            'column' => 'photo_id',
            'fallback' => 'user_not_found.png',
            'transform' => array(
                'resize' => array(100, 100)
                'rotate' => array(180)
            )),
        'coverPhoto' => array(
            'column' => 'cover_photo_id',
            'fallback' => 'cover_default.png'
        ),
    );

    use SimplePhotoTrait;
}

$user = User::find(1);
echo $user->photo->url();
echo $user->coverPhoto->url();
```

###  Health Score

23

—

LowBetter than 26% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/a28fa910f21fdbfeab53d5727fad337dc6680a16a7c69677dd89b712f1bfd7f5?d=identicon)[morrelinko](/maintainers/morrelinko)

---

Top Contributors

[![morrelinko](https://avatars.githubusercontent.com/u/2414096?v=4)](https://github.com/morrelinko "morrelinko (14 commits)")

### Embed Badge

![Health badge](/badges/morrelinko-laravel-simple-photo/health.svg)

```
[![Health](https://phpackages.com/badges/morrelinko-laravel-simple-photo/health.svg)](https://phpackages.com/packages/morrelinko-laravel-simple-photo)
```

###  Alternatives

[goat1000/svggraph

Generates SVG graphs

135911.1k3](/packages/goat1000-svggraph)[gravatarphp/gravatar

Gravatar URL builder which is most commonly called as a Gravatar library

16653.6k2](/packages/gravatarphp-gravatar)[rsoury/wp-imgix

Rewrites WordPress image URLs to use ImgIX

167.2k](/packages/rsoury-wp-imgix)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
