Added vendor/ directory for Composer's installed files

This commit is contained in:
Ascendings
2015-08-30 12:33:20 -04:00
parent 45df179c49
commit b66a773ed8
1162 changed files with 112457 additions and 0 deletions

View File

@ -0,0 +1,5 @@
<?php namespace Illuminate\Container;
use Exception;
class BindingResolutionException extends Exception {}

1291
vendor/illuminate/container/Container.php vendored Executable file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,58 @@
<?php namespace Illuminate\Container;
use Illuminate\Contracts\Container\ContextualBindingBuilder as ContextualBindingBuilderContract;
class ContextualBindingBuilder implements ContextualBindingBuilderContract {
/**
* The underlying container instance.
*
* @var \Illuminate\Container\Container
*/
protected $container;
/**
* The concrete instance.
*
* @var string
*/
protected $concrete;
/**
* Create a new contextual binding builder.
*
* @param \Illuminate\Container\Container $container
* @param string $concrete
* @return void
*/
public function __construct(Container $container, $concrete)
{
$this->concrete = $concrete;
$this->container = $container;
}
/**
* Define the abstract target that depends on the context.
*
* @param string $abstract
* @return $this
*/
public function needs($abstract)
{
$this->needs = $abstract;
return $this;
}
/**
* Define the implementation for the contextual binding.
*
* @param \Closure|string $implementation
* @return void
*/
public function give($implementation)
{
$this->container->addContextualBinding($this->concrete, $this->needs, $implementation);
}
}

31
vendor/illuminate/container/composer.json vendored Executable file
View File

@ -0,0 +1,31 @@
{
"name": "illuminate/container",
"description": "The Illuminate Container package.",
"license": "MIT",
"homepage": "http://laravel.com",
"support": {
"issues": "https://github.com/laravel/framework/issues",
"source": "https://github.com/laravel/framework"
},
"authors": [
{
"name": "Taylor Otwell",
"email": "taylorotwell@gmail.com"
}
],
"require": {
"php": ">=5.4.0",
"illuminate/contracts": "5.0.*"
},
"autoload": {
"psr-4": {
"Illuminate\\Container\\": ""
}
},
"extra": {
"branch-alias": {
"dev-master": "5.0-dev"
}
},
"minimum-stability": "dev"
}

View File

@ -0,0 +1,41 @@
<?php namespace Illuminate\Contracts\Auth;
interface Authenticatable {
/**
* Get the unique identifier for the user.
*
* @return mixed
*/
public function getAuthIdentifier();
/**
* Get the password for the user.
*
* @return string
*/
public function getAuthPassword();
/**
* Get the token value for the "remember me" session.
*
* @return string
*/
public function getRememberToken();
/**
* Set the token value for the "remember me" session.
*
* @param string $value
* @return void
*/
public function setRememberToken($value);
/**
* Get the column name for the "remember me" token.
*
* @return string
*/
public function getRememberTokenName();
}

View File

@ -0,0 +1,12 @@
<?php namespace Illuminate\Contracts\Auth;
interface CanResetPassword {
/**
* Get the e-mail address where password reset links are sent.
*
* @return string
*/
public function getEmailForPasswordReset();
}

100
vendor/illuminate/contracts/Auth/Guard.php vendored Executable file
View File

@ -0,0 +1,100 @@
<?php namespace Illuminate\Contracts\Auth;
interface Guard {
/**
* Determine if the current user is authenticated.
*
* @return bool
*/
public function check();
/**
* Determine if the current user is a guest.
*
* @return bool
*/
public function guest();
/**
* Get the currently authenticated user.
*
* @return \Illuminate\Contracts\Auth\Authenticatable|null
*/
public function user();
/**
* Log a user into the application without sessions or cookies.
*
* @param array $credentials
* @return bool
*/
public function once(array $credentials = array());
/**
* Attempt to authenticate a user using the given credentials.
*
* @param array $credentials
* @param bool $remember
* @param bool $login
* @return bool
*/
public function attempt(array $credentials = array(), $remember = false, $login = true);
/**
* Attempt to authenticate using HTTP Basic Auth.
*
* @param string $field
* @return \Symfony\Component\HttpFoundation\Response|null
*/
public function basic($field = 'email');
/**
* Perform a stateless HTTP Basic login attempt.
*
* @param string $field
* @return \Symfony\Component\HttpFoundation\Response|null
*/
public function onceBasic($field = 'email');
/**
* Validate a user's credentials.
*
* @param array $credentials
* @return bool
*/
public function validate(array $credentials = array());
/**
* Log a user into the application.
*
* @param \Illuminate\Contracts\Auth\Authenticatable $user
* @param bool $remember
* @return void
*/
public function login(Authenticatable $user, $remember = false);
/**
* Log the given user ID into the application.
*
* @param mixed $id
* @param bool $remember
* @return \Illuminate\Contracts\Auth\Authenticatable
*/
public function loginUsingId($id, $remember = false);
/**
* Determine if the user was authenticated via "remember me" cookie.
*
* @return bool
*/
public function viaRemember();
/**
* Log the user out of the application.
*
* @return void
*/
public function logout();
}

View File

@ -0,0 +1,76 @@
<?php namespace Illuminate\Contracts\Auth;
use Closure;
interface PasswordBroker {
/**
* Constant representing a successfully sent reminder.
*
* @var int
*/
const RESET_LINK_SENT = 'passwords.sent';
/**
* Constant representing a successfully reset password.
*
* @var int
*/
const PASSWORD_RESET = 'passwords.reset';
/**
* Constant representing the user not found response.
*
* @var int
*/
const INVALID_USER = 'passwords.user';
/**
* Constant representing an invalid password.
*
* @var int
*/
const INVALID_PASSWORD = 'passwords.password';
/**
* Constant representing an invalid token.
*
* @var int
*/
const INVALID_TOKEN = 'passwords.token';
/**
* Send a password reset link to a user.
*
* @param array $credentials
* @param \Closure|null $callback
* @return string
*/
public function sendResetLink(array $credentials, Closure $callback = null);
/**
* Reset the password for the given token.
*
* @param array $credentials
* @param \Closure $callback
* @return mixed
*/
public function reset(array $credentials, Closure $callback);
/**
* Set a custom password validator.
*
* @param \Closure $callback
* @return void
*/
public function validator(Closure $callback);
/**
* Determine if the passwords match for the request.
*
* @param array $credentials
* @return bool
*/
public function validateNewPassword(array $credentials);
}

View File

@ -0,0 +1,21 @@
<?php namespace Illuminate\Contracts\Auth;
interface Registrar {
/**
* Get a validator for an incoming registration request.
*
* @param array $data
* @return \Illuminate\Contracts\Validation\Validator
*/
public function validator(array $data);
/**
* Create a new user instance after a valid registration.
*
* @param array $data
* @return User
*/
public function create(array $data);
}

View File

@ -0,0 +1,48 @@
<?php namespace Illuminate\Contracts\Auth;
interface UserProvider {
/**
* Retrieve a user by their unique identifier.
*
* @param mixed $identifier
* @return \Illuminate\Contracts\Auth\Authenticatable|null
*/
public function retrieveById($identifier);
/**
* Retrieve a user by by their unique identifier and "remember me" token.
*
* @param mixed $identifier
* @param string $token
* @return \Illuminate\Contracts\Auth\Authenticatable|null
*/
public function retrieveByToken($identifier, $token);
/**
* Update the "remember me" token for the given user in storage.
*
* @param \Illuminate\Contracts\Auth\Authenticatable $user
* @param string $token
* @return void
*/
public function updateRememberToken(Authenticatable $user, $token);
/**
* Retrieve a user by the given credentials.
*
* @param array $credentials
* @return \Illuminate\Contracts\Auth\Authenticatable|null
*/
public function retrieveByCredentials(array $credentials);
/**
* Validate a user against the given credentials.
*
* @param \Illuminate\Contracts\Auth\Authenticatable $user
* @param array $credentials
* @return bool
*/
public function validateCredentials(Authenticatable $user, array $credentials);
}

View File

@ -0,0 +1,45 @@
<?php namespace Illuminate\Contracts\Bus;
use Closure;
use ArrayAccess;
interface Dispatcher {
/**
* Marshal a command and dispatch it to its appropriate handler.
*
* @param mixed $command
* @param array $array
* @return mixed
*/
public function dispatchFromArray($command, array $array);
/**
* Marshal a command and dispatch it to its appropriate handler.
*
* @param mixed $command
* @param \ArrayAccess $source
* @param array $extras
* @return mixed
*/
public function dispatchFrom($command, ArrayAccess $source, array $extras = []);
/**
* Dispatch a command to its appropriate handler.
*
* @param mixed $command
* @param \Closure|null $afterResolving
* @return mixed
*/
public function dispatch($command, Closure $afterResolving = null);
/**
* Dispatch a command to its appropriate handler in the current process.
*
* @param mixed $command
* @param \Closure|null $afterResolving
* @return mixed
*/
public function dispatchNow($command, Closure $afterResolving = null);
}

View File

@ -0,0 +1,47 @@
<?php namespace Illuminate\Contracts\Bus;
use Closure;
interface HandlerResolver {
/**
* Get the handler instance for the given command.
*
* @param mixed $command
* @return mixed
*/
public function resolveHandler($command);
/**
* Get the handler class for the given command.
*
* @param mixed $command
* @return string
*/
public function getHandlerClass($command);
/**
* Get the handler method for the given command.
*
* @param mixed $command
* @return string
*/
public function getHandlerMethod($command);
/**
* Register command to handler mappings.
*
* @param array $commands
* @return void
*/
public function maps(array $commands);
/**
* Register a fallback mapper callback.
*
* @param \Closure $mapper
* @return void
*/
public function mapUsing(Closure $mapper);
}

View File

@ -0,0 +1,13 @@
<?php namespace Illuminate\Contracts\Bus;
interface QueueingDispatcher extends Dispatcher {
/**
* Dispatch a command to its appropriate handler behind a queue.
*
* @param mixed $command
* @return mixed
*/
public function dispatchToQueue($command);
}

View File

@ -0,0 +1,3 @@
<?php namespace Illuminate\Contracts\Bus;
interface SelfHandling {}

13
vendor/illuminate/contracts/Cache/Factory.php vendored Executable file
View File

@ -0,0 +1,13 @@
<?php namespace Illuminate\Contracts\Cache;
interface Factory {
/**
* Get a cache store instance by name.
*
* @param string|null $name
* @return mixed
*/
public function store($name = null);
}

View File

@ -0,0 +1,98 @@
<?php namespace Illuminate\Contracts\Cache;
use Closure;
interface Repository {
/**
* Determine if an item exists in the cache.
*
* @param string $key
* @return bool
*/
public function has($key);
/**
* Retrieve an item from the cache by key.
*
* @param string $key
* @param mixed $default
* @return mixed
*/
public function get($key, $default = null);
/**
* Retrieve an item from the cache and delete it.
*
* @param string $key
* @param mixed $default
* @return mixed
*/
public function pull($key, $default = null);
/**
* Store an item in the cache.
*
* @param string $key
* @param mixed $value
* @param \DateTime|int $minutes
* @return void
*/
public function put($key, $value, $minutes);
/**
* Store an item in the cache if the key does not exist.
*
* @param string $key
* @param mixed $value
* @param \DateTime|int $minutes
* @return bool
*/
public function add($key, $value, $minutes);
/**
* Store an item in the cache indefinitely.
*
* @param string $key
* @param mixed $value
* @return void
*/
public function forever($key, $value);
/**
* Get an item from the cache, or store the default value.
*
* @param string $key
* @param \DateTime|int $minutes
* @param \Closure $callback
* @return mixed
*/
public function remember($key, $minutes, Closure $callback);
/**
* Get an item from the cache, or store the default value forever.
*
* @param string $key
* @param \Closure $callback
* @return mixed
*/
public function sear($key, Closure $callback);
/**
* Get an item from the cache, or store the default value forever.
*
* @param string $key
* @param \Closure $callback
* @return mixed
*/
public function rememberForever($key, Closure $callback);
/**
* Remove an item from the cache.
*
* @param string $key
* @return bool
*/
public function forget($key);
}

72
vendor/illuminate/contracts/Cache/Store.php vendored Executable file
View File

@ -0,0 +1,72 @@
<?php namespace Illuminate\Contracts\Cache;
interface Store {
/**
* Retrieve an item from the cache by key.
*
* @param string $key
* @return mixed
*/
public function get($key);
/**
* Store an item in the cache for a given number of minutes.
*
* @param string $key
* @param mixed $value
* @param int $minutes
* @return void
*/
public function put($key, $value, $minutes);
/**
* Increment the value of an item in the cache.
*
* @param string $key
* @param mixed $value
* @return int|bool
*/
public function increment($key, $value = 1);
/**
* Decrement the value of an item in the cache.
*
* @param string $key
* @param mixed $value
* @return int|bool
*/
public function decrement($key, $value = 1);
/**
* Store an item in the cache indefinitely.
*
* @param string $key
* @param mixed $value
* @return void
*/
public function forever($key, $value);
/**
* Remove an item from the cache.
*
* @param string $key
* @return bool
*/
public function forget($key);
/**
* Remove all items from the cache.
*
* @return void
*/
public function flush();
/**
* Get the cache key prefix.
*
* @return string
*/
public function getPrefix();
}

View File

@ -0,0 +1,49 @@
<?php namespace Illuminate\Contracts\Config;
interface Repository {
/**
* Determine if the given configuration value exists.
*
* @param string $key
* @return bool
*/
public function has($key);
/**
* Get the specified configuration value.
*
* @param string $key
* @param mixed $default
* @return mixed
*/
public function get($key, $default = null);
/**
* Set a given configuration value.
*
* @param array|string $key
* @param mixed $value
* @return void
*/
public function set($key, $value = null);
/**
* Prepend a value onto an array configuration value.
*
* @param string $key
* @param mixed $value
* @return void
*/
public function prepend($key, $value);
/**
* Push a value onto an array configuration value.
*
* @param string $key
* @param mixed $value
* @return void
*/
public function push($key, $value);
}

View File

@ -0,0 +1,21 @@
<?php namespace Illuminate\Contracts\Console;
interface Application {
/**
* Call a console application command.
*
* @param string $command
* @param array $parameters
* @return int
*/
public function call($command, array $parameters = array());
/**
* Get the output from the last command.
*
* @return string
*/
public function output();
}

View File

@ -0,0 +1,46 @@
<?php namespace Illuminate\Contracts\Console;
interface Kernel {
/**
* Handle an incoming console command.
*
* @param \Symfony\Component\Console\Input\InputInterface $input
* @param \Symfony\Component\Console\Output\OutputInterface $output
* @return int
*/
public function handle($input, $output = null);
/**
* Run an Artisan console command by name.
*
* @param string $command
* @param array $parameters
* @return int
*/
public function call($command, array $parameters = array());
/**
* Queue an Artisan console command by name.
*
* @param string $command
* @param array $parameters
* @return int
*/
public function queue($command, array $parameters = array());
/**
* Get all of the commands registered with the console.
*
* @return array
*/
public function all();
/**
* Get the output for the last run command.
*
* @return string
*/
public function output();
}

View File

