2017 © Pedro Peláez
 

library magician

A library for implementing repositories with magic finders for the Eloquent ORM.

image

pushoperations/magician

A library for implementing repositories with magic finders for the Eloquent ORM.

  • Saturday, June 20, 2015
  • by tonglil
  • Repository
  • 8 Watchers
  • 2 Stars
  • 60 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 3 Open issues
  • 8 Versions
  • 0 % Grown

The README.md

Magician

Build Status Coverage Status Scrutinizer Code Quality, (*1)

Total Downloads Latest Stable Version Latest Unstable Version License, (*2)

SensioLabsInsight, (*3)

A library for implementing repositories with magic finders and caching for the Eloquent ORM., (*4)

Contents

Install

The recommended way to install is through Composer., (*5)

Update your project's composer.json file to include Magic Repository:, (*6)

{
    "require": {
        "pushoperations/magician": "2.*"
    }
}

Then update the project dependencies to include this library:, (*7)

composer update pushoperations/magician

After installing, you need to require Composer's autoloader:, (*8)

require 'vendor/autoload.php';

Usage

A base implementation of the magic repository is already created for use out-of-the-box., (*9)

<?php namespace Controllers;

use Controller;
use Magician\Magician;

class ExampleController extends Controller
{
    public function __construct(Magician $magician)
    {
        // Tell this magician instance to be the repository manager for the 'User' model.
        $this->m = $magician->set('Models\User');
    }

    public function create()
    {
        $user = $this->m->firstOrMake(['email' => 'user@example.com']);

        if ($this->m->save($user)) {
            return $user;
        } else {
            return 'error: unable to save the user';
        }
    }

    public function read($id = null)
    {
        if ($id) {
            return $this->m->findById($id);
        } else {
            return $this->m->getById(['>', 0]);
        }
    }

    public function update($id)
    {
        $user = $this->m->findById($id);
        $user->fill([
            'trial' => true,
            'last_login' => new \DateTime,
            'subscription' => '2015',
        ]);

        $user->load('permissions');

        if ($this->rm->save($user)) {
            return $user;
        } else {
            return 'error: unable to save the user';
        }
    }

    public function inactive($date)
    {
        return $this->m->getByLastLogin(['<', $date]);
    }

    public function newTrials()
    {
        return $this->m->get10ByTrial(true, ['subscription' => 'asc'], ['email', 'subscription']);
    }
}

The Versions

20/06 2015

dev-master

9999999-dev https://github.com/pushoperations/Magician

A library for implementing repositories with magic finders for the Eloquent ORM.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel repository pattern repositories magic finders magician

20/06 2015

dev-laravel-5

dev-laravel-5 https://github.com/pushoperations/Magician

A library for implementing repositories with magic finders for the Eloquent ORM.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel repository pattern repositories magic finders magician

20/06 2015

v2.0.0

2.0.0.0 https://github.com/pushoperations/Magician

A library for implementing repositories with magic finders for the Eloquent ORM.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel repository pattern repositories magic finders magician

20/06 2015

dev-laravel-4

dev-laravel-4 https://github.com/pushoperations/Magician

A library for implementing repositories with magic finders for the Eloquent ORM.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel repository pattern repositories magic finders magician

20/06 2015

v1.0.0

1.0.0.0 https://github.com/pushoperations/Magician

A library for implementing repositories with magic finders for the Eloquent ORM.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel repository pattern repositories magic finders magician

20/06 2015

v0.9.0

0.9.0.0 https://github.com/pushoperations/Magician

A library for implementing repositories with magic finders for the Eloquent ORM.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel repository pattern repositories magic finders magician

28/01 2015

dev-associations

dev-associations https://github.com/pushoperations/Magician

A library for implementing repositories with magic finders for the Eloquent ORM.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel repository pattern repositories magic finders magician

19/01 2015

dev-tests

dev-tests https://github.com/pushoperations/Magician

A library for implementing repositories with magic finders for the Eloquent ORM.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel repository pattern repositories magic finders magician