@ -0,0 +1,143 @@
<?php namespace Illuminate\Contracts\Container;
use Closure;
interface Container {
/**
* Determine if the given abstract type has been bound.
*
* @param string $abstract
* @return bool
*/
public function bound($abstract);
/**
* Alias a type to a different name.
*
* @param string $abstract
* @param string $alias
* @return void
*/
public function alias($abstract, $alias);
/**
* Assign a set of tags to a given binding.
*
* @param array|string $abstracts
* @param array|mixed ...$tags
* @return void
*/
public function tag($abstracts, $tags);
/**
* Resolve all of the bindings for a given tag.
*
* @param array $tag
* @return array
*/
public function tagged($tag);
/**
* Register a binding with the container.
*
* @param string|array $abstract
* @param \Closure|string|null $concrete
* @param bool $shared
* @return void
*/
public function bind($abstract, $concrete = null, $shared = false);
/**
* Register a binding if it hasn't already been registered.
*
* @param string $abstract
* @param \Closure|string|null $concrete
* @param bool $shared
* @return void
*/
public function bindIf($abstract, $concrete = null, $shared = false);
/**
* Register a shared binding in the container.
*
* @param string $abstract
* @param \Closure|string|null $concrete
* @return void
*/
public function singleton($abstract, $concrete = null);
/**
* "Extend" an abstract type in the container.
*
* @param string $abstract
* @param \Closure $closure
* @return void
*
* @throws \InvalidArgumentException
*/
public function extend($abstract, Closure $closure);
/**
* Register an existing instance as shared in the container.
*
* @param string $abstract
* @param mixed $instance
* @return void
*/
public function instance($abstract, $instance);
/**
* Define a contextual binding.
*
* @param string $concrete
* @return \Illuminate\Contracts\Container\ContextualBindingBuilder
*/
public function when($concrete);
/**
* Resolve the given type from the container.
*
* @param string $abstract
* @param array $parameters
* @return mixed
*/
public function make($abstract, $parameters = array());
/**
* Call the given Closure / class@method and inject its dependencies.
*
* @param callable|string $callback
* @param array $parameters
* @param string|null $defaultMethod
* @return mixed
*/
public function call($callback, array $parameters = array(), $defaultMethod = null);
/**
* Determine if the given abstract type has been resolved.
*
* @param string $abstract
* @return bool
*/
public function resolved($abstract);
/**
* Register a new resolving callback.
*
* @param string $abstract
* @param \Closure $callback
* @return void
*/
public function resolving($abstract, Closure $callback = null);
/**
* Register a new after resolving callback.
*
* @param string $abstract
* @param \Closure $callback
* @return void
*/
public function afterResolving($abstract, Closure $callback = null);
}

View File

@ -0,0 +1,21 @@
<?php namespace Illuminate\Contracts\Container;
interface ContextualBindingBuilder {
/**
* Define the abstract target that depends on the context.
*
* @param string $abstract
* @return $this
*/
public function needs($abstract);
/**
* Define the implementation for the contextual binding.
*
* @param \Closure|string $implementation
* @return void
*/
public function give($implementation);
}

View File

@ -0,0 +1,42 @@
<?php namespace Illuminate\Contracts\Cookie;
interface Factory {
/**
* Create a new cookie instance.
*
* @param string $name
* @param string $value
* @param int $minutes
* @param string $path
* @param string $domain
* @param bool $secure
* @param bool $httpOnly
* @return \Symfony\Component\HttpFoundation\Cookie
*/
public function make($name, $value, $minutes = 0, $path = null, $domain = null, $secure = false, $httpOnly = true);
/**
* Create a cookie that lasts "forever" (five years).
*
* @param string $name
* @param string $value
* @param string $path
* @param string $domain
* @param bool $secure
* @param bool $httpOnly
* @return \Symfony\Component\HttpFoundation\Cookie
*/
public function forever($name, $value, $path = null, $domain = null, $secure = false, $httpOnly = true);
/**
* Expire the given cookie.
*
* @param string $name
* @param string $path
* @param string $domain
* @return \Symfony\Component\HttpFoundation\Cookie
*/
public function forget($name, $path = null, $domain = null);
}

View File

@ -0,0 +1,27 @@
<?php namespace Illuminate\Contracts\Cookie;
interface QueueingFactory extends Factory {
/**
* Queue a cookie to send with the next response.
*
* @param mixed
* @return void
*/
public function queue();
/**
* Remove a cookie from the queue.
*
* @param string $name
*/
public function unqueue($name);
/**
* Get the cookies which have been queued for the next request
*
* @return array
*/
public function getQueuedCookies();
}

View File

@ -0,0 +1,32 @@
<?php namespace Illuminate\Contracts\Database;
class ModelIdentifier {
/**
* The class name of the model.
*
* @var string
*/
public $class;
/**
* The unique identifier of the model.
*
* @var mixed
*/
public $id;
/**
* Create a new model identifier.
*
* @param string $class
* @param mixed $id
* @return void
*/
public function __construct($class, $id)
{
$this->id = $id;
$this->class = $class;
}
}

View File

@ -0,0 +1,33 @@
<?php namespace Illuminate\Contracts\Debug;
use Exception;
interface ExceptionHandler {
/**
* Report or log an exception.
*
* @param \Exception $e
* @return void
*/
public function report(Exception $e);
/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $e
* @return \Symfony\Component\HttpFoundation\Response
*/
public function render($request, Exception $e);
/**
* Render an exception to the console.
*
* @param \Symfony\Component\Console\Output\OutputInterface $output
* @param \Exception $e
* @return void
*/
public function renderForConsole($output, Exception $e);
}

View File

@ -0,0 +1,5 @@
<?php namespace Illuminate\Contracts\Encryption;
use RuntimeException;
class DecryptException extends RuntimeException {}

View File

@ -0,0 +1,37 @@
<?php namespace Illuminate\Contracts\Encryption;
interface Encrypter {
/**
* Encrypt the given value.
*
* @param string $value
* @return string
*/
public function encrypt($value);
/**
* Decrypt the given value.
*
* @param string $payload
* @return string
*/
public function decrypt($payload);
/**
* Set the encryption mode.
*
* @param string $mode
* @return void
*/
public function setMode($mode);
/**
* Set the encryption cipher.
*
* @param string $cipher
* @return void
*/
public function setCipher($cipher);
}

View File

@ -0,0 +1,64 @@
<?php namespace Illuminate\Contracts\Events;
interface Dispatcher {
/**
* Register an event listener with the dispatcher.
*
* @param string|array $events
* @param mixed $listener
* @param int $priority
* @return void
*/
public function listen($events, $listener, $priority = 0);
/**
* Determine if a given event has listeners.
*
* @param string $eventName
* @return bool
*/
public function hasListeners($eventName);
/**
* Fire an event until the first non-null response is returned.
*
* @param string $event
* @param array $payload
* @return mixed
*/
public function until($event, $payload = array());
/**
* Fire an event and call the listeners.
*
* @param string|object $event
* @param mixed $payload
* @param bool $halt
* @return array|null
*/
public function fire($event, $payload = array(), $halt = false);
/**
* Get the event that is currently firing.
*
* @return string
*/
public function firing();
/**
* Remove a set of listeners from the dispatcher.
*
* @param string $event
* @return void
*/
public function forget($event);
/**
* Forget all of the queued listeners.
*
* @return void
*/
public function forgetPushed();
}

View File

@ -0,0 +1,3 @@
<?php namespace Illuminate\Contracts\Filesystem;
interface Cloud extends Filesystem {}

View File

@ -0,0 +1,13 @@
<?php namespace Illuminate\Contracts\Filesystem;
interface Factory {
/**
* Get a filesystem implementation.
*
* @param string $name
* @return \Illuminate\Contracts\Filesystem\Filesystem
*/
public function disk($name = null);
}

View File

@ -0,0 +1,5 @@
<?php namespace Illuminate\Contracts\Filesystem;
use Exception;
class FileNotFoundException extends Exception {}

View File

@ -0,0 +1,174 @@
<?php namespace Illuminate\Contracts\Filesystem;
interface Filesystem {
/**
* The public visibility setting.
*
* @var string
*/
const VISIBILITY_PUBLIC = 'public';
/**
* The private visibility setting.
*
* @var string
*/
const VISIBILITY_PRIVATE = 'private';
/**
* Determine if a file exists.
*
* @param string $path
* @return bool
*/
public function exists($path);
/**
* Get the contents of a file.
*
* @param string $path
* @return string
*
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
*/
public function get($path);
/**
* Write the contents of a file.
*
* @param string $path
* @param string $contents
* @param string $visibility
* @return bool
*/
public function put($path, $contents, $visibility = null);
/**
* Get the visibility for the given path.
*
* @param string $path
* @return string
*/
public function getVisibility($path);
/**
* Set the visibility for the given path.
*
* @param string $path
* @param string $visibility
* @return void
*/
public function setVisibility($path, $visibility);
/**
* Prepend to a file.
*
* @param string $path
* @param string $data
* @return int
*/
public function prepend($path, $data);
/**
* Append to a file.
*
* @param string $path
* @param string $data
* @return int
*/
public function append($path, $data);
/**
* Delete the file at a given path.
*
* @param string|array $paths
* @return bool
*/
public function delete($paths);
/**
* Copy a file to a new location.
*
* @param string $from
* @param string $to
* @return bool
*/
public function copy($from, $to);
/**
* Move a file to a new location.
*
* @param string $from
* @param string $to
* @return bool
*/
public function move($from, $to);
/**
* Get the file size of a given file.
*
* @param string $path
* @return int
*/
public function size($path);
/**
* Get the file's last modification time.
*
* @param string $path
* @return int
*/
public function lastModified($path);
/**
* Get an array of all files in a directory.
*
* @param string|null $directory
* @param bool $recursive
* @return array
*/
public function files($directory = null, $recursive = false);
/**
* Get all of the files from the given directory (recursive).
*
* @param string|null $directory
* @return array
*/
public function allFiles($directory = null);
/**
* Get all of the directories within a given directory.
*
* @param string|null $directory
* @param bool $recursive
* @return array
*/
public function directories($directory = null, $recursive = false);
/**
* Get all (recursive) of the directories within a given directory.
*
* @param string|null $directory
* @return array
*/
public function allDirectories($directory = null);
/**
* Create a directory.
*
* @param string $path
* @return bool
*/
public function makeDirectory($path);
/**
* Recursively delete a directory.
*
* @param string $directory
* @return bool
*/
public function deleteDirectory($directory);
}

View File

@ -0,0 +1,78 @@
<?php namespace Illuminate\Contracts\Foundation;
use Illuminate\Contracts\Container\Container;
interface Application extends Container {
/**
* Get the version number of the application.
*
* @return string
*/
public function version();
/**
* Get or check the current application environment.
*
* @param mixed
* @return string
*/
public function environment();
/**
* Determine if the application is currently down for maintenance.
*
* @return bool
*/
public function isDownForMaintenance();
/**
* Register all of the configured providers.
*
* @return void
*/
public function registerConfiguredProviders();
/**
* Register a service provider with the application.
*
* @param \Illuminate\Support\ServiceProvider|string $provider
* @param array $options
* @param bool $force
* @return \Illuminate\Support\ServiceProvider
*/
public function register($provider, $options = array(), $force = false);
/**
* Register a deferred provider and service.
*
* @param string $provider
* @param string $service
* @return void
*/
public function registerDeferredProvider($provider, $service = null);
/**
* Boot the application's service providers.
*
* @return void
*/
public function boot();
/**
* Register a new boot listener.
*
* @param mixed $callback
* @return void
*/
public function booting($callback);
/**
* Register a new "booted" listener.
*
* @param mixed $callback
* @return void
*/
public function booted($callback);
}

View File

@ -0,0 +1,33 @@
<?php namespace Illuminate\Contracts\Hashing;
interface Hasher {
/**
* Hash the given value.
*
* @param string $value
* @param array $options
* @return string
*/
public function make($value, array $options = array());
/**
* Check the given plain value against a hash.
*
* @param string $value
* @param string $hashedValue
* @param array $options
* @return bool
*/
public function check($value, $hashedValue, array $options = array());
/**
* Check if the given hash has been hashed using the given options.
*
* @param string $hashedValue
* @param array $options
* @return bool
*/
public function needsRehash($hashedValue, array $options = array());
}

36
vendor/illuminate/contracts/Http/Kernel.php vendored Executable file
View File

@ -0,0 +1,36 @@
<?php namespace Illuminate\Contracts\Http;
interface Kernel {
/**
* Bootstrap the application for HTTP requests.
*
* @return void
*/
public function bootstrap();
/**
* Handle an incoming HTTP request.
*
* @param \Symfony\Component\HttpFoundation\Request $request
* @return \Symfony\Component\HttpFoundation\Response
*/
public function handle($request);
/**
* Perform any final actions for the request lifecycle.
*
* @param \Symfony\Component\HttpFoundation\Request $request
* @param \Symfony\Component\HttpFoundation\Response $response
* @return void
*/
public function terminate($request, $response);
/**
* Get the Laravel application instance.
*
* @return \Illuminate\Contracts\Foundation\Application
*/
public function getApplication();
}

97
vendor/illuminate/contracts/Logging/Log.php vendored Executable file
View File

@ -0,0 +1,97 @@
<?php namespace Illuminate\Contracts\Logging;
interface Log {
/**
* Log an alert message to the logs.
*
* @param string $message
* @param array $context
* @return void
*/
public function alert($message, array $context = array());
/**
* Log a critical message to the logs.
*
* @param string $message
* @param array $context
* @return void
*/
public function critical($message, array $context = array());
/**
* Log an error message to the logs.
*
* @param string $message
* @param array $context
* @return void
*/
public function error($message, array $context = array());
/**
* Log a warning message to the logs.
*
* @param string $message
* @param array $context
* @return void
*/
public function warning($message, array $context = array());
/**
* Log a notice to the logs.
*
* @param string $message
* @param array $context
* @return void
*/
public function notice($message, array $context = array());
/**
* Log an informational message to the logs.
*
* @param string $message
* @param array $context
* @return void
*/
public function info($message, array $context = array());
/**
* Log a debug message to the logs.
*
* @param string $message
* @param array $context
* @return void
*/
public function debug($message, array $context = array());
/**
* Log a message to the logs.
*
* @param string $level
* @param string $message
* @param array $context
* @return void
*/
public function log($level, $message, array $context = array());
/**
* Register a file log handler.
*
* @param string $path
* @param string $level
* @return void
*/
public function useFiles($path, $level = 'debug');
/**
* Register a daily file log handler.
*
* @param string $path
* @param int $days
* @param string $level
* @return void
*/
public function useDailyFiles($path, $days = 0, $level = 'debug');
}

View File

@ -0,0 +1,28 @@
<?php namespace Illuminate\Contracts\Mail;
interface MailQueue {
/**
* Queue a new e-mail message for sending.
*
* @param string|array $view
* @param array $data
* @param \Closure|string $callback
* @param string $queue
* @return mixed
*/
public function queue($view, array $data, $callback, $queue = null);
/**
* Queue a new e-mail message for sending after (n) seconds.
*
* @param int $delay
* @param string|array $view
* @param array $data
* @param \Closure|string $callback
* @param string $queue
* @return mixed
*/
public function later($delay, $view, array $data, $callback, $queue = null);
}

31
vendor/illuminate/contracts/Mail/Mailer.php vendored Executable file
View File

@ -0,0 +1,31 @@
<?php namespace Illuminate\Contracts\Mail;
interface Mailer {
/**
* Send a new message when only a raw text part.
*
* @param string $text
* @param \Closure|string $callback
* @return int
*/
public function raw($text, $callback);
/**
* Send a new message using a view.
*
* @param string|array $view
* @param array $data
* @param \Closure|string $callback
* @return void
*/
public function send($view, array $data, $callback);
/**
* Get the array of failed recipients.
*
* @return array
*/
public function failures();
}

View File

@ -0,0 +1,19 @@
<?php namespace Illuminate\Contracts\Pagination;
interface LengthAwarePaginator extends Paginator {
/**
* Determine the total number of items in the data store.
*
* @return int
*/
public function total();
/**
* Get the page number of the last available page.
*
* @return int
*/
public function lastPage();
}

View File

@ -0,0 +1,108 @@
<?php namespace Illuminate\Contracts\Pagination;
interface Paginator {
/**
* Get the URL for a given page.
*
* @param int $page
* @return string
*/
public function url($page);
/**
* Add a set of query string values to the paginator.
*
* @param array|string $key
* @param string|null $value
* @return $this
*/
public function appends($key, $value = null);
/**
* Get / set the URL fragment to be appended to URLs.
*
* @param string|null $fragment
* @return $this|string
*/
public function fragment($fragment = null);
/**
* The the URL for the next page, or null.
*
* @return string|null
*/
public function nextPageUrl();
/**
* Get the URL for the previous page, or null.
*
* @return string|null
*/
public function previousPageUrl();
/**
* Get all of the items being paginated.
*
* @return array
*/
public function items();
/**
* Get the "index" of the first item being paginated.
*
* @return int
*/
public function firstItem();
/**
* Get the "index" of the last item being paginated.
*
* @return int
*/
public function lastItem();
/**
* Determine how many items are being shown per page.
*
* @return int
*/
public function perPage();
/**
* Determine the current page being paginated.
*
* @return int
*/
public function currentPage();
/**
* Determine if there are enough items to split into multiple pages.
*
* @return bool
*/
public function hasPages();
/**
* Determine if there is more items in the data store.
*
* @return bool
*/
public function hasMorePages();
/**
* Determine if the list of items is empty or not.
*
* @return bool
*/
public function isEmpty();
/**
* Render the paginator using a given Presenter.
*
* @param \Illuminate\Contracts\Pagination\Presenter|null $presenter
* @return string
*/
public function render(Presenter $presenter = null);
}

View File

@ -0,0 +1,19 @@
<?php namespace Illuminate\Contracts\Pagination;
interface Presenter {
/**
* Render the given paginator.
*
* @return string
*/
public function render();
/**
* Determine if the underlying paginator being presented has pages to show.
*
* @return bool
*/
public function hasPages();
}

14
vendor/illuminate/contracts/Pipeline/Hub.php vendored Executable file
View File

@ -0,0 +1,14 @@
<?php namespace Illuminate\Contracts\Pipeline;
interface Hub {
/**
* Send an object through one of the available pipelines.
*
* @param mixed $object
* @param string|null $pipeline
* @return mixed
*/
public function pipe($object, $pipeline = null);
}

View File

@ -0,0 +1,39 @@
<?php namespace Illuminate\Contracts\Pipeline;
use Closure;
interface Pipeline {
/**
* Set the traveler object being sent on the pipeline.
*
* @param mixed $traveler
* @return $this
*/
public function send($traveler);
/**
* Set the stops of the pipeline.
*
* @param dynamic|array $stops
* @return $this
*/
public function through($stops);
/**
* Set the method to call on the stops.
*
* @param string $method
* @return $this
*/
public function via($method);
/**
* Run the pipeline with a final destination callback.
*
* @param \Closure $destination
* @return mixed
*/
public function then(Closure $destination);
}

View File

@ -0,0 +1,21 @@
<?php namespace Illuminate\Contracts\Queue;
use InvalidArgumentException;
class EntityNotFoundException extends InvalidArgumentException {
/**
* Create a new exception instance.
*
* @param string $type
* @param mixed $id
* @return void
*/
public function __construct($type, $id)
{
$id = (string) $id;
parent::__construct("Queueable entity [{$type}] not found for ID [{$id}].");
}
}

View File

@ -0,0 +1,14 @@
<?php namespace Illuminate\Contracts\Queue;
interface EntityResolver {
/**
* Resolve the entity for the given ID.
*
* @param string $type
* @param mixed $id
* @return mixed
*/
public function resolve($type, $id);
}

13
vendor/illuminate/contracts/Queue/Factory.php vendored Executable file
View File

@ -0,0 +1,13 @@
<?php namespace Illuminate\Contracts\Queue;
interface Factory {
/**
* Resolve a queue connection instance.
*
* @param string $name
* @return \Illuminate\Contracts\Queue\Queue
*/
public function connection($name = null);
}

48
vendor/illuminate/contracts/Queue/Job.php vendored Executable file
View File

@ -0,0 +1,48 @@
<?php namespace Illuminate\Contracts\Queue;
interface Job {
/**
* Fire the job.
*
* @return void
*/
public function fire();
/**
* Delete the job from the queue.
*
* @return void
*/
public function delete();
/**
* Release the job back into the queue.
*
* @param int $delay
* @return void
*/
public function release($delay = 0);
/**
* Get the number of times the job has been attempted.
*
* @return int
*/
public function attempts();
/**
* Get the name of the queued job class.
*
* @return string
*/
public function getName();
/**
* Get the name of the queue the job belongs to.
*
* @return string
*/
public function getQueue();
}

29
vendor/illuminate/contracts/Queue/Monitor.php vendored Executable file
View File

@ -0,0 +1,29 @@
<?php namespace Illuminate\Contracts\Queue;
interface Monitor {
/**
* Register a callback to be executed on every iteration through the queue loop.
*
* @param mixed $callback
* @return void
*/
public function looping($callback);
/**
* Register a callback to be executed when a job fails after the maximum amount of retries.
*
* @param mixed $callback
* @return void
*/
public function failing($callback);
/**
* Register a callback to be executed when a daemon queue is stopping.
*
* @param mixed $callback
* @return void
*/
public function stopping($callback);
}

65
vendor/illuminate/contracts/Queue/Queue.php vendored Executable file
View File

@ -0,0 +1,65 @@
<?php namespace Illuminate\Contracts\Queue;
interface Queue {
/**
* Push a new job onto the queue.
*
* @param string $job
* @param mixed $data
* @param string $queue
* @return mixed
*/
public function push($job, $data = '', $queue = null);
/**
* Push a raw payload onto the queue.
*
* @param string $payload
* @param string $queue
* @param array $options
* @return mixed
*/
public function pushRaw($payload, $queue = null, array $options = array());
/**
* Push a new job onto the queue after a delay.
*
* @param \DateTime|int $delay
* @param string $job
* @param mixed $data
* @param string $queue
* @return mixed
*/
public function later($delay, $job, $data = '', $queue = null);
/**
* Push a new job onto the queue.
*
* @param string $queue
* @param string $job
* @param mixed $data
* @return mixed
*/
public function pushOn($queue, $job, $data = '');
/**
* Push a new job onto the queue after a delay.
*
* @param string $queue
* @param \DateTime|int $delay
* @param string $job
* @param mixed $data
* @return mixed
*/
public function laterOn($queue, $delay, $job, $data = '');
/**
* Pop the next job off of the queue.
*
* @param string $queue
* @return \Illuminate\Contracts\Queue\Job|null
*/
public function pop($queue = null);
}

View File

@ -0,0 +1,12 @@
<?php namespace Illuminate\Contracts\Queue;
interface QueueableEntity {
/**
* Get the queueable identity for the entity.
*
* @return mixed
*/
public function getQueueableId();
}

View File

@ -0,0 +1,3 @@
<?php namespace Illuminate\Contracts\Queue;
interface ShouldBeQueued {}

View File

@ -0,0 +1,14 @@
<?php namespace Illuminate\Contracts\Redis;
interface Database {
/**
* Run a command against the Redis database.
*
* @param string $method
* @param array $parameters
* @return mixed
*/
public function command($method, array $parameters = array());
}

View File

@ -0,0 +1,16 @@
<?php namespace Illuminate\Contracts\Routing;
use Closure;
interface Middleware {
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next);
}

View File

@ -0,0 +1,115 @@
<?php namespace Illuminate\Contracts\Routing;
use Closure;
interface Registrar {
/**
* Register a new GET route with the router.
*
* @param string $uri
* @param \Closure|array|string $action
* @return void
*/
public function get($uri, $action);
/**
* Register a new POST route with the router.
*
* @param string $uri
* @param \Closure|array|string $action
* @return void
*/
public function post($uri, $action);
/**
* Register a new PUT route with the router.
*
* @param string $uri
* @param \Closure|array|string $action
* @return void
*/
public function put($uri, $action);
/**
* Register a new DELETE route with the router.
*
* @param string $uri
* @param \Closure|array|string $action
* @return void
*/
public function delete($uri, $action);
/**
* Register a new PATCH route with the router.
*
* @param string $uri
* @param \Closure|array|string $action
* @return void
*/
public function patch($uri, $action);
/**
* Register a new OPTIONS route with the router.
*
* @param string $uri
* @param \Closure|array|string $action
* @return void
*/
public function options($uri, $action);
/**
* Register a new route with the given verbs.
*
* @param array|string $methods
* @param string $uri
* @param \Closure|array|string $action
* @return void
*/
public function match($methods, $uri, $action);
/**
* Route a resource to a controller.
*
* @param string $name
* @param string $controller
* @param array $options
* @return void
*/
public function resource($name, $controller, array $options = array());
/**
* Create a route group with shared attributes.
*
* @param array $attributes
* @param \Closure $callback
* @return void
*/
public function group(array $attributes, Closure $callback);
/**
* Register a new "before" filter with the router.
*
* @param string|callable $callback
* @return void
*/
public function before($callback);
/**
* Register a new "after" filter with the router.
*
* @param string|callable $callback
* @return void
*/
public function after($callback);
/**
* Register a new filter with the router.
*
* @param string $name
* @param string|callable $callback
* @return void
*/
public function filter($name, $callback);
}

View File

@ -0,0 +1,125 @@
<?php namespace Illuminate\Contracts\Routing;
interface ResponseFactory {
/**
* Return a new response from the application.
*
* @param string $content
* @param int $status
* @param array $headers
* @return \Symfony\Component\HttpFoundation\Response
*/
public function make($content = '', $status = 200, array $headers = array());
/**
* Return a new view response from the application.
*
* @param string $view
* @param array $data
* @param int $status
* @param array $headers
* @return \Symfony\Component\HttpFoundation\Response
*/
public function view($view, $data = array(), $status = 200, array $headers = array());
/**
* Return a new JSON response from the application.
*
* @param string|array $data
* @param int $status
* @param array $headers
* @param int $options
* @return \Symfony\Component\HttpFoundation\Response
*/
public function json($data = array(), $status = 200, array $headers = array(), $options = 0);
/**
* Return a new JSONP response from the application.
*
* @param string $callback
* @param string|array $data
* @param int $status
* @param array $headers
* @param int $options
* @return \Symfony\Component\HttpFoundation\Response
*/
public function jsonp($callback, $data = array(), $status = 200, array $headers = array(), $options = 0);
/**
* Return a new streamed response from the application.
*
* @param \Closure $callback
* @param int $status
* @param array $headers
* @return \Symfony\Component\HttpFoundation\StreamedResponse
*/
public function stream($callback, $status = 200, array $headers = array());
/**
* Create a new file download response.
*
* @param \SplFileInfo|string $file
* @param string $name
* @param array $headers
* @param null|string $disposition
* @return \Symfony\Component\HttpFoundation\BinaryFileResponse
*/
public function download($file, $name = null, array $headers = array(), $disposition = 'attachment');
/**
* Create a new redirect response to the given path.
*
* @param string $path
* @param int $status
* @param array $headers
* @param bool $secure
* @return \Symfony\Component\HttpFoundation\Response
*/
public function redirectTo($path, $status = 302, $headers = array(), $secure = null);
/**
* Create a new redirect response to a named route.
*
* @param string $route
* @param array $parameters
* @param int $status
* @param array $headers
* @return \Symfony\Component\HttpFoundation\Response
*/
public function redirectToRoute($route, $parameters = array(), $status = 302, $headers = array());
/**
* Create a new redirect response to a controller action.
*
* @param string $action
* @param array $parameters
* @param int $status
* @param array $headers
* @return \Symfony\Component\HttpFoundation\Response
*/
public function redirectToAction($action, $parameters = array(), $status = 302, $headers = array());
/**
* Create a new redirect response, while putting the current URL in the session.
*
* @param string $path
* @param int $status
* @param array $headers
* @param bool $secure
* @return \Symfony\Component\HttpFoundation\Response
*/
public function redirectGuest($path, $status = 302, $headers = array(), $secure = null);
/**
* Create a new redirect response to the previously intended location.
*
* @param string $default
* @param int $status
* @param array $headers
* @param bool $secure
* @return \Symfony\Component\HttpFoundation\Response
*/
public function redirectToIntended($default = '/', $status = 302, $headers = array(), $secure = null);
}

View File

@ -0,0 +1,14 @@
<?php namespace Illuminate\Contracts\Routing;
interface TerminableMiddleware extends Middleware {
/**
* Perform any final actions for the request lifecycle.
*
* @param \Symfony\Component\HttpFoundation\Request $request
* @param \Symfony\Component\HttpFoundation\Response $response
* @return void
*/
public function terminate($request, $response);
}

View File

@ -0,0 +1,63 @@
<?php namespace Illuminate\Contracts\Routing;
interface UrlGenerator {
/**
* Generate a absolute URL to the given path.
*
* @param string $path
* @param mixed $extra
* @param bool $secure
* @return string
*/
public function to($path, $extra = array(), $secure = null);
/**
* Generate a secure, absolute URL to the given path.
*
* @param string $path
* @param array $parameters
* @return string
*/
public function secure($path, $parameters = array());
/**
* Generate a URL to an application asset.
*
* @param string $path
* @param bool $secure
* @return string
*/
public function asset($path, $secure = null);
/**
* Get the URL to a named route.
*
* @param string $name
* @param mixed $parameters
* @param bool $absolute
* @return string
*
* @throws \InvalidArgumentException
*/
public function route($name, $parameters = array(), $absolute = true);
/**
* Get the URL to a controller action.
*
* @param string $action
* @param mixed $parameters
* @param bool $absolute
* @return string
*/
public function action($action, $parameters = array(), $absolute = true);
/**
* Set the root controller namespace.
*
* @param string $rootNamespace
* @return $this
*/
public function setRootControllerNamespace($rootNamespace);
}

View File

@ -0,0 +1,19 @@
<?php namespace Illuminate\Contracts\Routing;
interface UrlRoutable {
/**
* Get the value of the model's route key.
*
* @return mixed
*/
public function getRouteKey();
/**
* Get the route key for the model.
*
* @return string
*/
public function getRouteKeyName();
}

View File

@ -0,0 +1,12 @@
<?php namespace Illuminate\Contracts\Support;
interface Arrayable {
/**
* Get the instance as an array.
*
* @return array
*/
public function toArray();
}

View File

@ -0,0 +1,13 @@
<?php namespace Illuminate\Contracts\Support;
interface Jsonable {
/**
* Convert the object to its JSON representation.
*
* @param int $options
* @return string
*/
public function toJson($options = 0);
}

View File

@ -0,0 +1,99 @@
<?php namespace Illuminate\Contracts\Support;
interface MessageBag {
/**
* Get the keys present in the message bag.
*
* @return array
*/
public function keys();
/**
* Add a message to the bag.
*
* @param string $key
* @param string $message
* @return $this
*/
public function add($key, $message);
/**
* Merge a new array of messages into the bag.
*
* @param \Illuminate\Contracts\Support\MessageProvider|array $messages
* @return $this
*/
public function merge($messages);
/**
* Determine if messages exist for a given key.
*
* @param string $key
* @return bool
*/
public function has($key = null);
/**
* Get the first message from the bag for a given key.
*
* @param string $key
* @param string $format
* @return string
*/
public function first($key = null, $format = null);
/**
* Get all of the messages from the bag for a given key.
*
* @param string $key
* @param string $format
* @return array
*/
public function get($key, $format = null);
/**
* Get all of the messages for every key in the bag.
*
* @param string $format
* @return array
*/
public function all($format = null);
/**
* Get the default message format.
*
* @return string
*/
public function getFormat();
/**
* Set the default message format.
*
* @param string $format
* @return $this
*/
public function setFormat($format = ':message');
/**
* Determine if the message bag has any messages.
*
* @return bool
*/
public function isEmpty();
/**
* Get the number of messages in the container.
*
* @return int
*/
public function count();
/**
* Get the instance as an array.
*
* @return array
*/
public function toArray();
}

View File

@ -0,0 +1,12 @@
<?php namespace Illuminate\Contracts\Support;
interface MessageProvider {
/**
* Get the messages for the instance.
*
* @return \Illuminate\Support\MessageBag
*/
public function getMessageBag();
}

View File

@ -0,0 +1,12 @@
<?php namespace Illuminate\Contracts\Support;
interface Renderable {
/**
* Get the evaluated contents of the object.
*
* @return string
*/
public function render();
}

View File

@ -0,0 +1,45 @@
<?php namespace Illuminate\Contracts\Validation;
interface Factory {
/**
* Create a new Validator instance.
*
* @param array $data
* @param array $rules
* @param array $messages
* @param array $customAttributes
* @return \Illuminate\Contracts\Validation\Validator
*/
public function make(array $data, array $rules, array $messages = array(), array $customAttributes = array());
/**
* Register a custom validator extension.
*
* @param string $rule
* @param \Closure|string $extension
* @param string $message
* @return void
*/
public function extend($rule, $extension, $message = null);
/**
* Register a custom implicit validator extension.
*
* @param string $rule
* @param \Closure|string $extension
* @param string $message
* @return void
*/
public function extendImplicit($rule, $extension, $message = null);
/**
* Register a custom implicit validator message replacer.
*
* @param string $rule
* @param \Closure|string $replacer
* @return void
*/
public function replacer($rule, $replacer);
}

View File

@ -0,0 +1,5 @@
<?php namespace Illuminate\Contracts\Validation;
use RuntimeException;
class UnauthorizedException extends RuntimeException {}

View File

@ -0,0 +1,12 @@
<?php namespace Illuminate\Contracts\Validation;
interface ValidatesWhenResolved {
/**
* Validate the given class instance.
*
* @return void
*/
public function validate();
}

View File

@ -0,0 +1,46 @@
<?php namespace Illuminate\Contracts\Validation;
use RuntimeException;
use Illuminate\Contracts\Support\MessageProvider;
class ValidationException extends RuntimeException {
/**
* The message provider implementation.
*
* @var \Illuminate\Contracts\Support\MessageProvider
*/
protected $provider;
/**
* Create a new validation exception instance.
*
* @param \Illuminate\Contracts\Support\MessageProvider $provider
* @return void
*/
public function __construct(MessageProvider $provider)
{
$this->provider = $provider;
}
/**
* Get the validation error message provider.
*
* @return \Illuminate\Contracts\Support\MessageProvider
*/
public function errors()
{
return $this->provider->getMessageBag();
}
/**
* Get the validation error message provider.
*
* @return \Illuminate\Contracts\Support\MessageProvider
*/
public function getMessageProvider()
{
return $this->provider;
}
}

View File

@ -0,0 +1,39 @@
<?php namespace Illuminate\Contracts\Validation;
use Illuminate\Contracts\Support\MessageProvider;
interface Validator extends MessageProvider {
/**
* Determine if the data fails the validation rules.
*
* @return bool
*/
public function fails();
/**
* Get the failed validation rules.
*
* @return array
*/
public function failed();
/**
* Add conditions to a given field based on a Closure.
*
* @param string $attribute
* @param string|array $rules
* @param callable $callback
* @return void
*/
public function sometimes($attribute, $rules, callable $callback);
/**
* After an after validation callback.
*
* @param callable|string $callback
* @return $this
*/
public function after($callback);
}

70
vendor/illuminate/contracts/View/Factory.php vendored Executable file
View File

@ -0,0 +1,70 @@
<?php namespace Illuminate\Contracts\View;
interface Factory {
/**
* Determine if a given view exists.
*
* @param string $view
* @return bool
*/
public function exists($view);
/**
* Get the evaluated view contents for the given path.
*
* @param string $path
* @param array $data
* @param array $mergeData
* @return \Illuminate\Contracts\View\View
*/
public function file($path, $data = array(), $mergeData = array());
/**
* Get the evaluated view contents for the given view.
*
* @param string $view
* @param array $data
* @param array $mergeData
* @return \Illuminate\Contracts\View\View
*/
public function make($view, $data = array(), $mergeData = array());
/**
* Add a piece of shared data to the environment.
*
* @param string $key
* @param mixed $value
* @return void
*/
public function share($key, $value = null);
/**
* Register a view composer event.
*
* @param array|string $views
* @param \Closure|string $callback
* @param int|null $priority
* @return array
*/
public function composer($views, $callback, $priority = null);
/**
* Register a view creator event.
*
* @param array|string $views
* @param \Closure|string $callback
* @return array
*/
public function creator($views, $callback);
/**
* Add a new namespace to the loader.
*
* @param string $namespace
* @param string|array $hints
* @return void
*/
public function addNamespace($namespace, $hints);
}

23
vendor/illuminate/contracts/View/View.php vendored Executable file
View File

@ -0,0 +1,23 @@
<?php namespace Illuminate\Contracts\View;
use Illuminate\Contracts\Support\Renderable;
interface View extends Renderable {
/**
* Get the name of the view.
*
* @return string
*/
public function name();
/**
* Add a piece of data to the view.
*
* @param string|array $key
* @param mixed $value
* @return $this
*/
public function with($key, $value = null);
}

25
vendor/illuminate/contracts/composer.json vendored Executable file
View File

@ -0,0 +1,25 @@
{
"name": "illuminate/contracts",
"description": "The Illuminate Contracts package.",
"license": "MIT",
"authors": [
{
"name": "Taylor Otwell",
"email": "taylorotwell@gmail.com"
}
],
"require": {
"php": ">=5.4.0"
},
"autoload": {
"psr-4": {
"Illuminate\\Contracts\\": ""
}
},
"extra": {
"branch-alias": {
"dev-master": "5.0-dev"
}
},
"minimum-stability": "dev"
}

202
vendor/illuminate/database/Capsule/Manager.php vendored Executable file
View File

@ -0,0 +1,202 @@
<?php namespace Illuminate\Database\Capsule;
use PDO;
use Illuminate\Container\Container;
use Illuminate\Database\DatabaseManager;
use Illuminate\Contracts\Events\Dispatcher;
use Illuminate\Database\Eloquent\Model as Eloquent;
use Illuminate\Database\Connectors\ConnectionFactory;
use Illuminate\Support\Traits\CapsuleManagerTrait;
class Manager {
use CapsuleManagerTrait;
/**
* The database manager instance.
*
* @var \Illuminate\Database\DatabaseManager
*/
protected $manager;
/**
* Create a new database capsule manager.
*
* @param \Illuminate\Container\Container|null $container
* @return void
*/
public function __construct(Container $container = null)
{
$this->setupContainer($container ?: new Container);
// Once we have the container setup, we will setup the default configuration
// options in the container "config" binding. This will make the database
// manager behave correctly since all the correct binding are in place.
$this->setupDefaultConfiguration();
$this->setupManager();
}
/**
* Setup the default database configuration options.
*
* @return void
*/
protected function setupDefaultConfiguration()
{
$this->container['config']['database.fetch'] = PDO::FETCH_ASSOC;
$this->container['config']['database.default'] = 'default';
}
/**
* Build the database manager instance.
*
* @return void
*/
protected function setupManager()
{
$factory = new ConnectionFactory($this->container);
$this->manager = new DatabaseManager($this->container, $factory);
}
/**
* Get a connection instance from the global manager.
*
* @param string $connection
* @return \Illuminate\Database\Connection
*/
public static function connection($connection = null)
{
return static::$instance->getConnection($connection);
}
/**
* Get a fluent query builder instance.
*
* @param string $table
* @param string $connection
* @return \Illuminate\Database\Query\Builder
*/
public static function table($table, $connection = null)
{
return static::$instance->connection($connection)->table($table);
}
/**
* Get a schema builder instance.
*
* @param string $connection
* @return \Illuminate\Database\Schema\Builder
*/
public static function schema($connection = null)
{
return static::$instance->connection($connection)->getSchemaBuilder();
}
/**
* Get a registered connection instance.
*
* @param string $name
* @return \Illuminate\Database\Connection
*/
public function getConnection($name = null)
{
return $this->manager->connection($name);
}
/**
* Register a connection with the manager.
*
* @param array $config
* @param string $name
* @return void
*/
public function addConnection(array $config, $name = 'default')
{
$connections = $this->container['config']['database.connections'];
$connections[$name] = $config;
$this->container['config']['database.connections'] = $connections;
}
/**
* Bootstrap Eloquent so it is ready for usage.
*
* @return void
*/
public function bootEloquent()
{
Eloquent::setConnectionResolver($this->manager);
// If we have an event dispatcher instance, we will go ahead and register it
// with the Eloquent ORM, allowing for model callbacks while creating and
// updating "model" instances; however, if it not necessary to operate.
if ($dispatcher = $this->getEventDispatcher())
{
Eloquent::setEventDispatcher($dispatcher);
}
}
/**
* Set the fetch mode for the database connections.
*
* @param int $fetchMode
* @return $this
*/
public function setFetchMode($fetchMode)
{
$this->container['config']['database.fetch'] = $fetchMode;
return $this;
}
/**
* Get the database manager instance.
*
* @return \Illuminate\Database\DatabaseManager
*/
public function getDatabaseManager()
{
return $this->manager;
}
/**
* Get the current event dispatcher instance.
*
* @return \Illuminate\Contracts\Events\Dispatcher
*/
public function getEventDispatcher()
{
if ($this->container->bound('events'))
{
return $this->container['events'];
}
}
/**
* Set the event dispatcher instance to be used by connections.
*
* @param \Illuminate\Contracts\Events\Dispatcher $dispatcher
* @return void
*/
public function setEventDispatcher(Dispatcher $dispatcher)
{
$this->container->instance('events', $dispatcher);
}
/**
* Dynamically pass methods to the default connection.
*
* @param string $method
* @param array $parameters
* @return mixed
*/
public static function __callStatic($method, $parameters)
{
return call_user_func_array(array(static::connection(), $method), $parameters);
}
}

1126
vendor/illuminate/database/Connection.php vendored Executable file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,148 @@
<?php namespace Illuminate\Database;
use Closure;
interface ConnectionInterface {
/**
* Begin a fluent query against a database table.
*
* @param string $table
* @return \Illuminate\Database\Query\Builder
*/
public function table($table);
/**
* Get a new raw query expression.
*
* @param mixed $value
* @return \Illuminate\Database\Query\Expression
*/
public function raw($value);
/**
* Run a select statement and return a single result.
*
* @param string $query
* @param array $bindings
* @return mixed
*/
public function selectOne($query, $bindings = array());
/**
* Run a select statement against the database.
*
* @param string $query
* @param array $bindings
* @return array
*/
public function select($query, $bindings = array());
/**
* Run an insert statement against the database.
*
* @param string $query
* @param array $bindings
* @return bool
*/
public function insert($query, $bindings = array());
/**
* Run an update statement against the database.
*
* @param string $query
* @param array $bindings
* @return int
*/
public function update($query, $bindings = array());
/**
* Run a delete statement against the database.
*
* @param string $query
* @param array $bindings
* @return int
*/
public function delete($query, $bindings = array());
/**
* Execute an SQL statement and return the boolean result.
*
* @param string $query
* @param array $bindings
* @return bool
*/
public function statement($query, $bindings = array());
/**
* Run an SQL statement and get the number of rows affected.
*
* @param string $query
* @param array $bindings
* @return int
*/
public function affectingStatement($query, $bindings = array());
/**
* Run a raw, unprepared query against the PDO connection.
*
* @param string $query
* @return bool
*/
public function unprepared($query);
/**
* Prepare the query bindings for execution.
*
* @param array $bindings
* @return array
*/
public function prepareBindings(array $bindings);
/**
* Execute a Closure within a transaction.
*
* @param \Closure $callback
* @return mixed
*
* @throws \Exception
*/
public function transaction(Closure $callback);
/**
* Start a new database transaction.
*
* @return void
*/
public function beginTransaction();
/**
* Commit the active database transaction.
*
* @return void
*/
public function commit();
/**
* Rollback the active database transaction.
*
* @return void
*/
public function rollBack();
/**
* Get the number of active transactions.
*
* @return int
*/
public function transactionLevel();
/**
* Execute the given callback in "dry run" mode.
*
* @param \Closure $callback
* @return array
*/
public function pretend(Closure $callback);
}

View File

@ -0,0 +1,90 @@
<?php namespace Illuminate\Database;
class ConnectionResolver implements ConnectionResolverInterface {
/**
* All of the registered connections.
*
* @var array
*/
protected $connections = array();
/**
* The default connection name.
*
* @var string
*/
protected $default;
/**
* Create a new connection resolver instance.
*
* @param array $connections
* @return void
*/
public function __construct(array $connections = array())
{
foreach ($connections as $name => $connection)
{
$this->addConnection($name, $connection);
}
}
/**
* Get a database connection instance.
*
* @param string $name
* @return \Illuminate\Database\ConnectionInterface
*/
public function connection($name = null)
{
if (is_null($name)) $name = $this->getDefaultConnection();
return $this->connections[$name];
}
/**
* Add a connection to the resolver.
*
* @param string $name
* @param \Illuminate\Database\ConnectionInterface $connection
* @return void
*/
public function addConnection($name, ConnectionInterface $connection)
{
$this->connections[$name] = $connection;
}
/**
* Check if a connection has been registered.
*
* @param string $name
* @return bool
*/
public function hasConnection($name)
{
return isset($this->connections[$name]);
}
/**
* Get the default connection name.
*
* @return string
*/
public function getDefaultConnection()
{
return $this->default;
}
/**
* Set the default connection name.
*
* @param string $name
* @return void
*/
public function setDefaultConnection($name)
{
$this->default = $name;
}
}

View File

@ -0,0 +1,28 @@
<?php namespace Illuminate\Database;
interface ConnectionResolverInterface {
/**
* Get a database connection instance.
*
* @param string $name
* @return \Illuminate\Database\Connection
*/
public function connection($name = null);
/**
* Get the default connection name.
*
* @return string
*/
public function getDefaultConnection();
/**
* Set the default connection name.
*
* @param string $name
* @return void
*/
public function setDefaultConnection($name);
}

View File

@ -0,0 +1,231 @@
<?php namespace Illuminate\Database\Connectors;
use PDO;
use InvalidArgumentException;
use Illuminate\Database\MySqlConnection;
use Illuminate\Database\SQLiteConnection;
use Illuminate\Database\PostgresConnection;
use Illuminate\Database\SqlServerConnection;
use Illuminate\Contracts\Container\Container;
class ConnectionFactory {
/**
* The IoC container instance.
*
* @var \Illuminate\Contracts\Container\Container
*/
protected $container;
/**
* Create a new connection factory instance.
*
* @param \Illuminate\Contracts\Container\Container $container
* @return void
*/
public function __construct(Container $container)
{
$this->container = $container;
}
/**
* Establish a PDO connection based on the configuration.
*
* @param array $config
* @param string $name
* @return \Illuminate\Database\Connection
*/
public function make(array $config, $name = null)
{
$config = $this->parseConfig($config, $name);
if (isset($config['read']))
{
return $this->createReadWriteConnection($config);
}
return $this->createSingleConnection($config);
}
/**
* Create a single database connection instance.
*
* @param array $config
* @return \Illuminate\Database\Connection
*/
protected function createSingleConnection(array $config)
{
$pdo = $this->createConnector($config)->connect($config);
return $this->createConnection($config['driver'], $pdo, $config['database'], $config['prefix'], $config);
}
/**
* Create a single database connection instance.
*
* @param array $config
* @return \Illuminate\Database\Connection
*/
protected function createReadWriteConnection(array $config)
{
$connection = $this->createSingleConnection($this->getWriteConfig($config));
return $connection->setReadPdo($this->createReadPdo($config));
}
/**
* Create a new PDO instance for reading.
*
* @param array $config
* @return \PDO
*/
protected function createReadPdo(array $config)
{
$readConfig = $this->getReadConfig($config);
return $this->createConnector($readConfig)->connect($readConfig);
}
/**
* Get the read configuration for a read / write connection.
*
* @param array $config
* @return array
*/
protected function getReadConfig(array $config)
{
$readConfig = $this->getReadWriteConfig($config, 'read');
return $this->mergeReadWriteConfig($config, $readConfig);
}
/**
* Get the read configuration for a read / write connection.
*
* @param array $config
* @return array
*/
protected function getWriteConfig(array $config)
{
$writeConfig = $this->getReadWriteConfig($config, 'write');
return $this->mergeReadWriteConfig($config, $writeConfig);
}
/**
* Get a read / write level configuration.
*
* @param array $config
* @param string $type
* @return array
*/
protected function getReadWriteConfig(array $config, $type)
{
if (isset($config[$type][0]))
{
return $config[$type][array_rand($config[$type])];
}
return $config[$type];
}
/**
* Merge a configuration for a read / write connection.
*
* @param array $config
* @param array $merge
* @return array
*/
protected function mergeReadWriteConfig(array $config, array $merge)
{
return array_except(array_merge($config, $merge), array('read', 'write'));
}
/**
* Parse and prepare the database configuration.
*
* @param array $config
* @param string $name
* @return array
*/
protected function parseConfig(array $config, $name)
{
return array_add(array_add($config, 'prefix', ''), 'name', $name);
}
/**
* Create a connector instance based on the configuration.
*
* @param array $config
* @return \Illuminate\Database\Connectors\ConnectorInterface
*
* @throws \InvalidArgumentException
*/
public function createConnector(array $config)
{
if ( ! isset($config['driver']))
{
throw new InvalidArgumentException("A driver must be specified.");
}
if ($this->container->bound($key = "db.connector.{$config['driver']}"))
{
return $this->container->make($key);
}
switch ($config['driver'])
{
case 'mysql':
return new MySqlConnector;
case 'pgsql':
return new PostgresConnector;
case 'sqlite':
return new SQLiteConnector;
case 'sqlsrv':
return new SqlServerConnector;
}
throw new InvalidArgumentException("Unsupported driver [{$config['driver']}]");
}
/**
* Create a new connection instance.
*
* @param string $driver
* @param \PDO $connection
* @param string $database
* @param string $prefix
* @param array $config
* @return \Illuminate\Database\Connection
*
* @throws \InvalidArgumentException
*/
protected function createConnection($driver, PDO $connection, $database, $prefix = '', array $config = array())
{
if ($this->container->bound($key = "db.connection.{$driver}"))
{
return $this->container->make($key, array($connection, $database, $prefix, $config));
}
switch ($driver)
{
case 'mysql':
return new MySqlConnection($connection, $database, $prefix, $config);
case 'pgsql':
return new PostgresConnection($connection, $database, $prefix, $config);
case 'sqlite':
return new SQLiteConnection($connection, $database, $prefix, $config);
case 'sqlsrv':
return new SqlServerConnection($connection, $database, $prefix, $config);
}
throw new InvalidArgumentException("Unsupported driver [$driver]");
}
}

View File

@ -0,0 +1,71 @@
<?php namespace Illuminate\Database\Connectors;
use PDO;
class Connector {
/**
* The default PDO connection options.
*
* @var array
*/
protected $options = array(
PDO::ATTR_CASE => PDO::CASE_NATURAL,
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_ORACLE_NULLS => PDO::NULL_NATURAL,
PDO::ATTR_STRINGIFY_FETCHES => false,
PDO::ATTR_EMULATE_PREPARES => false,
);
/**
* Get the PDO options based on the configuration.
*
* @param array $config
* @return array
*/
public function getOptions(array $config)
{
$options = array_get($config, 'options', array());
return array_diff_key($this->options, $options) + $options;
}
/**
* Create a new PDO connection.
*
* @param string $dsn
* @param array $config
* @param array $options
* @return \PDO
*/
public function createConnection($dsn, array $config, array $options)
{
$username = array_get($config, 'username');
$password = array_get($config, 'password');
return new PDO($dsn, $username, $password, $options);
}
/**
* Get the default PDO connection options.
*
* @return array
*/
public function getDefaultOptions()
{
return $this->options;
}
/**
* Set the default PDO connection options.
*
* @param array $options
* @return void
*/
public function setDefaultOptions(array $options)
{
$this->options = $options;
}
}

View File

@ -0,0 +1,13 @@
<?php namespace Illuminate\Database\Connectors;
interface ConnectorInterface {
/**
* Establish a database connection.
*
* @param array $config
* @return \PDO
*/
public function connect(array $config);
}

View File

@ -0,0 +1,112 @@
<?php namespace Illuminate\Database\Connectors;
class MySqlConnector extends Connector implements ConnectorInterface {
/**
* Establish a database connection.
*
* @param array $config
* @return \PDO
*/
public function connect(array $config)
{
$dsn = $this->getDsn($config);
$options = $this->getOptions($config);
// We need to grab the PDO options that should be used while making the brand
// new connection instance. The PDO options control various aspects of the
// connection's behavior, and some might be specified by the developers.
$connection = $this->createConnection($dsn, $config, $options);
if (isset($config['unix_socket']))
{
$connection->exec("use `{$config['database']}`;");
}
$collation = $config['collation'];
// Next we will set the "names" and "collation" on the clients connections so
// a correct character set will be used by this client. The collation also
// is set on the server but needs to be set here on this client objects.
$charset = $config['charset'];
$names = "set names '$charset'".
( ! is_null($collation) ? " collate '$collation'" : '');
$connection->prepare($names)->execute();
// Next, we will check to see if a timezone has been specified in this config
// and if it has we will issue a statement to modify the timezone with the
// database. Setting this DB timezone is an optional configuration item.
if (isset($config['timezone']))
{
$connection->prepare(
'set time_zone="'.$config['timezone'].'"'
)->execute();
}
// If the "strict" option has been configured for the connection we'll enable
// strict mode on all of these tables. This enforces some extra rules when
// using the MySQL database system and is a quicker way to enforce them.
if (isset($config['strict']) && $config['strict'])
{
$connection->prepare("set session sql_mode='STRICT_ALL_TABLES'")->execute();
}
return $connection;
}
/**
* Create a DSN string from a configuration.
*
* Chooses socket or host/port based on the 'unix_socket' config value.
*
* @param array $config
* @return string
*/
protected function getDsn(array $config)
{
return $this->configHasSocket($config) ? $this->getSocketDsn($config) : $this->getHostDsn($config);
}
/**
* Determine if the given configuration array has a UNIX socket value.
*
* @param array $config
* @return bool
*/
protected function configHasSocket(array $config)
{
return isset($config['unix_socket']) && ! empty($config['unix_socket']);
}
/**
* Get the DSN string for a socket configuration.
*
* @param array $config
* @return string
*/
protected function getSocketDsn(array $config)
{
extract($config);
return "mysql:unix_socket={$config['unix_socket']};dbname={$database}";
}
/**
* Get the DSN string for a host / port configuration.
*
* @param array $config
* @return string
*/
protected function getHostDsn(array $config)
{
extract($config);
return isset($config['port'])
? "mysql:host={$host};port={$port};dbname={$database}"
: "mysql:host={$host};dbname={$database}";
}
}

View File

@ -0,0 +1,96 @@
<?php namespace Illuminate\Database\Connectors;
use PDO;
class PostgresConnector extends Connector implements ConnectorInterface {
/**
* The default PDO connection options.
*
* @var array
*/
protected $options = array(
PDO::ATTR_CASE => PDO::CASE_NATURAL,
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_ORACLE_NULLS => PDO::NULL_NATURAL,
PDO::ATTR_STRINGIFY_FETCHES => false,
);
/**
* Establish a database connection.
*
* @param array $config
* @return \PDO
*/
public function connect(array $config)
{
// First we'll create the basic DSN and connection instance connecting to the
// using the configuration option specified by the developer. We will also
// set the default character set on the connections to UTF-8 by default.
$dsn = $this->getDsn($config);
$options = $this->getOptions($config);
$connection = $this->createConnection($dsn, $config, $options);
$charset = $config['charset'];
$connection->prepare("set names '$charset'")->execute();
// Next, we will check to see if a timezone has been specified in this config
// and if it has we will issue a statement to modify the timezone with the
// database. Setting this DB timezone is an optional configuration item.
if (isset($config['timezone']))
{
$timezone = $config['timezone'];
$connection->prepare("set time zone '$timezone'")->execute();
}
// Unlike MySQL, Postgres allows the concept of "schema" and a default schema
// may have been specified on the connections. If that is the case we will
// set the default schema search paths to the specified database schema.
if (isset($config['schema']))
{
$schema = $config['schema'];
$connection->prepare("set search_path to \"{$schema}\"")->execute();
}
return $connection;
}
/**
* Create a DSN string from a configuration.
*
* @param array $config
* @return string
*/
protected function getDsn(array $config)
{
// First we will create the basic DSN setup as well as the port if it is in
// in the configuration options. This will give us the basic DSN we will
// need to establish the PDO connections and return them back for use.
extract($config);
$host = isset($host) ? "host={$host};" : '';
$dsn = "pgsql:{$host}dbname={$database}";
// If a port was specified, we will add it to this Postgres DSN connections
// format. Once we have done that we are ready to return this connection
// string back out for usage, as this has been fully constructed here.
if (isset($config['port']))
{
$dsn .= ";port={$port}";
}
if (isset($config['sslmode']))
{
$dsn .= ";sslmode={$sslmode}";
}
return $dsn;
}
}

View File

@ -0,0 +1,40 @@
<?php namespace Illuminate\Database\Connectors;
use InvalidArgumentException;
class SQLiteConnector extends Connector implements ConnectorInterface {
/**
* Establish a database connection.
*
* @param array $config
* @return \PDO
*
* @throws \InvalidArgumentException
*/
public function connect(array $config)
{
$options = $this->getOptions($config);
// SQLite supports "in-memory" databases that only last as long as the owning
// connection does. These are useful for tests or for short lifetime store
// querying. In-memory databases may only have a single open connection.
if ($config['database'] == ':memory:')
{
return $this->createConnection('sqlite::memory:', $config, $options);
}
$path = realpath($config['database']);
// Here we'll verify that the SQLite database exists before going any further
// as the developer probably wants to know if the database exists and this
// SQLite driver will not throw any exception if it does not by default.
if ($path === false)
{
throw new InvalidArgumentException("Database does not exist.");
}
return $this->createConnection("sqlite:{$path}", $config, $options);
}
}

View File

@ -0,0 +1,142 @@
<?php namespace Illuminate\Database\Connectors;
use PDO;
class SqlServerConnector extends Connector implements ConnectorInterface {
/**
* The PDO connection options.
*
* @var array
*/
protected $options = array(
PDO::ATTR_CASE => PDO::CASE_NATURAL,
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_ORACLE_NULLS => PDO::NULL_NATURAL,
PDO::ATTR_STRINGIFY_FETCHES => false,
);
/**
* Establish a database connection.
*
* @param array $config
* @return \PDO
*/
public function connect(array $config)
{
$options = $this->getOptions($config);
return $this->createConnection($this->getDsn($config), $config, $options);
}
/**
* Create a DSN string from a configuration.
*
* @param array $config
* @return string
*/
protected function getDsn(array $config)
{
// First we will create the basic DSN setup as well as the port if it is in
// in the configuration options. This will give us the basic DSN we will
// need to establish the PDO connections and return them back for use.
if (in_array('dblib', $this->getAvailableDrivers()))
{
return $this->getDblibDsn($config);
}
else
{
return $this->getSqlSrvDsn($config);
}
}
/**
* Get the DSN string for a DbLib connection.
*
* @param array $config
* @return string
*/
protected function getDblibDsn(array $config)
{
$arguments = array(
'host' => $this->buildHostString($config, ':'),
'dbname' => $config['database']
);
$arguments = array_merge(
$arguments, array_only($config, ['appname', 'charset'])
);
return $this->buildConnectString('dblib', $arguments);
}
/**
* Get the DSN string for a SqlSrv connection.
*
* @param array $config
* @return string
*/
protected function getSqlSrvDsn(array $config)
{
$arguments = array(
'Server' => $this->buildHostString($config, ',')
);
if (isset($config['database'])) {
$arguments['Database'] = $config['database'];
}
if (isset($config['appname'])) {
$arguments['APP'] = $config['appname'];
}
return $this->buildConnectString('sqlsrv', $arguments);
}
/**
* Build a connection string from the given arguments.
*
* @param string $driver
* @param array $arguments
* @return string
*/
protected function buildConnectString($driver, array $arguments)
{
$options = array_map(function($key) use ($arguments)
{
return sprintf("%s=%s", $key, $arguments[$key]);
}, array_keys($arguments));
return $driver.":".implode(';', $options);
}
/**
* Build a host string from the given configuration.
*
* @param array $config
* @param string $separator
* @return string
*/
protected function buildHostString(array $config, $separator)
{
if(isset($config['port']))
{
return $config['host'].$separator.$config['port'];
}
else
{
return $config['host'];
}
}
/**
* Get the available PDO drivers.
*
* @return array
*/
protected function getAvailableDrivers()
{
return PDO::getAvailableDrivers();
}
}

View File

@ -0,0 +1,17 @@
<?php namespace Illuminate\Database\Console\Migrations;
use Illuminate\Console\Command;
class BaseCommand extends Command {
/**
* Get the path to the migration directory.
*
* @return string
*/
protected function getMigrationPath()
{
return $this->laravel->databasePath().'/migrations';
}
}

View File

@ -0,0 +1,69 @@
<?php namespace Illuminate\Database\Console\Migrations;
use Illuminate\Console\Command;
use Symfony\Component\Console\Input\InputOption;
use Illuminate\Database\Migrations\MigrationRepositoryInterface;
class InstallCommand extends Command {
/**
* The console command name.
*
* @var string
*/
protected $name = 'migrate:install';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Create the migration repository';
/**
* The repository instance.
*
* @var \Illuminate\Database\Migrations\MigrationRepositoryInterface
*/
protected $repository;
/**
* Create a new migration install command instance.
*
* @param \Illuminate\Database\Migrations\MigrationRepositoryInterface $repository
* @return void
*/
public function __construct(MigrationRepositoryInterface $repository)
{
parent::__construct();
$this->repository = $repository;
}
/**
* Execute the console command.
*
* @return void
*/
public function fire()
{
$this->repository->setSource($this->input->getOption('database'));
$this->repository->createRepository();
$this->info("Migration table created successfully.");
}
/**
* Get the console command options.
*
* @return array
*/
protected function getOptions()
{
return array(
array('database', null, InputOption::VALUE_OPTIONAL, 'The database connection to use.'),
);
}
}

View File

@ -0,0 +1,129 @@
<?php namespace Illuminate\Database\Console\Migrations;
use Illuminate\Console\ConfirmableTrait;
use Illuminate\Database\Migrations\Migrator;
use Symfony\Component\Console\Input\InputOption;
class MigrateCommand extends BaseCommand {
use ConfirmableTrait;
/**
* The console command name.
*
* @var string
*/
protected $name = 'migrate';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Run the database migrations';
/**
* The migrator instance.
*
* @var \Illuminate\Database\Migrations\Migrator
*/
protected $migrator;
/**
* Create a new migration command instance.
*
* @param \Illuminate\Database\Migrations\Migrator $migrator
* @return void
*/
public function __construct(Migrator $migrator)
{
parent::__construct();
$this->migrator = $migrator;
}
/**
* Execute the console command.
*
* @return void
*/
public function fire()
{
if ( ! $this->confirmToProceed()) return;
$this->prepareDatabase();
// The pretend option can be used for "simulating" the migration and grabbing
// the SQL queries that would fire if the migration were to be run against
// a database for real, which is helpful for double checking migrations.
$pretend = $this->input->getOption('pretend');
// Next, we will check to see if a path option has been defined. If it has
// we will use the path relative to the root of this installation folder
// so that migrations may be run for any path within the applications.
if ( ! is_null($path = $this->input->getOption('path')))
{
$path = $this->laravel->basePath().'/'.$path;
}
else
{
$path = $this->getMigrationPath();
}
$this->migrator->run($path, $pretend);
// Once the migrator has run we will grab the note output and send it out to
// the console screen, since the migrator itself functions without having
// any instances of the OutputInterface contract passed into the class.
foreach ($this->migrator->getNotes() as $note)
{
$this->output->writeln($note);
}
// Finally, if the "seed" option has been given, we will re-run the database
// seed task to re-populate the database, which is convenient when adding
// a migration and a seed at the same time, as it is only this command.
if ($this->input->getOption('seed'))
{
$this->call('db:seed', ['--force' => true]);
}
}
/**
* Prepare the migration database for running.
*
* @return void
*/
protected function prepareDatabase()
{
$this->migrator->setConnection($this->input->getOption('database'));
if ( ! $this->migrator->repositoryExists())
{
$options = array('--database' => $this->input->getOption('database'));
$this->call('migrate:install', $options);
}
}
/**
* Get the console command options.
*
* @return array
*/
protected function getOptions()
{
return array(
array('database', null, InputOption::VALUE_OPTIONAL, 'The database connection to use.'),
array('force', null, InputOption::VALUE_NONE, 'Force the operation to run when in production.'),
array('path', null, InputOption::VALUE_OPTIONAL, 'The path of migrations files to be executed.'),
array('pretend', null, InputOption::VALUE_NONE, 'Dump the SQL queries that would be run.'),
array('seed', null, InputOption::VALUE_NONE, 'Indicates if the seed task should be re-run.'),
);
}
}

View File

@ -0,0 +1,120 @@
<?php namespace Illuminate\Database\Console\Migrations;
use Illuminate\Foundation\Composer;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
use Illuminate\Database\Migrations\MigrationCreator;
class MigrateMakeCommand extends BaseCommand {
/**
* The console command name.
*
* @var string
*/
protected $name = 'make:migration';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Create a new migration file';
/**
* The migration creator instance.
*
* @var \Illuminate\Database\Migrations\MigrationCreator
*/
protected $creator;
/**
* @var \Illuminate\Foundation\Composer
*/
protected $composer;
/**
* Create a new migration install command instance.
*
* @param \Illuminate\Database\Migrations\MigrationCreator $creator
* @param \Illuminate\Foundation\Composer $composer
* @return void
*/
public function __construct(MigrationCreator $creator, Composer $composer)
{
parent::__construct();
$this->creator = $creator;
$this->composer = $composer;
}
/**
* Execute the console command.
*
* @return void
*/
public function fire()
{
// It's possible for the developer to specify the tables to modify in this
// schema operation. The developer may also specify if this table needs
// to be freshly created so we can create the appropriate migrations.
$name = $this->input->getArgument('name');
$table = $this->input->getOption('table');
$create = $this->input->getOption('create');
if ( ! $table && is_string($create)) $table = $create;
// Now we are ready to write the migration out to disk. Once we've written
// the migration out, we will dump-autoload for the entire framework to
// make sure that the migrations are registered by the class loaders.
$this->writeMigration($name, $table, $create);
$this->composer->dumpAutoloads();
}
/**
* Write the migration file to disk.
*
* @param string $name
* @param string $table
* @param bool $create
* @return string
*/
protected function writeMigration($name, $table, $create)
{
$path = $this->getMigrationPath();
$file = pathinfo($this->creator->create($name, $path, $table, $create), PATHINFO_FILENAME);
$this->line("<info>Created Migration:</info> $file");
}
/**
* Get the console command arguments.
*
* @return array
*/
protected function getArguments()
{
return array(
array('name', InputArgument::REQUIRED, 'The name of the migration'),
);
}
/**
* Get the console command options.
*
* @return array
*/
protected function getOptions()
{
return array(
array('create', null, InputOption::VALUE_OPTIONAL, 'The table to be created.'),
array('table', null, InputOption::VALUE_OPTIONAL, 'The table to migrate.'),
);
}
}

View File

@ -0,0 +1,96 @@
<?php namespace Illuminate\Database\Console\Migrations;
use Illuminate\Console\Command;
use Illuminate\Console\ConfirmableTrait;
use Symfony\Component\Console\Input\InputOption;
class RefreshCommand extends Command {
use ConfirmableTrait;
/**
* The console command name.
*
* @var string
*/
protected $name = 'migrate:refresh';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Reset and re-run all migrations';
/**
* Execute the console command.
*
* @return void
*/
public function fire()
{
if ( ! $this->confirmToProceed()) return;
$database = $this->input->getOption('database');
$force = $this->input->getOption('force');
$this->call('migrate:reset', array(
'--database' => $database, '--force' => $force,
));
// The refresh command is essentially just a brief aggregate of a few other of
// the migration commands and just provides a convenient wrapper to execute
// them in succession. We'll also see if we need to re-seed the database.
$this->call('migrate', array(
'--database' => $database, '--force' => $force,
));
if ($this->needsSeeding())
{
$this->runSeeder($database);
}
}
/**
* Determine if the developer has requested database seeding.
*
* @return bool
*/
protected function needsSeeding()
{
return $this->option('seed') || $this->option('seeder');
}
/**
* Run the database seeder command.
*
* @param string $database
* @return void
*/
protected function runSeeder($database)
{
$class = $this->option('seeder') ?: 'DatabaseSeeder';
$this->call('db:seed', array('--database' => $database, '--class' => $class));
}
/**
* Get the console command options.
*
* @return array
*/
protected function getOptions()
{
return array(
array('database', null, InputOption::VALUE_OPTIONAL, 'The database connection to use.'),
array('force', null, InputOption::VALUE_NONE, 'Force the operation to run when in production.'),
array('seed', null, InputOption::VALUE_NONE, 'Indicates if the seed task should be re-run.'),
array('seeder', null, InputOption::VALUE_OPTIONAL, 'The class name of the root seeder.'),
);
}
}

View File

@ -0,0 +1,86 @@
<?php namespace Illuminate\Database\Console\Migrations;
use Illuminate\Console\Command;
use Illuminate\Console\ConfirmableTrait;
use Illuminate\Database\Migrations\Migrator;
use Symfony\Component\Console\Input\InputOption;
class ResetCommand extends Command {
use ConfirmableTrait;
/**
* The console command name.
*
* @var string
*/
protected $name = 'migrate:reset';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Rollback all database migrations';
/**
* The migrator instance.
*
* @var \Illuminate\Database\Migrations\Migrator
*/
protected $migrator;
/**
* Create a new migration rollback command instance.
*
* @param \Illuminate\Database\Migrations\Migrator $migrator
* @return void
*/
public function __construct(Migrator $migrator)
{
parent::__construct();
$this->migrator = $migrator;
}
/**
* Execute the console command.
*
* @return void
*/
public function fire()
{
if ( ! $this->confirmToProceed()) return;
$this->migrator->setConnection($this->input->getOption('database'));
$pretend = $this->input->getOption('pretend');
$this->migrator->reset($pretend);
// Once the migrator has run we will grab the note output and send it out to
// the console screen, since the migrator itself functions without having
// any instances of the OutputInterface contract passed into the class.
foreach ($this->migrator->getNotes() as $note)
{
$this->output->writeln($note);
}
}
/**
* Get the console command options.
*
* @return array
*/
protected function getOptions()
{
return array(
array('database', null, InputOption::VALUE_OPTIONAL, 'The database connection to use.'),
array('force', null, InputOption::VALUE_NONE, 'Force the operation to run when in production.'),
array('pretend', null, InputOption::VALUE_NONE, 'Dump the SQL queries that would be run.'),
);
}
}

View File

@ -0,0 +1,86 @@
<?php namespace Illuminate\Database\Console\Migrations;
use Illuminate\Console\Command;
use Illuminate\Console\ConfirmableTrait;
use Illuminate\Database\Migrations\Migrator;
use Symfony\Component\Console\Input\InputOption;
class RollbackCommand extends Command {
use ConfirmableTrait;
/**
* The console command name.
*
* @var string
*/
protected $name = 'migrate:rollback';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Rollback the last database migration';
/**
* The migrator instance.
*
* @var \Illuminate\Database\Migrations\Migrator
*/
protected $migrator;
/**
* Create a new migration rollback command instance.
*
* @param \Illuminate\Database\Migrations\Migrator $migrator
* @return void
*/
public function __construct(Migrator $migrator)
{
parent::__construct();
$this->migrator = $migrator;
}
/**
* Execute the console command.
*
* @return void
*/
public function fire()
{
if ( ! $this->confirmToProceed()) return;
$this->migrator->setConnection($this->input->getOption('database'));
$pretend = $this->input->getOption('pretend');
$this->migrator->rollback($pretend);
// Once the migrator has run we will grab the note output and send it out to
// the console screen, since the migrator itself functions without having
// any instances of the OutputInterface contract passed into the class.
foreach ($this->migrator->getNotes() as $note)
{
$this->output->writeln($note);
}
}
/**
* Get the console command options.
*
* @return array
*/
protected function getOptions()
{
return array(
array('database', null, InputOption::VALUE_OPTIONAL, 'The database connection to use.'),
array('force', null, InputOption::VALUE_NONE, 'Force the operation to run when in production.'),
array('pretend', null, InputOption::VALUE_NONE, 'Dump the SQL queries that would be run.'),
);
}
}

View File

@ -0,0 +1,82 @@
<?php namespace Illuminate\Database\Console\Migrations;
use Illuminate\Database\Migrations\Migrator;
class StatusCommand extends BaseCommand {
/**
* The console command name.
*
* @var string
*/
protected $name = 'migrate:status';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Show the status of each migration';
/**
* The migrator instance.
*
* @var \Illuminate\Database\Migrations\Migrator
*/
protected $migrator;
/**
* Create a new migration rollback command instance.
*
* @param \Illuminate\Database\Migrations\Migrator $migrator
* @return \Illuminate\Database\Console\Migrations\StatusCommand
*/
public function __construct(Migrator $migrator)
{
parent::__construct();
$this->migrator = $migrator;
}
/**
* Execute the console command.
*
* @return void
*/
public function fire()
{
if ( ! $this->migrator->repositoryExists())
{
return $this->error('No migrations found.');
}
$ran = $this->migrator->getRepository()->getRan();
$migrations = [];
foreach ($this->getAllMigrationFiles() as $migration)
{
$migrations[] = in_array($migration, $ran) ? ['<info>Y</info>', $migration] : ['<fg=red>N</fg=red>', $migration];
}
if (count($migrations) > 0)
{
$this->table(['Ran?', 'Migration'], $migrations);
}
else
{
$this->error('No migrations found');
}
}
/**
* Get all of the migration files.
*
* @return array
*/
protected function getAllMigrationFiles()
{
return $this->migrator->getMigrationFiles($this->getMigrationPath());
}
}

View File

@ -0,0 +1,100 @@
<?php namespace Illuminate\Database\Console;
use Illuminate\Console\Command;
use Illuminate\Console\ConfirmableTrait;
use Symfony\Component\Console\Input\InputOption;
use Illuminate\Database\ConnectionResolverInterface as Resolver;
class SeedCommand extends Command {
use ConfirmableTrait;
/**
* The console command name.
*
* @var string
*/
protected $name = 'db:seed';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Seed the database with records';
/**
* The connection resolver instance.
*
* @var \Illuminate\Database\ConnectionResolverInterface
*/
protected $resolver;
/**
* Create a new database seed command instance.
*
* @param \Illuminate\Database\ConnectionResolverInterface $resolver
* @return void
*/
public function __construct(Resolver $resolver)
{
parent::__construct();
$this->resolver = $resolver;
}
/**
* Execute the console command.
*
* @return void
*/
public function fire()
{
if ( ! $this->confirmToProceed()) return;
$this->resolver->setDefaultConnection($this->getDatabase());
$this->getSeeder()->run();
}
/**
* Get a seeder instance from the container.
*
* @return \Illuminate\Database\Seeder
*/
protected function getSeeder()
{
$class = $this->laravel->make($this->input->getOption('class'));
return $class->setContainer($this->laravel)->setCommand($this);
}
/**
* Get the name of the database connection to use.
*
* @return string
*/
protected function getDatabase()
{
$database = $this->input->getOption('database');
return $database ?: $this->laravel['config']['database.default'];
}
/**
* Get the console command options.
*
* @return array
*/
protected function getOptions()
{
return array(
array('class', null, InputOption::VALUE_OPTIONAL, 'The class name of the root seeder', 'DatabaseSeeder'),
array('database', null, InputOption::VALUE_OPTIONAL, 'The database connection to seed'),
array('force', null, InputOption::VALUE_NONE, 'Force the operation to run when in production.'),
);
}
}

307
vendor/illuminate/database/DatabaseManager.php vendored Executable file
View File

@ -0,0 +1,307 @@
<?php namespace Illuminate\Database;
use Illuminate\Support\Str;
use InvalidArgumentException;
use Illuminate\Database\Connectors\ConnectionFactory;
class DatabaseManager implements ConnectionResolverInterface {
/**
* The application instance.
*
* @var \Illuminate\Foundation\Application
*/
protected $app;
/**
* The database connection factory instance.
*
* @var \Illuminate\Database\Connectors\ConnectionFactory
*/
protected $factory;
/**
* The active connection instances.
*
* @var array
*/
protected $connections = array();
/**
* The custom connection resolvers.
*
* @var array
*/
protected $extensions = array();
/**
* Create a new database manager instance.
*
* @param \Illuminate\Foundation\Application $app
* @param \Illuminate\Database\Connectors\ConnectionFactory $factory
* @return void
*/
public function __construct($app, ConnectionFactory $factory)
{
$this->app = $app;
$this->factory = $factory;
}
/**
* Get a database connection instance.
*
* @param string $name
* @return \Illuminate\Database\Connection
*/
public function connection($name = null)
{
list($name, $type) = $this->parseConnectionName($name);
// If we haven't created this connection, we'll create it based on the config
// provided in the application. Once we've created the connections we will
// set the "fetch mode" for PDO which determines the query return types.
if ( ! isset($this->connections[$name]))
{
$connection = $this->makeConnection($name);
$this->setPdoForType($connection, $type);
$this->connections[$name] = $this->prepare($connection);
}
return $this->connections[$name];
}
/**
* Parse the connection into an array of the name and read / write type.
*
* @param string $name
* @return array
*/
protected function parseConnectionName($name)
{
$name = $name ?: $this->getDefaultConnection();
return Str::endsWith($name, ['::read', '::write'])
? explode('::', $name, 2) : [$name, null];
}
/**
* Disconnect from the given database and remove from local cache.
*
* @param string $name
* @return void
*/
public function purge($name = null)
{
$this->disconnect($name);
unset($this->connections[$name]);
}
/**
* Disconnect from the given database.
*
* @param string $name
* @return void
*/
public function disconnect($name = null)
{
if (isset($this->connections[$name = $name ?: $this->getDefaultConnection()]))
{
$this->connections[$name]->disconnect();
}
}
/**
* Reconnect to the given database.
*
* @param string $name
* @return \Illuminate\Database\Connection
*/
public function reconnect($name = null)
{
$this->disconnect($name = $name ?: $this->getDefaultConnection());
if ( ! isset($this->connections[$name]))
{
return $this->connection($name);
}
return $this->refreshPdoConnections($name);
}
/**
* Refresh the PDO connections on a given connection.
*
* @param string $name
* @return \Illuminate\Database\Connection
*/
protected function refreshPdoConnections($name)
{
$fresh = $this->makeConnection($name);
return $this->connections[$name]
->setPdo($fresh->getPdo())
->setReadPdo($fresh->getReadPdo());
}
/**
* Make the database connection instance.
*
* @param string $name
* @return \Illuminate\Database\Connection
*/
protected function makeConnection($name)
{
$config = $this->getConfig($name);
// First we will check by the connection name to see if an extension has been
// registered specifically for that connection. If it has we will call the
// Closure and pass it the config allowing it to resolve the connection.
if (isset($this->extensions[$name]))
{
return call_user_func($this->extensions[$name], $config, $name);
}
$driver = $config['driver'];
// Next we will check to see if an extension has been registered for a driver
// and will call the Closure if so, which allows us to have a more generic
// resolver for the drivers themselves which applies to all connections.
if (isset($this->extensions[$driver]))
{
return call_user_func($this->extensions[$driver], $config, $name);
}
return $this->factory->make($config, $name);
}
/**
* Prepare the database connection instance.
*
* @param \Illuminate\Database\Connection $connection
* @return \Illuminate\Database\Connection
*/
protected function prepare(Connection $connection)
{
$connection->setFetchMode($this->app['config']['database.fetch']);
if ($this->app->bound('events'))
{
$connection->setEventDispatcher($this->app['events']);
}
// Here we'll set a reconnector callback. This reconnector can be any callable
// so we will set a Closure to reconnect from this manager with the name of
// the connection, which will allow us to reconnect from the connections.
$connection->setReconnector(function($connection)
{
$this->reconnect($connection->getName());
});
return $connection;
}
/**
* Prepare the read write mode for database connection instance.
*
* @param \Illuminate\Database\Connection $connection
* @param string $type
* @return \Illuminate\Database\Connection
*/
protected function setPdoForType(Connection $connection, $type = null)
{
if ($type == 'read')
{
$connection->setPdo($connection->getReadPdo());
}
elseif ($type == 'write')
{
$connection->setReadPdo($connection->getPdo());
}
return $connection;
}
/**
* Get the configuration for a connection.
*
* @param string $name
* @return array
*
* @throws \InvalidArgumentException
*/
protected function getConfig($name)
{
$name = $name ?: $this->getDefaultConnection();
// To get the database connection configuration, we will just pull each of the
// connection configurations and get the configurations for the given name.
// If the configuration doesn't exist, we'll throw an exception and bail.
$connections = $this->app['config']['database.connections'];
if (is_null($config = array_get($connections, $name)))
{
throw new InvalidArgumentException("Database [$name] not configured.");
}
return $config;
}
/**
* Get the default connection name.
*
* @return string
*/
public function getDefaultConnection()
{
return $this->app['config']['database.default'];
}
/**
* Set the default connection name.
*
* @param string $name
* @return void
*/
public function setDefaultConnection($name)
{
$this->app['config']['database.default'] = $name;
}
/**
* Register an extension connection resolver.
*
* @param string $name
* @param callable $resolver
* @return void
*/
public function extend($name, callable $resolver)
{
$this->extensions[$name] = $resolver;
}
/**
* Return all of the created connections.
*
* @return array
*/
public function getConnections()
{
return $this->connections;
}
/**
* Dynamically pass methods to the default connection.
*
* @param string $method
* @param array $parameters
* @return mixed
*/
public function __call($method, $parameters)
{
return call_user_func_array(array($this->connection(), $method), $parameters);
}
}

View File

@ -0,0 +1,61 @@
<?php namespace Illuminate\Database;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\ServiceProvider;
use Illuminate\Database\Eloquent\QueueEntityResolver;
use Illuminate\Database\Connectors\ConnectionFactory;
class DatabaseServiceProvider extends ServiceProvider {
/**
* Bootstrap the application events.
*
* @return void
*/
public function boot()
{
Model::setConnectionResolver($this->app['db']);
Model::setEventDispatcher($this->app['events']);
}
/**
* Register the service provider.
*
* @return void
*/
public function register()
{
$this->registerQueueableEntityResolver();
// The connection factory is used to create the actual connection instances on
// the database. We will inject the factory into the manager so that it may
// make the connections while they are actually needed and not of before.
$this->app->singleton('db.factory', function($app)
{
return new ConnectionFactory($app);
});
// The database manager is used to resolve various connections, since multiple
// connections might be managed. It also implements the connection resolver
// interface which may be used by other components requiring connections.
$this->app->singleton('db', function($app)
{
return new DatabaseManager($app, $app['db.factory']);
});
}
/**
* Register the queueable entity resolver implementation.
*
* @return void
*/
protected function registerQueueableEntityResolver()
{
$this->app->singleton('Illuminate\Contracts\Queue\EntityResolver', function()
{
return new QueueEntityResolver;
});
}
}

View File

@ -0,0 +1,948 @@
<?php namespace Illuminate\Database\Eloquent;
use Closure;
use Illuminate\Pagination\Paginator;
use Illuminate\Database\Query\Expression;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Database\Eloquent\Relations\Relation;
use Illuminate\Database\Query\Builder as QueryBuilder;
class Builder {
/**
* The base query builder instance.
*
* @var \Illuminate\Database\Query\Builder
*/
protected $query;
/**
* The model being queried.
*
* @var \Illuminate\Database\Eloquent\Model
*/
protected $model;
/**
* The relationships that should be eager loaded.
*
* @var array
*/
protected $eagerLoad = array();
/**
* All of the registered builder macros.
*
* @var array
*/
protected $macros = array();
/**
* A replacement for the typical delete function.
*
* @var \Closure
*/
protected $onDelete;
/**
* The methods that should be returned from query builder.
*
* @var array
*/
protected $passthru = array(
'toSql', 'lists', 'insert', 'insertGetId', 'pluck', 'count',
'min', 'max', 'avg', 'sum', 'exists', 'getBindings',
);
/**
* Create a new Eloquent query builder instance.
*
* @param \Illuminate\Database\Query\Builder $query
* @return void
*/
public function __construct(QueryBuilder $query)
{
$this->query = $query;
}
/**
* Find a model by its primary key.
*
* @param mixed $id
* @param array $columns
* @return \Illuminate\Database\Eloquent\Model|\Illuminate\Database\Eloquent\Collection|null
*/
public function find($id, $columns = array('*'))
{
if (is_array($id))
{
return $this->findMany($id, $columns);
}
$this->query->where($this->model->getQualifiedKeyName(), '=', $id);
return $this->first($columns);
}
/**
* Find a model by its primary key.
*
* @param array $ids
* @param array $columns
* @return \Illuminate\Database\Eloquent\Collection
*/
public function findMany($ids, $columns = array('*'))
{
if (empty($ids)) return $this->model->newCollection();
$this->query->whereIn($this->model->getQualifiedKeyName(), $ids);
return $this->get($columns);
}
/**
* Find a model by its primary key or throw an exception.
*
* @param mixed $id
* @param array $columns
* @return \Illuminate\Database\Eloquent\Model|\Illuminate\Database\Eloquent\Collection
*
* @throws \Illuminate\Database\Eloquent\ModelNotFoundException
*/
public function findOrFail($id, $columns = array('*'))
{
$result = $this->find($id, $columns);
if (is_array($id))
{
if (count($result) == count(array_unique($id))) return $result;
}
elseif ( ! is_null($result))
{
return $result;
}
throw (new ModelNotFoundException)->setModel(get_class($this->model));
}
/**
* Execute the query and get the first result.
*
* @param array $columns
* @return \Illuminate\Database\Eloquent\Model|static|null
*/
public function first($columns = array('*'))
{
return $this->take(1)->get($columns)->first();
}
/**
* Execute the query and get the first result or throw an exception.
*
* @param array $columns
* @return \Illuminate\Database\Eloquent\Model|static
*
* @throws \Illuminate\Database\Eloquent\ModelNotFoundException
*/
public function firstOrFail($columns = array('*'))
{
if ( ! is_null($model = $this->first($columns))) return $model;
throw (new ModelNotFoundException)->setModel(get_class($this->model));
}
/**
* Execute the query as a "select" statement.
*
* @param array $columns
* @return \Illuminate\Database\Eloquent\Collection|static[]
*/
public function get($columns = array('*'))
{
$models = $this->getModels($columns);
// If we actually found models we will also eager load any relationships that
// have been specified as needing to be eager loaded, which will solve the
// n+1 query issue for the developers to avoid running a lot of queries.
if (count($models) > 0)
{
$models = $this->eagerLoadRelations($models);
}
return $this->model->newCollection($models);
}
/**
* Pluck a single column from the database.
*
* @param string $column
* @return mixed
*/
public function pluck($column)
{
$result = $this->first(array($column));
if ($result) return $result->{$column};
}
/**
* Chunk the results of the query.
*
* @param int $count
* @param callable $callback
* @return void
*/
public function chunk($count, callable $callback)
{
$results = $this->forPage($page = 1, $count)->get();
while (count($results) > 0)
{
// On each chunk result set, we will pass them to the callback and then let the
// developer take care of everything within the callback, which allows us to
// keep the memory low for spinning through large result sets for working.
call_user_func($callback, $results);
$page++;
$results = $this->forPage($page, $count)->get();
}
}
/**
* Get an array with the values of a given column.
*
* @param string $column
* @param string $key
* @return array
*/
public function lists($column, $key = null)
{
$results = $this->query->lists($column, $key);
// If the model has a mutator for the requested column, we will spin through
// the results and mutate the values so that the mutated version of these
// columns are returned as you would expect from these Eloquent models.
if ($this->model->hasGetMutator($column))
{
foreach ($results as $key => &$value)
{
$fill = array($column => $value);
$value = $this->model->newFromBuilder($fill)->$column;
}
}
return $results;
}
/**
* Paginate the given query.
*
* @param int $perPage
* @param array $columns
* @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
*/
public function paginate($perPage = null, $columns = ['*'])
{
$total = $this->query->getCountForPagination();
$this->query->forPage(
$page = Paginator::resolveCurrentPage(),
$perPage = $perPage ?: $this->model->getPerPage()
);
return new LengthAwarePaginator($this->get($columns), $total, $perPage, $page, [
'path' => Paginator::resolveCurrentPath(),
]);
}
/**
* Paginate the given query into a simple paginator.
*
* @param int $perPage
* @param array $columns
* @return \Illuminate\Contracts\Pagination\Paginator
*/
public function simplePaginate($perPage = null, $columns = ['*'])
{
$page = Paginator::resolveCurrentPage();
$perPage = $perPage ?: $this->model->getPerPage();
$this->skip(($page - 1) * $perPage)->take($perPage + 1);
return new Paginator($this->get($columns), $perPage, $page, [
'path' => Paginator::resolveCurrentPath(),
]);
}
/**
* Update a record in the database.
*
* @param array $values
* @return int
*/
public function update(array $values)
{
return $this->query->update($this->addUpdatedAtColumn($values));
}
/**
* Increment a column's value by a given amount.
*
* @param string $column
* @param int $amount
* @param array $extra
* @return int
*/
public function increment($column, $amount = 1, array $extra = array())
{
$extra = $this->addUpdatedAtColumn($extra);
return $this->query->increment($column, $amount, $extra);
}
/**
* Decrement a column's value by a given amount.
*
* @param string $column
* @param int $amount
* @param array $extra
* @return int
*/
public function decrement($column, $amount = 1, array $extra = array())
{
$extra = $this->addUpdatedAtColumn($extra);
return $this->query->decrement($column, $amount, $extra);
}
/**
* Add the "updated at" column to an array of values.
*
* @param array $values
* @return array
*/
protected function addUpdatedAtColumn(array $values)
{
if ( ! $this->model->usesTimestamps()) return $values;
$column = $this->model->getUpdatedAtColumn();
return array_add($values, $column, $this->model->freshTimestampString());
}
/**
* Delete a record from the database.
*
* @return mixed
*/
public function delete()
{
if (isset($this->onDelete))
{
return call_user_func($this->onDelete, $this);
}
return $this->query->delete();
}
/**
* Run the default delete function on the builder.
*
* @return mixed
*/
public function forceDelete()
{
return $this->query->delete();
}
/**
* Register a replacement for the default delete function.
*
* @param \Closure $callback
* @return void
*/
public function onDelete(Closure $callback)
{
$this->onDelete = $callback;
}
/**
* Get the hydrated models without eager loading.
*
* @param array $columns
* @return \Illuminate\Database\Eloquent\Model[]
*/
public function getModels($columns = array('*'))
{
$results = $this->query->get($columns);
$connection = $this->model->getConnectionName();
return $this->model->hydrate($results, $connection)->all();
}
/**
* Eager load the relationships for the models.
*
* @param array $models
* @return array
*/
public function eagerLoadRelations(array $models)
{
foreach ($this->eagerLoad as $name => $constraints)
{
// For nested eager loads we'll skip loading them here and they will be set as an
// eager load on the query to retrieve the relation so that they will be eager
// loaded on that query, because that is where they get hydrated as models.
if (strpos($name, '.') === false)
{
$models = $this->loadRelation($models, $name, $constraints);
}
}
return $models;
}
/**
* Eagerly load the relationship on a set of models.
*
* @param array $models
* @param string $name
* @param \Closure $constraints
* @return array
*/
protected function loadRelation(array $models, $name, Closure $constraints)
{
// First we will "back up" the existing where conditions on the query so we can
// add our eager constraints. Then we will merge the wheres that were on the
// query back to it in order that any where conditions might be specified.
$relation = $this->getRelation($name);
$relation->addEagerConstraints($models);
call_user_func($constraints, $relation);
$models = $relation->initRelation($models, $name);
// Once we have the results, we just match those back up to their parent models
// using the relationship instance. Then we just return the finished arrays
// of models which have been eagerly hydrated and are readied for return.
$results = $relation->getEager();
return $relation->match($models, $results, $name);
}
/**
* Get the relation instance for the given relation name.
*
* @param string $relation
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function getRelation($relation)
{
// We want to run a relationship query without any constrains so that we will
// not have to remove these where clauses manually which gets really hacky
// and is error prone while we remove the developer's own where clauses.
$query = Relation::noConstraints(function() use ($relation)
{
return $this->getModel()->$relation();
});
$nested = $this->nestedRelations($relation);
// If there are nested relationships set on the query, we will put those onto
// the query instances so that they can be handled after this relationship
// is loaded. In this way they will all trickle down as they are loaded.
if (count($nested) > 0)
{
$query->getQuery()->with($nested);
}
return $query;
}
/**
* Get the deeply nested relations for a given top-level relation.
*
* @param string $relation
* @return array
*/
protected function nestedRelations($relation)
{
$nested = array();
// We are basically looking for any relationships that are nested deeper than
// the given top-level relationship. We will just check for any relations
// that start with the given top relations and adds them to our arrays.
foreach ($this->eagerLoad as $name => $constraints)
{
if ($this->isNested($name, $relation))
{
$nested[substr($name, strlen($relation.'.'))] = $constraints;
}
}
return $nested;
}
/**
* Determine if the relationship is nested.
*
* @param string $name
* @param string $relation
* @return bool
*/
protected function isNested($name, $relation)
{
$dots = str_contains($name, '.');
return $dots && starts_with($name, $relation.'.');
}
/**
* Add a basic where clause to the query.
*
* @param string $column
* @param string $operator
* @param mixed $value
* @param string $boolean
* @return $this
*/
public function where($column, $operator = null, $value = null, $boolean = 'and')
{
if ($column instanceof Closure)
{
$query = $this->model->newQueryWithoutScopes();
call_user_func($column, $query);
$this->query->addNestedWhereQuery($query->getQuery(), $boolean);
}
else
{
call_user_func_array(array($this->query, 'where'), func_get_args());
}
return $this;
}
/**
* Add an "or where" clause to the query.
*
* @param string $column
* @param string $operator
* @param mixed $value
* @return \Illuminate\Database\Eloquent\Builder|static
*/
public function orWhere($column, $operator = null, $value = null)
{
return $this->where($column, $operator, $value, 'or');
}
/**
* Add a relationship count condition to the query.
*
* @param string $relation
* @param string $operator
* @param int $count
* @param string $boolean
* @param \Closure|null $callback
* @return \Illuminate\Database\Eloquent\Builder|static
*/
public function has($relation, $operator = '>=', $count = 1, $boolean = 'and', Closure $callback = null)
{
if (strpos($relation, '.') !== false)
{
return $this->hasNested($relation, $operator, $count, $boolean, $callback);
}
$relation = $this->getHasRelationQuery($relation);
$query = $relation->getRelationCountQuery($relation->getRelated()->newQuery(), $this);
if ($callback) call_user_func($callback, $query);
return $this->addHasWhere($query, $relation, $operator, $count, $boolean);
}
/**
* Add nested relationship count conditions to the query.
*
* @param string $relations
* @param string $operator
* @param int $count
* @param string $boolean
* @param \Closure $callback
* @return \Illuminate\Database\Eloquent\Builder|static
*/
protected function hasNested($relations, $operator = '>=', $count = 1, $boolean = 'and', $callback = null)
{
$relations = explode('.', $relations);
// In order to nest "has", we need to add count relation constraints on the
// callback Closure. We'll do this by simply passing the Closure its own
// reference to itself so it calls itself recursively on each segment.
$closure = function ($q) use (&$closure, &$relations, $operator, $count, $boolean, $callback)
{
if (count($relations) > 1)
{
$q->whereHas(array_shift($relations), $closure);
}
else
{
$q->has(array_shift($relations), $operator, $count, 'and', $callback);
}
};
return $this->has(array_shift($relations), '>=', 1, $boolean, $closure);
}
/**
* Add a relationship count condition to the query.
*
* @param string $relation
* @param string $boolean
* @param \Closure|null $callback
* @return \Illuminate\Database\Eloquent\Builder|static
*/
public function doesntHave($relation, $boolean = 'and', Closure $callback = null)
{
return $this->has($relation, '<', 1, $boolean, $callback);
}
/**
* Add a relationship count condition to the query with where clauses.
*
* @param string $relation
* @param \Closure $callback
* @param string $operator
* @param int $count
* @return \Illuminate\Database\Eloquent\Builder|static
*/
public function whereHas($relation, Closure $callback, $operator = '>=', $count = 1)
{
return $this->has($relation, $operator, $count, 'and', $callback);
}
/**
* Add a relationship count condition to the query with where clauses.
*
* @param string $relation
* @param \Closure|null $callback
* @return \Illuminate\Database\Eloquent\Builder|static
*/
public function whereDoesntHave($relation, Closure $callback = null)
{
return $this->doesntHave($relation, 'and', $callback);
}
/**
* Add a relationship count condition to the query with an "or".
*
* @param string $relation
* @param string $operator
* @param int $count
* @return \Illuminate\Database\Eloquent\Builder|static
*/
public function orHas($relation, $operator = '>=', $count = 1)
{
return $this->has($relation, $operator, $count, 'or');
}
/**
* Add a relationship count condition to the query with where clauses and an "or".
*
* @param string $relation
* @param \Closure $callback
* @param string $operator
* @param int $count
* @return \Illuminate\Database\Eloquent\Builder|static
*/
public function orWhereHas($relation, Closure $callback, $operator = '>=', $count = 1)
{
return $this->has($relation, $operator, $count, 'or', $callback);
}
/**
* Add the "has" condition where clause to the query.
*
* @param \Illuminate\Database\Eloquent\Builder $hasQuery
* @param \Illuminate\Database\Eloquent\Relations\Relation $relation
* @param string $operator
* @param int $count
* @param string $boolean
* @return \Illuminate\Database\Eloquent\Builder
*/
protected function addHasWhere(Builder $hasQuery, Relation $relation, $operator, $count, $boolean)
{
$this->mergeWheresToHas($hasQuery, $relation);
if (is_numeric($count))
{
$count = new Expression($count);
}
return $this->where(new Expression('('.$hasQuery->toSql().')'), $operator, $count, $boolean);
}
/**
* Merge the "wheres" from a relation query to a has query.
*
* @param \Illuminate\Database\Eloquent\Builder $hasQuery
* @param \Illuminate\Database\Eloquent\Relations\Relation $relation
* @return void
*/
protected function mergeWheresToHas(Builder $hasQuery, Relation $relation)
{
// Here we have the "has" query and the original relation. We need to copy over any
// where clauses the developer may have put in the relationship function over to
// the has query, and then copy the bindings from the "has" query to the main.
$relationQuery = $relation->getBaseQuery();
$hasQuery = $hasQuery->getModel()->removeGlobalScopes($hasQuery);
$hasQuery->mergeWheres(
$relationQuery->wheres, $relationQuery->getBindings()
);
$this->query->mergeBindings($hasQuery->getQuery());
}
/**
* Get the "has relation" base query instance.
*
* @param string $relation
* @return \Illuminate\Database\Eloquent\Builder
*/
protected function getHasRelationQuery($relation)
{
return Relation::noConstraints(function() use ($relation)
{
return $this->getModel()->$relation();
});
}
/**
* Set the relationships that should be eager loaded.
*
* @param mixed $relations
* @return $this
*/
public function with($relations)
{
if (is_string($relations)) $relations = func_get_args();
$eagers = $this->parseRelations($relations);
$this->eagerLoad = array_merge($this->eagerLoad, $eagers);
return $this;
}
/**
* Parse a list of relations into individuals.
*
* @param array $relations
* @return array
*/
protected function parseRelations(array $relations)
{
$results = array();
foreach ($relations as $name => $constraints)
{
// If the "relation" value is actually a numeric key, we can assume that no
// constraints have been specified for the eager load and we'll just put
// an empty Closure with the loader so that we can treat all the same.
if (is_numeric($name))
{
$f = function() {};
list($name, $constraints) = array($constraints, $f);
}
// We need to separate out any nested includes. Which allows the developers
// to load deep relationships using "dots" without stating each level of
// the relationship with its own key in the array of eager load names.
$results = $this->parseNested($name, $results);
$results[$name] = $constraints;
}
return $results;
}
/**
* Parse the nested relationships in a relation.
*
* @param string $name
* @param array $results
* @return array
*/
protected function parseNested($name, $results)
{
$progress = array();
// If the relation has already been set on the result array, we will not set it
// again, since that would override any constraints that were already placed
// on the relationships. We will only set the ones that are not specified.
foreach (explode('.', $name) as $segment)
{
$progress[] = $segment;
if ( ! isset($results[$last = implode('.', $progress)]))
{
$results[$last] = function() {};
}
}
return $results;
}
/**
* Call the given model scope on the underlying model.
*
* @param string $scope
* @param array $parameters
* @return \Illuminate\Database\Query\Builder
*/
protected function callScope($scope, $parameters)
{
array_unshift($parameters, $this);
return call_user_func_array(array($this->model, $scope), $parameters) ?: $this;
}
/**
* Get the underlying query builder instance.
*
* @return \Illuminate\Database\Query\Builder|static
*/
public function getQuery()
{
return $this->query;
}
/**
* Set the underlying query builder instance.
*
* @param \Illuminate\Database\Query\Builder $query
* @return $this
*/
public function setQuery($query)
{
$this->query = $query;
return $this;
}
/**
* Get the relationships being eagerly loaded.
*
* @return array
*/
public function getEagerLoads()
{
return $this->eagerLoad;
}
/**
* Set the relationships being eagerly loaded.
*
* @param array $eagerLoad
* @return $this
*/
public function setEagerLoads(array $eagerLoad)
{
$this->eagerLoad = $eagerLoad;
return $this;
}
/**
* Get the model instance being queried.
*
* @return \Illuminate\Database\Eloquent\Model
*/
public function getModel()
{
return $this->model;
}
/**
* Set a model instance for the model being queried.
*
* @param \Illuminate\Database\Eloquent\Model $model
* @return $this
*/
public function setModel(Model $model)
{
$this->model = $model;
$this->query->from($model->getTable());
return $this;
}
/**
* Extend the builder with a given callback.
*
* @param string $name
* @param \Closure $callback
* @return void
*/
public function macro($name, Closure $callback)
{
$this->macros[$name] = $callback;
}
/**
* Get the given macro by name.
*
* @param string $name
* @return \Closure
*/
public function getMacro($name)
{
return array_get($this->macros, $name);
}
/**
* Dynamically handle calls into the query instance.
*
* @param string $method
* @param array $parameters
* @return mixed
*/
public function __call($method, $parameters)
{
if (isset($this->macros[$method]))
{
array_unshift($parameters, $this);
return call_user_func_array($this->macros[$method], $parameters);
}
elseif (method_exists($this->model, $scope = 'scope'.ucfirst($method)))
{
return $this->callScope($scope, $parameters);
}
$result = call_user_func_array(array($this->query, $method), $parameters);
return in_array($method, $this->passthru) ? $result : $this;
}
/**
* Force a clone of the underlying query builder when cloning.
*
* @return void
*/
public function __clone()
{
$this->query = clone $this->query;
}
}

View File

@ -0,0 +1,266 @@
<?php namespace Illuminate\Database\Eloquent;
use Illuminate\Support\Collection as BaseCollection;
class Collection extends BaseCollection {
/**
* Find a model in the collection by key.
*
* @param mixed $key
* @param mixed $default
* @return \Illuminate\Database\Eloquent\Model
*/
public function find($key, $default = null)
{
if ($key instanceof Model)
{
$key = $key->getKey();
}
return array_first($this->items, function($itemKey, $model) use ($key)
{
return $model->getKey() == $key;
}, $default);
}
/**
* Load a set of relationships onto the collection.
*
* @param mixed $relations
* @return $this
*/
public function load($relations)
{
if (count($this->items) > 0)
{
if (is_string($relations)) $relations = func_get_args();
$query = $this->first()->newQuery()->with($relations);
$this->items = $query->eagerLoadRelations($this->items);
}
return $this;
}
/**
* Add an item to the collection.
*
* @param mixed $item
* @return $this
*/
public function add($item)
{
$this->items[] = $item;
return $this;
}
/**
* Determine if a key exists in the collection.
*
* @param mixed $key
* @param mixed $value
* @return bool
*/
public function contains($key, $value = null)
{
if (func_num_args() == 2) return parent::contains($key, $value);
if ( ! $this->useAsCallable($key))
{
$key = $key instanceof Model ? $key->getKey() : $key;
return parent::contains(function($k, $m) use ($key)
{
return $m->getKey() == $key;
});
}
return parent::contains($key);
}
/**
* Fetch a nested element of the collection.
*
* @param string $key
* @return static
*/
public function fetch($key)
{
return new static(array_fetch($this->toArray(), $key));
}
/**
* Get the max value of a given key.
*
* @param string $key
* @return mixed
*/
public function max($key)
{
return $this->reduce(function($result, $item) use ($key)
{
return is_null($result) || $item->{$key} > $result ? $item->{$key} : $result;
});
}
/**
* Get the min value of a given key.
*
* @param string $key
* @return mixed
*/
public function min($key)
{
return $this->reduce(function($result, $item) use ($key)
{
return is_null($result) || $item->{$key} < $result ? $item->{$key} : $result;
});
}
/**
* Get the array of primary keys.
*
* @return array
*/
public function modelKeys()
{
return array_map(function($m) { return $m->getKey(); }, $this->items);
}
/**
* Merge the collection with the given items.
*
* @param \ArrayAccess|array $items
* @return static
*/
public function merge($items)
{
$dictionary = $this->getDictionary();
foreach ($items as $item)
{
$dictionary[$item->getKey()] = $item;
}
return new static(array_values($dictionary));
}
/**
* Diff the collection with the given items.
*
* @param \ArrayAccess|array $items
* @return static
*/
public function diff($items)
{
$diff = new static;
$dictionary = $this->getDictionary($items);
foreach ($this->items as $item)
{
if ( ! isset($dictionary[$item->getKey()]))
{
$diff->add($item);
}
}
return $diff;
}
/**
* Intersect the collection with the given items.
*
* @param \ArrayAccess|array $items
* @return static
*/
public function intersect($items)
{
$intersect = new static;
$dictionary = $this->getDictionary($items);
foreach ($this->items as $item)
{
if (isset($dictionary[$item->getKey()]))
{
$intersect->add($item);
}
}
return $intersect;
}
/**
* Return only unique items from the collection.
*
* @return static
*/
public function unique()
{
$dictionary = $this->getDictionary();
return new static(array_values($dictionary));
}
/**
* Returns only the models from the collection with the specified keys.
*
* @param mixed $keys
* @return static
*/
public function only($keys)
{
$dictionary = array_only($this->getDictionary(), $keys);
return new static(array_values($dictionary));
}
/**
* Returns all models in the collection except the models with specified keys.
*
* @param mixed $keys
* @return static
*/
public function except($keys)
{
$dictionary = array_except($this->getDictionary(), $keys);
return new static(array_values($dictionary));
}
/**
* Get a dictionary keyed by primary keys.
*
* @param \ArrayAccess|array $items
* @return array
*/
public function getDictionary($items = null)
{
$items = is_null($items) ? $this->items : $items;
$dictionary = array();
foreach ($items as $value)
{
$dictionary[$value->getKey()] = $value;
}
return $dictionary;
}
/**
* Get a base Support collection instance from this collection.
*
* @return \Illuminate\Support\Collection
*/
public function toBase()
{
return new BaseCollection($this->items);
}
}

View File

@ -0,0 +1,5 @@
<?php namespace Illuminate\Database\Eloquent;
use RuntimeException;
class MassAssignmentException extends RuntimeException {}

3399
vendor/illuminate/database/Eloquent/Model.php vendored Executable file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,39 @@
<?php namespace Illuminate\Database\Eloquent;
use RuntimeException;
class ModelNotFoundException extends RuntimeException {
/**
* Name of the affected Eloquent model.
*
* @var string
*/
protected $model;
/**
* Set the affected Eloquent model.
*
* @param string $model
* @return $this
*/
public function setModel($model)
{
$this->model = $model;
$this->message = "No query results for model [{$model}].";
return $this;
}
/**
* Get the affected Eloquent model.
*
* @return string
*/
public function getModel()
{
return $this->model;
}
}

Some files were not shown because too many files have changed in this diff Show More