+
{{ session('status') }}
@endif
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Auth/Console/stubs/make/views/layouts/app.stub b/pfosten/vendor/laravel/framework/src/Illuminate/Auth/Console/stubs/make/views/layouts/app.stub
index d4745b4e..9224ba38 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Auth/Console/stubs/make/views/layouts/app.stub
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Auth/Console/stubs/make/views/layouts/app.stub
@@ -1,8 +1,7 @@
-
+
-
@@ -10,71 +9,72 @@
{{ config('app.name', 'Laravel') }}
+
+
+
+
+
+
+
-
-
-
-
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Auth/CreatesUserProviders.php b/pfosten/vendor/laravel/framework/src/Illuminate/Auth/CreatesUserProviders.php
index 715dee04..46416b5e 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Auth/CreatesUserProviders.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Auth/CreatesUserProviders.php
@@ -16,28 +16,45 @@ trait CreatesUserProviders
/**
* Create the user provider implementation for the driver.
*
- * @param string $provider
- * @return \Illuminate\Contracts\Auth\UserProvider
+ * @param string|null $provider
+ * @return \Illuminate\Contracts\Auth\UserProvider|null
*
* @throws \InvalidArgumentException
*/
- public function createUserProvider($provider)
+ public function createUserProvider($provider = null)
{
- $config = $this->app['config']['auth.providers.'.$provider];
+ if (is_null($config = $this->getProviderConfiguration($provider))) {
+ return;
+ }
- if (isset($this->customProviderCreators[$config['driver']])) {
+ if (isset($this->customProviderCreators[$driver = ($config['driver'] ?? null)])) {
return call_user_func(
- $this->customProviderCreators[$config['driver']], $this->app, $config
+ $this->customProviderCreators[$driver], $this->app, $config
);
}
- switch ($config['driver']) {
+ switch ($driver) {
case 'database':
return $this->createDatabaseProvider($config);
case 'eloquent':
return $this->createEloquentProvider($config);
default:
- throw new InvalidArgumentException("Authentication user provider [{$config['driver']}] is not defined.");
+ throw new InvalidArgumentException(
+ "Authentication user provider [{$driver}] is not defined."
+ );
+ }
+ }
+
+ /**
+ * Get the user provider configuration.
+ *
+ * @param string|null $provider
+ * @return array|null
+ */
+ protected function getProviderConfiguration($provider)
+ {
+ if ($provider = $provider ?: $this->getDefaultUserProvider()) {
+ return $this->app['config']['auth.providers.'.$provider];
}
}
@@ -64,4 +81,14 @@ trait CreatesUserProviders
{
return new EloquentUserProvider($this->app['hash'], $config['model']);
}
+
+ /**
+ * Get the default user provider name.
+ *
+ * @return string
+ */
+ public function getDefaultUserProvider()
+ {
+ return $this->app['config']['auth.defaults.provider'];
+ }
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Auth/DatabaseUserProvider.php b/pfosten/vendor/laravel/framework/src/Illuminate/Auth/DatabaseUserProvider.php
index a94b74b8..f8005b7d 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Auth/DatabaseUserProvider.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Auth/DatabaseUserProvider.php
@@ -4,6 +4,7 @@ namespace Illuminate\Auth;
use Illuminate\Support\Str;
use Illuminate\Contracts\Auth\UserProvider;
+use Illuminate\Contracts\Support\Arrayable;
use Illuminate\Database\ConnectionInterface;
use Illuminate\Contracts\Hashing\Hasher as HasherContract;
use Illuminate\Contracts\Auth\Authenticatable as UserContract;
@@ -68,12 +69,12 @@ class DatabaseUserProvider implements UserProvider
*/
public function retrieveByToken($identifier, $token)
{
- $user = $this->conn->table($this->table)
- ->where('id', $identifier)
- ->where('remember_token', $token)
- ->first();
+ $user = $this->getGenericUser(
+ $this->conn->table($this->table)->find($identifier)
+ );
- return $this->getGenericUser($user);
+ return $user && $user->getRememberToken() && hash_equals($user->getRememberToken(), $token)
+ ? $user : null;
}
/**
@@ -86,8 +87,8 @@ class DatabaseUserProvider implements UserProvider
public function updateRememberToken(UserContract $user, $token)
{
$this->conn->table($this->table)
- ->where('id', $user->getAuthIdentifier())
- ->update(['remember_token' => $token]);
+ ->where($user->getAuthIdentifierName(), $user->getAuthIdentifier())
+ ->update([$user->getRememberTokenName() => $token]);
}
/**
@@ -98,13 +99,25 @@ class DatabaseUserProvider implements UserProvider
*/
public function retrieveByCredentials(array $credentials)
{
+ if (empty($credentials) ||
+ (count($credentials) === 1 &&
+ array_key_exists('password', $credentials))) {
+ return;
+ }
+
// First we will add each credential element to the query as a where clause.
// Then we can execute the query and, if we found a user, return it in a
// generic "user" object that will be utilized by the Guard instances.
$query = $this->conn->table($this->table);
foreach ($credentials as $key => $value) {
- if (! Str::contains($key, 'password')) {
+ if (Str::contains($key, 'password')) {
+ continue;
+ }
+
+ if (is_array($value) || $value instanceof Arrayable) {
+ $query->whereIn($key, $value);
+ } else {
$query->where($key, $value);
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Auth/EloquentUserProvider.php b/pfosten/vendor/laravel/framework/src/Illuminate/Auth/EloquentUserProvider.php
index 0d5cad9c..e3c40e6b 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Auth/EloquentUserProvider.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Auth/EloquentUserProvider.php
@@ -4,6 +4,7 @@ namespace Illuminate\Auth;
use Illuminate\Support\Str;
use Illuminate\Contracts\Auth\UserProvider;
+use Illuminate\Contracts\Support\Arrayable;
use Illuminate\Contracts\Hashing\Hasher as HasherContract;
use Illuminate\Contracts\Auth\Authenticatable as UserContract;
@@ -46,9 +47,9 @@ class EloquentUserProvider implements UserProvider
{
$model = $this->createModel();
- return $model->newQuery()
- ->where($model->getAuthIdentifierName(), $identifier)
- ->first();
+ return $this->newModelQuery($model)
+ ->where($model->getAuthIdentifierName(), $identifier)
+ ->first();
}
/**
@@ -62,16 +63,24 @@ class EloquentUserProvider implements UserProvider
{
$model = $this->createModel();
- return $model->newQuery()
- ->where($model->getAuthIdentifierName(), $identifier)
- ->where($model->getRememberTokenName(), $token)
- ->first();
+ $retrievedModel = $this->newModelQuery($model)->where(
+ $model->getAuthIdentifierName(), $identifier
+ )->first();
+
+ if (! $retrievedModel) {
+ return;
+ }
+
+ $rememberToken = $retrievedModel->getRememberToken();
+
+ return $rememberToken && hash_equals($rememberToken, $token)
+ ? $retrievedModel : null;
}
/**
* Update the "remember me" token for the given user in storage.
*
- * @param \Illuminate\Contracts\Auth\Authenticatable $user
+ * @param \Illuminate\Contracts\Auth\Authenticatable|\Illuminate\Database\Eloquent\Model $user
* @param string $token
* @return void
*/
@@ -96,17 +105,25 @@ class EloquentUserProvider implements UserProvider
*/
public function retrieveByCredentials(array $credentials)
{
- if (empty($credentials)) {
+ if (empty($credentials) ||
+ (count($credentials) === 1 &&
+ array_key_exists('password', $credentials))) {
return;
}
// First we will add each credential element to the query as a where clause.
// Then we can execute the query and, if we found a user, return it in a
// Eloquent User "model" that will be utilized by the Guard instances.
- $query = $this->createModel()->newQuery();
+ $query = $this->newModelQuery();
foreach ($credentials as $key => $value) {
- if (! Str::contains($key, 'password')) {
+ if (Str::contains($key, 'password')) {
+ continue;
+ }
+
+ if (is_array($value) || $value instanceof Arrayable) {
+ $query->whereIn($key, $value);
+ } else {
$query->where($key, $value);
}
}
@@ -128,6 +145,19 @@ class EloquentUserProvider implements UserProvider
return $this->hasher->check($plain, $user->getAuthPassword());
}
+ /**
+ * Get a new query builder for the model instance.
+ *
+ * @param \Illuminate\Database\Eloquent\Model|null $model
+ * @return \Illuminate\Database\Eloquent\Builder
+ */
+ protected function newModelQuery($model = null)
+ {
+ return is_null($model)
+ ? $this->createModel()->newQuery()
+ : $model->newQuery();
+ }
+
/**
* Create a new instance of the model.
*
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Auth/Events/Attempting.php b/pfosten/vendor/laravel/framework/src/Illuminate/Auth/Events/Attempting.php
index 3d047300..3f911bac 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Auth/Events/Attempting.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Auth/Events/Attempting.php
@@ -4,6 +4,13 @@ namespace Illuminate\Auth\Events;
class Attempting
{
+ /**
+ * The authentication guard name.
+ *
+ * @var string
+ */
+ public $guard;
+
/**
* The credentials for the user.
*
@@ -21,11 +28,14 @@ class Attempting
/**
* Create a new event instance.
*
+ * @param string $guard
* @param array $credentials
* @param bool $remember
+ * @return void
*/
- public function __construct($credentials, $remember)
+ public function __construct($guard, $credentials, $remember)
{
+ $this->guard = $guard;
$this->remember = $remember;
$this->credentials = $credentials;
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Auth/Events/Authenticated.php b/pfosten/vendor/laravel/framework/src/Illuminate/Auth/Events/Authenticated.php
index f33c198d..faefcbec 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Auth/Events/Authenticated.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Auth/Events/Authenticated.php
@@ -8,6 +8,13 @@ class Authenticated
{
use SerializesModels;
+ /**
+ * The authentication guard name.
+ *
+ * @var string
+ */
+ public $guard;
+
/**
* The authenticated user.
*
@@ -18,11 +25,13 @@ class Authenticated
/**
* Create a new event instance.
*
+ * @param string $guard
* @param \Illuminate\Contracts\Auth\Authenticatable $user
* @return void
*/
- public function __construct($user)
+ public function __construct($guard, $user)
{
$this->user = $user;
+ $this->guard = $guard;
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Auth/Events/Failed.php b/pfosten/vendor/laravel/framework/src/Illuminate/Auth/Events/Failed.php
index 5807e8e0..34f81248 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Auth/Events/Failed.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Auth/Events/Failed.php
@@ -4,6 +4,13 @@ namespace Illuminate\Auth\Events;
class Failed
{
+ /**
+ * The authentication guard name.
+ *
+ * @var string
+ */
+ public $guard;
+
/**
* The user the attempter was trying to authenticate as.
*
@@ -21,12 +28,15 @@ class Failed
/**
* Create a new event instance.
*
+ * @param string $guard
* @param \Illuminate\Contracts\Auth\Authenticatable|null $user
* @param array $credentials
+ * @return void
*/
- public function __construct($user, $credentials)
+ public function __construct($guard, $user, $credentials)
{
$this->user = $user;
+ $this->guard = $guard;
$this->credentials = $credentials;
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Auth/Events/Login.php b/pfosten/vendor/laravel/framework/src/Illuminate/Auth/Events/Login.php
index 88167459..3005183a 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Auth/Events/Login.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Auth/Events/Login.php
@@ -8,6 +8,13 @@ class Login
{
use SerializesModels;
+ /**
+ * The authentication guard name.
+ *
+ * @var string
+ */
+ public $guard;
+
/**
* The authenticated user.
*
@@ -25,13 +32,15 @@ class Login
/**
* Create a new event instance.
*
+ * @param string $guard
* @param \Illuminate\Contracts\Auth\Authenticatable $user
* @param bool $remember
* @return void
*/
- public function __construct($user, $remember)
+ public function __construct($guard, $user, $remember)
{
$this->user = $user;
+ $this->guard = $guard;
$this->remember = $remember;
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Auth/Events/Logout.php b/pfosten/vendor/laravel/framework/src/Illuminate/Auth/Events/Logout.php
index ea788e71..bc8c3940 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Auth/Events/Logout.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Auth/Events/Logout.php
@@ -8,6 +8,13 @@ class Logout
{
use SerializesModels;
+ /**
+ * The authentication guard name.
+ *
+ * @var string
+ */
+ public $guard;
+
/**
* The authenticated user.
*
@@ -18,11 +25,13 @@ class Logout
/**
* Create a new event instance.
*
+ * @param string $guard
* @param \Illuminate\Contracts\Auth\Authenticatable $user
* @return void
*/
- public function __construct($user)
+ public function __construct($guard, $user)
{
$this->user = $user;
+ $this->guard = $guard;
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Auth/GuardHelpers.php b/pfosten/vendor/laravel/framework/src/Illuminate/Auth/GuardHelpers.php
index 5a227964..8bfa77a0 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Auth/GuardHelpers.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Auth/GuardHelpers.php
@@ -2,6 +2,7 @@
namespace Illuminate\Auth;
+use Illuminate\Contracts\Auth\UserProvider;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
/**
@@ -24,7 +25,7 @@ trait GuardHelpers
protected $provider;
/**
- * Determine if the current user is authenticated.
+ * Determine if current user is authenticated. If not, throw an exception.
*
* @return \Illuminate\Contracts\Auth\Authenticatable
*
@@ -39,6 +40,16 @@ trait GuardHelpers
throw new AuthenticationException;
}
+ /**
+ * Determine if the guard has a user instance.
+ *
+ * @return bool
+ */
+ public function hasUser()
+ {
+ return ! is_null($this->user);
+ }
+
/**
* Determine if the current user is authenticated.
*
@@ -83,4 +94,25 @@ trait GuardHelpers
return $this;
}
+
+ /**
+ * Get the user provider used by the guard.
+ *
+ * @return \Illuminate\Contracts\Auth\UserProvider
+ */
+ public function getProvider()
+ {
+ return $this->provider;
+ }
+
+ /**
+ * Set the user provider used by the guard.
+ *
+ * @param \Illuminate\Contracts\Auth\UserProvider $provider
+ * @return void
+ */
+ public function setProvider(UserProvider $provider)
+ {
+ $this->provider = $provider;
+ }
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Auth/Middleware/Authenticate.php b/pfosten/vendor/laravel/framework/src/Illuminate/Auth/Middleware/Authenticate.php
index 21ea4b22..98b9bc67 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Auth/Middleware/Authenticate.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Auth/Middleware/Authenticate.php
@@ -38,7 +38,7 @@ class Authenticate
*/
public function handle($request, Closure $next, ...$guards)
{
- $this->authenticate($guards);
+ $this->authenticate($request, $guards);
return $next($request);
}
@@ -46,15 +46,16 @@ class Authenticate
/**
* Determine if the user is logged in to any of the given guards.
*
+ * @param \Illuminate\Http\Request $request
* @param array $guards
* @return void
*
* @throws \Illuminate\Auth\AuthenticationException
*/
- protected function authenticate(array $guards)
+ protected function authenticate($request, array $guards)
{
if (empty($guards)) {
- return $this->auth->authenticate();
+ $guards = [null];
}
foreach ($guards as $guard) {
@@ -63,6 +64,19 @@ class Authenticate
}
}
- throw new AuthenticationException('Unauthenticated.', $guards);
+ throw new AuthenticationException(
+ 'Unauthenticated.', $guards, $this->redirectTo($request)
+ );
+ }
+
+ /**
+ * Get the path the user should be redirected to when they are not authenticated.
+ *
+ * @param \Illuminate\Http\Request $request
+ * @return string
+ */
+ protected function redirectTo($request)
+ {
+ //
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Auth/Middleware/AuthenticateWithBasicAuth.php b/pfosten/vendor/laravel/framework/src/Illuminate/Auth/Middleware/AuthenticateWithBasicAuth.php
index 71f8be87..92c81e68 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Auth/Middleware/AuthenticateWithBasicAuth.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Auth/Middleware/AuthenticateWithBasicAuth.php
@@ -31,10 +31,15 @@ class AuthenticateWithBasicAuth
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param string|null $guard
+ * @param string|null $field
* @return mixed
+ *
+ * @throws \Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException
*/
- public function handle($request, Closure $next, $guard = null)
+ public function handle($request, Closure $next, $guard = null, $field = null)
{
- return $this->auth->guard($guard)->basic() ?: $next($request);
+ $this->auth->guard($guard)->basic($field ?: 'email');
+
+ return $next($request);
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Auth/Middleware/Authorize.php b/pfosten/vendor/laravel/framework/src/Illuminate/Auth/Middleware/Authorize.php
index 9220e584..00d8c954 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Auth/Middleware/Authorize.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Auth/Middleware/Authorize.php
@@ -5,17 +5,9 @@ namespace Illuminate\Auth\Middleware;
use Closure;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Contracts\Auth\Access\Gate;
-use Illuminate\Contracts\Auth\Factory as Auth;
class Authorize
{
- /**
- * The authentication factory instance.
- *
- * @var \Illuminate\Contracts\Auth\Factory
- */
- protected $auth;
-
/**
* The gate instance.
*
@@ -26,13 +18,11 @@ class Authorize
/**
* Create a new middleware instance.
*
- * @param \Illuminate\Contracts\Auth\Factory $auth
* @param \Illuminate\Contracts\Auth\Access\Gate $gate
* @return void
*/
- public function __construct(Auth $auth, Gate $gate)
+ public function __construct(Gate $gate)
{
- $this->auth = $auth;
$this->gate = $gate;
}
@@ -42,7 +32,7 @@ class Authorize
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param string $ability
- * @param array|null $models
+ * @param array|null ...$models
* @return mixed
*
* @throws \Illuminate\Auth\AuthenticationException
@@ -50,8 +40,6 @@ class Authorize
*/
public function handle($request, Closure $next, $ability, ...$models)
{
- $this->auth->authenticate();
-
$this->gate->authorize($ability, $this->getGateArguments($request, $models));
return $next($request);
@@ -80,11 +68,16 @@ class Authorize
*
* @param \Illuminate\Http\Request $request
* @param string $model
- * @return string|\Illuminate\Database\Eloquent\Model
+ * @return \Illuminate\Database\Eloquent\Model|string
*/
protected function getModel($request, $model)
{
- return $this->isClassName($model) ? $model : $request->route($model);
+ if ($this->isClassName($model)) {
+ return trim($model);
+ } else {
+ return $request->route($model, null) ?:
+ ((preg_match("/^['\"](.*)['\"]$/", trim($model), $matches)) ? $matches[1] : null);
+ }
}
/**
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Auth/Notifications/ResetPassword.php b/pfosten/vendor/laravel/framework/src/Illuminate/Auth/Notifications/ResetPassword.php
index cd1ca866..1b0077e7 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Auth/Notifications/ResetPassword.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Auth/Notifications/ResetPassword.php
@@ -2,6 +2,7 @@
namespace Illuminate\Auth\Notifications;
+use Illuminate\Support\Facades\Lang;
use Illuminate\Notifications\Notification;
use Illuminate\Notifications\Messages\MailMessage;
@@ -14,6 +15,13 @@ class ResetPassword extends Notification
*/
public $token;
+ /**
+ * The callback that should be used to build the mail message.
+ *
+ * @var \Closure|null
+ */
+ public static $toMailCallback;
+
/**
* Create a notification instance.
*
@@ -44,9 +52,26 @@ class ResetPassword extends Notification
*/
public function toMail($notifiable)
{
+ if (static::$toMailCallback) {
+ return call_user_func(static::$toMailCallback, $notifiable, $this->token);
+ }
+
return (new MailMessage)
- ->line('You are receiving this email because we received a password reset request for your account.')
- ->action('Reset Password', url(config('app.url').route('password.reset', $this->token, false)))
- ->line('If you did not request a password reset, no further action is required.');
+ ->subject(Lang::getFromJson('Reset Password Notification'))
+ ->line(Lang::getFromJson('You are receiving this email because we received a password reset request for your account.'))
+ ->action(Lang::getFromJson('Reset Password'), url(config('app.url').route('password.reset', ['token' => $this->token, 'email' => $notifiable->getEmailForPasswordReset()], false)))
+ ->line(Lang::getFromJson('This password reset link will expire in :count minutes.', ['count' => config('auth.passwords.'.config('auth.defaults.passwords').'.expire')]))
+ ->line(Lang::getFromJson('If you did not request a password reset, no further action is required.'));
+ }
+
+ /**
+ * Set a callback that should be used when building the notification mail message.
+ *
+ * @param \Closure $callback
+ * @return void
+ */
+ public static function toMailUsing($callback)
+ {
+ static::$toMailCallback = $callback;
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Auth/Passwords/DatabaseTokenRepository.php b/pfosten/vendor/laravel/framework/src/Illuminate/Auth/Passwords/DatabaseTokenRepository.php
index aff32ca1..c4701759 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Auth/Passwords/DatabaseTokenRepository.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Auth/Passwords/DatabaseTokenRepository.php
@@ -2,8 +2,8 @@
namespace Illuminate\Auth\Passwords;
-use Carbon\Carbon;
use Illuminate\Support\Str;
+use Illuminate\Support\Carbon;
use Illuminate\Database\ConnectionInterface;
use Illuminate\Contracts\Hashing\Hasher as HasherContract;
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Auth/Passwords/PasswordBroker.php b/pfosten/vendor/laravel/framework/src/Illuminate/Auth/Passwords/PasswordBroker.php
index e9354096..cefb7137 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Auth/Passwords/PasswordBroker.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Auth/Passwords/PasswordBroker.php
@@ -107,7 +107,7 @@ class PasswordBroker implements PasswordBrokerContract
* Validate a password reset for the given credentials.
*
* @param array $credentials
- * @return \Illuminate\Contracts\Auth\CanResetPassword
+ * @return \Illuminate\Contracts\Auth\CanResetPassword|string
*/
protected function validateReset(array $credentials)
{
@@ -146,7 +146,7 @@ class PasswordBroker implements PasswordBrokerContract
public function validateNewPassword(array $credentials)
{
if (isset($this->passwordValidator)) {
- list($password, $confirm) = [
+ [$password, $confirm] = [
$credentials['password'],
$credentials['password_confirmation'],
];
@@ -167,19 +167,19 @@ class PasswordBroker implements PasswordBrokerContract
*/
protected function validatePasswordWithDefaults(array $credentials)
{
- list($password, $confirm) = [
+ [$password, $confirm] = [
$credentials['password'],
$credentials['password_confirmation'],
];
- return $password === $confirm && mb_strlen($password) >= 6;
+ return $password === $confirm && mb_strlen($password) >= 8;
}
/**
* Get the user for the given credentials.
*
* @param array $credentials
- * @return \Illuminate\Contracts\Auth\CanResetPassword
+ * @return \Illuminate\Contracts\Auth\CanResetPassword|null
*
* @throws \UnexpectedValueException
*/
@@ -199,7 +199,7 @@ class PasswordBroker implements PasswordBrokerContract
/**
* Create a new password reset token for the given user.
*
- * @param CanResetPasswordContract $user
+ * @param \Illuminate\Contracts\Auth\CanResetPassword $user
* @return string
*/
public function createToken(CanResetPasswordContract $user)
@@ -221,7 +221,7 @@ class PasswordBroker implements PasswordBrokerContract
/**
* Validate the given password reset token.
*
- * @param CanResetPasswordContract $user
+ * @param \Illuminate\Contracts\Auth\CanResetPassword $user
* @param string $token
* @return bool
*/
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Auth/Passwords/PasswordBrokerManager.php b/pfosten/vendor/laravel/framework/src/Illuminate/Auth/Passwords/PasswordBrokerManager.php
index 1a9498f4..f73db6e7 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Auth/Passwords/PasswordBrokerManager.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Auth/Passwords/PasswordBrokerManager.php
@@ -14,7 +14,7 @@ class PasswordBrokerManager implements FactoryContract
/**
* The application instance.
*
- * @var \Illuminate\Foundation\Application
+ * @var \Illuminate\Contracts\Foundation\Application
*/
protected $app;
@@ -28,7 +28,7 @@ class PasswordBrokerManager implements FactoryContract
/**
* Create a new PasswordBroker manager instance.
*
- * @param \Illuminate\Foundation\Application $app
+ * @param \Illuminate\Contracts\Foundation\Application $app
* @return void
*/
public function __construct($app)
@@ -39,16 +39,14 @@ class PasswordBrokerManager implements FactoryContract
/**
* Attempt to get the broker from the local cache.
*
- * @param string $name
+ * @param string|null $name
* @return \Illuminate\Contracts\Auth\PasswordBroker
*/
public function broker($name = null)
{
$name = $name ?: $this->getDefaultDriver();
- return isset($this->brokers[$name])
- ? $this->brokers[$name]
- : $this->brokers[$name] = $this->resolve($name);
+ return $this->brokers[$name] ?? ($this->brokers[$name] = $this->resolve($name));
}
/**
@@ -72,7 +70,7 @@ class PasswordBrokerManager implements FactoryContract
// aggregate service of sorts providing a convenient interface for resets.
return new PasswordBroker(
$this->createTokenRepository($config),
- $this->app['auth']->createUserProvider($config['provider'])
+ $this->app['auth']->createUserProvider($config['provider'] ?? null)
);
}
@@ -90,7 +88,7 @@ class PasswordBrokerManager implements FactoryContract
$key = base64_decode(substr($key, 7));
}
- $connection = isset($config['connection']) ? $config['connection'] : null;
+ $connection = $config['connection'] ?? null;
return new DatabaseTokenRepository(
$this->app['db']->connection($connection),
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Auth/Passwords/PasswordResetServiceProvider.php b/pfosten/vendor/laravel/framework/src/Illuminate/Auth/Passwords/PasswordResetServiceProvider.php
index 165ecaf9..8df49f50 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Auth/Passwords/PasswordResetServiceProvider.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Auth/Passwords/PasswordResetServiceProvider.php
@@ -3,16 +3,10 @@
namespace Illuminate\Auth\Passwords;
use Illuminate\Support\ServiceProvider;
+use Illuminate\Contracts\Support\DeferrableProvider;
-class PasswordResetServiceProvider extends ServiceProvider
+class PasswordResetServiceProvider extends ServiceProvider implements DeferrableProvider
{
- /**
- * Indicates if loading of the provider is deferred.
- *
- * @var bool
- */
- protected $defer = true;
-
/**
* Register the service provider.
*
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Auth/Recaller.php b/pfosten/vendor/laravel/framework/src/Illuminate/Auth/Recaller.php
index 6d1253d1..3a127799 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Auth/Recaller.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Auth/Recaller.php
@@ -21,7 +21,7 @@ class Recaller
*/
public function __construct($recaller)
{
- $this->recaller = $recaller;
+ $this->recaller = @unserialize($recaller, ['allowed_classes' => false]) ?: $recaller;
}
/**
@@ -31,7 +31,7 @@ class Recaller
*/
public function id()
{
- return explode('|', $this->recaller, 2)[0];
+ return explode('|', $this->recaller, 3)[0];
}
/**
@@ -41,7 +41,17 @@ class Recaller
*/
public function token()
{
- return explode('|', $this->recaller, 2)[1];
+ return explode('|', $this->recaller, 3)[1];
+ }
+
+ /**
+ * Get the password from the recaller.
+ *
+ * @return string
+ */
+ public function hash()
+ {
+ return explode('|', $this->recaller, 3)[2];
}
/**
@@ -51,7 +61,7 @@ class Recaller
*/
public function valid()
{
- return $this->properString() && $this->hasBothSegments();
+ return $this->properString() && $this->hasAllSegments();
}
/**
@@ -65,14 +75,14 @@ class Recaller
}
/**
- * Determine if the recaller has both segments.
+ * Determine if the recaller has all segments.
*
* @return bool
*/
- protected function hasBothSegments()
+ protected function hasAllSegments()
{
$segments = explode('|', $this->recaller);
- return count($segments) == 2 && trim($segments[0]) !== '' && trim($segments[1]) !== '';
+ return count($segments) === 3 && trim($segments[0]) !== '' && trim($segments[1]) !== '';
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Auth/RequestGuard.php b/pfosten/vendor/laravel/framework/src/Illuminate/Auth/RequestGuard.php
index d1a18c0f..2adc2cc3 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Auth/RequestGuard.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Auth/RequestGuard.php
@@ -5,6 +5,7 @@ namespace Illuminate\Auth;
use Illuminate\Http\Request;
use Illuminate\Contracts\Auth\Guard;
use Illuminate\Support\Traits\Macroable;
+use Illuminate\Contracts\Auth\UserProvider;
class RequestGuard implements Guard
{
@@ -29,12 +30,14 @@ class RequestGuard implements Guard
*
* @param callable $callback
* @param \Illuminate\Http\Request $request
+ * @param \Illuminate\Contracts\Auth\UserProvider|null $provider
* @return void
*/
- public function __construct(callable $callback, Request $request)
+ public function __construct(callable $callback, Request $request, UserProvider $provider = null)
{
$this->request = $request;
$this->callback = $callback;
+ $this->provider = $provider;
}
/**
@@ -52,7 +55,7 @@ class RequestGuard implements Guard
}
return $this->user = call_user_func(
- $this->callback, $this->request
+ $this->callback, $this->request, $this->getProvider()
);
}
@@ -65,7 +68,7 @@ class RequestGuard implements Guard
public function validate(array $credentials = [])
{
return ! is_null((new static(
- $this->callback, $credentials['request']
+ $this->callback, $credentials['request'], $this->getProvider()
))->user());
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Auth/SessionGuard.php b/pfosten/vendor/laravel/framework/src/Illuminate/Auth/SessionGuard.php
index 39d71669..ccc68a2a 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Auth/SessionGuard.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Auth/SessionGuard.php
@@ -4,7 +4,7 @@ namespace Illuminate\Auth;
use RuntimeException;
use Illuminate\Support\Str;
-use Illuminate\Http\Response;
+use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Traits\Macroable;
use Illuminate\Contracts\Session\Session;
use Illuminate\Contracts\Auth\UserProvider;
@@ -13,6 +13,7 @@ use Illuminate\Contracts\Auth\StatefulGuard;
use Symfony\Component\HttpFoundation\Request;
use Illuminate\Contracts\Auth\SupportsBasicAuth;
use Illuminate\Contracts\Cookie\QueueingFactory as CookieJar;
+use Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
class SessionGuard implements StatefulGuard, SupportsBasicAuth
@@ -90,7 +91,7 @@ class SessionGuard implements StatefulGuard, SupportsBasicAuth
* @param string $name
* @param \Illuminate\Contracts\Auth\UserProvider $provider
* @param \Illuminate\Contracts\Session\Session $session
- * @param \Symfony\Component\HttpFoundation\Request $request
+ * @param \Symfony\Component\HttpFoundation\Request|null $request
* @return void
*/
public function __construct($name,
@@ -127,30 +128,24 @@ class SessionGuard implements StatefulGuard, SupportsBasicAuth
// First we will try to load the user using the identifier in the session if
// one exists. Otherwise we will check for a "remember me" cookie in this
// request, and if one exists, attempt to retrieve the user using that.
- $user = null;
-
- if (! is_null($id)) {
- if ($user = $this->provider->retrieveById($id)) {
- $this->fireAuthenticatedEvent($user);
- }
+ if (! is_null($id) && $this->user = $this->provider->retrieveById($id)) {
+ $this->fireAuthenticatedEvent($this->user);
}
// If the user is null, but we decrypt a "recaller" cookie we can attempt to
// pull the user data on that cookie which serves as a remember cookie on
// the application. Once we have a user we can return it to the caller.
- $recaller = $this->recaller();
+ if (is_null($this->user) && ! is_null($recaller = $this->recaller())) {
+ $this->user = $this->userFromRecaller($recaller);
- if (is_null($user) && ! is_null($recaller)) {
- $user = $this->userFromRecaller($recaller);
+ if ($this->user) {
+ $this->updateSession($this->user->getAuthIdentifier());
- if ($user) {
- $this->updateSession($user->getAuthIdentifier());
-
- $this->fireLoginEvent($user, true);
+ $this->fireLoginEvent($this->user, true);
}
}
- return $this->user = $user;
+ return $this->user;
}
/**
@@ -331,11 +326,13 @@ class SessionGuard implements StatefulGuard, SupportsBasicAuth
/**
* Get the response for basic authentication.
*
- * @return \Symfony\Component\HttpFoundation\Response
+ * @return void
+ *
+ * @throws \Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException
*/
protected function failedBasicResponse()
{
- return new Response('Invalid credentials.', 401, ['WWW-Authenticate' => 'Basic']);
+ throw new UnauthorizedHttpException('Basic', 'Invalid credentials.');
}
/**
@@ -461,7 +458,7 @@ class SessionGuard implements StatefulGuard, SupportsBasicAuth
protected function queueRecallerCookie(AuthenticatableContract $user)
{
$this->getCookieJar()->queue($this->createRecaller(
- $user->getAuthIdentifier().'|'.$user->getRememberToken()
+ $user->getAuthIdentifier().'|'.$user->getRememberToken().'|'.$user->getAuthPassword()
));
}
@@ -490,12 +487,12 @@ class SessionGuard implements StatefulGuard, SupportsBasicAuth
// listening for anytime a user signs out of this application manually.
$this->clearUserDataFromStorage();
- if (! is_null($this->user)) {
+ if (! is_null($this->user) && ! empty($user->getRememberToken())) {
$this->cycleRememberToken($user);
}
if (isset($this->events)) {
- $this->events->dispatch(new Events\Logout($user));
+ $this->events->dispatch(new Events\Logout($this->name, $user));
}
// Once we have fired the logout event we will clear the users out of memory
@@ -534,6 +531,35 @@ class SessionGuard implements StatefulGuard, SupportsBasicAuth
$this->provider->updateRememberToken($user, $token);
}
+ /**
+ * Invalidate other sessions for the current user.
+ *
+ * The application must be using the AuthenticateSession middleware.
+ *
+ * @param string $password
+ * @param string $attribute
+ * @return bool|null
+ */
+ public function logoutOtherDevices($password, $attribute = 'password')
+ {
+ if (! $this->user()) {
+ return;
+ }
+
+ $result = tap($this->user()->forceFill([
+ $attribute => Hash::make($password),
+ ]))->save();
+
+ if ($this->recaller() ||
+ $this->getCookieJar()->hasQueued($this->getRecallerName())) {
+ $this->queueRecallerCookie($this->user());
+ }
+
+ $this->fireOtherDeviceLogoutEvent($this->user());
+
+ return $result;
+ }
+
/**
* Register an authentication attempt event listener.
*
@@ -558,7 +584,7 @@ class SessionGuard implements StatefulGuard, SupportsBasicAuth
{
if (isset($this->events)) {
$this->events->dispatch(new Events\Attempting(
- $credentials, $remember
+ $this->name, $credentials, $remember
));
}
}
@@ -573,7 +599,9 @@ class SessionGuard implements StatefulGuard, SupportsBasicAuth
protected function fireLoginEvent($user, $remember = false)
{
if (isset($this->events)) {
- $this->events->dispatch(new Events\Login($user, $remember));
+ $this->events->dispatch(new Events\Login(
+ $this->name, $user, $remember
+ ));
}
}
@@ -586,7 +614,24 @@ class SessionGuard implements StatefulGuard, SupportsBasicAuth
protected function fireAuthenticatedEvent($user)
{
if (isset($this->events)) {
- $this->events->dispatch(new Events\Authenticated($user));
+ $this->events->dispatch(new Events\Authenticated(
+ $this->name, $user
+ ));
+ }
+ }
+
+ /**
+ * Fire the other device logout event if the dispatcher is set.
+ *
+ * @param \Illuminate\Contracts\Auth\Authenticatable $user
+ * @return void
+ */
+ protected function fireOtherDeviceLogoutEvent($user)
+ {
+ if (isset($this->events)) {
+ $this->events->dispatch(new Events\OtherDeviceLogout(
+ $this->name, $user
+ ));
}
}
@@ -600,7 +645,9 @@ class SessionGuard implements StatefulGuard, SupportsBasicAuth
protected function fireFailedEvent($user, array $credentials)
{
if (isset($this->events)) {
- $this->events->dispatch(new Events\Failed($user, $credentials));
+ $this->events->dispatch(new Events\Failed(
+ $this->name, $user, $credentials
+ ));
}
}
@@ -695,34 +742,13 @@ class SessionGuard implements StatefulGuard, SupportsBasicAuth
/**
* Get the session store used by the guard.
*
- * @return \Illuminate\Session\Store
+ * @return \Illuminate\Contracts\Session\Session
*/
public function getSession()
{
return $this->session;
}
- /**
- * Get the user provider used by the guard.
- *
- * @return \Illuminate\Contracts\Auth\UserProvider
- */
- public function getProvider()
- {
- return $this->provider;
- }
-
- /**
- * Set the user provider used by the guard.
- *
- * @param \Illuminate\Contracts\Auth\UserProvider $provider
- * @return void
- */
- public function setProvider(UserProvider $provider)
- {
- $this->provider = $provider;
- }
-
/**
* Return the currently cached user.
*
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Auth/TokenGuard.php b/pfosten/vendor/laravel/framework/src/Illuminate/Auth/TokenGuard.php
index dec39f43..93fa2576 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Auth/TokenGuard.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Auth/TokenGuard.php
@@ -31,19 +31,35 @@ class TokenGuard implements Guard
*/
protected $storageKey;
+ /**
+ * Indicates if the API token is hashed in storage.
+ *
+ * @var bool
+ */
+ protected $hash = false;
+
/**
* Create a new authentication guard.
*
* @param \Illuminate\Contracts\Auth\UserProvider $provider
* @param \Illuminate\Http\Request $request
+ * @param string $inputKey
+ * @param string $storageKey
+ * @param bool $hash
* @return void
*/
- public function __construct(UserProvider $provider, Request $request)
+ public function __construct(
+ UserProvider $provider,
+ Request $request,
+ $inputKey = 'api_token',
+ $storageKey = 'api_token',
+ $hash = false)
{
+ $this->hash = $hash;
$this->request = $request;
$this->provider = $provider;
- $this->inputKey = 'api_token';
- $this->storageKey = 'api_token';
+ $this->inputKey = $inputKey;
+ $this->storageKey = $storageKey;
}
/**
@@ -65,9 +81,9 @@ class TokenGuard implements Guard
$token = $this->getTokenForRequest();
if (! empty($token)) {
- $user = $this->provider->retrieveByCredentials(
- [$this->storageKey => $token]
- );
+ $user = $this->provider->retrieveByCredentials([
+ $this->storageKey => $this->hash ? hash('sha256', $token) : $token,
+ ]);
}
return $this->user = $user;
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Auth/composer.json b/pfosten/vendor/laravel/framework/src/Illuminate/Auth/composer.json
index 54525eb3..f9eaf684 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Auth/composer.json
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Auth/composer.json
@@ -14,12 +14,11 @@
}
],
"require": {
- "php": ">=5.6.4",
- "illuminate/contracts": "5.4.*",
- "illuminate/http": "5.4.*",
- "illuminate/queue": "5.4.*",
- "illuminate/support": "5.4.*",
- "nesbot/carbon": "~1.20"
+ "php": "^7.1.3",
+ "illuminate/contracts": "5.8.*",
+ "illuminate/http": "5.8.*",
+ "illuminate/queue": "5.8.*",
+ "illuminate/support": "5.8.*"
},
"autoload": {
"psr-4": {
@@ -28,13 +27,13 @@
},
"extra": {
"branch-alias": {
- "dev-master": "5.4-dev"
+ "dev-master": "5.8-dev"
}
},
"suggest": {
- "illuminate/console": "Required to use the auth:clear-resets command (5.4.*).",
- "illuminate/queue": "Required to fire login / logout events (5.4.*).",
- "illuminate/session": "Required to use the session based guard (5.4.*)."
+ "illuminate/console": "Required to use the auth:clear-resets command (5.8.*).",
+ "illuminate/queue": "Required to fire login / logout events (5.8.*).",
+ "illuminate/session": "Required to use the session based guard (5.8.*)."
},
"config": {
"sort-packages": true
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Broadcasting/BroadcastController.php b/pfosten/vendor/laravel/framework/src/Illuminate/Broadcasting/BroadcastController.php
index f71c9237..486a6023 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Broadcasting/BroadcastController.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Broadcasting/BroadcastController.php
@@ -16,6 +16,10 @@ class BroadcastController extends Controller
*/
public function authenticate(Request $request)
{
+ if ($request->hasSession()) {
+ $request->session()->reflash();
+ }
+
return Broadcast::auth($request);
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Broadcasting/BroadcastEvent.php b/pfosten/vendor/laravel/framework/src/Illuminate/Broadcasting/BroadcastEvent.php
index bfb74541..eb790f07 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Broadcasting/BroadcastEvent.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Broadcasting/BroadcastEvent.php
@@ -4,8 +4,8 @@ namespace Illuminate\Broadcasting;
use ReflectionClass;
use ReflectionProperty;
+use Illuminate\Support\Arr;
use Illuminate\Bus\Queueable;
-use Illuminate\Contracts\Queue\Job;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Contracts\Support\Arrayable;
use Illuminate\Contracts\Broadcasting\Broadcaster;
@@ -44,7 +44,7 @@ class BroadcastEvent implements ShouldQueue
? $this->event->broadcastAs() : get_class($this->event);
$broadcaster->broadcast(
- array_wrap($this->event->broadcastOn()), $name,
+ Arr::wrap($this->event->broadcastOn()), $name,
$this->getPayloadFromEvent($this->event)
);
}
@@ -98,4 +98,14 @@ class BroadcastEvent implements ShouldQueue
{
return get_class($this->event);
}
+
+ /**
+ * Prepare the instance for cloning.
+ *
+ * @return void
+ */
+ public function __clone()
+ {
+ $this->event = clone $this->event;
+ }
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Broadcasting/BroadcastManager.php b/pfosten/vendor/laravel/framework/src/Illuminate/Broadcasting/BroadcastManager.php
index 5eaedf1f..ef9c9235 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Broadcasting/BroadcastManager.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Broadcasting/BroadcastManager.php
@@ -2,9 +2,8 @@
namespace Illuminate\Broadcasting;
-use Pusher;
use Closure;
-use Illuminate\Support\Arr;
+use Pusher\Pusher;
use Psr\Log\LoggerInterface;
use InvalidArgumentException;
use Illuminate\Broadcasting\Broadcasters\LogBroadcaster;
@@ -22,7 +21,7 @@ class BroadcastManager implements FactoryContract
/**
* The application instance.
*
- * @var \Illuminate\Foundation\Application
+ * @var \Illuminate\Contracts\Foundation\Application
*/
protected $app;
@@ -43,7 +42,7 @@ class BroadcastManager implements FactoryContract
/**
* Create a new manager instance.
*
- * @param \Illuminate\Foundation\Application $app
+ * @param \Illuminate\Contracts\Foundation\Application $app
* @return void
*/
public function __construct($app)
@@ -66,7 +65,10 @@ class BroadcastManager implements FactoryContract
$attributes = $attributes ?: ['middleware' => ['web']];
$this->app['router']->group($attributes, function ($router) {
- $router->post('/broadcasting/auth', BroadcastController::class.'@authenticate');
+ $router->match(
+ ['get', 'post'], '/broadcasting/auth',
+ '\\'.BroadcastController::class.'@authenticate'
+ );
});
}
@@ -84,9 +86,7 @@ class BroadcastManager implements FactoryContract
$request = $request ?: $this->app['request'];
- if ($request->hasHeader('X-Socket-ID')) {
- return $request->header('X-Socket-ID');
- }
+ return $request->header('X-Socket-ID');
}
/**
@@ -132,7 +132,7 @@ class BroadcastManager implements FactoryContract
/**
* Get a driver instance.
*
- * @param string $driver
+ * @param string|null $driver
* @return mixed
*/
public function connection($driver = null)
@@ -143,7 +143,7 @@ class BroadcastManager implements FactoryContract
/**
* Get a driver instance.
*
- * @param string $name
+ * @param string|null $name
* @return mixed
*/
public function driver($name = null)
@@ -161,11 +161,11 @@ class BroadcastManager implements FactoryContract
*/
protected function get($name)
{
- return isset($this->drivers[$name]) ? $this->drivers[$name] : $this->resolve($name);
+ return $this->drivers[$name] ?? $this->resolve($name);
}
/**
- * Resolve the given store.
+ * Resolve the given broadcaster.
*
* @param string $name
* @return \Illuminate\Contracts\Broadcasting\Broadcaster
@@ -176,10 +176,6 @@ class BroadcastManager implements FactoryContract
{
$config = $this->getConfig($name);
- if (is_null($config)) {
- throw new InvalidArgumentException("Broadcaster [{$name}] is not defined.");
- }
-
if (isset($this->customCreators[$config['driver']])) {
return $this->callCustomCreator($config);
}
@@ -212,10 +208,16 @@ class BroadcastManager implements FactoryContract
*/
protected function createPusherDriver(array $config)
{
- return new PusherBroadcaster(
- new Pusher($config['key'], $config['secret'],
- $config['app_id'], Arr::get($config, 'options', []))
+ $pusher = new Pusher(
+ $config['key'], $config['secret'],
+ $config['app_id'], $config['options'] ?? []
);
+
+ if ($config['log'] ?? false) {
+ $pusher->setLogger($this->app->make(LoggerInterface::class));
+ }
+
+ return new PusherBroadcaster($pusher);
}
/**
@@ -227,7 +229,7 @@ class BroadcastManager implements FactoryContract
protected function createRedisDriver(array $config)
{
return new RedisBroadcaster(
- $this->app->make('redis'), Arr::get($config, 'connection')
+ $this->app->make('redis'), $config['connection'] ?? null
);
}
@@ -263,7 +265,11 @@ class BroadcastManager implements FactoryContract
*/
protected function getConfig($name)
{
- return $this->app['config']["broadcasting.connections.{$name}"];
+ if (! is_null($name) && $name !== 'null') {
+ return $this->app['config']["broadcasting.connections.{$name}"];
+ }
+
+ return ['driver' => 'null'];
}
/**
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Broadcasting/BroadcastServiceProvider.php b/pfosten/vendor/laravel/framework/src/Illuminate/Broadcasting/BroadcastServiceProvider.php
index adf88a6f..56628ef2 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Broadcasting/BroadcastServiceProvider.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Broadcasting/BroadcastServiceProvider.php
@@ -3,18 +3,12 @@
namespace Illuminate\Broadcasting;
use Illuminate\Support\ServiceProvider;
+use Illuminate\Contracts\Support\DeferrableProvider;
use Illuminate\Contracts\Broadcasting\Factory as BroadcastingFactory;
use Illuminate\Contracts\Broadcasting\Broadcaster as BroadcasterContract;
-class BroadcastServiceProvider extends ServiceProvider
+class BroadcastServiceProvider extends ServiceProvider implements DeferrableProvider
{
- /**
- * Indicates if loading of the provider is deferred.
- *
- * @var bool
- */
- protected $defer = true;
-
/**
* Register the service provider.
*
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Broadcasting/Broadcasters/Broadcaster.php b/pfosten/vendor/laravel/framework/src/Illuminate/Broadcasting/Broadcasters/Broadcaster.php
index ed1c9467..39b9ec1d 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Broadcasting/Broadcasters/Broadcaster.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Broadcasting/Broadcasters/Broadcaster.php
@@ -2,13 +2,15 @@
namespace Illuminate\Broadcasting\Broadcasters;
+use Exception;
+use ReflectionClass;
use ReflectionFunction;
-use ReflectionParameter;
+use Illuminate\Support\Arr;
use Illuminate\Support\Str;
use Illuminate\Container\Container;
-use Illuminate\Database\Eloquent\Model;
+use Illuminate\Contracts\Routing\UrlRoutable;
use Illuminate\Contracts\Routing\BindingRegistrar;
-use Symfony\Component\HttpKernel\Exception\HttpException;
+use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
use Illuminate\Contracts\Broadcasting\Broadcaster as BroadcasterContract;
abstract class Broadcaster implements BroadcasterContract
@@ -20,10 +22,17 @@ abstract class Broadcaster implements BroadcasterContract
*/
protected $channels = [];
+ /**
+ * The registered channel options.
+ *
+ * @var array
+ */
+ protected $channelOptions = [];
+
/**
* The binding registrar instance.
*
- * @var BindingRegistrar
+ * @var \Illuminate\Contracts\Routing\BindingRegistrar
*/
protected $bindingRegistrar;
@@ -31,13 +40,16 @@ abstract class Broadcaster implements BroadcasterContract
* Register a channel authenticator.
*
* @param string $channel
- * @param callable $callback
+ * @param callable|string $callback
+ * @param array $options
* @return $this
*/
- public function channel($channel, callable $callback)
+ public function channel($channel, $callback, $options = [])
{
$this->channels[$channel] = $callback;
+ $this->channelOptions[$channel] = $options;
+
return $this;
}
@@ -47,22 +59,26 @@ abstract class Broadcaster implements BroadcasterContract
* @param \Illuminate\Http\Request $request
* @param string $channel
* @return mixed
+ *
+ * @throws \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException
*/
protected function verifyUserCanAccessChannel($request, $channel)
{
foreach ($this->channels as $pattern => $callback) {
- if (! Str::is(preg_replace('/\{(.*?)\}/', '*', $pattern), $channel)) {
+ if (! $this->channelNameMatchesPattern($channel, $pattern)) {
continue;
}
$parameters = $this->extractAuthParameters($pattern, $channel, $callback);
- if ($result = $callback($request->user(), ...$parameters)) {
+ $handler = $this->normalizeChannelHandlerToCallable($callback);
+
+ if ($result = $handler($this->retrieveUser($request, $channel), ...$parameters)) {
return $this->validAuthenticationResponse($request, $result);
}
}
- throw new HttpException(403);
+ throw new AccessDeniedHttpException;
}
/**
@@ -70,12 +86,12 @@ abstract class Broadcaster implements BroadcasterContract
*
* @param string $pattern
* @param string $channel
- * @param callable $callback
+ * @param callable|string $callback
* @return array
*/
protected function extractAuthParameters($pattern, $channel, $callback)
{
- $callbackParameters = (new ReflectionFunction($callback))->getParameters();
+ $callbackParameters = $this->extractParameters($callback);
return collect($this->extractChannelKeys($pattern, $channel))->reject(function ($value, $key) {
return is_numeric($key);
@@ -84,6 +100,44 @@ abstract class Broadcaster implements BroadcasterContract
})->values()->all();
}
+ /**
+ * Extracts the parameters out of what the user passed to handle the channel authentication.
+ *
+ * @param callable|string $callback
+ * @return \ReflectionParameter[]
+ *
+ * @throws \Exception
+ */
+ protected function extractParameters($callback)
+ {
+ if (is_callable($callback)) {
+ return (new ReflectionFunction($callback))->getParameters();
+ } elseif (is_string($callback)) {
+ return $this->extractParametersFromClass($callback);
+ }
+
+ throw new Exception('Given channel handler is an unknown type.');
+ }
+
+ /**
+ * Extracts the parameters out of a class channel's "join" method.
+ *
+ * @param string $callback
+ * @return \ReflectionParameter[]
+ *
+ * @throws \Exception
+ */
+ protected function extractParametersFromClass($callback)
+ {
+ $reflection = new ReflectionClass($callback);
+
+ if (! $reflection->hasMethod('join')) {
+ throw new Exception('Class based channel must define a "join" method.');
+ }
+
+ return $reflection->getMethod('join')->getParameters();
+ }
+
/**
* Extract the channel keys from the incoming channel name.
*
@@ -140,6 +194,8 @@ abstract class Broadcaster implements BroadcasterContract
* @param mixed $value
* @param array $callbackParameters
* @return mixed
+ *
+ * @throws \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException
*/
protected function resolveImplicitBindingIfPossible($key, $value, $callbackParameters)
{
@@ -148,11 +204,13 @@ abstract class Broadcaster implements BroadcasterContract
continue;
}
- $model = $parameter->getClass()->newInstance();
+ $instance = $parameter->getClass()->newInstance();
- return $model->where($model->getRouteKeyName(), $value)->firstOr(function () {
- throw new HttpException(403);
- });
+ if (! $model = $instance->resolveRouteBinding($value)) {
+ throw new AccessDeniedHttpException;
+ }
+
+ return $model;
}
return $value;
@@ -162,13 +220,13 @@ abstract class Broadcaster implements BroadcasterContract
* Determine if a given key and parameter is implicitly bindable.
*
* @param string $key
- * @param ReflectionParameter $parameter
+ * @param \ReflectionParameter $parameter
* @return bool
*/
protected function isImplicitlyBindable($key, $parameter)
{
return $parameter->name === $key && $parameter->getClass() &&
- $parameter->getClass()->isSubclassOf(Model::class);
+ $parameter->getClass()->isSubclassOf(UrlRoutable::class);
}
/**
@@ -187,7 +245,7 @@ abstract class Broadcaster implements BroadcasterContract
/**
* Get the model binding registrar instance.
*
- * @return BindingRegistrar
+ * @return \Illuminate\Contracts\Routing\BindingRegistrar
*/
protected function binder()
{
@@ -198,4 +256,74 @@ abstract class Broadcaster implements BroadcasterContract
return $this->bindingRegistrar;
}
+
+ /**
+ * Normalize the given callback into a callable.
+ *
+ * @param mixed $callback
+ * @return callable|\Closure
+ */
+ protected function normalizeChannelHandlerToCallable($callback)
+ {
+ return is_callable($callback) ? $callback : function (...$args) use ($callback) {
+ return Container::getInstance()
+ ->make($callback)
+ ->join(...$args);
+ };
+ }
+
+ /**
+ * Retrieve the authenticated user using the configured guard (if any).
+ *
+ * @param \Illuminate\Http\Request $request
+ * @param string $channel
+ * @return mixed
+ */
+ protected function retrieveUser($request, $channel)
+ {
+ $options = $this->retrieveChannelOptions($channel);
+
+ $guards = $options['guards'] ?? null;
+
+ if (is_null($guards)) {
+ return $request->user();
+ }
+
+ foreach (Arr::wrap($guards) as $guard) {
+ if ($user = $request->user($guard)) {
+ return $user;
+ }
+ }
+ }
+
+ /**
+ * Retrieve options for a certain channel.
+ *
+ * @param string $channel
+ * @return array
+ */
+ protected function retrieveChannelOptions($channel)
+ {
+ foreach ($this->channelOptions as $pattern => $options) {
+ if (! $this->channelNameMatchesPattern($channel, $pattern)) {
+ continue;
+ }
+
+ return $options;
+ }
+
+ return [];
+ }
+
+ /**
+ * Check if channel name from request match a pattern from registered channels.
+ *
+ * @param string $channel
+ * @param string $pattern
+ * @return bool
+ */
+ protected function channelNameMatchesPattern($channel, $pattern)
+ {
+ return Str::is(preg_replace('/\{(.*?)\}/', '*', $pattern), $channel);
+ }
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Broadcasting/Broadcasters/PusherBroadcaster.php b/pfosten/vendor/laravel/framework/src/Illuminate/Broadcasting/Broadcasters/PusherBroadcaster.php
index 44e7e4db..5bdc305b 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Broadcasting/Broadcasters/PusherBroadcaster.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Broadcasting/Broadcasters/PusherBroadcaster.php
@@ -2,25 +2,27 @@
namespace Illuminate\Broadcasting\Broadcasters;
-use Pusher;
+use Pusher\Pusher;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
use Illuminate\Broadcasting\BroadcastException;
-use Symfony\Component\HttpKernel\Exception\HttpException;
+use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
class PusherBroadcaster extends Broadcaster
{
+ use UsePusherChannelConventions;
+
/**
* The Pusher SDK instance.
*
- * @var \Pusher
+ * @var \Pusher\Pusher
*/
protected $pusher;
/**
* Create a new broadcaster instance.
*
- * @param \Pusher $pusher
+ * @param \Pusher\Pusher $pusher
* @return void
*/
public function __construct(Pusher $pusher)
@@ -33,17 +35,17 @@ class PusherBroadcaster extends Broadcaster
*
* @param \Illuminate\Http\Request $request
* @return mixed
+ *
+ * @throws \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException
*/
public function auth($request)
{
- if (Str::startsWith($request->channel_name, ['private-', 'presence-']) &&
- ! $request->user()) {
- throw new HttpException(403);
- }
+ $channelName = $this->normalizeChannelName($request->channel_name);
- $channelName = Str::startsWith($request->channel_name, 'private-')
- ? Str::replaceFirst('private-', '', $request->channel_name)
- : Str::replaceFirst('presence-', '', $request->channel_name);
+ if ($this->isGuardedChannel($request->channel_name) &&
+ ! $this->retrieveUser($request, $channelName)) {
+ throw new AccessDeniedHttpException;
+ }
return parent::verifyUserCanAccessChannel(
$request, $channelName
@@ -61,25 +63,36 @@ class PusherBroadcaster extends Broadcaster
{
if (Str::startsWith($request->channel_name, 'private')) {
return $this->decodePusherResponse(
- $this->pusher->socket_auth($request->channel_name, $request->socket_id)
+ $request, $this->pusher->socket_auth($request->channel_name, $request->socket_id)
);
}
+ $channelName = $this->normalizeChannelName($request->channel_name);
+
return $this->decodePusherResponse(
+ $request,
$this->pusher->presence_auth(
- $request->channel_name, $request->socket_id, $request->user()->getAuthIdentifier(), $result)
+ $request->channel_name, $request->socket_id,
+ $this->retrieveUser($request, $channelName)->getAuthIdentifier(), $result
+ )
);
}
/**
* Decode the given Pusher response.
*
+ * @param \Illuminate\Http\Request $request
* @param mixed $response
* @return array
*/
- protected function decodePusherResponse($response)
+ protected function decodePusherResponse($request, $response)
{
- return json_decode($response, true);
+ if (! $request->input('callback', false)) {
+ return json_decode($response, true);
+ }
+
+ return response()->json(json_decode($response, true))
+ ->withCallback($request->callback);
}
/**
@@ -111,7 +124,7 @@ class PusherBroadcaster extends Broadcaster
/**
* Get the Pusher SDK instance.
*
- * @return \Pusher
+ * @return \Pusher\Pusher
*/
public function getPusher()
{
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Broadcasting/Broadcasters/RedisBroadcaster.php b/pfosten/vendor/laravel/framework/src/Illuminate/Broadcasting/Broadcasters/RedisBroadcaster.php
index 999899f2..b001c1d8 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Broadcasting/Broadcasters/RedisBroadcaster.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Broadcasting/Broadcasters/RedisBroadcaster.php
@@ -3,12 +3,13 @@
namespace Illuminate\Broadcasting\Broadcasters;
use Illuminate\Support\Arr;
-use Illuminate\Support\Str;
use Illuminate\Contracts\Redis\Factory as Redis;
-use Symfony\Component\HttpKernel\Exception\HttpException;
+use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
class RedisBroadcaster extends Broadcaster
{
+ use UsePusherChannelConventions;
+
/**
* The Redis instance.
*
@@ -27,7 +28,7 @@ class RedisBroadcaster extends Broadcaster
* Create a new broadcaster instance.
*
* @param \Illuminate\Contracts\Redis\Factory $redis
- * @param string $connection
+ * @param string|null $connection
* @return void
*/
public function __construct(Redis $redis, $connection = null)
@@ -41,17 +42,17 @@ class RedisBroadcaster extends Broadcaster
*
* @param \Illuminate\Http\Request $request
* @return mixed
+ *
+ * @throws \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException
*/
public function auth($request)
{
- if (Str::startsWith($request->channel_name, ['private-', 'presence-']) &&
- ! $request->user()) {
- throw new HttpException(403);
- }
+ $channelName = $this->normalizeChannelName($request->channel_name);
- $channelName = Str::startsWith($request->channel_name, 'private-')
- ? Str::replaceFirst('private-', '', $request->channel_name)
- : Str::replaceFirst('presence-', '', $request->channel_name);
+ if ($this->isGuardedChannel($request->channel_name) &&
+ ! $this->retrieveUser($request, $channelName)) {
+ throw new AccessDeniedHttpException;
+ }
return parent::verifyUserCanAccessChannel(
$request, $channelName
@@ -71,8 +72,10 @@ class RedisBroadcaster extends Broadcaster
return json_encode($result);
}
+ $channelName = $this->normalizeChannelName($request->channel_name);
+
return json_encode(['channel_data' => [
- 'user_id' => $request->user()->getAuthIdentifier(),
+ 'user_id' => $this->retrieveUser($request, $channelName)->getAuthIdentifier(),
'user_info' => $result,
]]);
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Broadcasting/composer.json b/pfosten/vendor/laravel/framework/src/Illuminate/Broadcasting/composer.json
index 965b29c0..bf6981f8 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Broadcasting/composer.json
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Broadcasting/composer.json
@@ -14,11 +14,13 @@
}
],
"require": {
- "php": ">=5.6.4",
- "illuminate/bus": "5.4.*",
- "illuminate/contracts": "5.4.*",
- "illuminate/queue": "5.4.*",
- "illuminate/support": "5.4.*"
+ "php": "^7.1.3",
+ "ext-json": "*",
+ "psr/log": "^1.0",
+ "illuminate/bus": "5.8.*",
+ "illuminate/contracts": "5.8.*",
+ "illuminate/queue": "5.8.*",
+ "illuminate/support": "5.8.*"
},
"autoload": {
"psr-4": {
@@ -27,11 +29,11 @@
},
"extra": {
"branch-alias": {
- "dev-master": "5.4-dev"
+ "dev-master": "5.8-dev"
}
},
"suggest": {
- "pusher/pusher-php-server": "Required to use the Pusher broadcast driver (~2.0)."
+ "pusher/pusher-php-server": "Required to use the Pusher broadcast driver (^3.0)."
},
"config": {
"sort-packages": true
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Bus/BusServiceProvider.php b/pfosten/vendor/laravel/framework/src/Illuminate/Bus/BusServiceProvider.php
index ade4a77a..d41fe6a0 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Bus/BusServiceProvider.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Bus/BusServiceProvider.php
@@ -3,19 +3,13 @@
namespace Illuminate\Bus;
use Illuminate\Support\ServiceProvider;
+use Illuminate\Contracts\Support\DeferrableProvider;
use Illuminate\Contracts\Bus\Dispatcher as DispatcherContract;
use Illuminate\Contracts\Queue\Factory as QueueFactoryContract;
use Illuminate\Contracts\Bus\QueueingDispatcher as QueueingDispatcherContract;
-class BusServiceProvider extends ServiceProvider
+class BusServiceProvider extends ServiceProvider implements DeferrableProvider
{
- /**
- * Indicates if loading of the provider is deferred.
- *
- * @var bool
- */
- protected $defer = true;
-
/**
* Register the service provider.
*
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php b/pfosten/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php
index 2690fe75..1a7b9a40 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php
@@ -71,9 +71,9 @@ class Dispatcher implements QueueingDispatcher
{
if ($this->queueResolver && $this->commandShouldBeQueued($command)) {
return $this->dispatchToQueue($command);
- } else {
- return $this->dispatchNow($command);
}
+
+ return $this->dispatchNow($command);
}
/**
@@ -145,7 +145,7 @@ class Dispatcher implements QueueingDispatcher
*/
public function dispatchToQueue($command)
{
- $connection = isset($command->connection) ? $command->connection : null;
+ $connection = $command->connection ?? null;
$queue = call_user_func($this->queueResolver, $connection);
@@ -155,9 +155,9 @@ class Dispatcher implements QueueingDispatcher
if (method_exists($command, 'queue')) {
return $command->queue($queue, $command);
- } else {
- return $this->pushCommandToQueue($queue, $command);
}
+
+ return $this->pushCommandToQueue($queue, $command);
}
/**
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Bus/Queueable.php b/pfosten/vendor/laravel/framework/src/Illuminate/Bus/Queueable.php
index 6813363e..48cee186 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Bus/Queueable.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Bus/Queueable.php
@@ -18,13 +18,34 @@ trait Queueable
*/
public $queue;
+ /**
+ * The name of the connection the chain should be sent to.
+ *
+ * @var string|null
+ */
+ public $chainConnection;
+
+ /**
+ * The name of the queue the chain should be sent to.
+ *
+ * @var string|null
+ */
+ public $chainQueue;
+
/**
* The number of seconds before the job should be made available.
*
- * @var \DateTime|int|null
+ * @var \DateTimeInterface|\DateInterval|int|null
*/
public $delay;
+ /**
+ * The jobs that should run if this job is successful.
+ *
+ * @var array
+ */
+ public $chained = [];
+
/**
* Set the desired connection for the job.
*
@@ -51,10 +72,38 @@ trait Queueable
return $this;
}
+ /**
+ * Set the desired connection for the chain.
+ *
+ * @param string|null $connection
+ * @return $this
+ */
+ public function allOnConnection($connection)
+ {
+ $this->chainConnection = $connection;
+ $this->connection = $connection;
+
+ return $this;
+ }
+
+ /**
+ * Set the desired queue for the chain.
+ *
+ * @param string|null $queue
+ * @return $this
+ */
+ public function allOnQueue($queue)
+ {
+ $this->chainQueue = $queue;
+ $this->queue = $queue;
+
+ return $this;
+ }
+
/**
* Set the desired delay for the job.
*
- * @param \DateTime|int|null $delay
+ * @param \DateTimeInterface|\DateInterval|int|null $delay
* @return $this
*/
public function delay($delay)
@@ -63,4 +112,39 @@ trait Queueable
return $this;
}
+
+ /**
+ * Set the jobs that should run if this job is successful.
+ *
+ * @param array $chain
+ * @return $this
+ */
+ public function chain($chain)
+ {
+ $this->chained = collect($chain)->map(function ($job) {
+ return serialize($job);
+ })->all();
+
+ return $this;
+ }
+
+ /**
+ * Dispatch the next job on the chain.
+ *
+ * @return void
+ */
+ public function dispatchNextJobInChain()
+ {
+ if (! empty($this->chained)) {
+ dispatch(tap(unserialize(array_shift($this->chained)), function ($next) {
+ $next->chained = $this->chained;
+
+ $next->onConnection($next->connection ?: $this->chainConnection);
+ $next->onQueue($next->queue ?: $this->chainQueue);
+
+ $next->chainConnection = $this->chainConnection;
+ $next->chainQueue = $this->chainQueue;
+ }));
+ }
+ }
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Bus/composer.json b/pfosten/vendor/laravel/framework/src/Illuminate/Bus/composer.json
index 1f29f620..d2662466 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Bus/composer.json
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Bus/composer.json
@@ -14,10 +14,10 @@
}
],
"require": {
- "php": ">=5.6.4",
- "illuminate/contracts": "5.4.*",
- "illuminate/pipeline": "5.4.*",
- "illuminate/support": "5.4.*"
+ "php": "^7.1.3",
+ "illuminate/contracts": "5.8.*",
+ "illuminate/pipeline": "5.8.*",
+ "illuminate/support": "5.8.*"
},
"autoload": {
"psr-4": {
@@ -26,7 +26,7 @@
},
"extra": {
"branch-alias": {
- "dev-master": "5.4-dev"
+ "dev-master": "5.8-dev"
}
},
"config": {
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Cache/ApcStore.php b/pfosten/vendor/laravel/framework/src/Illuminate/Cache/ApcStore.php
index db11ea4e..dc5e2f08 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Cache/ApcStore.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Cache/ApcStore.php
@@ -2,9 +2,7 @@
namespace Illuminate\Cache;
-use Illuminate\Contracts\Cache\Store;
-
-class ApcStore extends TaggableStore implements Store
+class ApcStore extends TaggableStore
{
use RetrievesMultipleKeys;
@@ -51,16 +49,16 @@ class ApcStore extends TaggableStore implements Store
}
/**
- * Store an item in the cache for a given number of minutes.
+ * Store an item in the cache for a given number of seconds.
*
* @param string $key
* @param mixed $value
- * @param float|int $minutes
- * @return void
+ * @param int $seconds
+ * @return bool
*/
- public function put($key, $value, $minutes)
+ public function put($key, $value, $seconds)
{
- $this->apc->put($this->prefix.$key, $value, (int) ($minutes * 60));
+ return $this->apc->put($this->prefix.$key, $value, $seconds);
}
/**
@@ -92,11 +90,11 @@ class ApcStore extends TaggableStore implements Store
*
* @param string $key
* @param mixed $value
- * @return void
+ * @return bool
*/
public function forever($key, $value)
{
- $this->put($key, $value, 0);
+ return $this->put($key, $value, 0);
}
/**
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Cache/ArrayStore.php b/pfosten/vendor/laravel/framework/src/Illuminate/Cache/ArrayStore.php
index 8901a489..f1f00d63 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Cache/ArrayStore.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Cache/ArrayStore.php
@@ -2,11 +2,11 @@
namespace Illuminate\Cache;
-use Illuminate\Contracts\Cache\Store;
+use Illuminate\Support\InteractsWithTime;
-class ArrayStore extends TaggableStore implements Store
+class ArrayStore extends TaggableStore
{
- use RetrievesMultipleKeys;
+ use InteractsWithTime, RetrievesMultipleKeys;
/**
* The array of stored values.
@@ -23,22 +23,39 @@ class ArrayStore extends TaggableStore implements Store
*/
public function get($key)
{
- if (array_key_exists($key, $this->storage)) {
- return $this->storage[$key];
+ if (! isset($this->storage[$key])) {
+ return;
}
+
+ $item = $this->storage[$key];
+
+ $expiresAt = $item['expiresAt'] ?? 0;
+
+ if ($expiresAt !== 0 && $this->currentTime() > $expiresAt) {
+ $this->forget($key);
+
+ return;
+ }
+
+ return $item['value'];
}
/**
- * Store an item in the cache for a given number of minutes.
+ * Store an item in the cache for a given number of seconds.
*
* @param string $key
* @param mixed $value
- * @param float|int $minutes
- * @return void
+ * @param int $seconds
+ * @return bool
*/
- public function put($key, $value, $minutes)
+ public function put($key, $value, $seconds)
{
- $this->storage[$key] = $value;
+ $this->storage[$key] = [
+ 'value' => $value,
+ 'expiresAt' => $this->calculateExpiration($seconds),
+ ];
+
+ return true;
}
/**
@@ -50,10 +67,15 @@ class ArrayStore extends TaggableStore implements Store
*/
public function increment($key, $value = 1)
{
- $this->storage[$key] = ! isset($this->storage[$key])
- ? $value : ((int) $this->storage[$key]) + $value;
+ if (! isset($this->storage[$key])) {
+ $this->forever($key, $value);
- return $this->storage[$key];
+ return $this->storage[$key]['value'];
+ }
+
+ $this->storage[$key]['value'] = ((int) $this->storage[$key]['value']) + $value;
+
+ return $this->storage[$key]['value'];
}
/**
@@ -73,11 +95,11 @@ class ArrayStore extends TaggableStore implements Store
*
* @param string $key
* @param mixed $value
- * @return void
+ * @return bool
*/
public function forever($key, $value)
{
- $this->put($key, $value, 0);
+ return $this->put($key, $value, 0);
}
/**
@@ -88,9 +110,13 @@ class ArrayStore extends TaggableStore implements Store
*/
public function forget($key)
{
- unset($this->storage[$key]);
+ if (array_key_exists($key, $this->storage)) {
+ unset($this->storage[$key]);
- return true;
+ return true;
+ }
+
+ return false;
}
/**
@@ -114,4 +140,26 @@ class ArrayStore extends TaggableStore implements Store
{
return '';
}
+
+ /**
+ * Get the expiration time of the key.
+ *
+ * @param int $seconds
+ * @return int
+ */
+ protected function calculateExpiration($seconds)
+ {
+ return $this->toTimestamp($seconds);
+ }
+
+ /**
+ * Get the UNIX timestamp for the given number of seconds.
+ *
+ * @param int $seconds
+ * @return int
+ */
+ protected function toTimestamp($seconds)
+ {
+ return $seconds > 0 ? $this->availableAt($seconds) : 0;
+ }
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Cache/CacheManager.php b/pfosten/vendor/laravel/framework/src/Illuminate/Cache/CacheManager.php
index 79dfea86..8c72c814 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Cache/CacheManager.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Cache/CacheManager.php
@@ -5,6 +5,7 @@ namespace Illuminate\Cache;
use Closure;
use Illuminate\Support\Arr;
use InvalidArgumentException;
+use Aws\DynamoDb\DynamoDbClient;
use Illuminate\Contracts\Cache\Store;
use Illuminate\Contracts\Cache\Factory as FactoryContract;
use Illuminate\Contracts\Events\Dispatcher as DispatcherContract;
@@ -17,7 +18,7 @@ class CacheManager implements FactoryContract
/**
* The application instance.
*
- * @var \Illuminate\Foundation\Application
+ * @var \Illuminate\Contracts\Foundation\Application
*/
protected $app;
@@ -38,7 +39,7 @@ class CacheManager implements FactoryContract
/**
* Create a new Cache manager instance.
*
- * @param \Illuminate\Foundation\Application $app
+ * @param \Illuminate\Contracts\Foundation\Application $app
* @return void
*/
public function __construct($app)
@@ -47,10 +48,10 @@ class CacheManager implements FactoryContract
}
/**
- * Get a cache store instance by name.
+ * Get a cache store instance by name, wrapped in a repository.
*
* @param string|null $name
- * @return mixed
+ * @return \Illuminate\Contracts\Cache\Repository
*/
public function store($name = null)
{
@@ -62,8 +63,8 @@ class CacheManager implements FactoryContract
/**
* Get a cache driver instance.
*
- * @param string $driver
- * @return mixed
+ * @param string|null $driver
+ * @return \Illuminate\Contracts\Cache\Repository
*/
public function driver($driver = null)
{
@@ -78,7 +79,7 @@ class CacheManager implements FactoryContract
*/
protected function get($name)
{
- return isset($this->stores[$name]) ? $this->stores[$name] : $this->resolve($name);
+ return $this->stores[$name] ?? $this->resolve($name);
}
/**
@@ -125,7 +126,7 @@ class CacheManager implements FactoryContract
* Create an instance of the APC cache driver.
*
* @param array $config
- * @return \Illuminate\Cache\ApcStore
+ * @return \Illuminate\Cache\Repository
*/
protected function createApcDriver(array $config)
{
@@ -137,7 +138,7 @@ class CacheManager implements FactoryContract
/**
* Create an instance of the array cache driver.
*
- * @return \Illuminate\Cache\ArrayStore
+ * @return \Illuminate\Cache\Repository
*/
protected function createArrayDriver()
{
@@ -148,7 +149,7 @@ class CacheManager implements FactoryContract
* Create an instance of the file cache driver.
*
* @param array $config
- * @return \Illuminate\Cache\FileStore
+ * @return \Illuminate\Cache\Repository
*/
protected function createFileDriver(array $config)
{
@@ -159,7 +160,7 @@ class CacheManager implements FactoryContract
* Create an instance of the Memcached cache driver.
*
* @param array $config
- * @return \Illuminate\Cache\MemcachedStore
+ * @return \Illuminate\Cache\Repository
*/
protected function createMemcachedDriver(array $config)
{
@@ -167,9 +168,9 @@ class CacheManager implements FactoryContract
$memcached = $this->app['memcached.connector']->connect(
$config['servers'],
- array_get($config, 'persistent_id'),
- array_get($config, 'options', []),
- array_filter(array_get($config, 'sasl', []))
+ $config['persistent_id'] ?? null,
+ $config['options'] ?? [],
+ array_filter($config['sasl'] ?? [])
);
return $this->repository(new MemcachedStore($memcached, $prefix));
@@ -178,7 +179,7 @@ class CacheManager implements FactoryContract
/**
* Create an instance of the Null cache driver.
*
- * @return \Illuminate\Cache\NullStore
+ * @return \Illuminate\Cache\Repository
*/
protected function createNullDriver()
{
@@ -189,13 +190,13 @@ class CacheManager implements FactoryContract
* Create an instance of the Redis cache driver.
*
* @param array $config
- * @return \Illuminate\Cache\RedisStore
+ * @return \Illuminate\Cache\Repository
*/
protected function createRedisDriver(array $config)
{
$redis = $this->app['redis'];
- $connection = Arr::get($config, 'connection', 'default');
+ $connection = $config['connection'] ?? 'default';
return $this->repository(new RedisStore($redis, $this->getPrefix($config), $connection));
}
@@ -204,15 +205,47 @@ class CacheManager implements FactoryContract
* Create an instance of the database cache driver.
*
* @param array $config
- * @return \Illuminate\Cache\DatabaseStore
+ * @return \Illuminate\Cache\Repository
*/
protected function createDatabaseDriver(array $config)
{
- $connection = $this->app['db']->connection(Arr::get($config, 'connection'));
+ $connection = $this->app['db']->connection($config['connection'] ?? null);
return $this->repository(
new DatabaseStore(
- $connection, $this->app['encrypter'], $config['table'], $this->getPrefix($config)
+ $connection, $config['table'], $this->getPrefix($config)
+ )
+ );
+ }
+
+ /**
+ * Create an instance of the DynamoDB cache driver.
+ *
+ * @param array $config
+ * @return \Illuminate\Cache\Repository
+ */
+ protected function createDynamodbDriver(array $config)
+ {
+ $dynamoConfig = [
+ 'region' => $config['region'],
+ 'version' => 'latest',
+ 'endpoint' => $config['endpoint'] ?? null,
+ ];
+
+ if ($config['key'] && $config['secret']) {
+ $dynamoConfig['credentials'] = Arr::only(
+ $config, ['key', 'secret', 'token']
+ );
+ }
+
+ return $this->repository(
+ new DynamoDbStore(
+ new DynamoDbClient($dynamoConfig),
+ $config['table'],
+ $config['attributes']['key'] ?? 'key',
+ $config['attributes']['value'] ?? 'value',
+ $config['attributes']['expiration'] ?? 'expires_at',
+ $this->getPrefix($config)
)
);
}
@@ -244,7 +277,7 @@ class CacheManager implements FactoryContract
*/
protected function getPrefix(array $config)
{
- return Arr::get($config, 'prefix') ?: $this->app['config']['cache.prefix'];
+ return $config['prefix'] ?? $this->app['config']['cache.prefix'];
}
/**
@@ -279,10 +312,29 @@ class CacheManager implements FactoryContract
$this->app['config']['cache.default'] = $name;
}
+ /**
+ * Unset the given driver instances.
+ *
+ * @param array|string|null $name
+ * @return $this
+ */
+ public function forgetDriver($name = null)
+ {
+ $name = $name ?? $this->getDefaultDriver();
+
+ foreach ((array) $name as $cacheName) {
+ if (isset($this->stores[$cacheName])) {
+ unset($this->stores[$cacheName]);
+ }
+ }
+
+ return $this;
+ }
+
/**
* Register a custom driver creator Closure.
*
- * @param string $driver
+ * @param string $driver
* @param \Closure $callback
* @return $this
*/
@@ -297,7 +349,7 @@ class CacheManager implements FactoryContract
* Dynamically call the default driver instance.
*
* @param string $method
- * @param array $parameters
+ * @param array $parameters
* @return mixed
*/
public function __call($method, $parameters)
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Cache/CacheServiceProvider.php b/pfosten/vendor/laravel/framework/src/Illuminate/Cache/CacheServiceProvider.php
index 8eb5ed60..8b6e929d 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Cache/CacheServiceProvider.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Cache/CacheServiceProvider.php
@@ -3,16 +3,10 @@
namespace Illuminate\Cache;
use Illuminate\Support\ServiceProvider;
+use Illuminate\Contracts\Support\DeferrableProvider;
-class CacheServiceProvider extends ServiceProvider
+class CacheServiceProvider extends ServiceProvider implements DeferrableProvider
{
- /**
- * Indicates if loading of the provider is deferred.
- *
- * @var bool
- */
- protected $defer = true;
-
/**
* Register the service provider.
*
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Cache/Console/CacheTableCommand.php b/pfosten/vendor/laravel/framework/src/Illuminate/Cache/Console/CacheTableCommand.php
index 7c3f4b62..bde2d4b9 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Cache/Console/CacheTableCommand.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Cache/Console/CacheTableCommand.php
@@ -54,7 +54,7 @@ class CacheTableCommand extends Command
*
* @return void
*/
- public function fire()
+ public function handle()
{
$fullPath = $this->createBaseMigration();
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Cache/Console/ClearCommand.php b/pfosten/vendor/laravel/framework/src/Illuminate/Cache/Console/ClearCommand.php
index 48c57634..4feeb17d 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Cache/Console/ClearCommand.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Cache/Console/ClearCommand.php
@@ -4,6 +4,7 @@ namespace Illuminate\Cache\Console;
use Illuminate\Console\Command;
use Illuminate\Cache\CacheManager;
+use Illuminate\Filesystem\Filesystem;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
@@ -30,17 +31,26 @@ class ClearCommand extends Command
*/
protected $cache;
+ /**
+ * The filesystem instance.
+ *
+ * @var \Illuminate\Filesystem\Filesystem
+ */
+ protected $files;
+
/**
* Create a new cache clear command instance.
*
* @param \Illuminate\Cache\CacheManager $cache
+ * @param \Illuminate\Filesystem\Filesystem $files
* @return void
*/
- public function __construct(CacheManager $cache)
+ public function __construct(CacheManager $cache, Filesystem $files)
{
parent::__construct();
$this->cache = $cache;
+ $this->files = $files;
}
/**
@@ -50,13 +60,41 @@ class ClearCommand extends Command
*/
public function handle()
{
- $this->laravel['events']->fire('cache:clearing', [$this->argument('store'), $this->tags()]);
+ $this->laravel['events']->dispatch(
+ 'cache:clearing', [$this->argument('store'), $this->tags()]
+ );
- $this->cache()->flush();
+ $successful = $this->cache()->flush();
- $this->laravel['events']->fire('cache:cleared', [$this->argument('store'), $this->tags()]);
+ $this->flushFacades();
- $this->info('Cache cleared successfully.');
+ if (! $successful) {
+ return $this->error('Failed to clear cache. Make sure you have the appropriate permissions.');
+ }
+
+ $this->laravel['events']->dispatch(
+ 'cache:cleared', [$this->argument('store'), $this->tags()]
+ );
+
+ $this->info('Application cache cleared!');
+ }
+
+ /**
+ * Flush the real-time facades stored in the cache directory.
+ *
+ * @return void
+ */
+ public function flushFacades()
+ {
+ if (! $this->files->exists($storagePath = storage_path('framework/cache'))) {
+ return;
+ }
+
+ foreach ($this->files->files($storagePath) as $file) {
+ if (preg_match('/facade-.*\.php$/', $file)) {
+ $this->files->delete($file);
+ }
+ }
}
/**
@@ -89,7 +127,7 @@ class ClearCommand extends Command
protected function getArguments()
{
return [
- ['store', InputArgument::OPTIONAL, 'The name of the store you would like to clear.'],
+ ['store', InputArgument::OPTIONAL, 'The name of the store you would like to clear'],
];
}
@@ -101,7 +139,7 @@ class ClearCommand extends Command
protected function getOptions()
{
return [
- ['tags', null, InputOption::VALUE_OPTIONAL, 'The cache tags you would like to clear.', null],
+ ['tags', null, InputOption::VALUE_OPTIONAL, 'The cache tags you would like to clear', null],
];
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Cache/Console/stubs/cache.stub b/pfosten/vendor/laravel/framework/src/Illuminate/Cache/Console/stubs/cache.stub
index 1f7761c2..058afe69 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Cache/Console/stubs/cache.stub
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Cache/Console/stubs/cache.stub
@@ -15,7 +15,7 @@ class CreateCacheTable extends Migration
{
Schema::create('cache', function (Blueprint $table) {
$table->string('key')->unique();
- $table->text('value');
+ $table->mediumText('value');
$table->integer('expiration');
});
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Cache/DatabaseStore.php b/pfosten/vendor/laravel/framework/src/Illuminate/Cache/DatabaseStore.php
index c120c975..a7de61bb 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Cache/DatabaseStore.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Cache/DatabaseStore.php
@@ -4,14 +4,15 @@ namespace Illuminate\Cache;
use Closure;
use Exception;
-use Carbon\Carbon;
+use Illuminate\Support\Str;
use Illuminate\Contracts\Cache\Store;
+use Illuminate\Support\InteractsWithTime;
+use Illuminate\Database\PostgresConnection;
use Illuminate\Database\ConnectionInterface;
-use Illuminate\Contracts\Encryption\Encrypter as EncrypterContract;
class DatabaseStore implements Store
{
- use RetrievesMultipleKeys;
+ use InteractsWithTime, RetrievesMultipleKeys;
/**
* The database connection instance.
@@ -20,13 +21,6 @@ class DatabaseStore implements Store
*/
protected $connection;
- /**
- * The encrypter instance.
- *
- * @var \Illuminate\Contracts\Encryption\Encrypter
- */
- protected $encrypter;
-
/**
* The name of the cache table.
*
@@ -45,17 +39,14 @@ class DatabaseStore implements Store
* Create a new database store.
*
* @param \Illuminate\Database\ConnectionInterface $connection
- * @param \Illuminate\Contracts\Encryption\Encrypter $encrypter
* @param string $table
* @param string $prefix
* @return void
*/
- public function __construct(ConnectionInterface $connection, EncrypterContract $encrypter,
- $table, $prefix = '')
+ public function __construct(ConnectionInterface $connection, $table, $prefix = '')
{
$this->table = $table;
$this->prefix = $prefix;
- $this->encrypter = $encrypter;
$this->connection = $connection;
}
@@ -83,38 +74,37 @@ class DatabaseStore implements Store
// If this cache expiration date is past the current time, we will remove this
// item from the cache. Then we will return a null value since the cache is
// expired. We will use "Carbon" to make this comparison with the column.
- if (Carbon::now()->getTimestamp() >= $cache->expiration) {
+ if ($this->currentTime() >= $cache->expiration) {
$this->forget($key);
return;
}
- return $this->encrypter->decrypt($cache->value);
+ return $this->unserialize($cache->value);
}
/**
- * Store an item in the cache for a given number of minutes.
+ * Store an item in the cache for a given number of seconds.
*
* @param string $key
* @param mixed $value
- * @param float|int $minutes
- * @return void
+ * @param int $seconds
+ * @return bool
*/
- public function put($key, $value, $minutes)
+ public function put($key, $value, $seconds)
{
$key = $this->prefix.$key;
- // All of the cached values in the database are encrypted in case this is used
- // as a session data store by the consumer. We'll also calculate the expire
- // time and place that on the table so we will check it on our retrieval.
- $value = $this->encrypter->encrypt($value);
+ $value = $this->serialize($value);
- $expiration = $this->getTime() + (int) ($minutes * 60);
+ $expiration = $this->getTime() + $seconds;
try {
- $this->table()->insert(compact('key', 'value', 'expiration'));
+ return $this->table()->insert(compact('key', 'value', 'expiration'));
} catch (Exception $e) {
- $this->table()->where('key', $key)->update(compact('value', 'expiration'));
+ $result = $this->table()->where('key', $key)->update(compact('value', 'expiration'));
+
+ return $result > 0;
}
}
@@ -171,7 +161,7 @@ class DatabaseStore implements Store
$cache = is_array($cache) ? (object) $cache : $cache;
- $current = $this->encrypter->decrypt($cache->value);
+ $current = $this->unserialize($cache->value);
// Here we'll call this callback function that was given to the function which
// is used to either increment or decrement the function. We use a callback
@@ -186,7 +176,7 @@ class DatabaseStore implements Store
// since database cache values are encrypted by default with secure storage
// that can't be easily read. We will return the new value after storing.
$this->table()->where('key', $prefixed)->update([
- 'value' => $this->encrypter->encrypt($new),
+ 'value' => $this->serialize($new),
]);
return $new;
@@ -200,7 +190,7 @@ class DatabaseStore implements Store
*/
protected function getTime()
{
- return Carbon::now()->getTimestamp();
+ return $this->currentTime();
}
/**
@@ -208,11 +198,11 @@ class DatabaseStore implements Store
*
* @param string $key
* @param mixed $value
- * @return void
+ * @return bool
*/
public function forever($key, $value)
{
- $this->put($key, $value, 5256000);
+ return $this->put($key, $value, 315360000);
}
/**
@@ -235,7 +225,9 @@ class DatabaseStore implements Store
*/
public function flush()
{
- return (bool) $this->table()->delete();
+ $this->table()->delete();
+
+ return true;
}
/**
@@ -258,16 +250,6 @@ class DatabaseStore implements Store
return $this->connection;
}
- /**
- * Get the encrypter instance.
- *
- * @return \Illuminate\Contracts\Encryption\Encrypter
- */
- public function getEncrypter()
- {
- return $this->encrypter;
- }
-
/**
* Get the cache key prefix.
*
@@ -277,4 +259,36 @@ class DatabaseStore implements Store
{
return $this->prefix;
}
+
+ /**
+ * Serialize the given value.
+ *
+ * @param mixed $value
+ * @return string
+ */
+ protected function serialize($value)
+ {
+ $result = serialize($value);
+
+ if ($this->connection instanceof PostgresConnection && Str::contains($result, "\0")) {
+ $result = base64_encode($result);
+ }
+
+ return $result;
+ }
+
+ /**
+ * Unserialize the given value.
+ *
+ * @param string $value
+ * @return mixed
+ */
+ protected function unserialize($value)
+ {
+ if ($this->connection instanceof PostgresConnection && ! Str::contains($value, [':', ';'])) {
+ $value = base64_decode($value);
+ }
+
+ return unserialize($value);
+ }
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Cache/Events/KeyWritten.php b/pfosten/vendor/laravel/framework/src/Illuminate/Cache/Events/KeyWritten.php
index 82ad0893..6474dced 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Cache/Events/KeyWritten.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Cache/Events/KeyWritten.php
@@ -12,26 +12,26 @@ class KeyWritten extends CacheEvent
public $value;
/**
- * The number of minutes the key should be valid.
+ * The number of seconds the key should be valid.
*
- * @var int
+ * @var int|null
*/
- public $minutes;
+ public $seconds;
/**
* Create a new event instance.
*
* @param string $key
* @param mixed $value
- * @param int $minutes
+ * @param int|null $seconds
* @param array $tags
* @return void
*/
- public function __construct($key, $value, $minutes, $tags = [])
+ public function __construct($key, $value, $seconds = null, $tags = [])
{
parent::__construct($key, $tags);
$this->value = $value;
- $this->minutes = $minutes;
+ $this->seconds = $seconds;
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Cache/FileStore.php b/pfosten/vendor/laravel/framework/src/Illuminate/Cache/FileStore.php
index 90d49c0b..228d6997 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Cache/FileStore.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Cache/FileStore.php
@@ -3,14 +3,13 @@
namespace Illuminate\Cache;
use Exception;
-use Carbon\Carbon;
-use Illuminate\Support\Arr;
use Illuminate\Contracts\Cache\Store;
use Illuminate\Filesystem\Filesystem;
+use Illuminate\Support\InteractsWithTime;
class FileStore implements Store
{
- use RetrievesMultipleKeys;
+ use InteractsWithTime, RetrievesMultipleKeys;
/**
* The Illuminate Filesystem instance.
@@ -47,24 +46,26 @@ class FileStore implements Store
*/
public function get($key)
{
- return Arr::get($this->getPayload($key), 'data');
+ return $this->getPayload($key)['data'] ?? null;
}
/**
- * Store an item in the cache for a given number of minutes.
+ * Store an item in the cache for a given number of seconds.
*
* @param string $key
* @param mixed $value
- * @param float|int $minutes
- * @return void
+ * @param int $seconds
+ * @return bool
*/
- public function put($key, $value, $minutes)
+ public function put($key, $value, $seconds)
{
$this->ensureCacheDirectoryExists($path = $this->path($key));
- $this->files->put(
- $path, $this->expiration($minutes).serialize($value), true
+ $result = $this->files->put(
+ $path, $this->expiration($seconds).serialize($value), true
);
+
+ return $result !== false && $result > 0;
}
/**
@@ -92,7 +93,7 @@ class FileStore implements Store
$raw = $this->getPayload($key);
return tap(((int) $raw['data']) + $value, function ($newValue) use ($key, $raw) {
- $this->put($key, $newValue, $raw['time']);
+ $this->put($key, $newValue, $raw['time'] ?? 0);
});
}
@@ -113,11 +114,11 @@ class FileStore implements Store
*
* @param string $key
* @param mixed $value
- * @return void
+ * @return bool
*/
public function forever($key, $value)
{
- $this->put($key, $value, 0);
+ return $this->put($key, $value, 0);
}
/**
@@ -165,7 +166,7 @@ class FileStore implements Store
{
$path = $this->path($key);
- // If the file doesn't exists, we obviously can't return the cache so we will
+ // If the file doesn't exist, we obviously cannot return the cache so we will
// just return null. Otherwise, we'll get the contents of the file and get
// the expiration UNIX timestamps from the start of the file's contents.
try {
@@ -179,18 +180,24 @@ class FileStore implements Store
// If the current time is greater than expiration timestamps we will delete
// the file and return null. This helps clean up the old files and keeps
// this directory much cleaner for us as old files aren't hanging out.
- if (Carbon::now()->getTimestamp() >= $expire) {
+ if ($this->currentTime() >= $expire) {
$this->forget($key);
return $this->emptyPayload();
}
- $data = unserialize(substr($contents, 10));
+ try {
+ $data = unserialize(substr($contents, 10));
+ } catch (Exception $e) {
+ $this->forget($key);
- // Next, we'll extract the number of minutes that are remaining for a cache
+ return $this->emptyPayload();
+ }
+
+ // Next, we'll extract the number of seconds that are remaining for a cache
// so that we can properly retain the time for things like the increment
// operation that may be performed on this cache on a later operation.
- $time = ($expire - Carbon::now()->getTimestamp()) / 60;
+ $time = $expire - $this->currentTime();
return compact('data', 'time');
}
@@ -219,16 +226,16 @@ class FileStore implements Store
}
/**
- * Get the expiration time based on the given minutes.
+ * Get the expiration time based on the given seconds.
*
- * @param float|int $minutes
+ * @param int $seconds
* @return int
*/
- protected function expiration($minutes)
+ protected function expiration($seconds)
{
- $time = Carbon::now()->getTimestamp() + (int) ($minutes * 60);
+ $time = $this->availableAt($seconds);
- return $minutes === 0 || $time > 9999999999 ? 9999999999 : (int) $time;
+ return $seconds === 0 || $time > 9999999999 ? 9999999999 : $time;
}
/**
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Cache/MemcachedConnector.php b/pfosten/vendor/laravel/framework/src/Illuminate/Cache/MemcachedConnector.php
index ebfb28c7..224d9409 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Cache/MemcachedConnector.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Cache/MemcachedConnector.php
@@ -47,7 +47,7 @@ class MemcachedConnector
{
$memcached = $this->createMemcachedInstance($connectionId);
- if (count($credentials) == 2) {
+ if (count($credentials) === 2) {
$this->setCredentials($memcached, $credentials);
}
@@ -78,7 +78,7 @@ class MemcachedConnector
*/
protected function setCredentials($memcached, $credentials)
{
- list($username, $password) = $credentials;
+ [$username, $password] = $credentials;
$memcached->setOption(Memcached::OPT_BINARY_PROTOCOL, true);
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Cache/MemcachedStore.php b/pfosten/vendor/laravel/framework/src/Illuminate/Cache/MemcachedStore.php
index dfd616b7..827f6029 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Cache/MemcachedStore.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Cache/MemcachedStore.php
@@ -3,12 +3,14 @@
namespace Illuminate\Cache;
use Memcached;
-use Carbon\Carbon;
use ReflectionMethod;
-use Illuminate\Contracts\Cache\Store;
+use Illuminate\Support\InteractsWithTime;
+use Illuminate\Contracts\Cache\LockProvider;
-class MemcachedStore extends TaggableStore implements Store
+class MemcachedStore extends TaggableStore implements LockProvider
{
+ use InteractsWithTime;
+
/**
* The Memcached instance.
*
@@ -91,26 +93,28 @@ class MemcachedStore extends TaggableStore implements Store
}
/**
- * Store an item in the cache for a given number of minutes.
+ * Store an item in the cache for a given number of seconds.
*
* @param string $key
* @param mixed $value
- * @param float|int $minutes
- * @return void
+ * @param int $seconds
+ * @return bool
*/
- public function put($key, $value, $minutes)
+ public function put($key, $value, $seconds)
{
- $this->memcached->set($this->prefix.$key, $value, $this->toTimestamp($minutes));
+ return $this->memcached->set(
+ $this->prefix.$key, $value, $this->calculateExpiration($seconds)
+ );
}
/**
- * Store multiple items in the cache for a given number of minutes.
+ * Store multiple items in the cache for a given number of seconds.
*
* @param array $values
- * @param float|int $minutes
- * @return void
+ * @param int $seconds
+ * @return bool
*/
- public function putMany(array $values, $minutes)
+ public function putMany(array $values, $seconds)
{
$prefixedValues = [];
@@ -118,7 +122,9 @@ class MemcachedStore extends TaggableStore implements Store
$prefixedValues[$this->prefix.$key] = $value;
}
- $this->memcached->setMulti($prefixedValues, $this->toTimestamp($minutes));
+ return $this->memcached->setMulti(
+ $prefixedValues, $this->calculateExpiration($seconds)
+ );
}
/**
@@ -126,12 +132,14 @@ class MemcachedStore extends TaggableStore implements Store
*
* @param string $key
* @param mixed $value
- * @param float|int $minutes
+ * @param int $seconds
* @return bool
*/
- public function add($key, $value, $minutes)
+ public function add($key, $value, $seconds)
{
- return $this->memcached->add($this->prefix.$key, $value, $this->toTimestamp($minutes));
+ return $this->memcached->add(
+ $this->prefix.$key, $value, $this->calculateExpiration($seconds)
+ );
}
/**
@@ -163,11 +171,36 @@ class MemcachedStore extends TaggableStore implements Store
*
* @param string $key
* @param mixed $value
- * @return void
+ * @return bool
*/
public function forever($key, $value)
{
- $this->put($key, $value, 0);
+ return $this->put($key, $value, 0);
+ }
+
+ /**
+ * Get a lock instance.
+ *
+ * @param string $name
+ * @param int $seconds
+ * @param string|null $owner
+ * @return \Illuminate\Contracts\Cache\Lock
+ */
+ public function lock($name, $seconds = 0, $owner = null)
+ {
+ return new MemcachedLock($this->memcached, $this->prefix.$name, $seconds, $owner);
+ }
+
+ /**
+ * Restore a lock instance using the owner identifier.
+ *
+ * @param string $name
+ * @param string $owner
+ * @return \Illuminate\Contracts\Cache\Lock
+ */
+ public function restoreLock($name, $owner)
+ {
+ return $this->lock($name, 0, $owner);
}
/**
@@ -192,14 +225,25 @@ class MemcachedStore extends TaggableStore implements Store
}
/**
- * Get the UNIX timestamp for the given number of minutes.
+ * Get the expiration time of the key.
*
- * @param int $minutes
+ * @param int $seconds
* @return int
*/
- protected function toTimestamp($minutes)
+ protected function calculateExpiration($seconds)
{
- return $minutes > 0 ? Carbon::now()->addSeconds($minutes * 60)->getTimestamp() : 0;
+ return $this->toTimestamp($seconds);
+ }
+
+ /**
+ * Get the UNIX timestamp for the given number of seconds.
+ *
+ * @param int $seconds
+ * @return int
+ */
+ protected function toTimestamp($seconds)
+ {
+ return $seconds > 0 ? $this->availableAt($seconds) : 0;
}
/**
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Cache/NullStore.php b/pfosten/vendor/laravel/framework/src/Illuminate/Cache/NullStore.php
index 16e869c8..aa7a3975 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Cache/NullStore.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Cache/NullStore.php
@@ -2,9 +2,7 @@
namespace Illuminate\Cache;
-use Illuminate\Contracts\Cache\Store;
-
-class NullStore extends TaggableStore implements Store
+class NullStore extends TaggableStore
{
use RetrievesMultipleKeys;
@@ -23,20 +21,19 @@ class NullStore extends TaggableStore implements Store
*/
public function get($key)
{
- //
}
/**
- * Store an item in the cache for a given number of minutes.
+ * Store an item in the cache for a given number of seconds.
*
* @param string $key
* @param mixed $value
- * @param float|int $minutes
- * @return void
+ * @param int $seconds
+ * @return bool
*/
- public function put($key, $value, $minutes)
+ public function put($key, $value, $seconds)
{
- //
+ return false;
}
/**
@@ -44,11 +41,11 @@ class NullStore extends TaggableStore implements Store
*
* @param string $key
* @param mixed $value
- * @return int
+ * @return int|bool
*/
public function increment($key, $value = 1)
{
- //
+ return false;
}
/**
@@ -56,11 +53,11 @@ class NullStore extends TaggableStore implements Store
*
* @param string $key
* @param mixed $value
- * @return int
+ * @return int|bool
*/
public function decrement($key, $value = 1)
{
- //
+ return false;
}
/**
@@ -68,22 +65,22 @@ class NullStore extends TaggableStore implements Store
*
* @param string $key
* @param mixed $value
- * @return void
+ * @return bool
*/
public function forever($key, $value)
{
- //
+ return false;
}
/**
* Remove an item from the cache.
*
* @param string $key
- * @return void
+ * @return bool
*/
public function forget($key)
{
- //
+ return true;
}
/**
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Cache/RateLimiter.php b/pfosten/vendor/laravel/framework/src/Illuminate/Cache/RateLimiter.php
index 810092bf..c8b2d32d 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Cache/RateLimiter.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Cache/RateLimiter.php
@@ -2,11 +2,13 @@
namespace Illuminate\Cache;
-use Carbon\Carbon;
+use Illuminate\Support\InteractsWithTime;
use Illuminate\Contracts\Cache\Repository as Cache;
class RateLimiter
{
+ use InteractsWithTime;
+
/**
* The cache store implementation.
*
@@ -30,55 +32,40 @@ class RateLimiter
*
* @param string $key
* @param int $maxAttempts
- * @param float|int $decayMinutes
* @return bool
*/
- public function tooManyAttempts($key, $maxAttempts, $decayMinutes = 1)
+ public function tooManyAttempts($key, $maxAttempts)
{
- if ($this->cache->has($key.':lockout')) {
- return true;
- }
-
if ($this->attempts($key) >= $maxAttempts) {
- $this->lockout($key, $decayMinutes);
+ if ($this->cache->has($key.':timer')) {
+ return true;
+ }
$this->resetAttempts($key);
-
- return true;
}
return false;
}
- /**
- * Add the lockout key to the cache.
- *
- * @param string $key
- * @param int $decayMinutes
- * @return void
- */
- protected function lockout($key, $decayMinutes)
- {
- $this->cache->add(
- $key.':lockout', Carbon::now()->getTimestamp() + ($decayMinutes * 60), $decayMinutes
- );
- }
-
/**
* Increment the counter for a given key for a given decay time.
*
* @param string $key
- * @param float|int $decayMinutes
+ * @param int $decaySeconds
* @return int
*/
- public function hit($key, $decayMinutes = 1)
+ public function hit($key, $decaySeconds = 60)
{
- $added = $this->cache->add($key, 0, $decayMinutes);
+ $this->cache->add(
+ $key.':timer', $this->availableAt($decaySeconds), $decaySeconds
+ );
+
+ $added = $this->cache->add($key, 0, $decaySeconds);
$hits = (int) $this->cache->increment($key);
if (! $added && $hits == 1) {
- $this->cache->put($key, 1, $decayMinutes);
+ $this->cache->put($key, 1, $decaySeconds);
}
return $hits;
@@ -121,7 +108,7 @@ class RateLimiter
}
/**
- * Clear the hits and lockout for the given key.
+ * Clear the hits and lockout timer for the given key.
*
* @param string $key
* @return void
@@ -130,7 +117,7 @@ class RateLimiter
{
$this->resetAttempts($key);
- $this->cache->forget($key.':lockout');
+ $this->cache->forget($key.':timer');
}
/**
@@ -141,6 +128,6 @@ class RateLimiter
*/
public function availableIn($key)
{
- return $this->cache->get($key.':lockout') - Carbon::now()->getTimestamp();
+ return $this->cache->get($key.':timer') - $this->currentTime();
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Cache/RedisStore.php b/pfosten/vendor/laravel/framework/src/Illuminate/Cache/RedisStore.php
index 100af0d3..d3b19b09 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Cache/RedisStore.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Cache/RedisStore.php
@@ -2,10 +2,10 @@
namespace Illuminate\Cache;
-use Illuminate\Contracts\Cache\Store;
+use Illuminate\Contracts\Cache\LockProvider;
use Illuminate\Contracts\Redis\Factory as Redis;
-class RedisStore extends TaggableStore implements Store
+class RedisStore extends TaggableStore implements LockProvider
{
/**
* The Redis factory implementation.
@@ -80,36 +80,42 @@ class RedisStore extends TaggableStore implements Store
}
/**
- * Store an item in the cache for a given number of minutes.
+ * Store an item in the cache for a given number of seconds.
*
* @param string $key
* @param mixed $value
- * @param float|int $minutes
- * @return void
+ * @param int $seconds
+ * @return bool
*/
- public function put($key, $value, $minutes)
+ public function put($key, $value, $seconds)
{
- $this->connection()->setex(
- $this->prefix.$key, (int) max(1, $minutes * 60), $this->serialize($value)
+ return (bool) $this->connection()->setex(
+ $this->prefix.$key, (int) max(1, $seconds), $this->serialize($value)
);
}
/**
- * Store multiple items in the cache for a given number of minutes.
+ * Store multiple items in the cache for a given number of seconds.
*
* @param array $values
- * @param float|int $minutes
- * @return void
+ * @param int $seconds
+ * @return bool
*/
- public function putMany(array $values, $minutes)
+ public function putMany(array $values, $seconds)
{
$this->connection()->multi();
+ $manyResult = null;
+
foreach ($values as $key => $value) {
- $this->put($key, $value, $minutes);
+ $result = $this->put($key, $value, $seconds);
+
+ $manyResult = is_null($manyResult) ? $result : $result && $manyResult;
}
$this->connection()->exec();
+
+ return $manyResult ?: false;
}
/**
@@ -117,15 +123,15 @@ class RedisStore extends TaggableStore implements Store
*
* @param string $key
* @param mixed $value
- * @param float|int $minutes
+ * @param int $seconds
* @return bool
*/
- public function add($key, $value, $minutes)
+ public function add($key, $value, $seconds)
{
$lua = "return redis.call('exists',KEYS[1])<1 and redis.call('setex',KEYS[1],ARGV[2],ARGV[1])";
return (bool) $this->connection()->eval(
- $lua, 1, $this->prefix.$key, $this->serialize($value), (int) max(1, $minutes * 60)
+ $lua, 1, $this->prefix.$key, $this->serialize($value), (int) max(1, $seconds)
);
}
@@ -158,11 +164,36 @@ class RedisStore extends TaggableStore implements Store
*
* @param string $key
* @param mixed $value
- * @return void
+ * @return bool
*/
public function forever($key, $value)
{
- $this->connection()->set($this->prefix.$key, $this->serialize($value));
+ return (bool) $this->connection()->set($this->prefix.$key, $this->serialize($value));
+ }
+
+ /**
+ * Get a lock instance.
+ *
+ * @param string $name
+ * @param int $seconds
+ * @param string|null $owner
+ * @return \Illuminate\Contracts\Cache\Lock
+ */
+ public function lock($name, $seconds = 0, $owner = null)
+ {
+ return new RedisLock($this->connection(), $this->prefix.$name, $seconds, $owner);
+ }
+
+ /**
+ * Restore a lock instance using the owner identifier.
+ *
+ * @param string $name
+ * @param string $owner
+ * @return \Illuminate\Contracts\Cache\Lock
+ */
+ public function restoreLock($name, $owner)
+ {
+ return $this->lock($name, 0, $owner);
}
/**
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Cache/RedisTaggedCache.php b/pfosten/vendor/laravel/framework/src/Illuminate/Cache/RedisTaggedCache.php
index d2325a00..ed90db1b 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Cache/RedisTaggedCache.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Cache/RedisTaggedCache.php
@@ -22,41 +22,73 @@ class RedisTaggedCache extends TaggedCache
*
* @param string $key
* @param mixed $value
- * @param \DateTime|float|int $minutes
+ * @param \DateTimeInterface|\DateInterval|int|null $ttl
+ * @return bool
+ */
+ public function put($key, $value, $ttl = null)
+ {
+ if ($ttl === null) {
+ return $this->forever($key, $value);
+ }
+
+ $this->pushStandardKeys($this->tags->getNamespace(), $key);
+
+ return parent::put($key, $value, $ttl);
+ }
+
+ /**
+ * Increment the value of an item in the cache.
+ *
+ * @param string $key
+ * @param mixed $value
* @return void
*/
- public function put($key, $value, $minutes = null)
+ public function increment($key, $value = 1)
{
$this->pushStandardKeys($this->tags->getNamespace(), $key);
- parent::put($key, $value, $minutes);
+ parent::increment($key, $value);
+ }
+
+ /**
+ * Decrement the value of an item in the cache.
+ *
+ * @param string $key
+ * @param mixed $value
+ * @return void
+ */
+ public function decrement($key, $value = 1)
+ {
+ $this->pushStandardKeys($this->tags->getNamespace(), $key);
+
+ parent::decrement($key, $value);
}
/**
* Store an item in the cache indefinitely.
*
* @param string $key
- * @param mixed $value
- * @return void
+ * @param mixed $value
+ * @return bool
*/
public function forever($key, $value)
{
$this->pushForeverKeys($this->tags->getNamespace(), $key);
- parent::forever($key, $value);
+ return parent::forever($key, $value);
}
/**
* Remove all items from the cache.
*
- * @return void
+ * @return bool
*/
public function flush()
{
$this->deleteForeverKeys();
$this->deleteStandardKeys();
- parent::flush();
+ return parent::flush();
}
/**
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Cache/Repository.php b/pfosten/vendor/laravel/framework/src/Illuminate/Cache/Repository.php
index 7ee1484d..a0b7d2c6 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Cache/Repository.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Cache/Repository.php
@@ -3,16 +3,17 @@
namespace Illuminate\Cache;
use Closure;
-use DateTime;
use ArrayAccess;
-use Carbon\Carbon;
+use DateTimeInterface;
use BadMethodCallException;
+use Illuminate\Support\Carbon;
use Illuminate\Cache\Events\CacheHit;
use Illuminate\Contracts\Cache\Store;
use Illuminate\Cache\Events\KeyWritten;
use Illuminate\Cache\Events\CacheMissed;
use Illuminate\Support\Traits\Macroable;
use Illuminate\Cache\Events\KeyForgotten;
+use Illuminate\Support\InteractsWithTime;
use Illuminate\Contracts\Events\Dispatcher;
use Illuminate\Contracts\Cache\Repository as CacheContract;
@@ -21,6 +22,7 @@ use Illuminate\Contracts\Cache\Repository as CacheContract;
*/
class Repository implements CacheContract, ArrayAccess
{
+ use InteractsWithTime;
use Macroable {
__call as macroCall;
}
@@ -40,11 +42,11 @@ class Repository implements CacheContract, ArrayAccess
protected $events;
/**
- * The default number of minutes to store items.
+ * The default number of seconds to store items.
*
- * @var float|int
+ * @var int|null
*/
- protected $default = 60;
+ protected $default = 3600;
/**
* Create a new cache repository instance.
@@ -68,11 +70,22 @@ class Repository implements CacheContract, ArrayAccess
return ! is_null($this->get($key));
}
+ /**
+ * Determine if an item doesn't exist in the cache.
+ *
+ * @param string $key
+ * @return bool
+ */
+ public function missing($key)
+ {
+ return ! $this->has($key);
+ }
+
/**
* Retrieve an item from the cache by key.
*
* @param string $key
- * @param mixed $default
+ * @param mixed $default
* @return mixed
*/
public function get($key, $default = null)
@@ -116,6 +129,20 @@ class Repository implements CacheContract, ArrayAccess
})->all();
}
+ /**
+ * {@inheritdoc}
+ */
+ public function getMultiple($keys, $default = null)
+ {
+ $defaults = [];
+
+ foreach ($keys as $key) {
+ $defaults[$key] = $default;
+ }
+
+ return $this->many($defaults);
+ }
+
/**
* Handle a result for the "many" method.
*
@@ -147,12 +174,12 @@ class Repository implements CacheContract, ArrayAccess
* Retrieve an item from the cache and delete it.
*
* @param string $key
- * @param mixed $default
+ * @param mixed $default
* @return mixed
*/
public function pull($key, $default = null)
{
- return tap($this->get($key, $default), function ($value) use ($key) {
+ return tap($this->get($key, $default), function () use ($key) {
$this->forget($key);
});
}
@@ -161,71 +188,132 @@ class Repository implements CacheContract, ArrayAccess
* Store an item in the cache.
*
* @param string $key
- * @param mixed $value
- * @param \DateTime|float|int $minutes
- * @return void
+ * @param mixed $value
+ * @param \DateTimeInterface|\DateInterval|int|null $ttl
+ * @return bool
*/
- public function put($key, $value, $minutes = null)
+ public function put($key, $value, $ttl = null)
{
if (is_array($key)) {
return $this->putMany($key, $value);
}
- if (! is_null($minutes = $this->getMinutes($minutes))) {
- $this->store->put($this->itemKey($key), $value, $minutes);
-
- $this->event(new KeyWritten($key, $value, $minutes));
+ if ($ttl === null) {
+ return $this->forever($key, $value);
}
+
+ $seconds = $this->getSeconds($ttl);
+
+ if ($seconds <= 0) {
+ return $this->forget($key);
+ }
+
+ $result = $this->store->put($this->itemKey($key), $value, $seconds);
+
+ if ($result) {
+ $this->event(new KeyWritten($key, $value, $seconds));
+ }
+
+ return $result;
}
/**
- * Store multiple items in the cache for a given number of minutes.
+ * {@inheritdoc}
+ */
+ public function set($key, $value, $ttl = null)
+ {
+ return $this->put($key, $value, $ttl);
+ }
+
+ /**
+ * Store multiple items in the cache for a given number of seconds.
*
* @param array $values
- * @param float|int $minutes
- * @return void
+ * @param \DateTimeInterface|\DateInterval|int|null $ttl
+ * @return bool
*/
- public function putMany(array $values, $minutes)
+ public function putMany(array $values, $ttl = null)
{
- if (! is_null($minutes = $this->getMinutes($minutes))) {
- $this->store->putMany($values, $minutes);
+ if ($ttl === null) {
+ return $this->putManyForever($values);
+ }
+ $seconds = $this->getSeconds($ttl);
+
+ if ($seconds <= 0) {
+ return $this->deleteMultiple(array_keys($values));
+ }
+
+ $result = $this->store->putMany($values, $seconds);
+
+ if ($result) {
foreach ($values as $key => $value) {
- $this->event(new KeyWritten($key, $value, $minutes));
+ $this->event(new KeyWritten($key, $value, $seconds));
}
}
+
+ return $result;
+ }
+
+ /**
+ * Store multiple items in the cache indefinitely.
+ *
+ * @param array $values
+ * @return bool
+ */
+ protected function putManyForever(array $values)
+ {
+ $result = true;
+
+ foreach ($values as $key => $value) {
+ if (! $this->forever($key, $value)) {
+ $result = false;
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function setMultiple($values, $ttl = null)
+ {
+ return $this->putMany(is_array($values) ? $values : iterator_to_array($values), $ttl);
}
/**
* Store an item in the cache if the key does not exist.
*
* @param string $key
- * @param mixed $value
- * @param \DateTime|float|int $minutes
+ * @param mixed $value
+ * @param \DateTimeInterface|\DateInterval|int|null $ttl
* @return bool
*/
- public function add($key, $value, $minutes)
+ public function add($key, $value, $ttl = null)
{
- if (is_null($minutes = $this->getMinutes($minutes))) {
- return false;
- }
+ if ($ttl !== null) {
+ if ($this->getSeconds($ttl) <= 0) {
+ return false;
+ }
- // If the store has an "add" method we will call the method on the store so it
- // has a chance to override this logic. Some drivers better support the way
- // this operation should work with a total "atomic" implementation of it.
- if (method_exists($this->store, 'add')) {
- return $this->store->add(
- $this->itemKey($key), $value, $minutes
- );
+ // If the store has an "add" method we will call the method on the store so it
+ // has a chance to override this logic. Some drivers better support the way
+ // this operation should work with a total "atomic" implementation of it.
+ if (method_exists($this->store, 'add')) {
+ $seconds = $this->getSeconds($ttl);
+
+ return $this->store->add(
+ $this->itemKey($key), $value, $seconds
+ );
+ }
}
// If the value did not exist in the cache, we will put the value in the cache
// so it exists for subsequent requests. Then, we will return true so it is
// easy to know if the value gets added. Otherwise, we will return false.
if (is_null($this->get($key))) {
- $this->put($key, $value, $minutes);
-
- return true;
+ return $this->put($key, $value, $ttl);
}
return false;
@@ -259,44 +347,48 @@ class Repository implements CacheContract, ArrayAccess
* Store an item in the cache indefinitely.
*
* @param string $key
- * @param mixed $value
- * @return void
+ * @param mixed $value
+ * @return bool
*/
public function forever($key, $value)
{
- $this->store->forever($this->itemKey($key), $value);
+ $result = $this->store->forever($this->itemKey($key), $value);
- $this->event(new KeyWritten($key, $value, 0));
+ if ($result) {
+ $this->event(new KeyWritten($key, $value));
+ }
+
+ return $result;
}
/**
- * Get an item from the cache, or store the default value.
+ * Get an item from the cache, or execute the given Closure and store the result.
*
* @param string $key
- * @param \DateTime|float|int $minutes
+ * @param \DateTimeInterface|\DateInterval|int|null $ttl
* @param \Closure $callback
* @return mixed
*/
- public function remember($key, $minutes, Closure $callback)
+ public function remember($key, $ttl, Closure $callback)
{
$value = $this->get($key);
// If the item exists in the cache we will just return this immediately and if
// not we will execute the given Closure and cache the result of that for a
- // given number of minutes so it's available for all subsequent requests.
+ // given number of seconds so it's available for all subsequent requests.
if (! is_null($value)) {
return $value;
}
- $this->put($key, $value = $callback(), $minutes);
+ $this->put($key, $value = $callback(), $ttl);
return $value;
}
/**
- * Get an item from the cache, or store the default value forever.
+ * Get an item from the cache, or execute the given Closure and store the result forever.
*
- * @param string $key
+ * @param string $key
* @param \Closure $callback
* @return mixed
*/
@@ -306,9 +398,9 @@ class Repository implements CacheContract, ArrayAccess
}
/**
- * Get an item from the cache, or store the default value forever.
+ * Get an item from the cache, or execute the given Closure and store the result forever.
*
- * @param string $key
+ * @param string $key
* @param \Closure $callback
* @return mixed
*/
@@ -316,9 +408,9 @@ class Repository implements CacheContract, ArrayAccess
{
$value = $this->get($key);
- // If the item exists in the cache we will just return this immediately and if
- // not we will execute the given Closure and cache the result of that for a
- // given number of minutes so it's available for all subsequent requests.
+ // If the item exists in the cache we will just return this immediately
+ // and if not we will execute the given Closure and cache the result
+ // of that forever so it is available for all subsequent requests.
if (! is_null($value)) {
return $value;
}
@@ -336,11 +428,45 @@ class Repository implements CacheContract, ArrayAccess
*/
public function forget($key)
{
- return tap($this->store->forget($this->itemKey($key)), function () use ($key) {
- $this->event(new KeyForgotten($key));
+ return tap($this->store->forget($this->itemKey($key)), function ($result) use ($key) {
+ if ($result) {
+ $this->event(new KeyForgotten($key));
+ }
});
}
+ /**
+ * {@inheritdoc}
+ */
+ public function delete($key)
+ {
+ return $this->forget($key);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function deleteMultiple($keys)
+ {
+ $result = true;
+
+ foreach ($keys as $key) {
+ if (! $this->forget($key)) {
+ $result = false;
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function clear()
+ {
+ return $this->store->flush();
+ }
+
/**
* Begin executing a new tags operation if the store supports it.
*
@@ -355,7 +481,7 @@ class Repository implements CacheContract, ArrayAccess
throw new BadMethodCallException('This cache store does not support tagging.');
}
- $cache = $this->store->tags($names);
+ $cache = $this->store->tags(is_array($names) ? $names : func_get_args());
if (! is_null($this->events)) {
$cache->setEventDispatcher($this->events);
@@ -378,7 +504,7 @@ class Repository implements CacheContract, ArrayAccess
/**
* Get the default cache time.
*
- * @return float|int
+ * @return int
*/
public function getDefaultCacheTime()
{
@@ -386,14 +512,14 @@ class Repository implements CacheContract, ArrayAccess
}
/**
- * Set the default cache time in minutes.
+ * Set the default cache time in seconds.
*
- * @param float|int $minutes
+ * @param int|null $seconds
* @return $this
*/
- public function setDefaultCacheTime($minutes)
+ public function setDefaultCacheTime($seconds)
{
- $this->default = $minutes;
+ $this->default = $seconds;
return $this;
}
@@ -478,25 +604,27 @@ class Repository implements CacheContract, ArrayAccess
}
/**
- * Calculate the number of minutes with the given duration.
+ * Calculate the number of seconds for the given TTL.
*
- * @param \DateTime|float|int $duration
- * @return float|int|null
+ * @param \DateTimeInterface|\DateInterval|int $ttl
+ * @return int
*/
- protected function getMinutes($duration)
+ protected function getSeconds($ttl)
{
- if ($duration instanceof DateTime) {
- $duration = Carbon::now()->diffInSeconds(Carbon::instance($duration), false) / 60;
+ $duration = $this->parseDateInterval($ttl);
+
+ if ($duration instanceof DateTimeInterface) {
+ $duration = Carbon::now()->diffInRealSeconds($duration, false);
}
- return (int) ($duration * 60) > 0 ? $duration : null;
+ return (int) $duration > 0 ? $duration : 0;
}
/**
* Handle dynamic calls into macros or pass missing methods to the store.
*
* @param string $method
- * @param array $parameters
+ * @param array $parameters
* @return mixed
*/
public function __call($method, $parameters)
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Cache/RetrievesMultipleKeys.php b/pfosten/vendor/laravel/framework/src/Illuminate/Cache/RetrievesMultipleKeys.php
index 4d467975..5dd41edb 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Cache/RetrievesMultipleKeys.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Cache/RetrievesMultipleKeys.php
@@ -24,16 +24,22 @@ trait RetrievesMultipleKeys
}
/**
- * Store multiple items in the cache for a given number of minutes.
+ * Store multiple items in the cache for a given number of seconds.
*
* @param array $values
- * @param float|int $minutes
- * @return void
+ * @param int $seconds
+ * @return bool
*/
- public function putMany(array $values, $minutes)
+ public function putMany(array $values, $seconds)
{
+ $manyResult = null;
+
foreach ($values as $key => $value) {
- $this->put($key, $value, $minutes);
+ $result = $this->put($key, $value, $seconds);
+
+ $manyResult = is_null($manyResult) ? $result : $result && $manyResult;
}
+
+ return $manyResult ?: false;
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Cache/TaggableStore.php b/pfosten/vendor/laravel/framework/src/Illuminate/Cache/TaggableStore.php
index ba00fa45..6a12b45d 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Cache/TaggableStore.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Cache/TaggableStore.php
@@ -2,7 +2,9 @@
namespace Illuminate\Cache;
-abstract class TaggableStore
+use Illuminate\Contracts\Cache\Store;
+
+abstract class TaggableStore implements Store
{
/**
* Begin executing a new tags operation.
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Cache/TaggedCache.php b/pfosten/vendor/laravel/framework/src/Illuminate/Cache/TaggedCache.php
index 095f296a..01e483b6 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Cache/TaggedCache.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Cache/TaggedCache.php
@@ -6,7 +6,9 @@ use Illuminate\Contracts\Cache\Store;
class TaggedCache extends Repository
{
- use RetrievesMultipleKeys;
+ use RetrievesMultipleKeys {
+ putMany as putManyAlias;
+ }
/**
* The tag set instance.
@@ -29,11 +31,27 @@ class TaggedCache extends Repository
$this->tags = $tags;
}
+ /**
+ * Store multiple items in the cache for a given number of seconds.
+ *
+ * @param array $values
+ * @param int|null $ttl
+ * @return bool
+ */
+ public function putMany(array $values, $ttl = null)
+ {
+ if ($ttl === null) {
+ return $this->putManyForever($values);
+ }
+
+ return $this->putManyAlias($values, $ttl);
+ }
+
/**
* Increment the value of an item in the cache.
*
* @param string $key
- * @param mixed $value
+ * @param mixed $value
* @return void
*/
public function increment($key, $value = 1)
@@ -42,10 +60,10 @@ class TaggedCache extends Repository
}
/**
- * Increment the value of an item in the cache.
+ * Decrement the value of an item in the cache.
*
* @param string $key
- * @param mixed $value
+ * @param mixed $value
* @return void
*/
public function decrement($key, $value = 1)
@@ -56,11 +74,13 @@ class TaggedCache extends Repository
/**
* Remove all items from the cache.
*
- * @return void
+ * @return bool
*/
public function flush()
{
$this->tags->reset();
+
+ return true;
}
/**
@@ -92,4 +112,14 @@ class TaggedCache extends Repository
{
parent::event($event->setTags($this->tags->getNames()));
}
+
+ /**
+ * Get the tag set instance.
+ *
+ * @return \Illuminate\Cache\TagSet
+ */
+ public function getTags()
+ {
+ return $this->tags;
+ }
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Cache/composer.json b/pfosten/vendor/laravel/framework/src/Illuminate/Cache/composer.json
index 0b9f812f..974782f0 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Cache/composer.json
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Cache/composer.json
@@ -14,10 +14,9 @@
}
],
"require": {
- "php": ">=5.6.4",
- "illuminate/contracts": "5.4.*",
- "illuminate/support": "5.4.*",
- "nesbot/carbon": "~1.20"
+ "php": "^7.1.3",
+ "illuminate/contracts": "5.8.*",
+ "illuminate/support": "5.8.*"
},
"autoload": {
"psr-4": {
@@ -26,13 +25,13 @@
},
"extra": {
"branch-alias": {
- "dev-master": "5.4-dev"
+ "dev-master": "5.8-dev"
}
},
"suggest": {
- "illuminate/database": "Required to use the database cache driver (5.4.*).",
- "illuminate/filesystem": "Required to use the file cache driver (5.4.*).",
- "illuminate/redis": "Required to use the redis cache driver (5.4.*)."
+ "illuminate/database": "Required to use the database cache driver (5.8.*).",
+ "illuminate/filesystem": "Required to use the file cache driver (5.8.*).",
+ "illuminate/redis": "Required to use the redis cache driver (5.8.*)."
},
"config": {
"sort-packages": true
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Config/Repository.php b/pfosten/vendor/laravel/framework/src/Illuminate/Config/Repository.php
index 2c00686a..cadcd64c 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Config/Repository.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Config/Repository.php
@@ -40,15 +40,40 @@ class Repository implements ArrayAccess, ConfigContract
/**
* Get the specified configuration value.
*
- * @param string $key
+ * @param array|string $key
* @param mixed $default
* @return mixed
*/
public function get($key, $default = null)
{
+ if (is_array($key)) {
+ return $this->getMany($key);
+ }
+
return Arr::get($this->items, $key, $default);
}
+ /**
+ * Get many configuration values.
+ *
+ * @param array $keys
+ * @return array
+ */
+ public function getMany($keys)
+ {
+ $config = [];
+
+ foreach ($keys as $key => $default) {
+ if (is_numeric($key)) {
+ [$key, $default] = [$default, null];
+ }
+
+ $config[$key] = Arr::get($this->items, $key, $default);
+ }
+
+ return $config;
+ }
+
/**
* Set a given configuration value.
*
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Config/composer.json b/pfosten/vendor/laravel/framework/src/Illuminate/Config/composer.json
index 69ab6e77..66110403 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Config/composer.json
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Config/composer.json
@@ -14,9 +14,9 @@
}
],
"require": {
- "php": ">=5.6.4",
- "illuminate/contracts": "5.4.*",
- "illuminate/support": "5.4.*"
+ "php": "^7.1.3",
+ "illuminate/contracts": "5.8.*",
+ "illuminate/support": "5.8.*"
},
"autoload": {
"psr-4": {
@@ -25,7 +25,7 @@
},
"extra": {
"branch-alias": {
- "dev-master": "5.4-dev"
+ "dev-master": "5.8-dev"
}
},
"config": {
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Console/Application.php b/pfosten/vendor/laravel/framework/src/Illuminate/Console/Application.php
index 820b16e6..4e6ba853 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Console/Application.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Console/Application.php
@@ -3,15 +3,21 @@
namespace Illuminate\Console;
use Closure;
+use Illuminate\Support\ProcessUtils;
use Illuminate\Contracts\Events\Dispatcher;
-use Symfony\Component\Process\ProcessUtils;
use Illuminate\Contracts\Container\Container;
+use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Input\InputOption;
+use Symfony\Component\Console\Input\StringInput;
use Symfony\Component\Process\PhpExecutableFinder;
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Output\ConsoleOutput;
use Symfony\Component\Console\Output\BufferedOutput;
+use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Application as SymfonyApplication;
use Symfony\Component\Console\Command\Command as SymfonyCommand;
+use Symfony\Component\Console\Exception\CommandNotFoundException;
use Illuminate\Contracts\Console\Application as ApplicationContract;
class Application extends SymfonyApplication implements ApplicationContract
@@ -37,6 +43,13 @@ class Application extends SymfonyApplication implements ApplicationContract
*/
protected static $bootstrappers = [];
+ /**
+ * The Event Dispatcher.
+ *
+ * @var \Illuminate\Contracts\Events\Dispatcher
+ */
+ protected $events;
+
/**
* Create a new Artisan console application.
*
@@ -50,14 +63,39 @@ class Application extends SymfonyApplication implements ApplicationContract
parent::__construct('Laravel Framework', $version);
$this->laravel = $laravel;
+ $this->events = $events;
$this->setAutoExit(false);
$this->setCatchExceptions(false);
- $events->dispatch(new Events\ArtisanStarting($this));
+ $this->events->dispatch(new Events\ArtisanStarting($this));
$this->bootstrap();
}
+ /**
+ * {@inheritdoc}
+ */
+ public function run(InputInterface $input = null, OutputInterface $output = null)
+ {
+ $commandName = $this->getCommandName(
+ $input = $input ?: new ArgvInput
+ );
+
+ $this->events->dispatch(
+ new Events\CommandStarting(
+ $commandName, $input, $output = $output ?: new ConsoleOutput
+ )
+ );
+
+ $exitCode = parent::run($input, $output);
+
+ $this->events->dispatch(
+ new Events\CommandFinished($commandName, $input, $output, $exitCode)
+ );
+
+ return $exitCode;
+ }
+
/**
* Determine the proper PHP executable.
*
@@ -127,22 +165,48 @@ class Application extends SymfonyApplication implements ApplicationContract
*
* @param string $command
* @param array $parameters
- * @param \Symfony\Component\Console\Output\OutputInterface $outputBuffer
+ * @param \Symfony\Component\Console\Output\OutputInterface|null $outputBuffer
* @return int
+ *
+ * @throws \Symfony\Component\Console\Exception\CommandNotFoundException
*/
public function call($command, array $parameters = [], $outputBuffer = null)
{
- $parameters = collect($parameters)->prepend($command);
+ [$command, $input] = $this->parseCommand($command, $parameters);
- $this->lastOutput = $outputBuffer ?: new BufferedOutput;
+ if (! $this->has($command)) {
+ throw new CommandNotFoundException(sprintf('The command "%s" does not exist.', $command));
+ }
- $this->setCatchExceptions(false);
+ return $this->run(
+ $input, $this->lastOutput = $outputBuffer ?: new BufferedOutput
+ );
+ }
- $result = $this->run(new ArrayInput($parameters->toArray()), $this->lastOutput);
+ /**
+ * Parse the incoming Artisan command and its input.
+ *
+ * @param string $command
+ * @param array $parameters
+ * @return array
+ */
+ protected function parseCommand($command, $parameters)
+ {
+ if (is_subclass_of($command, SymfonyCommand::class)) {
+ $callingClass = true;
- $this->setCatchExceptions(true);
+ $command = $this->laravel->make($command)->getName();
+ }
- return $result;
+ if (! isset($callingClass) && empty($parameters)) {
+ $command = $this->getCommandName($input = new StringInput($command));
+ } else {
+ array_unshift($parameters, $command);
+
+ $input = new ArrayInput($parameters);
+ }
+
+ return [$command, $input ?? null];
}
/**
@@ -152,7 +216,9 @@ class Application extends SymfonyApplication implements ApplicationContract
*/
public function output()
{
- return $this->lastOutput ? $this->lastOutput->fetch() : '';
+ return $this->lastOutput && method_exists($this->lastOutput, 'fetch')
+ ? $this->lastOutput->fetch()
+ : '';
}
/**
@@ -210,7 +276,7 @@ class Application extends SymfonyApplication implements ApplicationContract
}
/**
- * Get the default input definitions for the applications.
+ * Get the default input definition for the application.
*
* This is used to add the --env option to every available command.
*
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Console/Command.php b/pfosten/vendor/laravel/framework/src/Illuminate/Console/Command.php
index d0f09b38..a15691e3 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Console/Command.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Console/Command.php
@@ -2,6 +2,8 @@
namespace Illuminate\Console;
+use Illuminate\Support\Str;
+use Illuminate\Support\Traits\Macroable;
use Illuminate\Contracts\Support\Arrayable;
use Symfony\Component\Console\Helper\Table;
use Symfony\Component\Console\Input\ArrayInput;
@@ -15,6 +17,8 @@ use Symfony\Component\Console\Command\Command as SymfonyCommand;
class Command extends SymfonyCommand
{
+ use Macroable;
+
/**
* The Laravel application instance.
*
@@ -105,7 +109,7 @@ class Command extends SymfonyCommand
// the command we'll set the arguments and the options on this command.
$this->setDescription($this->description);
- $this->setHidden($this->hidden);
+ $this->setHidden($this->isHidden());
if (! isset($this->signature)) {
$this->specifyParameters();
@@ -119,20 +123,15 @@ class Command extends SymfonyCommand
*/
protected function configureUsingFluentDefinition()
{
- list($name, $arguments, $options) = Parser::parse($this->signature);
+ [$name, $arguments, $options] = Parser::parse($this->signature);
parent::__construct($this->name = $name);
// After parsing the signature we will spin through the arguments and options
// and set them on this command. These will already be changed into proper
// instances of these "InputArgument" and "InputOption" Symfony classes.
- foreach ($arguments as $argument) {
- $this->getDefinition()->addArgument($argument);
- }
-
- foreach ($options as $option) {
- $this->getDefinition()->addOption($option);
- }
+ $this->getDefinition()->addArguments($arguments);
+ $this->getDefinition()->addOptions($options);
}
/**
@@ -163,8 +162,12 @@ class Command extends SymfonyCommand
*/
public function run(InputInterface $input, OutputInterface $output)
{
+ $this->output = $this->laravel->make(
+ OutputStyle::class, ['input' => $input, 'output' => $output]
+ );
+
return parent::run(
- $this->input = $input, $this->output = new OutputStyle($input, $output)
+ $this->input = $input, $this->output
);
}
@@ -177,9 +180,7 @@ class Command extends SymfonyCommand
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
- $method = method_exists($this, 'handle') ? 'handle' : 'fire';
-
- return $this->laravel->call([$this, $method]);
+ return $this->laravel->call([$this, 'handle']);
}
/**
@@ -194,7 +195,7 @@ class Command extends SymfonyCommand
$arguments['command'] = $command;
return $this->getApplication()->find($command)->run(
- new ArrayInput($arguments), $this->output
+ $this->createInputFromArguments($arguments), $this->output
);
}
@@ -210,10 +211,43 @@ class Command extends SymfonyCommand
$arguments['command'] = $command;
return $this->getApplication()->find($command)->run(
- new ArrayInput($arguments), new NullOutput
+ $this->createInputFromArguments($arguments), new NullOutput
);
}
+ /**
+ * Create an input instance from the given arguments.
+ *
+ * @param array $arguments
+ * @return \Symfony\Component\Console\Input\ArrayInput
+ */
+ protected function createInputFromArguments(array $arguments)
+ {
+ return tap(new ArrayInput(array_merge($this->context(), $arguments)), function ($input) {
+ if ($input->hasParameterOption(['--no-interaction'], true)) {
+ $input->setInteractive(false);
+ }
+ });
+ }
+
+ /**
+ * Get all of the context passed to the command.
+ *
+ * @return array
+ */
+ protected function context()
+ {
+ return collect($this->option())->only([
+ 'ansi',
+ 'no-ansi',
+ 'no-interaction',
+ 'quiet',
+ 'verbose',
+ ])->filter()->mapWithKeys(function ($value, $key) {
+ return ["--{$key}" => $value];
+ })->all();
+ }
+
/**
* Determine if the given argument is present.
*
@@ -229,7 +263,7 @@ class Command extends SymfonyCommand
* Get the value of a command argument.
*
* @param string|null $key
- * @return string|array
+ * @return string|array|null
*/
public function argument($key = null)
{
@@ -264,8 +298,8 @@ class Command extends SymfonyCommand
/**
* Get the value of a command option.
*
- * @param string $key
- * @return string|array
+ * @param string|null $key
+ * @return string|array|bool|null
*/
public function option($key = null)
{
@@ -302,8 +336,8 @@ class Command extends SymfonyCommand
* Prompt the user for input.
*
* @param string $question
- * @param string $default
- * @return string
+ * @param string|null $default
+ * @return mixed
*/
public function ask($question, $default = null)
{
@@ -315,8 +349,8 @@ class Command extends SymfonyCommand
*
* @param string $question
* @param array $choices
- * @param string $default
- * @return string
+ * @param string|null $default
+ * @return mixed
*/
public function anticipate($question, array $choices, $default = null)
{
@@ -328,8 +362,8 @@ class Command extends SymfonyCommand
*
* @param string $question
* @param array $choices
- * @param string $default
- * @return string
+ * @param string|null $default
+ * @return mixed
*/
public function askWithCompletion($question, array $choices, $default = null)
{
@@ -345,7 +379,7 @@ class Command extends SymfonyCommand
*
* @param string $question
* @param bool $fallback
- * @return string
+ * @return mixed
*/
public function secret($question, $fallback = true)
{
@@ -361,9 +395,9 @@ class Command extends SymfonyCommand
*
* @param string $question
* @param array $choices
- * @param string $default
- * @param mixed $attempts
- * @param bool $multiple
+ * @param string|null $default
+ * @param mixed|null $attempts
+ * @param bool|null $multiple
* @return string
*/
public function choice($question, array $choices, $default = null, $attempts = null, $multiple = null)
@@ -380,10 +414,11 @@ class Command extends SymfonyCommand
*
* @param array $headers
* @param \Illuminate\Contracts\Support\Arrayable|array $rows
- * @param string $style
+ * @param string $tableStyle
+ * @param array $columnStyles
* @return void
*/
- public function table(array $headers, $rows, $style = 'default')
+ public function table($headers, $rows, $tableStyle = 'default', array $columnStyles = [])
{
$table = new Table($this->output);
@@ -391,14 +426,20 @@ class Command extends SymfonyCommand
$rows = $rows->toArray();
}
- $table->setHeaders($headers)->setRows($rows)->setStyle($style)->render();
+ $table->setHeaders((array) $headers)->setRows($rows)->setStyle($tableStyle);
+
+ foreach ($columnStyles as $columnIndex => $columnStyle) {
+ $table->setColumnStyle($columnIndex, $columnStyle);
+ }
+
+ $table->render();
}
/**
* Write a string as information output.
*
* @param string $string
- * @param null|int|string $verbosity
+ * @param int|string|null $verbosity
* @return void
*/
public function info($string, $verbosity = null)
@@ -410,8 +451,8 @@ class Command extends SymfonyCommand
* Write a string as standard output.
*
* @param string $string
- * @param string $style
- * @param null|int|string $verbosity
+ * @param string|null $style
+ * @param int|string|null $verbosity
* @return void
*/
public function line($string, $style = null, $verbosity = null)
@@ -425,7 +466,7 @@ class Command extends SymfonyCommand
* Write a string as comment output.
*
* @param string $string
- * @param null|int|string $verbosity
+ * @param int|string|null $verbosity
* @return void
*/
public function comment($string, $verbosity = null)
@@ -437,7 +478,7 @@ class Command extends SymfonyCommand
* Write a string as question output.
*
* @param string $string
- * @param null|int|string $verbosity
+ * @param int|string|null $verbosity
* @return void
*/
public function question($string, $verbosity = null)
@@ -449,7 +490,7 @@ class Command extends SymfonyCommand
* Write a string as error output.
*
* @param string $string
- * @param null|int|string $verbosity
+ * @param int|string|null $verbosity
* @return void
*/
public function error($string, $verbosity = null)
@@ -461,7 +502,7 @@ class Command extends SymfonyCommand
* Write a string as warning output.
*
* @param string $string
- * @param null|int|string $verbosity
+ * @param int|string|null $verbosity
* @return void
*/
public function warn($string, $verbosity = null)
@@ -483,11 +524,13 @@ class Command extends SymfonyCommand
*/
public function alert($string)
{
- $this->comment(str_repeat('*', strlen($string) + 12));
- $this->comment('* '.$string.' *');
- $this->comment(str_repeat('*', strlen($string) + 12));
+ $length = Str::length(strip_tags($string)) + 12;
- $this->output->writeln('');
+ $this->comment(str_repeat('*', $length));
+ $this->comment('* '.$string.' *');
+ $this->comment(str_repeat('*', $length));
+
+ $this->output->newLine();
}
/**
@@ -504,7 +547,7 @@ class Command extends SymfonyCommand
/**
* Get the verbosity level in terms of Symfony's OutputInterface level.
*
- * @param string|int $level
+ * @param string|int|null $level
* @return int
*/
protected function parseVerbosity($level = null)
@@ -518,6 +561,24 @@ class Command extends SymfonyCommand
return $level;
}
+ /**
+ * {@inheritdoc}
+ */
+ public function isHidden()
+ {
+ return $this->hidden;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function setHidden($hidden)
+ {
+ parent::setHidden($this->hidden = $hidden);
+
+ return $this;
+ }
+
/**
* Get the console command arguments.
*
@@ -541,7 +602,7 @@ class Command extends SymfonyCommand
/**
* Get the output implementation.
*
- * @return \Symfony\Component\Console\Output\OutputInterface
+ * @return \Illuminate\Console\OutputStyle
*/
public function getOutput()
{
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Console/ConfirmableTrait.php b/pfosten/vendor/laravel/framework/src/Illuminate/Console/ConfirmableTrait.php
index 71722153..280747cf 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Console/ConfirmableTrait.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Console/ConfirmableTrait.php
@@ -22,7 +22,7 @@ trait ConfirmableTrait
$shouldConfirm = $callback instanceof Closure ? call_user_func($callback) : $callback;
if ($shouldConfirm) {
- if ($this->option('force')) {
+ if ($this->hasOption('force') && $this->option('force')) {
return true;
}
@@ -48,7 +48,7 @@ trait ConfirmableTrait
protected function getDefaultConfirmCallback()
{
return function () {
- return $this->getLaravel()->environment() == 'production';
+ return $this->getLaravel()->environment() === 'production';
};
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Console/GeneratorCommand.php b/pfosten/vendor/laravel/framework/src/Illuminate/Console/GeneratorCommand.php
index c9522e7f..ec5eb8cd 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Console/GeneratorCommand.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Console/GeneratorCommand.php
@@ -46,8 +46,9 @@ abstract class GeneratorCommand extends Command
* Execute the console command.
*
* @return bool|null
+ * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
*/
- public function fire()
+ public function handle()
{
$name = $this->qualifyClass($this->getNameInput());
@@ -56,7 +57,9 @@ abstract class GeneratorCommand extends Command
// First we will check to see if the class already exists. If it does, we don't want
// to create the class and overwrite the user's code. So, we will bail out so the
// code is untouched. Otherwise, we will continue generating this class' files.
- if ($this->alreadyExists($this->getNameInput())) {
+ if ((! $this->hasOption('force') ||
+ ! $this->option('force')) &&
+ $this->alreadyExists($this->getNameInput())) {
$this->error($this->type.' already exists!');
return false;
@@ -80,6 +83,8 @@ abstract class GeneratorCommand extends Command
*/
protected function qualifyClass($name)
{
+ $name = ltrim($name, '\\/');
+
$rootNamespace = $this->rootNamespace();
if (Str::startsWith($name, $rootNamespace)) {
@@ -123,7 +128,7 @@ abstract class GeneratorCommand extends Command
*/
protected function getPath($name)
{
- $name = str_replace_first($this->rootNamespace(), '', $name);
+ $name = Str::replaceFirst($this->rootNamespace(), '', $name);
return $this->laravel['path'].'/'.str_replace('\\', '/', $name).'.php';
}
@@ -148,6 +153,7 @@ abstract class GeneratorCommand extends Command
*
* @param string $name
* @return string
+ * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
*/
protected function buildClass($name)
{
@@ -166,8 +172,8 @@ abstract class GeneratorCommand extends Command
protected function replaceNamespace(&$stub, $name)
{
$stub = str_replace(
- ['DummyNamespace', 'DummyRootNamespace'],
- [$this->getNamespace($name), $this->rootNamespace()],
+ ['DummyNamespace', 'DummyRootNamespace', 'NamespacedDummyUserModel'],
+ [$this->getNamespace($name), $this->rootNamespace(), $this->userProviderModel()],
$stub
);
@@ -219,6 +225,20 @@ abstract class GeneratorCommand extends Command
return $this->laravel->getNamespace();
}
+ /**
+ * Get the model for the default guard's user provider.
+ *
+ * @return string|null
+ */
+ protected function userProviderModel()
+ {
+ $guard = config('auth.defaults.guard');
+
+ $provider = config("auth.guards.{$guard}.provider");
+
+ return config("auth.providers.{$provider}.model");
+ }
+
/**
* Get the console command arguments.
*
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Console/Parser.php b/pfosten/vendor/laravel/framework/src/Illuminate/Console/Parser.php
index 4ccc88dc..77643101 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Console/Parser.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Console/Parser.php
@@ -35,6 +35,8 @@ class Parser
*
* @param string $expression
* @return string
+ *
+ * @throws \InvalidArgumentException
*/
protected static function name($expression)
{
@@ -80,7 +82,7 @@ class Parser
*/
protected static function parseArgument($token)
{
- list($token, $description) = static::extractDescription($token);
+ [$token, $description] = static::extractDescription($token);
switch (true) {
case Str::endsWith($token, '?*'):
@@ -89,6 +91,8 @@ class Parser
return new InputArgument(trim($token, '*'), InputArgument::IS_ARRAY | InputArgument::REQUIRED, $description);
case Str::endsWith($token, '?'):
return new InputArgument(trim($token, '?'), InputArgument::OPTIONAL, $description);
+ case preg_match('/(.+)\=\*(.+)/', $token, $matches):
+ return new InputArgument($matches[1], InputArgument::IS_ARRAY, $description, preg_split('/,\s?/', $matches[2]));
case preg_match('/(.+)\=(.+)/', $token, $matches):
return new InputArgument($matches[1], InputArgument::OPTIONAL, $description, $matches[2]);
default:
@@ -104,7 +108,7 @@ class Parser
*/
protected static function parseOption($token)
{
- list($token, $description) = static::extractDescription($token);
+ [$token, $description] = static::extractDescription($token);
$matches = preg_split('/\s*\|\s*/', $token, 2);
@@ -120,6 +124,8 @@ class Parser
return new InputOption(trim($token, '='), $shortcut, InputOption::VALUE_OPTIONAL, $description);
case Str::endsWith($token, '=*'):
return new InputOption(trim($token, '=*'), $shortcut, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, $description);
+ case preg_match('/(.+)\=\*(.+)/', $token, $matches):
+ return new InputOption($matches[1], $shortcut, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, $description, preg_split('/,\s?/', $matches[2]));
case preg_match('/(.+)\=(.+)/', $token, $matches):
return new InputOption($matches[1], $shortcut, InputOption::VALUE_OPTIONAL, $description, $matches[2]);
default:
@@ -137,6 +143,6 @@ class Parser
{
$parts = preg_split('/\s+:\s+/', trim($token), 2);
- return count($parts) === 2 ? $parts : [$token, null];
+ return count($parts) === 2 ? $parts : [$token, ''];
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Console/Scheduling/CacheMutex.php b/pfosten/vendor/laravel/framework/src/Illuminate/Console/Scheduling/CacheMutex.php
deleted file mode 100644
index f698ff2c..00000000
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Console/Scheduling/CacheMutex.php
+++ /dev/null
@@ -1,61 +0,0 @@
-cache = $cache;
- }
-
- /**
- * Attempt to obtain a mutex for the given event.
- *
- * @param \Illuminate\Console\Scheduling\Event $event
- * @return bool
- */
- public function create(Event $event)
- {
- return $this->cache->add(
- $event->mutexName(), true, $event->expiresAt
- );
- }
-
- /**
- * Determine if a mutex exists for the given event.
- *
- * @param \Illuminate\Console\Scheduling\Event $event
- * @return bool
- */
- public function exists(Event $event)
- {
- return $this->cache->has($event->mutexName());
- }
-
- /**
- * Clear the mutex for the given event.
- *
- * @param \Illuminate\Console\Scheduling\Event $event
- * @return void
- */
- public function forget(Event $event)
- {
- $this->cache->forget($event->mutexName());
- }
-}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Console/Scheduling/CallbackEvent.php b/pfosten/vendor/laravel/framework/src/Illuminate/Console/Scheduling/CallbackEvent.php
index 50bfc13e..a66b5140 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Console/Scheduling/CallbackEvent.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Console/Scheduling/CallbackEvent.php
@@ -25,14 +25,14 @@ class CallbackEvent extends Event
/**
* Create a new event instance.
*
- * @param \Illuminate\Console\Scheduling\Mutex $mutex
+ * @param \Illuminate\Console\Scheduling\EventMutex $mutex
* @param string $callback
* @param array $parameters
* @return void
*
* @throws \InvalidArgumentException
*/
- public function __construct(Mutex $mutex, $callback, array $parameters = [])
+ public function __construct(EventMutex $mutex, $callback, array $parameters = [])
{
if (! is_string($callback) && ! is_callable($callback)) {
throw new InvalidArgumentException(
@@ -60,17 +60,25 @@ class CallbackEvent extends Event
return;
}
- register_shutdown_function(function () {
- $this->removeMutex();
+ $pid = getmypid();
+
+ register_shutdown_function(function () use ($pid) {
+ if ($pid === getmypid()) {
+ $this->removeMutex();
+ }
});
+ parent::callBeforeCallbacks($container);
+
try {
- $response = $container->call($this->callback, $this->parameters);
+ $response = is_object($this->callback)
+ ? $container->call([$this->callback, '__invoke'], $this->parameters)
+ : $container->call($this->callback, $this->parameters);
} finally {
$this->removeMutex();
- }
- parent::callAfterCallbacks($container);
+ parent::callAfterCallbacks($container);
+ }
return $response;
}
@@ -82,7 +90,7 @@ class CallbackEvent extends Event
*/
protected function removeMutex()
{
- if ($this->description) {
+ if ($this->description && $this->withoutOverlapping) {
$this->mutex->forget($this);
}
}
@@ -92,6 +100,8 @@ class CallbackEvent extends Event
*
* @param int $expiresAt
* @return $this
+ *
+ * @throws \LogicException
*/
public function withoutOverlapping($expiresAt = 1440)
{
@@ -110,6 +120,26 @@ class CallbackEvent extends Event
});
}
+ /**
+ * Allow the event to only run on one server for each cron expression.
+ *
+ * @return $this
+ *
+ * @throws \LogicException
+ */
+ public function onOneServer()
+ {
+ if (! isset($this->description)) {
+ throw new LogicException(
+ "A scheduled event name is required to only run on one server. Use the 'name' method before 'onOneServer'."
+ );
+ }
+
+ $this->onOneServer = true;
+
+ return $this;
+ }
+
/**
* Get the mutex name for the scheduled command.
*
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Console/Scheduling/CommandBuilder.php b/pfosten/vendor/laravel/framework/src/Illuminate/Console/Scheduling/CommandBuilder.php
index acf60dd6..df7cdf61 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Console/Scheduling/CommandBuilder.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Console/Scheduling/CommandBuilder.php
@@ -3,7 +3,7 @@
namespace Illuminate\Console\Scheduling;
use Illuminate\Console\Application;
-use Symfony\Component\Process\ProcessUtils;
+use Illuminate\Support\ProcessUtils;
class CommandBuilder
{
@@ -17,9 +17,9 @@ class CommandBuilder
{
if ($event->runInBackground) {
return $this->buildBackgroundCommand($event);
- } else {
- return $this->buildForegroundCommand($event);
}
+
+ return $this->buildForegroundCommand($event);
}
/**
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Console/Scheduling/Event.php b/pfosten/vendor/laravel/framework/src/Illuminate/Console/Scheduling/Event.php
index bce490eb..510cbaba 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Console/Scheduling/Event.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Console/Scheduling/Event.php
@@ -3,9 +3,11 @@
namespace Illuminate\Console\Scheduling;
use Closure;
-use Carbon\Carbon;
use Cron\CronExpression;
+use Illuminate\Support\Arr;
+use Illuminate\Support\Carbon;
use GuzzleHttp\Client as HttpClient;
+use Illuminate\Support\Facades\Date;
use Illuminate\Contracts\Mail\Mailer;
use Symfony\Component\Process\Process;
use Illuminate\Support\Traits\Macroable;
@@ -27,7 +29,7 @@ class Event
*
* @var string
*/
- public $expression = '* * * * * *';
+ public $expression = '* * * * *';
/**
* The timezone the date should be evaluated on.
@@ -64,6 +66,13 @@ class Event
*/
public $withoutOverlapping = false;
+ /**
+ * Indicates if the command should only be allowed to run on one server for each cron expression.
+ *
+ * @var bool
+ */
+ public $onOneServer = false;
+
/**
* The amount of time the mutex should be valid.
*
@@ -128,23 +137,33 @@ class Event
public $description;
/**
- * The mutex implementation.
+ * The event mutex implementation.
*
- * @var \Illuminate\Console\Scheduling\Mutex
+ * @var \Illuminate\Console\Scheduling\EventMutex
*/
public $mutex;
+ /**
+ * The exit status code of the command.
+ *
+ * @var int|null
+ */
+ public $exitCode;
+
/**
* Create a new event instance.
*
- * @param \Illuminate\Console\Scheduling\Mutex $mutex
+ * @param \Illuminate\Console\Scheduling\EventMutex $mutex
* @param string $command
+ * @param \DateTimeZone|string|null $timezone
* @return void
*/
- public function __construct(Mutex $mutex, $command)
+ public function __construct(EventMutex $mutex, $command, $timezone = null)
{
$this->mutex = $mutex;
$this->command = $command;
+ $this->timezone = $timezone;
+
$this->output = $this->getDefaultOutput();
}
@@ -155,7 +174,7 @@ class Event
*/
public function getDefaultOutput()
{
- return (DIRECTORY_SEPARATOR == '\\') ? 'NUL' : '/dev/null';
+ return (DIRECTORY_SEPARATOR === '\\') ? 'NUL' : '/dev/null';
}
/**
@@ -196,9 +215,7 @@ class Event
{
$this->callBeforeCallbacks($container);
- (new Process(
- $this->buildCommand(), base_path(), null, null, null
- ))->run();
+ $this->exitCode = Process::fromShellCommandline($this->buildCommand(), base_path(), null, null, null)->run();
$this->callAfterCallbacks($container);
}
@@ -213,9 +230,7 @@ class Event
{
$this->callBeforeCallbacks($container);
- (new Process(
- $this->buildCommand(), base_path(), null, null, null
- ))->run();
+ Process::fromShellCommandline($this->buildCommand(), base_path(), null, null, null)->run();
}
/**
@@ -330,6 +345,18 @@ class Event
return true;
}
+ /**
+ * Ensure that the output is stored on disk in a log file.
+ *
+ * @return $this
+ */
+ public function storeOutput()
+ {
+ $this->ensureOutputIsBeingCaptured();
+
+ return $this;
+ }
+
/**
* Send the output of the command to a given location.
*
@@ -368,9 +395,9 @@ class Event
*/
public function emailOutputTo($addresses, $onlyIfOutputExists = false)
{
- $this->ensureOutputIsBeingCapturedForEmail();
+ $this->ensureOutputIsBeingCaptured();
- $addresses = is_array($addresses) ? $addresses : [$addresses];
+ $addresses = Arr::wrap($addresses);
return $this->then(function (Mailer $mailer) use ($addresses, $onlyIfOutputExists) {
$this->emailOutput($mailer, $addresses, $onlyIfOutputExists);
@@ -391,11 +418,28 @@ class Event
}
/**
- * Ensure that output is being captured for email.
+ * E-mail the results of the scheduled operation if it fails.
+ *
+ * @param array|mixed $addresses
+ * @return $this
+ */
+ public function emailOutputOnFailure($addresses)
+ {
+ $this->ensureOutputIsBeingCaptured();
+
+ $addresses = Arr::wrap($addresses);
+
+ return $this->onFailure(function (Mailer $mailer) use ($addresses) {
+ $this->emailOutput($mailer, $addresses, false);
+ });
+ }
+
+ /**
+ * Ensure that the command output is being captured.
*
* @return void
*/
- protected function ensureOutputIsBeingCapturedForEmail()
+ protected function ensureOutputIsBeingCaptured()
{
if (is_null($this->output) || $this->output == $this->getDefaultOutput()) {
$this->sendOutputTo(storage_path('logs/schedule-'.sha1($this->mutexName()).'.log'));
@@ -434,7 +478,7 @@ class Event
return $this->description;
}
- return 'Scheduled Job Output';
+ return "Scheduled Job Output For [{$this->command}]";
}
/**
@@ -450,6 +494,18 @@ class Event
});
}
+ /**
+ * Register a callback to ping a given URL before the job runs if the given condition is true.
+ *
+ * @param bool $value
+ * @param string $url
+ * @return $this
+ */
+ public function pingBeforeIf($value, $url)
+ {
+ return $value ? $this->pingBefore($url) : $this;
+ }
+
/**
* Register a callback to ping a given URL after the job runs.
*
@@ -463,6 +519,44 @@ class Event
});
}
+ /**
+ * Register a callback to ping a given URL after the job runs if the given condition is true.
+ *
+ * @param bool $value
+ * @param string $url
+ * @return $this
+ */
+ public function thenPingIf($value, $url)
+ {
+ return $value ? $this->thenPing($url) : $this;
+ }
+
+ /**
+ * Register a callback to ping a given URL if the operation succeeds.
+ *
+ * @param string $url
+ * @return $this
+ */
+ public function pingOnSuccess($url)
+ {
+ return $this->onSuccess(function () use ($url) {
+ (new HttpClient)->get($url);
+ });
+ }
+
+ /**
+ * Register a callback to ping a given URL if the operation fails.
+ *
+ * @param string $url
+ * @return $this
+ */
+ public function pingOnFailure($url)
+ {
+ return $this->onFailure(function () use ($url) {
+ (new HttpClient)->get($url);
+ });
+ }
+
/**
* State that the command should run in background.
*
@@ -533,14 +627,13 @@ class Event
}
/**
- * Register a callback to further filter the schedule.
+ * Allow the event to only run on one server for each cron expression.
*
- * @param \Closure $callback
* @return $this
*/
- public function when(Closure $callback)
+ public function onOneServer()
{
- $this->filters[] = $callback;
+ $this->onOneServer = true;
return $this;
}
@@ -548,12 +641,29 @@ class Event
/**
* Register a callback to further filter the schedule.
*
- * @param \Closure $callback
+ * @param \Closure|bool $callback
* @return $this
*/
- public function skip(Closure $callback)
+ public function when($callback)
{
- $this->rejects[] = $callback;
+ $this->filters[] = is_callable($callback) ? $callback : function () use ($callback) {
+ return $callback;
+ };
+
+ return $this;
+ }
+
+ /**
+ * Register a callback to further filter the schedule.
+ *
+ * @param \Closure|bool $callback
+ * @return $this
+ */
+ public function skip($callback)
+ {
+ $this->rejects[] = is_callable($callback) ? $callback : function () use ($callback) {
+ return $callback;
+ };
return $this;
}
@@ -595,6 +705,36 @@ class Event
return $this;
}
+ /**
+ * Register a callback to be called if the operation succeeds.
+ *
+ * @param \Closure $callback
+ * @return $this
+ */
+ public function onSuccess(Closure $callback)
+ {
+ return $this->then(function (Container $container) use ($callback) {
+ if (0 === $this->exitCode) {
+ $container->call($callback);
+ }
+ });
+ }
+
+ /**
+ * Register a callback to be called if the operation fails.
+ *
+ * @param \Closure $callback
+ * @return $this
+ */
+ public function onFailure(Closure $callback)
+ {
+ return $this->then(function (Container $container) use ($callback) {
+ if (0 !== $this->exitCode) {
+ $container->call($callback);
+ }
+ });
+ }
+
/**
* Set the human-friendly description of the event.
*
@@ -636,16 +776,16 @@ class Event
/**
* Determine the next due date for an event.
*
- * @param \DateTime|string $currentTime
+ * @param \DateTimeInterface|string $currentTime
* @param int $nth
* @param bool $allowCurrentDate
- * @return \Carbon\Carbon
+ * @return \Illuminate\Support\Carbon
*/
public function nextRunDate($currentTime = 'now', $nth = 0, $allowCurrentDate = false)
{
- return Carbon::instance($nextDue = CronExpression::factory(
+ return Date::instance(CronExpression::factory(
$this->getExpression()
- )->getNextRunDate($currentTime, $nth, $allowCurrentDate));
+ )->getNextRunDate($currentTime, $nth, $allowCurrentDate, $this->timezone));
}
/**
@@ -659,12 +799,12 @@ class Event
}
/**
- * Set the mutex implementation to be used.
+ * Set the event mutex implementation to be used.
*
- * @param \Illuminate\Console\Scheduling\Mutex $mutex
+ * @param \Illuminate\Console\Scheduling\EventMutex $mutex
* @return $this
*/
- public function preventOverlapsUsing(Mutex $mutex)
+ public function preventOverlapsUsing(EventMutex $mutex)
{
$this->mutex = $mutex;
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Console/Scheduling/ManagesFrequencies.php b/pfosten/vendor/laravel/framework/src/Illuminate/Console/Scheduling/ManagesFrequencies.php
index 4606db97..ced7e754 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Console/Scheduling/ManagesFrequencies.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Console/Scheduling/ManagesFrequencies.php
@@ -2,7 +2,7 @@
namespace Illuminate\Console\Scheduling;
-use Carbon\Carbon;
+use Illuminate\Support\Carbon;
trait ManagesFrequencies
{
@@ -61,6 +61,56 @@ trait ManagesFrequencies
};
}
+ /**
+ * Schedule the event to run every minute.
+ *
+ * @return $this
+ */
+ public function everyMinute()
+ {
+ return $this->spliceIntoPosition(1, '*');
+ }
+
+ /**
+ * Schedule the event to run every five minutes.
+ *
+ * @return $this
+ */
+ public function everyFiveMinutes()
+ {
+ return $this->spliceIntoPosition(1, '*/5');
+ }
+
+ /**
+ * Schedule the event to run every ten minutes.
+ *
+ * @return $this
+ */
+ public function everyTenMinutes()
+ {
+ return $this->spliceIntoPosition(1, '*/10');
+ }
+
+ /**
+ * Schedule the event to run every fifteen minutes.
+ *
+ * @return $this
+ */
+ public function everyFifteenMinutes()
+ {
+ return $this->spliceIntoPosition(1, '*/15');
+ }
+
+ /**
+ * Schedule the event to run every thirty minutes.
+ *
+ * @return $this
+ */
+ public function everyThirtyMinutes()
+ {
+ return $this->spliceIntoPosition(1, '0,30');
+ }
+
/**
* Schedule the event to run hourly.
*
@@ -74,11 +124,13 @@ trait ManagesFrequencies
/**
* Schedule the event to run hourly at a given offset in the hour.
*
- * @param int $offset
+ * @param array|int $offset
* @return $this
*/
public function hourlyAt($offset)
{
+ $offset = is_array($offset) ? implode(',', $offset) : $offset;
+
return $this->spliceIntoPosition(1, $offset);
}
@@ -115,7 +167,7 @@ trait ManagesFrequencies
$segments = explode(':', $time);
return $this->spliceIntoPosition(2, (int) $segments[0])
- ->spliceIntoPosition(1, count($segments) == 2 ? (int) $segments[1] : '0');
+ ->spliceIntoPosition(1, count($segments) === 2 ? (int) $segments[1] : '0');
}
/**
@@ -301,7 +353,7 @@ trait ManagesFrequencies
return $this->spliceIntoPosition(1, 0)
->spliceIntoPosition(2, 0)
->spliceIntoPosition(3, 1)
- ->spliceIntoPosition(4, '*/3');
+ ->spliceIntoPosition(4, '1-12/3');
}
/**
@@ -317,46 +369,6 @@ trait ManagesFrequencies
->spliceIntoPosition(4, 1);
}
- /**
- * Schedule the event to run every minute.
- *
- * @return $this
- */
- public function everyMinute()
- {
- return $this->spliceIntoPosition(1, '*');
- }
-
- /**
- * Schedule the event to run every five minutes.
- *
- * @return $this
- */
- public function everyFiveMinutes()
- {
- return $this->spliceIntoPosition(1, '*/5');
- }
-
- /**
- * Schedule the event to run every ten minutes.
- *
- * @return $this
- */
- public function everyTenMinutes()
- {
- return $this->spliceIntoPosition(1, '*/10');
- }
-
- /**
- * Schedule the event to run every thirty minutes.
- *
- * @return $this
- */
- public function everyThirtyMinutes()
- {
- return $this->spliceIntoPosition(1, '0,30');
- }
-
/**
* Set the days of the week the command should run on.
*
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Console/Scheduling/Mutex.php b/pfosten/vendor/laravel/framework/src/Illuminate/Console/Scheduling/Mutex.php
deleted file mode 100644
index 47ca939e..00000000
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Console/Scheduling/Mutex.php
+++ /dev/null
@@ -1,30 +0,0 @@
-timezone = $timezone;
+
$container = Container::getInstance();
- $this->mutex = $container->bound(Mutex::class)
- ? $container->make(Mutex::class)
- : $container->make(CacheMutex::class);
+ $this->eventMutex = $container->bound(EventMutex::class)
+ ? $container->make(EventMutex::class)
+ : $container->make(CacheEventMutex::class);
+
+ $this->schedulingMutex = $container->bound(SchedulingMutex::class)
+ ? $container->make(SchedulingMutex::class)
+ : $container->make(CacheSchedulingMutex::class);
}
/**
* Add a new callback event to the schedule.
*
* @param string|callable $callback
- * @param array $parameters
+ * @param array $parameters
* @return \Illuminate\Console\Scheduling\CallbackEvent
*/
public function call($callback, array $parameters = [])
{
$this->events[] = $event = new CallbackEvent(
- $this->mutex, $callback, $parameters
+ $this->eventMutex, $callback, $parameters
);
return $event;
@@ -74,12 +97,22 @@ class Schedule
* Add a new job callback event to the schedule.
*
* @param object|string $job
+ * @param string|null $queue
+ * @param string|null $connection
* @return \Illuminate\Console\Scheduling\CallbackEvent
*/
- public function job($job)
+ public function job($job, $queue = null, $connection = null)
{
- return $this->call(function () use ($job) {
- dispatch(is_string($job) ? resolve($job) : $job);
+ return $this->call(function () use ($job, $queue, $connection) {
+ $job = is_string($job) ? resolve($job) : $job;
+
+ if ($job instanceof ShouldQueue) {
+ dispatch($job)
+ ->onConnection($connection ?? $job->connection)
+ ->onQueue($queue ?? $job->queue);
+ } else {
+ dispatch_now($job);
+ }
})->name(is_string($job) ? $job : get_class($job));
}
@@ -96,7 +129,7 @@ class Schedule
$command .= ' '.$this->compileParameters($parameters);
}
- $this->events[] = $event = new Event($this->mutex, $command);
+ $this->events[] = $event = new Event($this->eventMutex, $command, $this->timezone);
return $event;
}
@@ -122,11 +155,23 @@ class Schedule
})->implode(' ');
}
+ /**
+ * Determine if the server is allowed to run this event.
+ *
+ * @param \Illuminate\Console\Scheduling\Event $event
+ * @param \DateTimeInterface $time
+ * @return bool
+ */
+ public function serverShouldRun(Event $event, DateTimeInterface $time)
+ {
+ return $this->schedulingMutex->create($event, $time);
+ }
+
/**
* Get all of the events on the schedule that are due.
*
* @param \Illuminate\Contracts\Foundation\Application $app
- * @return array
+ * @return \Illuminate\Support\Collection
*/
public function dueEvents($app)
{
@@ -142,4 +187,23 @@ class Schedule
{
return $this->events;
}
+
+ /**
+ * Specify the cache store that should be used to store mutexes.
+ *
+ * @param string $store
+ * @return $this
+ */
+ public function useCache($store)
+ {
+ if ($this->eventMutex instanceof CacheEventMutex) {
+ $this->eventMutex->useStore($store);
+ }
+
+ if ($this->schedulingMutex instanceof CacheSchedulingMutex) {
+ $this->schedulingMutex->useStore($store);
+ }
+
+ return $this;
+ }
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Console/Scheduling/ScheduleFinishCommand.php b/pfosten/vendor/laravel/framework/src/Illuminate/Console/Scheduling/ScheduleFinishCommand.php
index f22a0c5b..f697ea81 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Console/Scheduling/ScheduleFinishCommand.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Console/Scheduling/ScheduleFinishCommand.php
@@ -52,7 +52,7 @@ class ScheduleFinishCommand extends Command
*
* @return void
*/
- public function fire()
+ public function handle()
{
collect($this->schedule->events())->filter(function ($value) {
return $value->mutexName() == $this->argument('id');
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Console/Scheduling/ScheduleRunCommand.php b/pfosten/vendor/laravel/framework/src/Illuminate/Console/Scheduling/ScheduleRunCommand.php
index 8bf7c902..1340141c 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Console/Scheduling/ScheduleRunCommand.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Console/Scheduling/ScheduleRunCommand.php
@@ -3,6 +3,7 @@
namespace Illuminate\Console\Scheduling;
use Illuminate\Console\Command;
+use Illuminate\Support\Facades\Date;
class ScheduleRunCommand extends Command
{
@@ -27,6 +28,20 @@ class ScheduleRunCommand extends Command
*/
protected $schedule;
+ /**
+ * The 24 hour timestamp this scheduler command started running.
+ *
+ * @var \Illuminate\Support\Carbon;
+ */
+ protected $startedAt;
+
+ /**
+ * Check if any events ran.
+ *
+ * @var bool
+ */
+ protected $eventsRan = false;
+
/**
* Create a new command instance.
*
@@ -37,6 +52,8 @@ class ScheduleRunCommand extends Command
{
$this->schedule = $schedule;
+ $this->startedAt = Date::now();
+
parent::__construct();
}
@@ -45,24 +62,54 @@ class ScheduleRunCommand extends Command
*
* @return void
*/
- public function fire()
+ public function handle()
{
- $eventsRan = false;
-
foreach ($this->schedule->dueEvents($this->laravel) as $event) {
if (! $event->filtersPass($this->laravel)) {
continue;
}
- $this->line('
Running scheduled command: '.$event->getSummaryForDisplay());
+ if ($event->onOneServer) {
+ $this->runSingleServerEvent($event);
+ } else {
+ $this->runEvent($event);
+ }
- $event->run($this->laravel);
-
- $eventsRan = true;
+ $this->eventsRan = true;
}
- if (! $eventsRan) {
+ if (! $this->eventsRan) {
$this->info('No scheduled commands are ready to run.');
}
}
+
+ /**
+ * Run the given single server event.
+ *
+ * @param \Illuminate\Console\Scheduling\Event $event
+ * @return void
+ */
+ protected function runSingleServerEvent($event)
+ {
+ if ($this->schedule->serverShouldRun($event, $this->startedAt)) {
+ $this->runEvent($event);
+ } else {
+ $this->line('
Skipping command (has already run on another server): '.$event->getSummaryForDisplay());
+ }
+ }
+
+ /**
+ * Run the given event.
+ *
+ * @param \Illuminate\Console\Scheduling\Event $event
+ * @return void
+ */
+ protected function runEvent($event)
+ {
+ $this->line('
Running scheduled command: '.$event->getSummaryForDisplay());
+
+ $event->run($this->laravel);
+
+ $this->eventsRan = true;
+ }
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Console/composer.json b/pfosten/vendor/laravel/framework/src/Illuminate/Console/composer.json
index 60a138b1..cd088215 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Console/composer.json
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Console/composer.json
@@ -14,11 +14,11 @@
}
],
"require": {
- "php": ">=5.6.4",
- "illuminate/contracts": "5.4.*",
- "illuminate/support": "5.4.*",
- "nesbot/carbon": "~1.20",
- "symfony/console": "~3.2"
+ "php": "^7.1.3",
+ "illuminate/contracts": "5.8.*",
+ "illuminate/support": "5.8.*",
+ "symfony/console": "^4.2",
+ "symfony/process": "^4.2"
},
"autoload": {
"psr-4": {
@@ -27,13 +27,13 @@
},
"extra": {
"branch-alias": {
- "dev-master": "5.4-dev"
+ "dev-master": "5.8-dev"
}
},
"suggest": {
- "guzzlehttp/guzzle": "Required to use the ping methods on schedules (~6.0).",
- "mtdowling/cron-expression": "Required to use scheduling component (~1.0).",
- "symfony/process": "Required to use scheduling component (~3.2)."
+ "dragonmantank/cron-expression": "Required to use scheduling component (^2.0).",
+ "guzzlehttp/guzzle": "Required to use the ping methods on schedules (^6.0).",
+ "illuminate/filesystem": "Required to use the generator command (5.8.*)"
},
"config": {
"sort-packages": true
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php b/pfosten/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php
index d422ea4b..f5d4bba3 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php
@@ -17,6 +17,9 @@ class BoundMethod
* @param array $parameters
* @param string|null $defaultMethod
* @return mixed
+ *
+ * @throws \ReflectionException
+ * @throws \InvalidArgumentException
*/
public static function call($container, $callback, array $parameters = [], $defaultMethod = null)
{
@@ -49,7 +52,7 @@ class BoundMethod
// We will assume an @ sign is used to delimit the class name from the method
// name. We will split on this @ sign and then build a callable array that
// we can pass right back into the "call" method for dependency binding.
- $method = count($segments) == 2
+ $method = count($segments) === 2
? $segments[1] : $defaultMethod;
if (is_null($method)) {
@@ -103,10 +106,12 @@ class BoundMethod
/**
* Get all dependencies for a given method.
*
- * @param \Illuminate\Container\Container
+ * @param \Illuminate\Container\Container $container
* @param callable|string $callback
* @param array $parameters
* @return array
+ *
+ * @throws \ReflectionException
*/
protected static function getMethodDependencies($container, $callback, array $parameters = [])
{
@@ -122,8 +127,10 @@ class BoundMethod
/**
* Get the proper reflection instance for the given callback.
*
- * @param callable|string $callback
+ * @param callable|string $callback
* @return \ReflectionFunctionAbstract
+ *
+ * @throws \ReflectionException
*/
protected static function getCallReflector($callback)
{
@@ -143,7 +150,7 @@ class BoundMethod
* @param \ReflectionParameter $parameter
* @param array $parameters
* @param array $dependencies
- * @return mixed
+ * @return void
*/
protected static function addDependencyForCallParameter($container, $parameter,
array &$parameters, &$dependencies)
@@ -152,6 +159,10 @@ class BoundMethod
$dependencies[] = $parameters[$parameter->name];
unset($parameters[$parameter->name]);
+ } elseif ($parameter->getClass() && array_key_exists($parameter->getClass()->name, $parameters)) {
+ $dependencies[] = $parameters[$parameter->getClass()->name];
+
+ unset($parameters[$parameter->getClass()->name]);
} elseif ($parameter->getClass()) {
$dependencies[] = $container->make($parameter->getClass()->name);
} elseif ($parameter->isDefaultValueAvailable()) {
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Container/Container.php b/pfosten/vendor/laravel/framework/src/Illuminate/Container/Container.php
index 0945cb01..7dc70f7f 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Container/Container.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Container/Container.php
@@ -3,10 +3,12 @@
namespace Illuminate\Container;
use Closure;
+use Exception;
use ArrayAccess;
use LogicException;
use ReflectionClass;
use ReflectionParameter;
+use Illuminate\Support\Arr;
use Illuminate\Contracts\Container\BindingResolutionException;
use Illuminate\Contracts\Container\Container as ContainerContract;
@@ -22,124 +24,130 @@ class Container implements ArrayAccess, ContainerContract
/**
* An array of the types that have been resolved.
*
- * @var array
+ * @var bool[]
*/
protected $resolved = [];
/**
* The container's bindings.
*
- * @var array
+ * @var array[]
*/
protected $bindings = [];
/**
* The container's method bindings.
*
- * @var array
+ * @var \Closure[]
*/
protected $methodBindings = [];
/**
* The container's shared instances.
*
- * @var array
+ * @var object[]
*/
protected $instances = [];
/**
* The registered type aliases.
*
- * @var array
+ * @var string[]
*/
protected $aliases = [];
/**
* The registered aliases keyed by the abstract name.
*
- * @var array
+ * @var array[]
*/
protected $abstractAliases = [];
/**
* The extension closures for services.
*
- * @var array
+ * @var array[]
*/
protected $extenders = [];
/**
* All of the registered tags.
*
- * @var array
+ * @var array[]
*/
protected $tags = [];
/**
* The stack of concretions currently being built.
*
- * @var array
+ * @var array[]
*/
protected $buildStack = [];
/**
* The parameter override stack.
*
- * @var array
+ * @var array[]
*/
protected $with = [];
/**
* The contextual binding map.
*
- * @var array
+ * @var array[]
*/
public $contextual = [];
/**
* All of the registered rebound callbacks.
*
- * @var array
+ * @var array[]
*/
protected $reboundCallbacks = [];
/**
* All of the global resolving callbacks.
*
- * @var array
+ * @var \Closure[]
*/
protected $globalResolvingCallbacks = [];
/**
* All of the global after resolving callbacks.
*
- * @var array
+ * @var \Closure[]
*/
protected $globalAfterResolvingCallbacks = [];
/**
* All of the resolving callbacks by class type.
*
- * @var array
+ * @var array[]
*/
protected $resolvingCallbacks = [];
/**
* All of the after resolving callbacks by class type.
*
- * @var array
+ * @var array[]
*/
protected $afterResolvingCallbacks = [];
/**
* Define a contextual binding.
*
- * @param string $concrete
+ * @param array|string $concrete
* @return \Illuminate\Contracts\Container\ContextualBindingBuilder
*/
public function when($concrete)
{
- return new ContextualBindingBuilder($this, $this->getAlias($concrete));
+ $aliases = [];
+
+ foreach (Arr::wrap($concrete) as $c) {
+ $aliases[] = $this->getAlias($c);
+ }
+
+ return new ContextualBindingBuilder($this, $aliases);
}
/**
@@ -155,6 +163,14 @@ class Container implements ArrayAccess, ContainerContract
$this->isAlias($abstract);
}
+ /**
+ * {@inheritdoc}
+ */
+ public function has($id)
+ {
+ return $this->bound($id);
+ }
+
/**
* Determine if the given abstract type has been resolved.
*
@@ -180,7 +196,7 @@ class Container implements ArrayAccess, ContainerContract
public function isShared($abstract)
{
return isset($this->instances[$abstract]) ||
- (isset($this->bindings[$abstract]['shared']) &&
+ (isset($this->bindings[$abstract]['shared']) &&
$this->bindings[$abstract]['shared'] === true);
}
@@ -198,18 +214,18 @@ class Container implements ArrayAccess, ContainerContract
/**
* Register a binding with the container.
*
- * @param string|array $abstract
+ * @param string $abstract
* @param \Closure|string|null $concrete
* @param bool $shared
* @return void
*/
public function bind($abstract, $concrete = null, $shared = false)
{
+ $this->dropStaleInstances($abstract);
+
// If no concrete type was given, we will simply set the concrete type to the
// abstract type. After that, the concrete type to be registered as shared
// without being forced to state their classes in both of the parameters.
- $this->dropStaleInstances($abstract);
-
if (is_null($concrete)) {
$concrete = $abstract;
}
@@ -245,7 +261,9 @@ class Container implements ArrayAccess, ContainerContract
return $container->build($concrete);
}
- return $container->makeWith($concrete, $parameters);
+ return $container->resolve(
+ $concrete, $parameters, $raiseEvents = false
+ );
};
}
@@ -263,13 +281,28 @@ class Container implements ArrayAccess, ContainerContract
/**
* Bind a callback to resolve with Container::call.
*
- * @param string $method
+ * @param array|string $method
* @param \Closure $callback
* @return void
*/
public function bindMethod($method, $callback)
{
- $this->methodBindings[$method] = $callback;
+ $this->methodBindings[$this->parseBindMethod($method)] = $callback;
+ }
+
+ /**
+ * Get the method to be bound in class@method format.
+ *
+ * @param array|string $method
+ * @return string
+ */
+ protected function parseBindMethod($method)
+ {
+ if (is_array($method)) {
+ return $method[0].'@'.$method[1];
+ }
+
+ return $method;
}
/**
@@ -315,7 +348,7 @@ class Container implements ArrayAccess, ContainerContract
/**
* Register a shared binding in the container.
*
- * @param string|array $abstract
+ * @param string $abstract
* @param \Closure|string|null $concrete
* @return void
*/
@@ -355,7 +388,7 @@ class Container implements ArrayAccess, ContainerContract
*
* @param string $abstract
* @param mixed $instance
- * @return void
+ * @return mixed
*/
public function instance($abstract, $instance)
{
@@ -373,6 +406,8 @@ class Container implements ArrayAccess, ContainerContract
if ($isBound) {
$this->rebound($abstract);
}
+
+ return $instance;
}
/**
@@ -422,19 +457,19 @@ class Container implements ArrayAccess, ContainerContract
* Resolve all of the bindings for a given tag.
*
* @param string $tag
- * @return array
+ * @return iterable
*/
public function tagged($tag)
{
- $results = [];
-
- if (isset($this->tags[$tag])) {
- foreach ($this->tags[$tag] as $abstract) {
- $results[] = $this->make($abstract);
- }
+ if (! isset($this->tags[$tag])) {
+ return [];
}
- return $results;
+ return new RewindableGenerator(function () use ($tag) {
+ foreach ($this->tags[$tag] as $abstract) {
+ yield $this->make($abstract);
+ }
+ }, count($this->tags[$tag]));
}
/**
@@ -443,9 +478,15 @@ class Container implements ArrayAccess, ContainerContract
* @param string $abstract
* @param string $alias
* @return void
+ *
+ * @throws \LogicException
*/
public function alias($abstract, $alias)
{
+ if ($alias === $abstract) {
+ throw new LogicException("[{$abstract}] is aliased to itself.");
+ }
+
$this->aliases[$alias] = $abstract;
$this->abstractAliases[$abstract][] = $alias;
@@ -505,11 +546,7 @@ class Container implements ArrayAccess, ContainerContract
*/
protected function getReboundCallbacks($abstract)
{
- if (isset($this->reboundCallbacks[$abstract])) {
- return $this->reboundCallbacks[$abstract];
- }
-
- return [];
+ return $this->reboundCallbacks[$abstract] ?? [];
}
/**
@@ -553,26 +590,45 @@ class Container implements ArrayAccess, ContainerContract
}
/**
- * Resolve the given type with the given parameter overrides.
+ * An alias function name for make().
*
* @param string $abstract
* @param array $parameters
* @return mixed
*/
- public function makeWith($abstract, array $parameters)
+ public function makeWith($abstract, array $parameters = [])
+ {
+ return $this->make($abstract, $parameters);
+ }
+
+ /**
+ * Resolve the given type from the container.
+ *
+ * @param string $abstract
+ * @param array $parameters
+ * @return mixed
+ *
+ * @throws \Illuminate\Contracts\Container\BindingResolutionException
+ */
+ public function make($abstract, array $parameters = [])
{
return $this->resolve($abstract, $parameters);
}
/**
- * Resolve the given type from the container.
- *
- * @param string $abstract
- * @return mixed
+ * {@inheritdoc}
*/
- public function make($abstract)
+ public function get($id)
{
- return $this->resolve($abstract);
+ try {
+ return $this->resolve($id);
+ } catch (Exception $e) {
+ if ($this->has($id)) {
+ throw $e;
+ }
+
+ throw new EntryNotFoundException($id);
+ }
}
/**
@@ -580,9 +636,12 @@ class Container implements ArrayAccess, ContainerContract
*
* @param string $abstract
* @param array $parameters
+ * @param bool $raiseEvents
* @return mixed
+ *
+ * @throws \Illuminate\Contracts\Container\BindingResolutionException
*/
- protected function resolve($abstract, $parameters = [])
+ protected function resolve($abstract, $parameters = [], $raiseEvents = true)
{
$abstract = $this->getAlias($abstract);
@@ -624,7 +683,9 @@ class Container implements ArrayAccess, ContainerContract
$this->instances[$abstract] = $object;
}
- $this->fireResolvingCallbacks($abstract, $object);
+ if ($raiseEvents) {
+ $this->fireResolvingCallbacks($abstract, $object);
+ }
// Before returning, we will also set the resolved flag to "true" and pop off
// the parameter overrides for this build. After those two things are done
@@ -662,7 +723,7 @@ class Container implements ArrayAccess, ContainerContract
* Get the contextual concrete binding for the given abstract.
*
* @param string $abstract
- * @return string|null
+ * @return \Closure|string|null
*/
protected function getContextualConcrete($abstract)
{
@@ -688,13 +749,11 @@ class Container implements ArrayAccess, ContainerContract
* Find the concrete binding for the given abstract in the contextual binding array.
*
* @param string $abstract
- * @return string|null
+ * @return \Closure|string|null
*/
protected function findInContextualBindings($abstract)
{
- if (isset($this->contextual[end($this->buildStack)][$abstract])) {
- return $this->contextual[end($this->buildStack)][$abstract];
- }
+ return $this->contextual[end($this->buildStack)][$abstract] ?? null;
}
/**
@@ -729,7 +788,7 @@ class Container implements ArrayAccess, ContainerContract
$reflector = new ReflectionClass($concrete);
// If the type is not instantiable, the developer is attempting to resolve
- // an abstract type such as an Interface of Abstract Class and there is
+ // an abstract type such as an Interface or Abstract Class and there is
// no binding registered for the abstractions so we need to bail out.
if (! $reflector->isInstantiable()) {
return $this->notInstantiable($concrete);
@@ -753,9 +812,13 @@ class Container implements ArrayAccess, ContainerContract
// Once we have all the constructor's parameters we can create each of the
// dependency instances and then use the reflection instances to make a
// new instance of this class, injecting the created dependencies in.
- $instances = $this->resolveDependencies(
- $dependencies
- );
+ try {
+ $instances = $this->resolveDependencies($dependencies);
+ } catch (BindingResolutionException $e) {
+ array_pop($this->buildStack);
+
+ throw $e;
+ }
array_pop($this->buildStack);
@@ -767,6 +830,8 @@ class Container implements ArrayAccess, ContainerContract
*
* @param array $dependencies
* @return array
+ *
+ * @throws \Illuminate\Contracts\Container\BindingResolutionException
*/
protected function resolveDependencies(array $dependencies)
{
@@ -785,7 +850,7 @@ class Container implements ArrayAccess, ContainerContract
// If the class is null, it means the dependency is a string or some other
// primitive type which we can not resolve since it is not a class and
// we will just bomb out with an error since we have no-where to go.
- $results[] = is_null($class = $dependency->getClass())
+ $results[] = is_null($dependency->getClass())
? $this->resolvePrimitive($dependency)
: $this->resolveClass($dependency);
}
@@ -794,7 +859,7 @@ class Container implements ArrayAccess, ContainerContract
}
/**
- * Determine if the given dependency has a parameter override from makeWith.
+ * Determine if the given dependency has a parameter override.
*
* @param \ReflectionParameter $dependency
* @return bool
@@ -913,7 +978,7 @@ class Container implements ArrayAccess, ContainerContract
/**
* Register a new resolving callback.
*
- * @param string $abstract
+ * @param \Closure|string $abstract
* @param \Closure|null $callback
* @return void
*/
@@ -933,8 +998,8 @@ class Container implements ArrayAccess, ContainerContract
/**
* Register a new after resolving callback for all types.
*
- * @param string $abstract
- * @param \Closure|null $callback
+ * @param \Closure|string $abstract
+ * @param \Closure|null $callback
* @return void
*/
public function afterResolving($abstract, Closure $callback = null)
@@ -1035,8 +1100,6 @@ class Container implements ArrayAccess, ContainerContract
*
* @param string $abstract
* @return string
- *
- * @throws \LogicException
*/
public function getAlias($abstract)
{
@@ -1044,10 +1107,6 @@ class Container implements ArrayAccess, ContainerContract
return $abstract;
}
- if ($this->aliases[$abstract] === $abstract) {
- throw new LogicException("[{$abstract}] is aliased to itself.");
- }
-
return $this->getAlias($this->aliases[$abstract]);
}
@@ -1061,11 +1120,7 @@ class Container implements ArrayAccess, ContainerContract
{
$abstract = $this->getAlias($abstract);
- if (isset($this->extenders[$abstract])) {
- return $this->extenders[$abstract];
- }
-
- return [];
+ return $this->extenders[$abstract] ?? [];
}
/**
@@ -1126,7 +1181,7 @@ class Container implements ArrayAccess, ContainerContract
}
/**
- * Set the globally available instance of the container.
+ * Get the globally available instance of the container.
*
* @return static
*/
@@ -1143,7 +1198,7 @@ class Container implements ArrayAccess, ContainerContract
* Set the shared instance of the container.
*
* @param \Illuminate\Contracts\Container\Container|null $container
- * @return static
+ * @return \Illuminate\Contracts\Container\Container|static
*/
public static function setInstance(ContainerContract $container = null)
{
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Container/ContextualBindingBuilder.php b/pfosten/vendor/laravel/framework/src/Illuminate/Container/ContextualBindingBuilder.php
index 58b70cee..ac280dba 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Container/ContextualBindingBuilder.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Container/ContextualBindingBuilder.php
@@ -2,6 +2,8 @@
namespace Illuminate\Container;
+use Illuminate\Support\Arr;
+use Illuminate\Contracts\Container\Container;
use Illuminate\Contracts\Container\ContextualBindingBuilder as ContextualBindingBuilderContract;
class ContextualBindingBuilder implements ContextualBindingBuilderContract
@@ -9,14 +11,14 @@ class ContextualBindingBuilder implements ContextualBindingBuilderContract
/**
* The underlying container instance.
*
- * @var \Illuminate\Container\Container
+ * @var \Illuminate\Contracts\Container\Container
*/
protected $container;
/**
* The concrete instance.
*
- * @var string
+ * @var string|array
*/
protected $concrete;
@@ -30,8 +32,8 @@ class ContextualBindingBuilder implements ContextualBindingBuilderContract
/**
* Create a new contextual binding builder.
*
- * @param \Illuminate\Container\Container $container
- * @param string $concrete
+ * @param \Illuminate\Contracts\Container\Container $container
+ * @param string|array $concrete
* @return void
*/
public function __construct(Container $container, $concrete)
@@ -61,8 +63,8 @@ class ContextualBindingBuilder implements ContextualBindingBuilderContract
*/
public function give($implementation)
{
- $this->container->addContextualBinding(
- $this->concrete, $this->needs, $implementation
- );
+ foreach (Arr::wrap($this->concrete) as $concrete) {
+ $this->container->addContextualBinding($concrete, $this->needs, $implementation);
+ }
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Container/composer.json b/pfosten/vendor/laravel/framework/src/Illuminate/Container/composer.json
index 97a919b2..92f0063c 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Container/composer.json
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Container/composer.json
@@ -14,8 +14,10 @@
}
],
"require": {
- "php": ">=5.6.4",
- "illuminate/contracts": "5.4.*"
+ "php": "^7.1.3",
+ "illuminate/contracts": "5.8.*",
+ "illuminate/support": "5.8.*",
+ "psr/container": "^1.0"
},
"autoload": {
"psr-4": {
@@ -24,7 +26,7 @@
},
"extra": {
"branch-alias": {
- "dev-master": "5.4-dev"
+ "dev-master": "5.8-dev"
}
},
"config": {
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Auth/Access/Gate.php b/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Auth/Access/Gate.php
index 9d838908..779ad46d 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Auth/Access/Gate.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Auth/Access/Gate.php
@@ -65,13 +65,22 @@ interface Gate
public function denies($ability, $arguments = []);
/**
- * Determine if the given ability should be granted.
+ * Determine if all of the given abilities should be granted for the current user.
*
- * @param string $ability
+ * @param iterable|string $abilities
* @param array|mixed $arguments
* @return bool
*/
- public function check($ability, $arguments = []);
+ public function check($abilities, $arguments = []);
+
+ /**
+ * Determine if any one of the given abilities should be granted for the current user.
+ *
+ * @param iterable|string $abilities
+ * @param array|mixed $arguments
+ * @return bool
+ */
+ public function any($abilities, $arguments = []);
/**
* Determine if the given ability should be granted for the current user.
@@ -84,6 +93,15 @@ interface Gate
*/
public function authorize($ability, $arguments = []);
+ /**
+ * Get the raw result from the authorization callback.
+ *
+ * @param string $ability
+ * @param array|mixed $arguments
+ * @return mixed
+ */
+ public function raw($ability, $arguments = []);
+
/**
* Get a policy instance for a given class.
*
@@ -101,4 +119,11 @@ interface Gate
* @return static
*/
public function forUser($user);
+
+ /**
+ * Get all of the defined abilities.
+ *
+ * @return array
+ */
+ public function abilities();
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Auth/Guard.php b/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Auth/Guard.php
index 2a2ed3d9..2a27fb5f 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Auth/Guard.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Auth/Guard.php
@@ -28,7 +28,7 @@ interface Guard
/**
* Get the ID for the currently authenticated user.
*
- * @return int|null
+ * @return int|string|null
*/
public function id();
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Auth/UserProvider.php b/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Auth/UserProvider.php
index a12aa3de..a2ab1227 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Auth/UserProvider.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Auth/UserProvider.php
@@ -15,7 +15,7 @@ interface UserProvider
/**
* Retrieve a user by their unique identifier and "remember me" token.
*
- * @param mixed $identifier
+ * @param mixed $identifier
* @param string $token
* @return \Illuminate\Contracts\Auth\Authenticatable|null
*/
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Broadcasting/Factory.php b/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Broadcasting/Factory.php
index 1d3a7374..384c2d02 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Broadcasting/Factory.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Broadcasting/Factory.php
@@ -7,7 +7,7 @@ interface Factory
/**
* Get a broadcaster implementation by name.
*
- * @param string $name
+ * @param string|null $name
* @return void
*/
public function connection($name = null);
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Broadcasting/ShouldBroadcast.php b/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Broadcasting/ShouldBroadcast.php
index bdabc08e..a4802fe4 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Broadcasting/ShouldBroadcast.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Broadcasting/ShouldBroadcast.php
@@ -7,7 +7,7 @@ interface ShouldBroadcast
/**
* Get the channels the event should broadcast on.
*
- * @return array
+ * @return \Illuminate\Broadcasting\Channel|\Illuminate\Broadcasting\Channel[]
*/
public function broadcastOn();
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Bus/Dispatcher.php b/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Bus/Dispatcher.php
index 3370ad3d..12ed2226 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Bus/Dispatcher.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Bus/Dispatcher.php
@@ -21,6 +21,22 @@ interface Dispatcher
*/
public function dispatchNow($command, $handler = null);
+ /**
+ * Determine if the given command has a handler.
+ *
+ * @param mixed $command
+ * @return bool
+ */
+ public function hasCommandHandler($command);
+
+ /**
+ * Retrieve the handler for a command.
+ *
+ * @param mixed $command
+ * @return bool|mixed
+ */
+ public function getCommandHandler($command);
+
/**
* Set the pipes commands should be piped through before dispatching.
*
@@ -28,4 +44,12 @@ interface Dispatcher
* @return $this
*/
public function pipeThrough(array $pipes);
+
+ /**
+ * Map a command to a handler.
+ *
+ * @param array $map
+ * @return $this
+ */
+ public function map(array $map);
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Cache/Factory.php b/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Cache/Factory.php
index b3337294..3924662d 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Cache/Factory.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Cache/Factory.php
@@ -8,7 +8,7 @@ interface Factory
* Get a cache store instance by name.
*
* @param string|null $name
- * @return mixed
+ * @return \Illuminate\Contracts\Cache\Repository
*/
public function store($name = null);
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Cache/Repository.php b/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Cache/Repository.php
index 4749bccf..f69c6f98 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Cache/Repository.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Cache/Repository.php
@@ -3,31 +3,15 @@
namespace Illuminate\Contracts\Cache;
use Closure;
+use Psr\SimpleCache\CacheInterface;
-interface Repository
+interface Repository extends CacheInterface
{
- /**
- * 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
+ * @param mixed $default
* @return mixed
*/
public function pull($key, $default = null);
@@ -36,21 +20,21 @@ interface Repository
* Store an item in the cache.
*
* @param string $key
- * @param mixed $value
- * @param \DateTime|float|int $minutes
- * @return void
+ * @param mixed $value
+ * @param \DateTimeInterface|\DateInterval|int|null $ttl
+ * @return bool
*/
- public function put($key, $value, $minutes);
+ public function put($key, $value, $ttl = null);
/**
* Store an item in the cache if the key does not exist.
*
* @param string $key
- * @param mixed $value
- * @param \DateTime|float|int $minutes
+ * @param mixed $value
+ * @param \DateTimeInterface|\DateInterval|int|null $ttl
* @return bool
*/
- public function add($key, $value, $minutes);
+ public function add($key, $value, $ttl = null);
/**
* Increment the value of an item in the cache.
@@ -74,34 +58,34 @@ interface Repository
* Store an item in the cache indefinitely.
*
* @param string $key
- * @param mixed $value
- * @return void
+ * @param mixed $value
+ * @return bool
*/
public function forever($key, $value);
/**
- * Get an item from the cache, or store the default value.
+ * Get an item from the cache, or execute the given Closure and store the result.
*
* @param string $key
- * @param \DateTime|float|int $minutes
+ * @param \DateTimeInterface|\DateInterval|int|null $ttl
* @param \Closure $callback
* @return mixed
*/
- public function remember($key, $minutes, Closure $callback);
+ public function remember($key, $ttl, Closure $callback);
/**
- * Get an item from the cache, or store the default value forever.
+ * Get an item from the cache, or execute the given Closure and store the result forever.
*
- * @param string $key
+ * @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.
+ * Get an item from the cache, or execute the given Closure and store the result forever.
*
- * @param string $key
+ * @param string $key
* @param \Closure $callback
* @return mixed
*/
@@ -114,4 +98,11 @@ interface Repository
* @return bool
*/
public function forget($key);
+
+ /**
+ * Get the cache store implementation.
+ *
+ * @return \Illuminate\Contracts\Cache\Store
+ */
+ public function getStore();
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Cache/Store.php b/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Cache/Store.php
index 5615762b..133bc43e 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Cache/Store.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Cache/Store.php
@@ -23,29 +23,29 @@ interface Store
public function many(array $keys);
/**
- * Store an item in the cache for a given number of minutes.
+ * Store an item in the cache for a given number of seconds.
*
* @param string $key
- * @param mixed $value
- * @param float|int $minutes
- * @return void
+ * @param mixed $value
+ * @param int $seconds
+ * @return bool
*/
- public function put($key, $value, $minutes);
+ public function put($key, $value, $seconds);
/**
- * Store multiple items in the cache for a given number of minutes.
+ * Store multiple items in the cache for a given number of seconds.
*
* @param array $values
- * @param float|int $minutes
- * @return void
+ * @param int $seconds
+ * @return bool
*/
- public function putMany(array $values, $minutes);
+ public function putMany(array $values, $seconds);
/**
* Increment the value of an item in the cache.
*
* @param string $key
- * @param mixed $value
+ * @param mixed $value
* @return int|bool
*/
public function increment($key, $value = 1);
@@ -54,7 +54,7 @@ interface Store
* Decrement the value of an item in the cache.
*
* @param string $key
- * @param mixed $value
+ * @param mixed $value
* @return int|bool
*/
public function decrement($key, $value = 1);
@@ -63,8 +63,8 @@ interface Store
* Store an item in the cache indefinitely.
*
* @param string $key
- * @param mixed $value
- * @return void
+ * @param mixed $value
+ * @return bool
*/
public function forever($key, $value);
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Config/Repository.php b/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Config/Repository.php
index 18a773dc..17c1d5f2 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Config/Repository.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Config/Repository.php
@@ -15,7 +15,7 @@ interface Repository
/**
* Get the specified configuration value.
*
- * @param string $key
+ * @param array|string $key
* @param mixed $default
* @return mixed
*/
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Console/Application.php b/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Console/Application.php
index a59e4312..ba628c9f 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Console/Application.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Console/Application.php
@@ -5,13 +5,14 @@ namespace Illuminate\Contracts\Console;
interface Application
{
/**
- * Call a console application command.
+ * Run an Artisan console command by name.
*
* @param string $command
* @param array $parameters
+ * @param \Symfony\Component\Console\Output\OutputInterface|null $outputBuffer
* @return int
*/
- public function call($command, array $parameters = []);
+ public function call($command, array $parameters = [], $outputBuffer = null);
/**
* Get the output from the last command.
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Console/Kernel.php b/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Console/Kernel.php
index 4cf79869..a7423af3 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Console/Kernel.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Console/Kernel.php
@@ -8,7 +8,7 @@ interface Kernel
* Handle an incoming console command.
*
* @param \Symfony\Component\Console\Input\InputInterface $input
- * @param \Symfony\Component\Console\Output\OutputInterface $output
+ * @param \Symfony\Component\Console\Output\OutputInterface|null $output
* @return int
*/
public function handle($input, $output = null);
@@ -18,9 +18,10 @@ interface Kernel
*
* @param string $command
* @param array $parameters
+ * @param \Symfony\Component\Console\Output\OutputInterface|null $outputBuffer
* @return int
*/
- public function call($command, array $parameters = []);
+ public function call($command, array $parameters = [], $outputBuffer = null);
/**
* Queue an Artisan console command by name.
@@ -44,4 +45,13 @@ interface Kernel
* @return string
*/
public function output();
+
+ /**
+ * Terminate the application.
+ *
+ * @param \Symfony\Component\Console\Input\InputInterface $input
+ * @param int $status
+ * @return void
+ */
+ public function terminate($input, $status);
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Container/BindingResolutionException.php b/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Container/BindingResolutionException.php
index dfedd947..a69c24c5 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Container/BindingResolutionException.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Container/BindingResolutionException.php
@@ -3,8 +3,9 @@
namespace Illuminate\Contracts\Container;
use Exception;
+use Psr\Container\ContainerExceptionInterface;
-class BindingResolutionException extends Exception
+class BindingResolutionException extends Exception implements ContainerExceptionInterface
{
//
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Container/Container.php b/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Container/Container.php
index 45daa479..095c2c3b 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Container/Container.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Container/Container.php
@@ -3,8 +3,9 @@
namespace Illuminate\Contracts\Container;
use Closure;
+use Psr\Container\ContainerInterface;
-interface Container
+interface Container extends ContainerInterface
{
/**
* Determine if the given abstract type has been bound.
@@ -20,6 +21,8 @@ interface Container
* @param string $abstract
* @param string $alias
* @return void
+ *
+ * @throws \LogicException
*/
public function alias($abstract, $alias);
@@ -35,15 +38,15 @@ interface Container
/**
* Resolve all of the bindings for a given tag.
*
- * @param array $tag
- * @return array
+ * @param string $tag
+ * @return iterable
*/
public function tagged($tag);
/**
* Register a binding with the container.
*
- * @param string|array $abstract
+ * @param string $abstract
* @param \Closure|string|null $concrete
* @param bool $shared
* @return void
@@ -63,7 +66,7 @@ interface Container
/**
* Register a shared binding in the container.
*
- * @param string|array $abstract
+ * @param string $abstract
* @param \Closure|string|null $concrete
* @return void
*/
@@ -85,14 +88,24 @@ interface Container
*
* @param string $abstract
* @param mixed $instance
- * @return void
+ * @return mixed
*/
public function instance($abstract, $instance);
/**
- * Define a contextual binding.
+ * Add a contextual binding to the container.
*
* @param string $concrete
+ * @param string $abstract
+ * @param \Closure|string $implementation
+ * @return void
+ */
+ public function addContextualBinding($concrete, $abstract, $implementation);
+
+ /**
+ * Define a contextual binding.
+ *
+ * @param string|array $concrete
* @return \Illuminate\Contracts\Container\ContextualBindingBuilder
*/
public function when($concrete);
@@ -105,13 +118,23 @@ interface Container
*/
public function factory($abstract);
+ /**
+ * Flush the container of all bindings and resolved instances.
+ *
+ * @return void
+ */
+ public function flush();
+
/**
* Resolve the given type from the container.
*
* @param string $abstract
+ * @param array $parameters
* @return mixed
+ *
+ * @throws \Illuminate\Contracts\Container\BindingResolutionException
*/
- public function make($abstract);
+ public function make($abstract, array $parameters = []);
/**
* Call the given Closure / class@method and inject its dependencies.
@@ -134,7 +157,7 @@ interface Container
/**
* Register a new resolving callback.
*
- * @param string $abstract
+ * @param \Closure|string $abstract
* @param \Closure|null $callback
* @return void
*/
@@ -143,7 +166,7 @@ interface Container
/**
* Register a new after resolving callback.
*
- * @param string $abstract
+ * @param \Closure|string $abstract
* @param \Closure|null $callback
* @return void
*/
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Cookie/Factory.php b/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Cookie/Factory.php
index 61243976..71765578 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Cookie/Factory.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Cookie/Factory.php
@@ -10,33 +10,37 @@ interface Factory
* @param string $name
* @param string $value
* @param int $minutes
- * @param string $path
- * @param string $domain
- * @param bool $secure
+ * @param string|null $path
+ * @param string|null $domain
+ * @param bool|null $secure
* @param bool $httpOnly
+ * @param bool $raw
+ * @param string|null $sameSite
* @return \Symfony\Component\HttpFoundation\Cookie
*/
- public function make($name, $value, $minutes = 0, $path = null, $domain = null, $secure = false, $httpOnly = true);
+ public function make($name, $value, $minutes = 0, $path = null, $domain = null, $secure = null, $httpOnly = true, $raw = false, $sameSite = null);
/**
* Create a cookie that lasts "forever" (five years).
*
* @param string $name
* @param string $value
- * @param string $path
- * @param string $domain
- * @param bool $secure
+ * @param string|null $path
+ * @param string|null $domain
+ * @param bool|null $secure
* @param bool $httpOnly
+ * @param bool $raw
+ * @param string|null $sameSite
* @return \Symfony\Component\HttpFoundation\Cookie
*/
- public function forever($name, $value, $path = null, $domain = null, $secure = false, $httpOnly = true);
+ public function forever($name, $value, $path = null, $domain = null, $secure = null, $httpOnly = true, $raw = false, $sameSite = null);
/**
* Expire the given cookie.
*
* @param string $name
- * @param string $path
- * @param string $domain
+ * @param string|null $path
+ * @param string|null $domain
* @return \Symfony\Component\HttpFoundation\Cookie
*/
public function forget($name, $path = null, $domain = null);
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Database/ModelIdentifier.php b/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Database/ModelIdentifier.php
index c4069fd7..9893d280 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Database/ModelIdentifier.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Database/ModelIdentifier.php
@@ -20,16 +20,34 @@ class ModelIdentifier
*/
public $id;
+ /**
+ * The relationships loaded on the model.
+ *
+ * @var array
+ */
+ public $relations;
+
+ /**
+ * The connection name of the model.
+ *
+ * @var string|null
+ */
+ public $connection;
+
/**
* Create a new model identifier.
*
* @param string $class
* @param mixed $id
+ * @param array $relations
+ * @param mixed $connection
* @return void
*/
- public function __construct($class, $id)
+ public function __construct($class, $id, array $relations, $connection)
{
$this->id = $id;
$this->class = $class;
+ $this->relations = $relations;
+ $this->connection = $connection;
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Debug/ExceptionHandler.php b/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Debug/ExceptionHandler.php
index e3f18a59..975ed6c2 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Debug/ExceptionHandler.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Debug/ExceptionHandler.php
@@ -14,6 +14,14 @@ interface ExceptionHandler
*/
public function report(Exception $e);
+ /**
+ * Determine if the exception should be reported.
+ *
+ * @param \Exception $e
+ * @return bool
+ */
+ public function shouldReport(Exception $e);
+
/**
* Render an exception into an HTTP response.
*
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Encryption/Encrypter.php b/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Encryption/Encrypter.php
index 11e0b45a..4747b68a 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Encryption/Encrypter.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Encryption/Encrypter.php
@@ -7,9 +7,11 @@ interface Encrypter
/**
* Encrypt the given value.
*
- * @param string $value
+ * @param mixed $value
* @param bool $serialize
* @return string
+ *
+ * @throws \Illuminate\Contracts\Encryption\EncryptException
*/
public function encrypt($value, $serialize = true);
@@ -18,7 +20,9 @@ interface Encrypter
*
* @param string $payload
* @param bool $unserialize
- * @return string
+ * @return mixed
+ *
+ * @throws \Illuminate\Contracts\Encryption\DecryptException
*/
public function decrypt($payload, $unserialize = true);
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Filesystem/Factory.php b/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Filesystem/Factory.php
index 7a861380..d0f9cd2b 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Filesystem/Factory.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Filesystem/Factory.php
@@ -7,7 +7,7 @@ interface Factory
/**
* Get a filesystem implementation.
*
- * @param string $name
+ * @param string|null $name
* @return \Illuminate\Contracts\Filesystem\Filesystem
*/
public function disk($name = null);
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Filesystem/Filesystem.php b/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Filesystem/Filesystem.php
index 164f9b1c..399b6276 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Filesystem/Filesystem.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Filesystem/Filesystem.php
@@ -36,15 +36,38 @@ interface Filesystem
*/
public function get($path);
+ /**
+ * Get a resource to read the file.
+ *
+ * @param string $path
+ * @return resource|null The path resource or null on failure.
+ *
+ * @throws FileNotFoundException
+ */
+ public function readStream($path);
+
/**
* Write the contents of a file.
*
* @param string $path
* @param string|resource $contents
- * @param string $visibility
+ * @param mixed $options
* @return bool
*/
- public function put($path, $contents, $visibility = null);
+ public function put($path, $contents, $options = []);
+
+ /**
+ * Write a new file using a stream.
+ *
+ * @param string $path
+ * @param resource $resource
+ * @param array $options
+ * @return bool
+ *
+ * @throws \InvalidArgumentException If $resource is not a file handle.
+ * @throws FileExistsException
+ */
+ public function writeStream($path, $resource, array $options = []);
/**
* Get the visibility for the given path.
@@ -59,7 +82,7 @@ interface Filesystem
*
* @param string $path
* @param string $visibility
- * @return void
+ * @return bool
*/
public function setVisibility($path, $visibility);
@@ -68,7 +91,7 @@ interface Filesystem
*
* @param string $path
* @param string $data
- * @return int
+ * @return bool
*/
public function prepend($path, $data);
@@ -77,7 +100,7 @@ interface Filesystem
*
* @param string $path
* @param string $data
- * @return int
+ * @return bool
*/
public function append($path, $data);
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Foundation/Application.php b/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Foundation/Application.php
index 84ce820f..aa277d7f 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Foundation/Application.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Foundation/Application.php
@@ -2,6 +2,7 @@
namespace Illuminate\Contracts\Foundation;
+use Closure;
use Illuminate\Contracts\Container\Container;
interface Application extends Container
@@ -21,11 +22,72 @@ interface Application extends Container
public function basePath();
/**
- * Get or check the current application environment.
+ * Get the path to the bootstrap directory.
+ *
+ * @param string $path Optionally, a path to append to the bootstrap path
+ * @return string
+ */
+ public function bootstrapPath($path = '');
+
+ /**
+ * Get the path to the application configuration files.
+ *
+ * @param string $path Optionally, a path to append to the config path
+ * @return string
+ */
+ public function configPath($path = '');
+
+ /**
+ * Get the path to the database directory.
+ *
+ * @param string $path Optionally, a path to append to the database path
+ * @return string
+ */
+ public function databasePath($path = '');
+
+ /**
+ * Get the path to the environment file directory.
*
* @return string
*/
- public function environment();
+ public function environmentPath();
+
+ /**
+ * Get the path to the resources directory.
+ *
+ * @param string $path
+ * @return string
+ */
+ public function resourcePath($path = '');
+
+ /**
+ * Get the path to the storage directory.
+ *
+ * @return string
+ */
+ public function storagePath();
+
+ /**
+ * Get or check the current application environment.
+ *
+ * @param string|array $environments
+ * @return string|bool
+ */
+ public function environment(...$environments);
+
+ /**
+ * Determine if the application is running in the console.
+ *
+ * @return bool
+ */
+ public function runningInConsole();
+
+ /**
+ * Determine if the application is running unit tests.
+ *
+ * @return bool
+ */
+ public function runningUnitTests();
/**
* Determine if the application is currently down for maintenance.
@@ -45,11 +107,10 @@ interface Application extends Container
* 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 = [], $force = false);
+ public function register($provider, $force = false);
/**
* Register a deferred provider and service.
@@ -60,6 +121,14 @@ interface Application extends Container
*/
public function registerDeferredProvider($provider, $service = null);
+ /**
+ * Resolve a service provider instance from the class name.
+ *
+ * @param string $provider
+ * @return \Illuminate\Support\ServiceProvider
+ */
+ public function resolveProvider($provider);
+
/**
* Boot the application's service providers.
*
@@ -70,7 +139,7 @@ interface Application extends Container
/**
* Register a new boot listener.
*
- * @param mixed $callback
+ * @param callable $callback
* @return void
*/
public function booting($callback);
@@ -78,15 +147,148 @@ interface Application extends Container
/**
* Register a new "booted" listener.
*
- * @param mixed $callback
+ * @param callable $callback
* @return void
*/
public function booted($callback);
+ /**
+ * Run the given array of bootstrap classes.
+ *
+ * @param array $bootstrappers
+ * @return void
+ */
+ public function bootstrapWith(array $bootstrappers);
+
+ /**
+ * Determine if the application configuration is cached.
+ *
+ * @return bool
+ */
+ public function configurationIsCached();
+
+ /**
+ * Detect the application's current environment.
+ *
+ * @param \Closure $callback
+ * @return string
+ */
+ public function detectEnvironment(Closure $callback);
+
+ /**
+ * Get the environment file the application is using.
+ *
+ * @return string
+ */
+ public function environmentFile();
+
+ /**
+ * Get the fully qualified path to the environment file.
+ *
+ * @return string
+ */
+ public function environmentFilePath();
+
+ /**
+ * Get the path to the configuration cache file.
+ *
+ * @return string
+ */
+ public function getCachedConfigPath();
+
/**
* Get the path to the cached services.php file.
*
* @return string
*/
public function getCachedServicesPath();
+
+ /**
+ * Get the path to the cached packages.php file.
+ *
+ * @return string
+ */
+ public function getCachedPackagesPath();
+
+ /**
+ * Get the path to the routes cache file.
+ *
+ * @return string
+ */
+ public function getCachedRoutesPath();
+
+ /**
+ * Get the current application locale.
+ *
+ * @return string
+ */
+ public function getLocale();
+
+ /**
+ * Get the application namespace.
+ *
+ * @return string
+ *
+ * @throws \RuntimeException
+ */
+ public function getNamespace();
+
+ /**
+ * Get the registered service provider instances if any exist.
+ *
+ * @param \Illuminate\Support\ServiceProvider|string $provider
+ * @return array
+ */
+ public function getProviders($provider);
+
+ /**
+ * Determine if the application has been bootstrapped before.
+ *
+ * @return bool
+ */
+ public function hasBeenBootstrapped();
+
+ /**
+ * Load and boot all of the remaining deferred providers.
+ *
+ * @return void
+ */
+ public function loadDeferredProviders();
+
+ /**
+ * Set the environment file to be loaded during bootstrapping.
+ *
+ * @param string $file
+ * @return $this
+ */
+ public function loadEnvironmentFrom($file);
+
+ /**
+ * Determine if the application routes are cached.
+ *
+ * @return bool
+ */
+ public function routesAreCached();
+
+ /**
+ * Set the current application locale.
+ *
+ * @param string $locale
+ * @return void
+ */
+ public function setLocale($locale);
+
+ /**
+ * Determine if middleware has been disabled for the application.
+ *
+ * @return bool
+ */
+ public function shouldSkipMiddleware();
+
+ /**
+ * Terminate the application.
+ *
+ * @return void
+ */
+ public function terminate();
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Hashing/Hasher.php b/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Hashing/Hasher.php
index 3310136e..8771c7c6 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Hashing/Hasher.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Hashing/Hasher.php
@@ -4,6 +4,14 @@ namespace Illuminate\Contracts\Hashing;
interface Hasher
{
+ /**
+ * Get information about the given hashed value.
+ *
+ * @param string $hashedValue
+ * @return array
+ */
+ public function info($hashedValue);
+
/**
* Hash the given value.
*
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Logging/Log.php b/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Logging/Log.php
deleted file mode 100644
index 5ecb9f8b..00000000
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Contracts/Logging/Log.php
+++ /dev/null
@@ -1,98 +0,0 @@
-=5.6.4"
+ "php": "^7.1.3",
+ "psr/container": "^1.0",
+ "psr/simple-cache": "^1.0"
},
"autoload": {
"psr-4": {
@@ -23,7 +25,7 @@
},
"extra": {
"branch-alias": {
- "dev-master": "5.4-dev"
+ "dev-master": "5.8-dev"
}
},
"config": {
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Cookie/CookieJar.php b/pfosten/vendor/laravel/framework/src/Illuminate/Cookie/CookieJar.php
index 93f53f53..bb255dae 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Cookie/CookieJar.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Cookie/CookieJar.php
@@ -2,13 +2,16 @@
namespace Illuminate\Cookie;
-use Carbon\Carbon;
use Illuminate\Support\Arr;
+use Illuminate\Support\Traits\Macroable;
+use Illuminate\Support\InteractsWithTime;
use Symfony\Component\HttpFoundation\Cookie;
use Illuminate\Contracts\Cookie\QueueingFactory as JarContract;
class CookieJar implements JarContract
{
+ use InteractsWithTime, Macroable;
+
/**
* The default path (if specified).
*
@@ -30,56 +33,67 @@ class CookieJar implements JarContract
*/
protected $secure = false;
+ /**
+ * The default SameSite option (if specified).
+ *
+ * @var string
+ */
+ protected $sameSite;
+
/**
* All of the cookies queued for sending.
*
- * @var array
+ * @var \Symfony\Component\HttpFoundation\Cookie[]
*/
protected $queued = [];
/**
* 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
+ * @param string $name
+ * @param string $value
+ * @param int $minutes
+ * @param string|null $path
+ * @param string|null $domain
+ * @param bool|null $secure
+ * @param bool $httpOnly
+ * @param bool $raw
+ * @param string|null $sameSite
* @return \Symfony\Component\HttpFoundation\Cookie
*/
- public function make($name, $value, $minutes = 0, $path = null, $domain = null, $secure = false, $httpOnly = true)
+ public function make($name, $value, $minutes = 0, $path = null, $domain = null, $secure = null, $httpOnly = true, $raw = false, $sameSite = null)
{
- list($path, $domain, $secure) = $this->getPathAndDomain($path, $domain, $secure);
+ [$path, $domain, $secure, $sameSite] = $this->getPathAndDomain($path, $domain, $secure, $sameSite);
- $time = ($minutes == 0) ? 0 : Carbon::now()->getTimestamp() + ($minutes * 60);
+ $time = ($minutes == 0) ? 0 : $this->availableAt($minutes * 60);
- return new Cookie($name, $value, $time, $path, $domain, $secure, $httpOnly);
+ return new Cookie($name, $value, $time, $path, $domain, $secure, $httpOnly, $raw, $sameSite);
}
/**
* 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
+ * @param string $name
+ * @param string $value
+ * @param string|null $path
+ * @param string|null $domain
+ * @param bool|null $secure
+ * @param bool $httpOnly
+ * @param bool $raw
+ * @param string|null $sameSite
* @return \Symfony\Component\HttpFoundation\Cookie
*/
- public function forever($name, $value, $path = null, $domain = null, $secure = false, $httpOnly = true)
+ public function forever($name, $value, $path = null, $domain = null, $secure = null, $httpOnly = true, $raw = false, $sameSite = null)
{
- return $this->make($name, $value, 2628000, $path, $domain, $secure, $httpOnly);
+ return $this->make($name, $value, 2628000, $path, $domain, $secure, $httpOnly, $raw, $sameSite);
}
/**
* Expire the given cookie.
*
* @param string $name
- * @param string $path
- * @param string $domain
+ * @param string|null $path
+ * @param string|null $domain
* @return \Symfony\Component\HttpFoundation\Cookie
*/
public function forget($name, $path = null, $domain = null)
@@ -141,14 +155,15 @@ class CookieJar implements JarContract
/**
* Get the path and domain, or the default values.
*
- * @param string $path
- * @param string $domain
- * @param bool $secure
+ * @param string $path
+ * @param string $domain
+ * @param bool|null $secure
+ * @param string|null $sameSite
* @return array
*/
- protected function getPathAndDomain($path, $domain, $secure = false)
+ protected function getPathAndDomain($path, $domain, $secure = null, $sameSite = null)
{
- return [$path ?: $this->path, $domain ?: $this->domain, $secure ?: $this->secure];
+ return [$path ?: $this->path, $domain ?: $this->domain, is_bool($secure) ? $secure : $this->secure, $sameSite ?: $this->sameSite];
}
/**
@@ -157,11 +172,12 @@ class CookieJar implements JarContract
* @param string $path
* @param string $domain
* @param bool $secure
+ * @param string|null $sameSite
* @return $this
*/
- public function setDefaultPathAndDomain($path, $domain, $secure = false)
+ public function setDefaultPathAndDomain($path, $domain, $secure = false, $sameSite = null)
{
- list($this->path, $this->domain, $this->secure) = [$path, $domain, $secure];
+ [$this->path, $this->domain, $this->secure, $this->sameSite] = [$path, $domain, $secure, $sameSite];
return $this;
}
@@ -169,7 +185,7 @@ class CookieJar implements JarContract
/**
* Get the cookies which have been queued for the next request.
*
- * @return array
+ * @return \Symfony\Component\HttpFoundation\Cookie[]
*/
public function getQueuedCookies()
{
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Cookie/CookieServiceProvider.php b/pfosten/vendor/laravel/framework/src/Illuminate/Cookie/CookieServiceProvider.php
index faeaa2a5..7c82dc14 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Cookie/CookieServiceProvider.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Cookie/CookieServiceProvider.php
@@ -16,7 +16,9 @@ class CookieServiceProvider extends ServiceProvider
$this->app->singleton('cookie', function ($app) {
$config = $app->make('config')->get('session');
- return (new CookieJar)->setDefaultPathAndDomain($config['path'], $config['domain'], $config['secure']);
+ return (new CookieJar)->setDefaultPathAndDomain(
+ $config['path'], $config['domain'], $config['secure'], $config['same_site'] ?? null
+ );
});
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php b/pfosten/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php
index 1e630118..1036a082 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php
@@ -25,6 +25,13 @@ class EncryptCookies
*/
protected $except = [];
+ /**
+ * Indicates if cookies should be serialized.
+ *
+ * @var bool
+ */
+ protected static $serialize = false;
+
/**
* Create a new CookieGuard instance.
*
@@ -39,12 +46,12 @@ class EncryptCookies
/**
* Disable encryption for the given cookie name(s).
*
- * @param string|array $cookieName
+ * @param string|array $name
* @return void
*/
- public function disableFor($cookieName)
+ public function disableFor($name)
{
- $this->except = array_merge($this->except, (array) $cookieName);
+ $this->except = array_merge($this->except, (array) $name);
}
/**
@@ -52,7 +59,7 @@ class EncryptCookies
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
- * @return mixed
+ * @return \Symfony\Component\HttpFoundation\Response
*/
public function handle($request, Closure $next)
{
@@ -67,13 +74,13 @@ class EncryptCookies
*/
protected function decrypt(Request $request)
{
- foreach ($request->cookies as $key => $c) {
+ foreach ($request->cookies as $key => $cookie) {
if ($this->isDisabled($key)) {
continue;
}
try {
- $request->cookies->set($key, $this->decryptCookie($c));
+ $request->cookies->set($key, $this->decryptCookie($key, $cookie));
} catch (DecryptException $e) {
$request->cookies->set($key, null);
}
@@ -85,14 +92,15 @@ class EncryptCookies
/**
* Decrypt the given cookie and return the value.
*
+ * @param string $name
* @param string|array $cookie
* @return string|array
*/
- protected function decryptCookie($cookie)
+ protected function decryptCookie($name, $cookie)
{
return is_array($cookie)
? $this->decryptArray($cookie)
- : $this->encrypter->decrypt($cookie);
+ : $this->encrypter->decrypt($cookie, static::serialized($name));
}
/**
@@ -107,7 +115,7 @@ class EncryptCookies
foreach ($cookie as $key => $value) {
if (is_string($value)) {
- $decrypted[$key] = $this->encrypter->decrypt($value);
+ $decrypted[$key] = $this->encrypter->decrypt($value, static::serialized($key));
}
}
@@ -128,7 +136,7 @@ class EncryptCookies
}
$response->headers->setCookie($this->duplicate(
- $cookie, $this->encrypter->encrypt($cookie->getValue())
+ $cookie, $this->encrypter->encrypt($cookie->getValue(), static::serialized($cookie->getName()))
));
}
@@ -138,15 +146,16 @@ class EncryptCookies
/**
* Duplicate a cookie with a new value.
*
- * @param \Symfony\Component\HttpFoundation\Cookie $c
+ * @param \Symfony\Component\HttpFoundation\Cookie $cookie
* @param mixed $value
* @return \Symfony\Component\HttpFoundation\Cookie
*/
- protected function duplicate(Cookie $c, $value)
+ protected function duplicate(Cookie $cookie, $value)
{
return new Cookie(
- $c->getName(), $value, $c->getExpiresTime(), $c->getPath(),
- $c->getDomain(), $c->isSecure(), $c->isHttpOnly()
+ $cookie->getName(), $value, $cookie->getExpiresTime(),
+ $cookie->getPath(), $cookie->getDomain(), $cookie->isSecure(),
+ $cookie->isHttpOnly(), $cookie->isRaw(), $cookie->getSameSite()
);
}
@@ -160,4 +169,15 @@ class EncryptCookies
{
return in_array($name, $this->except);
}
+
+ /**
+ * Determine if the cookie contents should be serialized.
+ *
+ * @param string $name
+ * @return bool
+ */
+ public static function serialized($name)
+ {
+ return static::$serialize;
+ }
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Cookie/composer.json b/pfosten/vendor/laravel/framework/src/Illuminate/Cookie/composer.json
index d412bad4..e6c6b9a9 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Cookie/composer.json
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Cookie/composer.json
@@ -14,11 +14,11 @@
}
],
"require": {
- "php": ">=5.6.4",
- "illuminate/contracts": "5.4.*",
- "illuminate/support": "5.4.*",
- "symfony/http-foundation": "~3.2",
- "symfony/http-kernel": "~3.2"
+ "php": "^7.1.3",
+ "illuminate/contracts": "5.8.*",
+ "illuminate/support": "5.8.*",
+ "symfony/http-foundation": "^4.2",
+ "symfony/http-kernel": "^4.2"
},
"autoload": {
"psr-4": {
@@ -27,7 +27,7 @@
},
"extra": {
"branch-alias": {
- "dev-master": "5.4-dev"
+ "dev-master": "5.8-dev"
}
},
"config": {
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Capsule/Manager.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Capsule/Manager.php
index b82a792c..11572432 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Capsule/Manager.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Capsule/Manager.php
@@ -66,7 +66,7 @@ class Manager
/**
* Get a connection instance from the global manager.
*
- * @param string $connection
+ * @param string|null $connection
* @return \Illuminate\Database\Connection
*/
public static function connection($connection = null)
@@ -78,7 +78,7 @@ class Manager
* Get a fluent query builder instance.
*
* @param string $table
- * @param string $connection
+ * @param string|null $connection
* @return \Illuminate\Database\Query\Builder
*/
public static function table($table, $connection = null)
@@ -89,7 +89,7 @@ class Manager
/**
* Get a schema builder instance.
*
- * @param string $connection
+ * @param string|null $connection
* @return \Illuminate\Database\Schema\Builder
*/
public static function schema($connection = null)
@@ -100,7 +100,7 @@ class Manager
/**
* Get a registered connection instance.
*
- * @param string $name
+ * @param string|null $name
* @return \Illuminate\Database\Connection
*/
public function getConnection($name = null)
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Concerns/BuildsQueries.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Concerns/BuildsQueries.php
index d1d1d2ef..f68ab43c 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Concerns/BuildsQueries.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Concerns/BuildsQueries.php
@@ -36,10 +36,12 @@ trait BuildsQueries
// 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.
- if ($callback($results) === false) {
+ if ($callback($results, $page) === false) {
return false;
}
+ unset($results);
+
$page++;
} while ($countResults == $count);
@@ -68,7 +70,7 @@ trait BuildsQueries
* Execute the query and get the first result.
*
* @param array $columns
- * @return \Illuminate\Database\Eloquent\Model|static|null
+ * @return \Illuminate\Database\Eloquent\Model|object|static|null
*/
public function first($columns = ['*'])
{
@@ -80,8 +82,8 @@ trait BuildsQueries
*
* @param mixed $value
* @param callable $callback
- * @param callable $default
- * @return mixed
+ * @param callable|null $default
+ * @return mixed|$this
*/
public function when($value, $callback, $default = null)
{
@@ -97,7 +99,7 @@ trait BuildsQueries
/**
* Pass the query to a given callback.
*
- * @param \Closure $callback
+ * @param callable $callback
* @return \Illuminate\Database\Query\Builder
*/
public function tap($callback)
@@ -110,8 +112,8 @@ trait BuildsQueries
*
* @param mixed $value
* @param callable $callback
- * @param callable $default
- * @return mixed
+ * @param callable|null $default
+ * @return mixed|$this
*/
public function unless($value, $callback, $default = null)
{
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Concerns/ManagesTransactions.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Concerns/ManagesTransactions.php
index 9b1dcd16..f8a3d661 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Concerns/ManagesTransactions.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Concerns/ManagesTransactions.php
@@ -26,7 +26,7 @@ trait ManagesTransactions
// catch any exception we can rollback this transaction so that none of this
// gets actually persisted to a database or stored in a permanent fashion.
try {
- return tap($callback($this), function ($result) {
+ return tap($callback($this), function () {
$this->commit();
});
}
@@ -63,7 +63,7 @@ trait ManagesTransactions
// let the developer handle it in another way. We will decrement too.
if ($this->causedByDeadlock($e) &&
$this->transactions > 1) {
- --$this->transactions;
+ $this->transactions--;
throw $e;
}
@@ -85,13 +85,14 @@ trait ManagesTransactions
* Start a new database transaction.
*
* @return void
+ *
* @throws \Exception
*/
public function beginTransaction()
{
$this->createTransaction();
- ++$this->transactions;
+ $this->transactions++;
$this->fireConnectionEvent('beganTransaction');
}
@@ -129,7 +130,7 @@ trait ManagesTransactions
/**
* Handle an exception from a transaction beginning.
*
- * @param \Exception $e
+ * @param \Throwable $e
* @return void
*
* @throws \Exception
@@ -166,6 +167,8 @@ trait ManagesTransactions
*
* @param int|null $toLevel
* @return void
+ *
+ * @throws \Exception
*/
public function rollBack($toLevel = null)
{
@@ -183,7 +186,11 @@ trait ManagesTransactions
// Next, we will actually perform this rollback within this database and fire the
// rollback event. We will also set the current transaction level to the given
// level that was passed into this method so it will be right from here out.
- $this->performRollBack($toLevel);
+ try {
+ $this->performRollBack($toLevel);
+ } catch (Exception $e) {
+ $this->handleRollBackException($e);
+ }
$this->transactions = $toLevel;
@@ -207,6 +214,22 @@ trait ManagesTransactions
}
}
+ /**
+ * Handle an exception from a rollback.
+ *
+ * @param \Exception $e
+ *
+ * @throws \Exception
+ */
+ protected function handleRollBackException($e)
+ {
+ if ($this->causedByLostConnection($e)) {
+ $this->transactions = 0;
+ }
+
+ throw $e;
+ }
+
/**
* Get the number of active transactions.
*
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Connection.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Connection.php
index 8c744eb7..9341a2fc 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Connection.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Connection.php
@@ -108,6 +108,13 @@ class Connection implements ConnectionInterface
*/
protected $transactions = 0;
+ /**
+ * Indicates if changes have been made to the database.
+ *
+ * @var int
+ */
+ protected $recordsModified = false;
+
/**
* All of the queries run against the connection.
*
@@ -446,6 +453,8 @@ class Connection implements ConnectionInterface
$this->bindValues($statement, $this->prepareBindings($bindings));
+ $this->recordsHaveBeenModified();
+
return $statement->execute();
});
}
@@ -473,7 +482,11 @@ class Connection implements ConnectionInterface
$statement->execute();
- return $statement->rowCount();
+ $this->recordsHaveBeenModified(
+ ($count = $statement->rowCount()) > 0
+ );
+
+ return $count;
});
}
@@ -490,7 +503,11 @@ class Connection implements ConnectionInterface
return true;
}
- return $this->getPdo()->exec($query) === false ? false : true;
+ $this->recordsHaveBeenModified(
+ $change = $this->getPdo()->exec($query) !== false
+ );
+
+ return $change;
});
}
@@ -535,7 +552,7 @@ class Connection implements ConnectionInterface
// Now we'll execute this callback and capture the result. Once it has been
// executed we will restore the value of query logging and give back the
- // value of hte callback so the original callers can have the results.
+ // value of the callback so the original callers can have the results.
$result = $callback();
$this->loggingQueries = $loggingQueries;
@@ -576,8 +593,8 @@ class Connection implements ConnectionInterface
// so we'll just ask the grammar for the format to get from the date.
if ($value instanceof DateTimeInterface) {
$bindings[$key] = $value->format($grammar->getDateFormat());
- } elseif ($value === false) {
- $bindings[$key] = 0;
+ } elseif (is_bool($value)) {
+ $bindings[$key] = (int) $value;
}
}
@@ -683,14 +700,15 @@ class Connection implements ConnectionInterface
/**
* Handle a query exception.
*
- * @param \Exception $e
+ * @param \Illuminate\Database\QueryException $e
* @param string $query
* @param array $bindings
* @param \Closure $callback
* @return mixed
- * @throws \Exception
+ *
+ * @throws \Illuminate\Database\QueryException
*/
- protected function handleQueryException($e, $query, $bindings, Closure $callback)
+ protected function handleQueryException(QueryException $e, $query, $bindings, Closure $callback)
{
if ($this->transactions >= 1) {
throw $e;
@@ -733,6 +751,8 @@ class Connection implements ConnectionInterface
public function reconnect()
{
if (is_callable($this->reconnector)) {
+ $this->doctrineConnection = null;
+
return call_user_func($this->reconnector, $this);
}
@@ -820,6 +840,19 @@ class Connection implements ConnectionInterface
return new Expression($value);
}
+ /**
+ * Indicate if any records have been modified.
+ *
+ * @param bool $value
+ * @return void
+ */
+ public function recordsHaveBeenModified($value = true)
+ {
+ if (! $this->recordsModified) {
+ $this->recordsModified = $value;
+ }
+ }
+
/**
* Is Doctrine available?
*
@@ -862,11 +895,14 @@ class Connection implements ConnectionInterface
public function getDoctrineConnection()
{
if (is_null($this->doctrineConnection)) {
- $data = ['pdo' => $this->getPdo(), 'dbname' => $this->getConfig('database')];
+ $driver = $this->getDoctrineDriver();
- $this->doctrineConnection = new DoctrineConnection(
- $data, $this->getDoctrineDriver()
- );
+ $this->doctrineConnection = new DoctrineConnection(array_filter([
+ 'pdo' => $this->getPdo(),
+ 'dbname' => $this->getConfig('database'),
+ 'driver' => $driver->getName(),
+ 'serverVersion' => $this->getConfig('server_version'),
+ ]), $driver);
}
return $this->doctrineConnection;
@@ -893,7 +929,11 @@ class Connection implements ConnectionInterface
*/
public function getReadPdo()
{
- if ($this->transactions >= 1) {
+ if ($this->transactions > 0) {
+ return $this->getPdo();
+ }
+
+ if ($this->recordsModified && $this->getConfig('sticky')) {
return $this->getPdo();
}
@@ -922,7 +962,7 @@ class Connection implements ConnectionInterface
/**
* Set the PDO connection used for reading.
*
- * @param \PDO||\Closure|null $pdo
+ * @param \PDO|\Closure|null $pdo
* @return $this
*/
public function setReadPdo($pdo)
@@ -990,11 +1030,13 @@ class Connection implements ConnectionInterface
* Set the query grammar used by the connection.
*
* @param \Illuminate\Database\Query\Grammars\Grammar $grammar
- * @return void
+ * @return $this
*/
public function setQueryGrammar(Query\Grammars\Grammar $grammar)
{
$this->queryGrammar = $grammar;
+
+ return $this;
}
/**
@@ -1011,11 +1053,13 @@ class Connection implements ConnectionInterface
* Set the schema grammar used by the connection.
*
* @param \Illuminate\Database\Schema\Grammars\Grammar $grammar
- * @return void
+ * @return $this
*/
public function setSchemaGrammar(Schema\Grammars\Grammar $grammar)
{
$this->schemaGrammar = $grammar;
+
+ return $this;
}
/**
@@ -1032,11 +1076,13 @@ class Connection implements ConnectionInterface
* Set the query post processor used by the connection.
*
* @param \Illuminate\Database\Query\Processors\Processor $processor
- * @return void
+ * @return $this
*/
public function setPostProcessor(Processor $processor)
{
$this->postProcessor = $processor;
+
+ return $this;
}
/**
@@ -1053,15 +1099,27 @@ class Connection implements ConnectionInterface
* Set the event dispatcher instance on the connection.
*
* @param \Illuminate\Contracts\Events\Dispatcher $events
- * @return void
+ * @return $this
*/
public function setEventDispatcher(Dispatcher $events)
{
$this->events = $events;
+
+ return $this;
}
/**
- * Determine if the connection in a "dry run".
+ * Unset the event dispatcher for this connection.
+ *
+ * @return void
+ */
+ public function unsetEventDispatcher()
+ {
+ $this->events = null;
+ }
+
+ /**
+ * Determine if the connection is in a "dry run".
*
* @return bool
*/
@@ -1134,11 +1192,13 @@ class Connection implements ConnectionInterface
* Set the name of the connected database.
*
* @param string $database
- * @return string
+ * @return $this
*/
public function setDatabaseName($database)
{
$this->database = $database;
+
+ return $this;
}
/**
@@ -1155,13 +1215,15 @@ class Connection implements ConnectionInterface
* Set the table prefix in use by the connection.
*
* @param string $prefix
- * @return void
+ * @return $this
*/
public function setTablePrefix($prefix)
{
$this->tablePrefix = $prefix;
$this->getQueryGrammar()->setTablePrefix($prefix);
+
+ return $this;
}
/**
@@ -1197,7 +1259,6 @@ class Connection implements ConnectionInterface
*/
public static function getResolver($driver)
{
- return isset(static::$resolvers[$driver]) ?
- static::$resolvers[$driver] : null;
+ return static::$resolvers[$driver] ?? null;
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/ConnectionInterface.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/ConnectionInterface.php
index 9262d6fd..56127e1c 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/ConnectionInterface.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/ConnectionInterface.php
@@ -27,18 +27,30 @@ interface ConnectionInterface
*
* @param string $query
* @param array $bindings
+ * @param bool $useReadPdo
* @return mixed
*/
- public function selectOne($query, $bindings = []);
+ public function selectOne($query, $bindings = [], $useReadPdo = true);
/**
* Run a select statement against the database.
*
* @param string $query
* @param array $bindings
+ * @param bool $useReadPdo
* @return array
*/
- public function select($query, $bindings = []);
+ public function select($query, $bindings = [], $useReadPdo = true);
+
+ /**
+ * Run a select statement against the database and returns a generator.
+ *
+ * @param string $query
+ * @param array $bindings
+ * @param bool $useReadPdo
+ * @return \Generator
+ */
+ public function cursor($query, $bindings = [], $useReadPdo = true);
/**
* Run an insert statement against the database.
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/ConnectionResolver.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/ConnectionResolver.php
index 425ab6bc..ebfc15c9 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/ConnectionResolver.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/ConnectionResolver.php
@@ -34,7 +34,7 @@ class ConnectionResolver implements ConnectionResolverInterface
/**
* Get a database connection instance.
*
- * @param string $name
+ * @param string|null $name
* @return \Illuminate\Database\ConnectionInterface
*/
public function connection($name = null)
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/ConnectionResolverInterface.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/ConnectionResolverInterface.php
index eb0397a5..b31e5a79 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/ConnectionResolverInterface.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/ConnectionResolverInterface.php
@@ -7,7 +7,7 @@ interface ConnectionResolverInterface
/**
* Get a database connection instance.
*
- * @param string $name
+ * @param string|null $name
* @return \Illuminate\Database\ConnectionInterface
*/
public function connection($name = null);
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Connectors/ConnectionFactory.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Connectors/ConnectionFactory.php
index 98fb7018..4153196c 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Connectors/ConnectionFactory.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Connectors/ConnectionFactory.php
@@ -11,7 +11,6 @@ use Illuminate\Database\SQLiteConnection;
use Illuminate\Database\PostgresConnection;
use Illuminate\Database\SqlServerConnection;
use Illuminate\Contracts\Container\Container;
-use Illuminate\Contracts\Debug\ExceptionHandler;
class ConnectionFactory
{
@@ -37,7 +36,7 @@ class ConnectionFactory
* Establish a PDO connection based on the configuration.
*
* @param array $config
- * @param string $name
+ * @param string|null $name
* @return \Illuminate\Database\Connection
*/
public function make(array $config, $name = null)
@@ -182,9 +181,7 @@ class ConnectionFactory
try {
return $this->createConnector($config)->connect($config);
} catch (PDOException $e) {
- if (count($hosts) - 1 === $key && $this->container->bound(ExceptionHandler::class)) {
- $this->container->make(ExceptionHandler::class)->report($e);
- }
+ continue;
}
}
@@ -200,7 +197,7 @@ class ConnectionFactory
*/
protected function parseHosts(array $config)
{
- $hosts = array_wrap($config['host']);
+ $hosts = Arr::wrap($config['host']);
if (empty($hosts)) {
throw new InvalidArgumentException('Database hosts array is empty.');
@@ -283,6 +280,6 @@ class ConnectionFactory
return new SqlServerConnection($connection, $database, $prefix, $config);
}
- throw new InvalidArgumentException("Unsupported driver [$driver]");
+ throw new InvalidArgumentException("Unsupported driver [{$driver}]");
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php
index a56fe95a..ab0903d9 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php
@@ -4,7 +4,7 @@ namespace Illuminate\Database\Connectors;
use PDO;
use Exception;
-use Illuminate\Support\Arr;
+use Throwable;
use Doctrine\DBAL\Driver\PDOConnection;
use Illuminate\Database\DetectsLostConnections;
@@ -32,11 +32,13 @@ class Connector
* @param array $config
* @param array $options
* @return \PDO
+ *
+ * @throws \Exception
*/
public function createConnection($dsn, array $config, array $options)
{
- list($username, $password) = [
- Arr::get($config, 'username'), Arr::get($config, 'password'),
+ [$username, $password] = [
+ $config['username'] ?? null, $config['password'] ?? null,
];
try {
@@ -83,7 +85,7 @@ class Connector
/**
* Handle an exception that occurred during connect execution.
*
- * @param \Exception $e
+ * @param \Throwable $e
* @param string $dsn
* @param string $username
* @param string $password
@@ -92,7 +94,7 @@ class Connector
*
* @throws \Exception
*/
- protected function tryAgainIfCausedByLostConnection(Exception $e, $dsn, $username, $password, $options)
+ protected function tryAgainIfCausedByLostConnection(Throwable $e, $dsn, $username, $password, $options)
{
if ($this->causedByLostConnection($e)) {
return $this->createPdoConnection($dsn, $username, $password, $options);
@@ -109,7 +111,7 @@ class Connector
*/
public function getOptions(array $config)
{
- $options = Arr::get($config, 'options', []);
+ $options = $config['options'] ?? [];
return array_diff_key($this->options, $options) + $options;
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Connectors/MySqlConnector.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Connectors/MySqlConnector.php
index 3b12b300..9665172e 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Connectors/MySqlConnector.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Connectors/MySqlConnector.php
@@ -147,7 +147,7 @@ class MySqlConnector extends Connector implements ConnectorInterface
$this->setCustomModes($connection, $config);
} elseif (isset($config['strict'])) {
if ($config['strict']) {
- $connection->prepare($this->strictMode())->execute();
+ $connection->prepare($this->strictMode($connection))->execute();
} else {
$connection->prepare("set session sql_mode='NO_ENGINE_SUBSTITUTION'")->execute();
}
@@ -171,10 +171,15 @@ class MySqlConnector extends Connector implements ConnectorInterface
/**
* Get the query to enable strict mode.
*
+ * @param \PDO $connection
* @return string
*/
- protected function strictMode()
+ protected function strictMode(PDO $connection)
{
+ if (version_compare($connection->getAttribute(PDO::ATTR_SERVER_VERSION), '8.0.11') >= 0) {
+ return "set session sql_mode='ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION'";
+ }
+
return "set session sql_mode='ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'";
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Connectors/PostgresConnector.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Connectors/PostgresConnector.php
index 0581b8b2..c80fea63 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Connectors/PostgresConnector.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Connectors/PostgresConnector.php
@@ -59,9 +59,11 @@ class PostgresConnector extends Connector implements ConnectorInterface
*/
protected function configureEncoding($connection, $config)
{
- $charset = $config['charset'];
+ if (! isset($config['charset'])) {
+ return;
+ }
- $connection->prepare("set names '$charset'")->execute();
+ $connection->prepare("set names '{$config['charset']}'")->execute();
}
/**
@@ -106,9 +108,9 @@ class PostgresConnector extends Connector implements ConnectorInterface
{
if (is_array($schema)) {
return '"'.implode('", "', $schema).'"';
- } else {
- return '"'.$schema.'"';
}
+
+ return '"'.$schema.'"';
}
/**
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Connectors/SQLiteConnector.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Connectors/SQLiteConnector.php
index 28f90915..90dc16be 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Connectors/SQLiteConnector.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Connectors/SQLiteConnector.php
@@ -21,7 +21,7 @@ class SQLiteConnector extends Connector implements ConnectorInterface
// 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:') {
+ if ($config['database'] === ':memory:') {
return $this->createConnection('sqlite::memory:', $config, $options);
}
@@ -31,7 +31,7 @@ class SQLiteConnector extends Connector implements ConnectorInterface
// 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 (${config['database']}) does not exist.");
+ throw new InvalidArgumentException("Database ({$config['database']}) does not exist.");
}
return $this->createConnection("sqlite:{$path}", $config, $options);
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Connectors/SqlServerConnector.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Connectors/SqlServerConnector.php
index 02883d5b..6d6ac2d0 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Connectors/SqlServerConnector.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Connectors/SqlServerConnector.php
@@ -43,12 +43,14 @@ class SqlServerConnector extends Connector implements ConnectorInterface
// 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);
- } elseif ($this->prefersOdbc($config)) {
+ if ($this->prefersOdbc($config)) {
return $this->getOdbcDsn($config);
- } else {
+ }
+
+ if (in_array('sqlsrv', $this->getAvailableDrivers())) {
return $this->getSqlSrvDsn($config);
+ } else {
+ return $this->getDblibDsn($config);
}
}
@@ -61,7 +63,7 @@ class SqlServerConnector extends Connector implements ConnectorInterface
protected function prefersOdbc(array $config)
{
return in_array('odbc', $this->getAvailableDrivers()) &&
- array_get($config, 'odbc') === true;
+ ($config['odbc'] ?? null) === true;
}
/**
@@ -75,7 +77,7 @@ class SqlServerConnector extends Connector implements ConnectorInterface
return $this->buildConnectString('dblib', array_merge([
'host' => $this->buildHostString($config, ':'),
'dbname' => $config['database'],
- ], Arr::only($config, ['appname', 'charset'])));
+ ], Arr::only($config, ['appname', 'charset', 'version'])));
}
/**
@@ -130,6 +132,14 @@ class SqlServerConnector extends Connector implements ConnectorInterface
$arguments['MultipleActiveResultSets'] = 'false';
}
+ if (isset($config['transaction_isolation'])) {
+ $arguments['TransactionIsolation'] = $config['transaction_isolation'];
+ }
+
+ if (isset($config['multi_subnet_failover'])) {
+ $arguments['MultiSubnetFailover'] = $config['multi_subnet_failover'];
+ }
+
return $this->buildConnectString('sqlsrv', $arguments);
}
@@ -156,11 +166,11 @@ class SqlServerConnector extends Connector implements ConnectorInterface
*/
protected function buildHostString(array $config, $separator)
{
- if (isset($config['port']) && ! empty($config['port'])) {
- return $config['host'].$separator.$config['port'];
- } else {
+ if (empty($config['port'])) {
return $config['host'];
}
+
+ return $config['host'].$separator.$config['port'];
}
/**
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/BaseCommand.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/BaseCommand.php
index 81ca3cc7..6c4f2550 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/BaseCommand.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/BaseCommand.php
@@ -18,15 +18,27 @@ class BaseCommand extends Command
// migrations may be run for any customized path from within the application.
if ($this->input->hasOption('path') && $this->option('path')) {
return collect($this->option('path'))->map(function ($path) {
- return $this->laravel->basePath().'/'.$path;
+ return ! $this->usingRealPath()
+ ? $this->laravel->basePath().'/'.$path
+ : $path;
})->all();
}
return array_merge(
- [$this->getMigrationPath()], $this->migrator->paths()
+ $this->migrator->paths(), [$this->getMigrationPath()]
);
}
+ /**
+ * Determine if the given path(s) are pre-resolved "real" paths.
+ *
+ * @return bool
+ */
+ protected function usingRealPath()
+ {
+ return $this->input->hasOption('realpath') && $this->option('realpath');
+ }
+
/**
* Get the path to the migration directory.
*
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/InstallCommand.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/InstallCommand.php
index 103dcaa9..354d7a1c 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/InstallCommand.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/InstallCommand.php
@@ -47,7 +47,7 @@ class InstallCommand extends Command
*
* @return void
*/
- public function fire()
+ public function handle()
{
$this->repository->setSource($this->input->getOption('database'));
@@ -64,7 +64,7 @@ class InstallCommand extends Command
protected function getOptions()
{
return [
- ['database', null, InputOption::VALUE_OPTIONAL, 'The database connection to use.'],
+ ['database', null, InputOption::VALUE_OPTIONAL, 'The database connection to use'],
];
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/MigrateCommand.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/MigrateCommand.php
index 092a7d24..9fa978d0 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/MigrateCommand.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/MigrateCommand.php
@@ -14,12 +14,13 @@ class MigrateCommand extends BaseCommand
*
* @var string
*/
- protected $signature = 'migrate {--database= : The database connection to use.}
- {--force : Force the operation to run when in production.}
- {--path= : The path of migrations files to be executed.}
- {--pretend : Dump the SQL queries that would be run.}
- {--seed : Indicates if the seed task should be re-run.}
- {--step : Force the migrations to be run so they can be rolled back individually.}';
+ protected $signature = 'migrate {--database= : The database connection to use}
+ {--force : Force the operation to run when in production}
+ {--path=* : The path(s) to the migrations files to be executed}
+ {--realpath : Indicate any provided migration file paths are pre-resolved absolute paths}
+ {--pretend : Dump the SQL queries that would be run}
+ {--seed : Indicates if the seed task should be re-run}
+ {--step : Force the migrations to be run so they can be rolled back individually}';
/**
* The console command description.
@@ -53,7 +54,7 @@ class MigrateCommand extends BaseCommand
*
* @return void
*/
- public function fire()
+ public function handle()
{
if (! $this->confirmToProceed()) {
return;
@@ -64,22 +65,16 @@ class MigrateCommand extends BaseCommand
// 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.
- $this->migrator->run($this->getMigrationPaths(), [
- 'pretend' => $this->option('pretend'),
- 'step' => $this->option('step'),
- ]);
-
- // 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);
- }
+ $this->migrator->setOutput($this->output)
+ ->run($this->getMigrationPaths(), [
+ 'pretend' => $this->option('pretend'),
+ 'step' => $this->option('step'),
+ ]);
// 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->option('seed')) {
+ if ($this->option('seed') && ! $this->option('pretend')) {
$this->call('db:seed', ['--force' => true]);
}
}
@@ -94,9 +89,9 @@ class MigrateCommand extends BaseCommand
$this->migrator->setConnection($this->option('database'));
if (! $this->migrator->repositoryExists()) {
- $this->call(
- 'migrate:install', ['--database' => $this->option('database')]
- );
+ $this->call('migrate:install', array_filter([
+ '--database' => $this->option('database'),
+ ]));
}
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/MigrateMakeCommand.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/MigrateMakeCommand.php
index fa2024af..c41986d9 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/MigrateMakeCommand.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/MigrateMakeCommand.php
@@ -2,6 +2,7 @@
namespace Illuminate\Database\Console\Migrations;
+use Illuminate\Support\Str;
use Illuminate\Support\Composer;
use Illuminate\Database\Migrations\MigrationCreator;
@@ -12,10 +13,12 @@ class MigrateMakeCommand extends BaseCommand
*
* @var string
*/
- protected $signature = 'make:migration {name : The name of the migration.}
- {--create= : The table to be created.}
- {--table= : The table to migrate.}
- {--path= : The location where the migration file should be created.}';
+ protected $signature = 'make:migration {name : The name of the migration}
+ {--create= : The table to be created}
+ {--table= : The table to migrate}
+ {--path= : The location where the migration file should be created}
+ {--realpath : Indicate any provided migration file paths are pre-resolved absolute paths}
+ {--fullpath : Output the full path of the migration}';
/**
* The console command description.
@@ -58,12 +61,12 @@ class MigrateMakeCommand extends BaseCommand
*
* @return void
*/
- public function fire()
+ public function handle()
{
// 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 = trim($this->input->getArgument('name'));
+ $name = Str::snake(trim($this->input->getArgument('name')));
$table = $this->input->getOption('table');
@@ -78,6 +81,13 @@ class MigrateMakeCommand extends BaseCommand
$create = true;
}
+ // Next, we will attempt to guess the table name if this the migration has
+ // "create" in the name. This will allow us to provide a convenient way
+ // of creating migrations that create new tables for the application.
+ if (! $table) {
+ [$table, $create] = TableGuesser::guess($name);
+ }
+
// 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.
@@ -96,9 +106,13 @@ class MigrateMakeCommand extends BaseCommand
*/
protected function writeMigration($name, $table, $create)
{
- $file = pathinfo($this->creator->create(
+ $file = $this->creator->create(
$name, $this->getMigrationPath(), $table, $create
- ), PATHINFO_FILENAME);
+ );
+
+ if (! $this->option('fullpath')) {
+ $file = pathinfo($file, PATHINFO_FILENAME);
+ }
$this->line("
Created Migration: {$file}");
}
@@ -111,9 +125,21 @@ class MigrateMakeCommand extends BaseCommand
protected function getMigrationPath()
{
if (! is_null($targetPath = $this->input->getOption('path'))) {
- return $this->laravel->basePath().'/'.$targetPath;
+ return ! $this->usingRealPath()
+ ? $this->laravel->basePath().'/'.$targetPath
+ : $targetPath;
}
return parent::getMigrationPath();
}
+
+ /**
+ * Determine if the given path(s) are pre-resolved "real" paths.
+ *
+ * @return bool
+ */
+ protected function usingRealPath()
+ {
+ return $this->input->hasOption('realpath') && $this->option('realpath');
+ }
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/RefreshCommand.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/RefreshCommand.php
index 4d2772b9..d27bb155 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/RefreshCommand.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/RefreshCommand.php
@@ -29,7 +29,7 @@ class RefreshCommand extends Command
*
* @return void
*/
- public function fire()
+ public function handle()
{
if (! $this->confirmToProceed()) {
return;
@@ -42,27 +42,26 @@ class RefreshCommand extends Command
$path = $this->input->getOption('path');
- $force = $this->input->getOption('force');
-
// If the "step" option is specified it means we only want to rollback a small
// number of migrations before migrating again. For example, the user might
// only rollback and remigrate the latest four migrations instead of all.
$step = $this->input->getOption('step') ?: 0;
if ($step > 0) {
- $this->runRollback($database, $path, $step, $force);
+ $this->runRollback($database, $path, $step);
} else {
- $this->runReset($database, $path, $force);
+ $this->runReset($database, $path);
}
// 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', [
+ $this->call('migrate', array_filter([
'--database' => $database,
'--path' => $path,
- '--force' => $force,
- ]);
+ '--realpath' => $this->input->getOption('realpath'),
+ '--force' => true,
+ ]));
if ($this->needsSeeding()) {
$this->runSeeder($database);
@@ -74,18 +73,18 @@ class RefreshCommand extends Command
*
* @param string $database
* @param string $path
- * @param bool $step
- * @param bool $force
+ * @param int $step
* @return void
*/
- protected function runRollback($database, $path, $step, $force)
+ protected function runRollback($database, $path, $step)
{
- $this->call('migrate:rollback', [
+ $this->call('migrate:rollback', array_filter([
'--database' => $database,
'--path' => $path,
+ '--realpath' => $this->input->getOption('realpath'),
'--step' => $step,
- '--force' => $force,
- ]);
+ '--force' => true,
+ ]));
}
/**
@@ -93,16 +92,16 @@ class RefreshCommand extends Command
*
* @param string $database
* @param string $path
- * @param bool $force
* @return void
*/
- protected function runReset($database, $path, $force)
+ protected function runReset($database, $path)
{
- $this->call('migrate:reset', [
+ $this->call('migrate:reset', array_filter([
'--database' => $database,
'--path' => $path,
- '--force' => $force,
- ]);
+ '--realpath' => $this->input->getOption('realpath'),
+ '--force' => true,
+ ]));
}
/**
@@ -123,11 +122,11 @@ class RefreshCommand extends Command
*/
protected function runSeeder($database)
{
- $this->call('db:seed', [
+ $this->call('db:seed', array_filter([
'--database' => $database,
'--class' => $this->option('seeder') ?: 'DatabaseSeeder',
- '--force' => $this->option('force'),
- ]);
+ '--force' => true,
+ ]));
}
/**
@@ -138,17 +137,19 @@ class RefreshCommand extends Command
protected function getOptions()
{
return [
- ['database', null, InputOption::VALUE_OPTIONAL, 'The database connection to use.'],
+ ['database', null, InputOption::VALUE_OPTIONAL, 'The database connection to use'],
- ['force', null, InputOption::VALUE_NONE, 'Force the operation to run when in production.'],
+ ['force', null, InputOption::VALUE_NONE, 'Force the operation to run when in production'],
- ['path', null, InputOption::VALUE_OPTIONAL, 'The path of migrations files to be executed.'],
+ ['path', null, InputOption::VALUE_OPTIONAL, 'The path to the migrations files to be executed'],
- ['seed', null, InputOption::VALUE_NONE, 'Indicates if the seed task should be re-run.'],
+ ['realpath', null, InputOption::VALUE_NONE, 'Indicate any provided migration file paths are pre-resolved absolute paths'],
- ['seeder', null, InputOption::VALUE_OPTIONAL, 'The class name of the root seeder.'],
+ ['seed', null, InputOption::VALUE_NONE, 'Indicates if the seed task should be re-run'],
- ['step', null, InputOption::VALUE_OPTIONAL, 'The number of migrations to be reverted & re-run.'],
+ ['seeder', null, InputOption::VALUE_OPTIONAL, 'The class name of the root seeder'],
+
+ ['step', null, InputOption::VALUE_OPTIONAL, 'The number of migrations to be reverted & re-run'],
];
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/ResetCommand.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/ResetCommand.php
index 3b8dab3e..28803806 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/ResetCommand.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/ResetCommand.php
@@ -49,7 +49,7 @@ class ResetCommand extends BaseCommand
*
* @return void
*/
- public function fire()
+ public function handle()
{
if (! $this->confirmToProceed()) {
return;
@@ -64,16 +64,9 @@ class ResetCommand extends BaseCommand
return $this->comment('Migration table not found.');
}
- $this->migrator->reset(
+ $this->migrator->setOutput($this->output)->reset(
$this->getMigrationPaths(), $this->option('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);
- }
}
/**
@@ -84,13 +77,15 @@ class ResetCommand extends BaseCommand
protected function getOptions()
{
return [
- ['database', null, InputOption::VALUE_OPTIONAL, 'The database connection to use.'],
+ ['database', null, InputOption::VALUE_OPTIONAL, 'The database connection to use'],
- ['force', null, InputOption::VALUE_NONE, 'Force the operation to run when in production.'],
+ ['force', null, InputOption::VALUE_NONE, 'Force the operation to run when in production'],
- ['path', null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, 'The path(s) of migrations files to be executed.'],
+ ['path', null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, 'The path(s) to the migrations files to be executed'],
- ['pretend', null, InputOption::VALUE_NONE, 'Dump the SQL queries that would be run.'],
+ ['realpath', null, InputOption::VALUE_NONE, 'Indicate any provided migration file paths are pre-resolved absolute paths'],
+
+ ['pretend', null, InputOption::VALUE_NONE, 'Dump the SQL queries that would be run'],
];
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/RollbackCommand.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/RollbackCommand.php
index 4b1a75fa..65a50eb0 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/RollbackCommand.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/RollbackCommand.php
@@ -49,7 +49,7 @@ class RollbackCommand extends BaseCommand
*
* @return void
*/
- public function fire()
+ public function handle()
{
if (! $this->confirmToProceed()) {
return;
@@ -57,19 +57,12 @@ class RollbackCommand extends BaseCommand
$this->migrator->setConnection($this->option('database'));
- $this->migrator->rollback(
+ $this->migrator->setOutput($this->output)->rollback(
$this->getMigrationPaths(), [
'pretend' => $this->option('pretend'),
'step' => (int) $this->option('step'),
]
);
-
- // 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);
- }
}
/**
@@ -80,15 +73,17 @@ class RollbackCommand extends BaseCommand
protected function getOptions()
{
return [
- ['database', null, InputOption::VALUE_OPTIONAL, 'The database connection to use.'],
+ ['database', null, InputOption::VALUE_OPTIONAL, 'The database connection to use'],
- ['force', null, InputOption::VALUE_NONE, 'Force the operation to run when in production.'],
+ ['force', null, InputOption::VALUE_NONE, 'Force the operation to run when in production'],
- ['path', null, InputOption::VALUE_OPTIONAL, 'The path of migrations files to be executed.'],
+ ['path', null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, 'The path(s) to the migrations files to be executed'],
- ['pretend', null, InputOption::VALUE_NONE, 'Dump the SQL queries that would be run.'],
+ ['realpath', null, InputOption::VALUE_NONE, 'Indicate any provided migration file paths are pre-resolved absolute paths'],
- ['step', null, InputOption::VALUE_OPTIONAL, 'The number of migrations to be reverted.'],
+ ['pretend', null, InputOption::VALUE_NONE, 'Dump the SQL queries that would be run'],
+
+ ['step', null, InputOption::VALUE_OPTIONAL, 'The number of migrations to be reverted'],
];
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/StatusCommand.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/StatusCommand.php
index 34b98f27..0040fe51 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/StatusCommand.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/StatusCommand.php
@@ -33,7 +33,7 @@ class StatusCommand extends BaseCommand
* Create a new migration rollback command instance.
*
* @param \Illuminate\Database\Migrations\Migrator $migrator
- * @return \Illuminate\Database\Console\Migrations\StatusCommand
+ * @return void
*/
public function __construct(Migrator $migrator)
{
@@ -47,18 +47,20 @@ class StatusCommand extends BaseCommand
*
* @return void
*/
- public function fire()
+ public function handle()
{
$this->migrator->setConnection($this->option('database'));
if (! $this->migrator->repositoryExists()) {
- return $this->error('No migrations found.');
+ return $this->error('Migration table not found.');
}
$ran = $this->migrator->getRepository()->getRan();
- if (count($migrations = $this->getStatusFor($ran)) > 0) {
- $this->table(['Ran?', 'Migration'], $migrations);
+ $batches = $this->migrator->getRepository()->getMigrationBatches();
+
+ if (count($migrations = $this->getStatusFor($ran, $batches)) > 0) {
+ $this->table(['Ran?', 'Migration', 'Batch'], $migrations);
} else {
$this->error('No migrations found');
}
@@ -68,17 +70,18 @@ class StatusCommand extends BaseCommand
* Get the status for the given ran migrations.
*
* @param array $ran
+ * @param array $batches
* @return \Illuminate\Support\Collection
*/
- protected function getStatusFor(array $ran)
+ protected function getStatusFor(array $ran, array $batches)
{
return Collection::make($this->getAllMigrationFiles())
- ->map(function ($migration) use ($ran) {
+ ->map(function ($migration) use ($ran, $batches) {
$migrationName = $this->migrator->getMigrationName($migration);
return in_array($migrationName, $ran)
- ? ['
Y', $migrationName]
- : ['
N', $migrationName];
+ ? ['
Yes', $migrationName, $batches[$migrationName]]
+ : ['
No', $migrationName];
});
}
@@ -100,9 +103,11 @@ class StatusCommand extends BaseCommand
protected function getOptions()
{
return [
- ['database', null, InputOption::VALUE_OPTIONAL, 'The database connection to use.'],
+ ['database', null, InputOption::VALUE_OPTIONAL, 'The database connection to use'],
- ['path', null, InputOption::VALUE_OPTIONAL, 'The path of migrations files to use.'],
+ ['path', null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, 'The path(s) to the migrations files to use'],
+
+ ['realpath', null, InputOption::VALUE_NONE, 'Indicate any provided migration file paths are pre-resolved absolute paths'],
];
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Console/Seeds/SeedCommand.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Console/Seeds/SeedCommand.php
index cf866e04..06a13e0c 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Console/Seeds/SeedCommand.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Console/Seeds/SeedCommand.php
@@ -51,7 +51,7 @@ class SeedCommand extends Command
*
* @return void
*/
- public function fire()
+ public function handle()
{
if (! $this->confirmToProceed()) {
return;
@@ -62,6 +62,8 @@ class SeedCommand extends Command
Model::unguarded(function () {
$this->getSeeder()->__invoke();
});
+
+ $this->info('Database seeding completed successfully.');
}
/**
@@ -100,7 +102,7 @@ class SeedCommand extends Command
['database', null, InputOption::VALUE_OPTIONAL, 'The database connection to seed'],
- ['force', null, InputOption::VALUE_NONE, 'Force the operation to run when in production.'],
+ ['force', null, InputOption::VALUE_NONE, 'Force the operation to run when in production'],
];
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Console/Seeds/SeederMakeCommand.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Console/Seeds/SeederMakeCommand.php
index 89b79312..6e85e3e4 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Console/Seeds/SeederMakeCommand.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Console/Seeds/SeederMakeCommand.php
@@ -55,9 +55,9 @@ class SeederMakeCommand extends GeneratorCommand
*
* @return void
*/
- public function fire()
+ public function handle()
{
- parent::fire();
+ parent::handle();
$this->composer->dumpAutoloads();
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/DatabaseManager.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/DatabaseManager.php
index d60b23a1..c95b5835 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/DatabaseManager.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/DatabaseManager.php
@@ -6,6 +6,7 @@ use PDO;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
use InvalidArgumentException;
+use Illuminate\Support\ConfigurationUrlParser;
use Illuminate\Database\Connectors\ConnectionFactory;
/**
@@ -16,7 +17,7 @@ class DatabaseManager implements ConnectionResolverInterface
/**
* The application instance.
*
- * @var \Illuminate\Foundation\Application
+ * @var \Illuminate\Contracts\Foundation\Application
*/
protected $app;
@@ -41,10 +42,17 @@ class DatabaseManager implements ConnectionResolverInterface
*/
protected $extensions = [];
+ /**
+ * The callback to be executed to reconnect to a database.
+ *
+ * @var callable
+ */
+ protected $reconnector;
+
/**
* Create a new database manager instance.
*
- * @param \Illuminate\Foundation\Application $app
+ * @param \Illuminate\Contracts\Foundation\Application $app
* @param \Illuminate\Database\Connectors\ConnectionFactory $factory
* @return void
*/
@@ -52,17 +60,21 @@ class DatabaseManager implements ConnectionResolverInterface
{
$this->app = $app;
$this->factory = $factory;
+
+ $this->reconnector = function ($connection) {
+ $this->reconnect($connection->getName());
+ };
}
/**
* Get a database connection instance.
*
- * @param string $name
+ * @param string|null $name
* @return \Illuminate\Database\Connection
*/
public function connection($name = null)
{
- list($database, $type) = $this->parseConnectionName($name);
+ [$database, $type] = $this->parseConnectionName($name);
$name = $name ?: $database;
@@ -71,7 +83,7 @@ class DatabaseManager implements ConnectionResolverInterface
// set the "fetch mode" for PDO which determines the query return types.
if (! isset($this->connections[$name])) {
$this->connections[$name] = $this->configure(
- $connection = $this->makeConnection($database), $type
+ $this->makeConnection($database), $type
);
}
@@ -137,10 +149,11 @@ class DatabaseManager implements ConnectionResolverInterface
$connections = $this->app['config']['database.connections'];
if (is_null($config = Arr::get($connections, $name))) {
- throw new InvalidArgumentException("Database [$name] not configured.");
+ throw new InvalidArgumentException("Database [{$name}] not configured.");
}
- return $config;
+ return (new ConfigurationUrlParser)
+ ->parseConfiguration($config);
}
/**
@@ -164,9 +177,7 @@ class DatabaseManager implements ConnectionResolverInterface
// 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());
- });
+ $connection->setReconnector($this->reconnector);
return $connection;
}
@@ -175,14 +186,14 @@ class DatabaseManager implements ConnectionResolverInterface
* Prepare the read / write mode for database connection instance.
*
* @param \Illuminate\Database\Connection $connection
- * @param string $type
+ * @param string|null $type
* @return \Illuminate\Database\Connection
*/
protected function setPdoForType(Connection $connection, $type = null)
{
- if ($type == 'read') {
+ if ($type === 'read') {
$connection->setPdo($connection->getReadPdo());
- } elseif ($type == 'write') {
+ } elseif ($type === 'write') {
$connection->setReadPdo($connection->getPdo());
}
@@ -192,7 +203,7 @@ class DatabaseManager implements ConnectionResolverInterface
/**
* Disconnect from the given database and remove from local cache.
*
- * @param string $name
+ * @param string|null $name
* @return void
*/
public function purge($name = null)
@@ -207,7 +218,7 @@ class DatabaseManager implements ConnectionResolverInterface
/**
* Disconnect from the given database.
*
- * @param string $name
+ * @param string|null $name
* @return void
*/
public function disconnect($name = null)
@@ -220,7 +231,7 @@ class DatabaseManager implements ConnectionResolverInterface
/**
* Reconnect to the given database.
*
- * @param string $name
+ * @param string|null $name
* @return \Illuminate\Database\Connection
*/
public function reconnect($name = null)
@@ -315,6 +326,17 @@ class DatabaseManager implements ConnectionResolverInterface
return $this->connections;
}
+ /**
+ * Set the database reconnector callback.
+ *
+ * @param callable $reconnector
+ * @return void
+ */
+ public function setReconnector(callable $reconnector)
+ {
+ $this->reconnector = $reconnector;
+ }
+
/**
* Dynamically pass methods to the default connection.
*
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/DetectsDeadlocks.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/DetectsDeadlocks.php
index ee034b60..a8193eeb 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/DetectsDeadlocks.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/DetectsDeadlocks.php
@@ -26,6 +26,7 @@ trait DetectsDeadlocks
'A table in the database is locked',
'has been chosen as the deadlock victim',
'Lock wait timeout exceeded; try restarting transaction',
+ 'WSREP detected deadlock/conflict and aborted the transaction. Try restarting the transaction',
]);
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/DetectsLostConnections.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/DetectsLostConnections.php
index 034fbe64..7a69bec0 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/DetectsLostConnections.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/DetectsLostConnections.php
@@ -2,7 +2,7 @@
namespace Illuminate\Database;
-use Exception;
+use Throwable;
use Illuminate\Support\Str;
trait DetectsLostConnections
@@ -10,10 +10,10 @@ trait DetectsLostConnections
/**
* Determine if the given exception was caused by a lost connection.
*
- * @param \Exception $e
+ * @param \Throwable $e
* @return bool
*/
- protected function causedByLostConnection(Exception $e)
+ protected function causedByLostConnection(Throwable $e)
{
$message = $e->getMessage();
@@ -29,6 +29,15 @@ trait DetectsLostConnections
'Error writing data to the connection',
'Resource deadlock avoided',
'Transaction() on null',
+ 'child connection forced to terminate due to client_idle_limit',
+ 'query_wait_timeout',
+ 'reset by peer',
+ 'Physical connection is not usable',
+ 'TCP Provider: Error code 0x68',
+ 'ORA-03114',
+ 'Packets out of order. Expected',
+ 'Adaptive Server connection failed',
+ 'Communication link failure',
]);
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php
index 9582fe02..051b5aa2 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php
@@ -3,21 +3,25 @@
namespace Illuminate\Database\Eloquent;
use Closure;
+use Exception;
use BadMethodCallException;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
use Illuminate\Pagination\Paginator;
use Illuminate\Contracts\Support\Arrayable;
+use Illuminate\Support\Traits\ForwardsCalls;
use Illuminate\Database\Concerns\BuildsQueries;
use Illuminate\Database\Eloquent\Relations\Relation;
use Illuminate\Database\Query\Builder as QueryBuilder;
/**
+ * @property-read HigherOrderBuilderProxy $orWhere
+ *
* @mixin \Illuminate\Database\Query\Builder
*/
class Builder
{
- use BuildsQueries, Concerns\QueriesRelationships;
+ use BuildsQueries, Concerns\QueriesRelationships, ForwardsCalls;
/**
* The base query builder instance.
@@ -67,8 +71,8 @@ class Builder
* @var array
*/
protected $passthru = [
- 'insert', 'insertGetId', 'getBindings', 'toSql',
- 'exists', 'count', 'min', 'max', 'avg', 'sum', 'getConnection',
+ 'insert', 'insertOrIgnore', 'insertGetId', 'insertUsing', 'getBindings', 'toSql', 'dump', 'dd',
+ 'exists', 'doesntExist', 'count', 'min', 'max', 'avg', 'average', 'sum', 'getConnection',
];
/**
@@ -152,12 +156,12 @@ class Builder
*/
public function withoutGlobalScopes(array $scopes = null)
{
- if (is_array($scopes)) {
- foreach ($scopes as $scope) {
- $this->withoutGlobalScope($scope);
- }
- } else {
- $this->scopes = [];
+ if (! is_array($scopes)) {
+ $scopes = array_keys($this->scopes);
+ }
+
+ foreach ($scopes as $scope) {
+ $this->withoutGlobalScope($scope);
}
return $this;
@@ -190,21 +194,36 @@ class Builder
return $this->where($this->model->getQualifiedKeyName(), '=', $id);
}
+ /**
+ * Add a where clause on the primary key to the query.
+ *
+ * @param mixed $id
+ * @return $this
+ */
+ public function whereKeyNot($id)
+ {
+ if (is_array($id) || $id instanceof Arrayable) {
+ $this->query->whereNotIn($this->model->getQualifiedKeyName(), $id);
+
+ return $this;
+ }
+
+ return $this->where($this->model->getQualifiedKeyName(), '!=', $id);
+ }
+
/**
* Add a basic where clause to the query.
*
* @param string|array|\Closure $column
- * @param string $operator
- * @param mixed $value
+ * @param mixed $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();
-
- $column($query);
+ $column($query = $this->model->newModelQuery());
$this->query->addNestedWhereQuery($query->getQuery(), $boolean);
} else {
@@ -217,16 +236,54 @@ class Builder
/**
* Add an "or where" clause to the query.
*
- * @param string|array|\Closure $column
- * @param string $operator
+ * @param \Closure|array|string $column
+ * @param mixed $operator
* @param mixed $value
* @return \Illuminate\Database\Eloquent\Builder|static
*/
public function orWhere($column, $operator = null, $value = null)
{
+ [$value, $operator] = $this->query->prepareValueAndOperator(
+ $value, $operator, func_num_args() === 2
+ );
+
return $this->where($column, $operator, $value, 'or');
}
+ /**
+ * Add an "order by" clause for a timestamp to the query.
+ *
+ * @param string $column
+ * @return $this
+ */
+ public function latest($column = null)
+ {
+ if (is_null($column)) {
+ $column = $this->model->getCreatedAtColumn() ?? 'created_at';
+ }
+
+ $this->query->latest($column);
+
+ return $this;
+ }
+
+ /**
+ * Add an "order by" clause for a timestamp to the query.
+ *
+ * @param string $column
+ * @return $this
+ */
+ public function oldest($column = null)
+ {
+ if (is_null($column)) {
+ $column = $this->model->getCreatedAtColumn() ?? 'created_at';
+ }
+
+ $this->query->oldest($column);
+
+ return $this;
+ }
+
/**
* Create a collection of models from plain arrays.
*
@@ -275,12 +332,14 @@ class Builder
/**
* Find multiple models by their primary keys.
*
- * @param array $ids
+ * @param \Illuminate\Contracts\Support\Arrayable|array $ids
* @param array $columns
* @return \Illuminate\Database\Eloquent\Collection
*/
public function findMany($ids, $columns = ['*'])
{
+ $ids = $ids instanceof Arrayable ? $ids->toArray() : $ids;
+
if (empty($ids)) {
return $this->model->newCollection();
}
@@ -293,7 +352,7 @@ class Builder
*
* @param mixed $id
* @param array $columns
- * @return \Illuminate\Database\Eloquent\Model|\Illuminate\Database\Eloquent\Collection
+ * @return \Illuminate\Database\Eloquent\Model|\Illuminate\Database\Eloquent\Collection|static|static[]
*
* @throws \Illuminate\Database\Eloquent\ModelNotFoundException
*/
@@ -302,7 +361,7 @@ class Builder
$result = $this->find($id, $columns);
if (is_array($id)) {
- if (count($result) == count(array_unique($id))) {
+ if (count($result) === count(array_unique($id))) {
return $result;
}
} elseif (! is_null($result)) {
@@ -319,7 +378,7 @@ class Builder
*
* @param mixed $id
* @param array $columns
- * @return \Illuminate\Database\Eloquent\Model
+ * @return \Illuminate\Database\Eloquent\Model|static
*/
public function findOrNew($id, $columns = ['*'])
{
@@ -335,7 +394,7 @@ class Builder
*
* @param array $attributes
* @param array $values
- * @return \Illuminate\Database\Eloquent\Model
+ * @return \Illuminate\Database\Eloquent\Model|static
*/
public function firstOrNew(array $attributes, array $values = [])
{
@@ -351,7 +410,7 @@ class Builder
*
* @param array $attributes
* @param array $values
- * @return \Illuminate\Database\Eloquent\Model
+ * @return \Illuminate\Database\Eloquent\Model|static
*/
public function firstOrCreate(array $attributes, array $values = [])
{
@@ -369,7 +428,7 @@ class Builder
*
* @param array $attributes
* @param array $values
- * @return \Illuminate\Database\Eloquent\Model
+ * @return \Illuminate\Database\Eloquent\Model|static
*/
public function updateOrCreate(array $attributes, array $values = [])
{
@@ -454,7 +513,7 @@ class Builder
* Get the hydrated models without eager loading.
*
* @param array $columns
- * @return \Illuminate\Database\Eloquent\Model[]
+ * @return \Illuminate\Database\Eloquent\Model[]|static[]
*/
public function getModels($columns = ['*'])
{
@@ -524,7 +583,7 @@ class Builder
// and error prone. We don't want constraints because we add eager ones.
$relation = Relation::noConstraints(function () use ($name) {
try {
- return $this->getModel()->{$name}();
+ return $this->getModel()->newInstance()->$name();
} catch (BadMethodCallException $e) {
throw RelationNotFoundException::make($this->getModel(), $name);
}
@@ -584,7 +643,7 @@ class Builder
public function cursor()
{
foreach ($this->applyScopes()->query->cursor() as $record) {
- yield $this->model->newFromBuilder($record);
+ yield $this->newModelInstance()->newFromBuilder($record);
}
}
@@ -593,7 +652,7 @@ class Builder
*
* @param int $count
* @param callable $callback
- * @param string $column
+ * @param string|null $column
* @param string|null $alias
* @return bool
*/
@@ -603,7 +662,7 @@ class Builder
$alias = is_null($alias) ? $column : $alias;
- $lastId = 0;
+ $lastId = null;
do {
$clone = clone $this;
@@ -627,6 +686,8 @@ class Builder
}
$lastId = $results->last()->{$alias};
+
+ unset($results);
} while ($countResults == $count);
return true;
@@ -763,7 +824,7 @@ class Builder
* Increment a column's value by a given amount.
*
* @param string $column
- * @param int $amount
+ * @param float|int $amount
* @param array $extra
* @return int
*/
@@ -778,7 +839,7 @@ class Builder
* Decrement a column's value by a given amount.
*
* @param string $column
- * @param int $amount
+ * @param float|int $amount
* @param array $extra
* @return int
*/
@@ -797,14 +858,27 @@ class Builder
*/
protected function addUpdatedAtColumn(array $values)
{
- if (! $this->model->usesTimestamps()) {
+ if (! $this->model->usesTimestamps() ||
+ is_null($this->model->getUpdatedAtColumn())) {
return $values;
}
- return Arr::add(
- $values, $this->model->getUpdatedAtColumn(),
- $this->model->freshTimestampString()
+ $column = $this->model->getUpdatedAtColumn();
+
+ $values = array_merge(
+ [$column => $this->model->freshTimestampString()],
+ $values
);
+
+ $segments = preg_split('/\s+as\s+/i', $this->query->from);
+
+ $qualifiedColumn = end($segments).'.'.$column;
+
+ $values[$qualifiedColumn] = $values[$column];
+
+ unset($values[$column]);
+
+ return $values;
}
/**
@@ -848,7 +922,7 @@ class Builder
* Call the given local model scopes.
*
* @param array $scopes
- * @return mixed
+ * @return static|mixed
*/
public function scopes(array $scopes)
{
@@ -859,11 +933,11 @@ class Builder
// the parameter list is empty, so we will format the scope name and these
// parameters here. Then, we'll be ready to call the scope on the model.
if (is_int($scope)) {
- list($scope, $parameters) = [$parameters, []];
+ [$scope, $parameters] = [$parameters, []];
}
// Next we'll pass the scope callback to the callScope method which will take
- // care of groping the "wheres" correctly so the logical order doesn't get
+ // care of grouping the "wheres" properly so the logical order doesn't get
// messed up when adding scopes. Then we'll return back out the builder.
$builder = $builder->callScope(
[$this->model, 'scope'.ucfirst($scope)],
@@ -877,7 +951,7 @@ class Builder
/**
* Apply the scopes to the Eloquent builder instance and return it.
*
- * @return \Illuminate\Database\Eloquent\Builder|static
+ * @return static
*/
public function applyScopes()
{
@@ -892,7 +966,7 @@ class Builder
continue;
}
- $builder->callScope(function (Builder $builder) use ($scope) {
+ $builder->callScope(function (self $builder) use ($scope) {
// If the scope is a Closure we will just go ahead and call the scope with the
// builder instance. The "callScope" method will properly group the clauses
// that are added to this query so "where" clauses maintain proper logic.
@@ -931,7 +1005,7 @@ class Builder
$originalWhereCount = is_null($query->wheres)
? 0 : count($query->wheres);
- $result = $scope(...array_values($parameters)) ?: $this;
+ $result = $scope(...array_values($parameters)) ?? $this;
if (count((array) $query->wheres) > $originalWhereCount) {
$this->addNewWheresWithinGroup($query, $originalWhereCount);
@@ -1038,7 +1112,7 @@ class Builder
* Create a new instance of the model being queried.
*
* @param array $attributes
- * @return \Illuminate\Database\Eloquent\Model
+ * @return \Illuminate\Database\Eloquent\Model|static
*/
public function newModelInstance($attributes = [])
{
@@ -1058,22 +1132,22 @@ class Builder
$results = [];
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 the "name" value is a numeric key, we can assume that no
+ // constraints have been specified. We'll just put an empty
+ // Closure there, so that we can treat them all the same.
if (is_numeric($name)) {
$name = $constraints;
- list($name, $constraints) = Str::contains($name, ':')
+ [$name, $constraints] = Str::contains($name, ':')
? $this->createSelectWithConstraint($name)
: [$name, function () {
//
}];
}
- // We need to separate out any nested includes. Which allows the developers
+ // 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.
+ // the relationship with its own key in the array of eager-load names.
$results = $this->addNestedWiths($name, $results);
$results[$name] = $constraints;
@@ -1181,7 +1255,7 @@ class Builder
/**
* Get the model instance being queried.
*
- * @return \Illuminate\Database\Eloquent\Model
+ * @return \Illuminate\Database\Eloquent\Model|static
*/
public function getModel()
{
@@ -1203,6 +1277,17 @@ class Builder
return $this;
}
+ /**
+ * Qualify the given column name by the model's table.
+ *
+ * @param string $column
+ * @return string
+ */
+ public function qualifyColumn($column)
+ {
+ return $this->model->qualifyColumn($column);
+ }
+
/**
* Get the given macro by name.
*
@@ -1214,6 +1299,23 @@ class Builder
return Arr::get($this->localMacros, $name);
}
+ /**
+ * Dynamically access builder proxies.
+ *
+ * @param string $key
+ * @return mixed
+ *
+ * @throws \Exception
+ */
+ public function __get($key)
+ {
+ if ($key === 'orWhere') {
+ return new HigherOrderBuilderProxy($this, $key);
+ }
+
+ throw new Exception("Property [{$key}] does not exist on the Eloquent builder instance.");
+ }
+
/**
* Dynamically handle calls into the query instance.
*
@@ -1235,12 +1337,12 @@ class Builder
return $this->localMacros[$method](...$parameters);
}
- if (isset(static::$macros[$method]) and static::$macros[$method] instanceof Closure) {
- return call_user_func_array(static::$macros[$method]->bindTo($this, static::class), $parameters);
- }
-
if (isset(static::$macros[$method])) {
- return call_user_func_array(static::$macros[$method]->bindTo($this, static::class), $parameters);
+ if (static::$macros[$method] instanceof Closure) {
+ return call_user_func_array(static::$macros[$method]->bindTo($this, static::class), $parameters);
+ }
+
+ return call_user_func_array(static::$macros[$method], $parameters);
}
if (method_exists($this->model, $scope = 'scope'.ucfirst($method))) {
@@ -1251,7 +1353,7 @@ class Builder
return $this->toBase()->{$method}(...$parameters);
}
- $this->query->{$method}(...$parameters);
+ $this->forwardCallTo($this->query, $method, $parameters);
return $this;
}
@@ -1274,7 +1376,7 @@ class Builder
}
if (! isset(static::$macros[$method])) {
- throw new BadMethodCallException("Method {$method} does not exist.");
+ static::throwBadMethodCallException($method);
}
if (static::$macros[$method] instanceof Closure) {
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Collection.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Collection.php
index 5c679c20..cbbf3c59 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Collection.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Collection.php
@@ -4,6 +4,9 @@ namespace Illuminate\Database\Eloquent;
use LogicException;
use Illuminate\Support\Arr;
+use Illuminate\Support\Str;
+use Illuminate\Contracts\Support\Arrayable;
+use Illuminate\Contracts\Queue\QueueableEntity;
use Illuminate\Contracts\Queue\QueueableCollection;
use Illuminate\Support\Collection as BaseCollection;
@@ -14,7 +17,7 @@ class Collection extends BaseCollection implements QueueableCollection
*
* @param mixed $key
* @param mixed $default
- * @return \Illuminate\Database\Eloquent\Model|static
+ * @return \Illuminate\Database\Eloquent\Model|static|null
*/
public function find($key, $default = null)
{
@@ -22,6 +25,10 @@ class Collection extends BaseCollection implements QueueableCollection
$key = $key->getKey();
}
+ if ($key instanceof Arrayable) {
+ $key = $key->toArray();
+ }
+
if (is_array($key)) {
if ($this->isEmpty()) {
return new static;
@@ -38,17 +45,17 @@ class Collection extends BaseCollection implements QueueableCollection
/**
* Load a set of relationships onto the collection.
*
- * @param mixed $relations
+ * @param array|string $relations
* @return $this
*/
public function load($relations)
{
- if (count($this->items) > 0) {
+ if ($this->isNotEmpty()) {
if (is_string($relations)) {
$relations = func_get_args();
}
- $query = $this->first()->newQuery()->with($relations);
+ $query = $this->first()->newQueryWithoutRelationships()->with($relations);
$this->items = $query->eagerLoadRelations($this->items);
}
@@ -57,14 +64,127 @@ class Collection extends BaseCollection implements QueueableCollection
}
/**
- * Add an item to the collection.
+ * Load a set of relationship counts onto the collection.
*
- * @param mixed $item
+ * @param array|string $relations
* @return $this
*/
- public function add($item)
+ public function loadCount($relations)
{
- $this->items[] = $item;
+ if ($this->isEmpty()) {
+ return $this;
+ }
+
+ $models = $this->first()->newModelQuery()
+ ->whereKey($this->modelKeys())
+ ->select($this->first()->getKeyName())
+ ->withCount(...func_get_args())
+ ->get();
+
+ $attributes = Arr::except(
+ array_keys($models->first()->getAttributes()),
+ $models->first()->getKeyName()
+ );
+
+ $models->each(function ($model) use ($attributes) {
+ $this->find($model->getKey())->forceFill(
+ Arr::only($model->getAttributes(), $attributes)
+ )->syncOriginalAttributes($attributes);
+ });
+
+ return $this;
+ }
+
+ /**
+ * Load a set of relationships onto the collection if they are not already eager loaded.
+ *
+ * @param array|string $relations
+ * @return $this
+ */
+ public function loadMissing($relations)
+ {
+ if (is_string($relations)) {
+ $relations = func_get_args();
+ }
+
+ foreach ($relations as $key => $value) {
+ if (is_numeric($key)) {
+ $key = $value;
+ }
+
+ $segments = explode('.', explode(':', $key)[0]);
+
+ if (Str::contains($key, ':')) {
+ $segments[count($segments) - 1] .= ':'.explode(':', $key)[1];
+ }
+
+ $path = [];
+
+ foreach ($segments as $segment) {
+ $path[] = [$segment => $segment];
+ }
+
+ if (is_callable($value)) {
+ $path[count($segments) - 1][end($segments)] = $value;
+ }
+
+ $this->loadMissingRelation($this, $path);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Load a relationship path if it is not already eager loaded.
+ *
+ * @param \Illuminate\Database\Eloquent\Collection $models
+ * @param array $path
+ * @return void
+ */
+ protected function loadMissingRelation(self $models, array $path)
+ {
+ $relation = array_shift($path);
+
+ $name = explode(':', key($relation))[0];
+
+ if (is_string(reset($relation))) {
+ $relation = reset($relation);
+ }
+
+ $models->filter(function ($model) use ($name) {
+ return ! is_null($model) && ! $model->relationLoaded($name);
+ })->load($relation);
+
+ if (empty($path)) {
+ return;
+ }
+
+ $models = $models->pluck($name);
+
+ if ($models->first() instanceof BaseCollection) {
+ $models = $models->collapse();
+ }
+
+ $this->loadMissingRelation(new static($models), $path);
+ }
+
+ /**
+ * Load a set of relationships onto the mixed relationship collection.
+ *
+ * @param string $relation
+ * @param array $relations
+ * @return $this
+ */
+ public function loadMorph($relation, $relations)
+ {
+ $this->pluck($relation)
+ ->filter()
+ ->groupBy(function ($model) {
+ return get_class($model);
+ })
+ ->each(function ($models, $className) use ($relations) {
+ static::make($models)->load($relations[$className] ?? []);
+ });
return $this;
}
@@ -159,7 +279,8 @@ class Collection extends BaseCollection implements QueueableCollection
->getDictionary();
return $this->map(function ($model) use ($freshModels) {
- return $model->exists ? $freshModels[$model->getKey()] : null;
+ return $model->exists && isset($freshModels[$model->getKey()])
+ ? $freshModels[$model->getKey()] : null;
});
}
@@ -259,9 +380,7 @@ class Collection extends BaseCollection implements QueueableCollection
*/
public function makeHidden($attributes)
{
- return $this->each(function ($model) use ($attributes) {
- $model->addHidden($attributes);
- });
+ return $this->each->addHidden($attributes);
}
/**
@@ -272,9 +391,7 @@ class Collection extends BaseCollection implements QueueableCollection
*/
public function makeVisible($attributes)
{
- return $this->each(function ($model) use ($attributes) {
- $model->makeVisible($attributes);
- });
+ return $this->each->makeVisible($attributes);
}
/**
@@ -364,14 +481,41 @@ class Collection extends BaseCollection implements QueueableCollection
return $this->toBase()->flip();
}
+ /**
+ * Pad collection to the specified length with a value.
+ *
+ * @param int $size
+ * @param mixed $value
+ * @return \Illuminate\Support\Collection
+ */
+ public function pad($size, $value)
+ {
+ return $this->toBase()->pad($size, $value);
+ }
+
+ /**
+ * Get the comparison function to detect duplicates.
+ *
+ * @param bool $strict
+ * @return \Closure
+ */
+ protected function duplicateComparator($strict)
+ {
+ return function ($a, $b) {
+ return $a->is($b);
+ };
+ }
+
/**
* Get the type of the entities being queued.
*
* @return string|null
+ *
+ * @throws \LogicException
*/
public function getQueueableClass()
{
- if ($this->count() === 0) {
+ if ($this->isEmpty()) {
return;
}
@@ -393,6 +537,46 @@ class Collection extends BaseCollection implements QueueableCollection
*/
public function getQueueableIds()
{
- return $this->modelKeys();
+ if ($this->isEmpty()) {
+ return [];
+ }
+
+ return $this->first() instanceof QueueableEntity
+ ? $this->map->getQueueableId()->all()
+ : $this->modelKeys();
+ }
+
+ /**
+ * Get the relationships of the entities being queued.
+ *
+ * @return array
+ */
+ public function getQueueableRelations()
+ {
+ return $this->isNotEmpty() ? $this->first()->getQueueableRelations() : [];
+ }
+
+ /**
+ * Get the connection of the entities being queued.
+ *
+ * @return string|null
+ *
+ * @throws \LogicException
+ */
+ public function getQueueableConnection()
+ {
+ if ($this->isEmpty()) {
+ return;
+ }
+
+ $connection = $this->first()->getConnectionName();
+
+ $this->each(function ($model) use ($connection) {
+ if ($model->getConnectionName() !== $connection) {
+ throw new LogicException('Queueing collections with multiple model connections is not supported.');
+ }
+ });
+
+ return $connection;
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/GuardsAttributes.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/GuardsAttributes.php
index 96317cf5..b9095c04 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/GuardsAttributes.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/GuardsAttributes.php
@@ -173,7 +173,7 @@ trait GuardsAttributes
*/
public function totallyGuarded()
{
- return count($this->getFillable()) == 0 && $this->getGuarded() == ['*'];
+ return count($this->getFillable()) === 0 && $this->getGuarded() == ['*'];
}
/**
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php
index ae42b7d6..f69af679 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php
@@ -2,11 +2,13 @@
namespace Illuminate\Database\Eloquent\Concerns;
-use Carbon\Carbon;
use LogicException;
use DateTimeInterface;
+use Carbon\CarbonInterface;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
+use Illuminate\Support\Carbon;
+use Illuminate\Support\Facades\Date;
use Illuminate\Contracts\Support\Arrayable;
use Illuminate\Database\Eloquent\Relations\Relation;
use Illuminate\Support\Collection as BaseCollection;
@@ -28,6 +30,13 @@ trait HasAttributes
*/
protected $original = [];
+ /**
+ * The changed model attributes.
+ *
+ * @var array
+ */
+ protected $changes = [];
+
/**
* The attributes that should be cast to native types.
*
@@ -176,12 +185,16 @@ trait HasAttributes
);
// If the attribute cast was a date or a datetime, we will serialize the date as
- // a string. This allows the developers to customize hwo dates are serialized
+ // a string. This allows the developers to customize how dates are serialized
// into an array without affecting how they are persisted into the storage.
if ($attributes[$key] &&
($value === 'date' || $value === 'datetime')) {
$attributes[$key] = $this->serializeDate($attributes[$key]);
}
+
+ if ($attributes[$key] && $this->isCustomDateTimeCast($value)) {
+ $attributes[$key] = $attributes[$key]->format(explode(':', $value, 2)[1]);
+ }
}
return $attributes;
@@ -307,7 +320,7 @@ trait HasAttributes
}
// Here we will determine if the model base class itself contains this given key
- // since we do not want to treat any of those methods are relationships since
+ // since we don't want to treat any of those methods as relationships because
// they are all intended as helper methods and none of these are relations.
if (method_exists(self::class, $key)) {
return;
@@ -359,9 +372,7 @@ trait HasAttributes
*/
protected function getAttributeFromArray($key)
{
- if (isset($this->attributes[$key])) {
- return $this->attributes[$key];
- }
+ return $this->attributes[$key] ?? null;
}
/**
@@ -400,8 +411,15 @@ trait HasAttributes
$relation = $this->$method();
if (! $relation instanceof Relation) {
- throw new LogicException('Relationship method must return an object of type '
- .'Illuminate\Database\Eloquent\Relations\Relation');
+ if (is_null($relation)) {
+ throw new LogicException(sprintf(
+ '%s::%s must return a relationship instance, but "null" was returned. Was the "return" keyword used?', static::class, $method
+ ));
+ }
+
+ throw new LogicException(sprintf(
+ '%s::%s must return a relationship instance.', static::class, $method
+ ));
}
return tap($relation->getResults(), function ($results) use ($method) {
@@ -466,7 +484,9 @@ trait HasAttributes
case 'real':
case 'float':
case 'double':
- return (float) $value;
+ return $this->fromFloat($value);
+ case 'decimal':
+ return $this->asDecimal($value, explode(':', $this->getCasts()[$key], 2)[1]);
case 'string':
return (string) $value;
case 'bool':
@@ -482,6 +502,7 @@ trait HasAttributes
case 'date':
return $this->asDate($value);
case 'datetime':
+ case 'custom_datetime':
return $this->asDateTime($value);
case 'timestamp':
return $this->asTimestamp($value);
@@ -498,15 +519,46 @@ trait HasAttributes
*/
protected function getCastType($key)
{
+ if ($this->isCustomDateTimeCast($this->getCasts()[$key])) {
+ return 'custom_datetime';
+ }
+
+ if ($this->isDecimalCast($this->getCasts()[$key])) {
+ return 'decimal';
+ }
+
return trim(strtolower($this->getCasts()[$key]));
}
+ /**
+ * Determine if the cast type is a custom date time cast.
+ *
+ * @param string $cast
+ * @return bool
+ */
+ protected function isCustomDateTimeCast($cast)
+ {
+ return strncmp($cast, 'date:', 5) === 0 ||
+ strncmp($cast, 'datetime:', 9) === 0;
+ }
+
+ /**
+ * Determine if the cast type is a decimal cast.
+ *
+ * @param string $cast
+ * @return bool
+ */
+ protected function isDecimalCast($cast)
+ {
+ return strncmp($cast, 'decimal:', 8) === 0;
+ }
+
/**
* Set a given attribute on the model.
*
* @param string $key
* @param mixed $value
- * @return $this
+ * @return mixed
*/
public function setAttribute($key, $value)
{
@@ -514,9 +566,7 @@ trait HasAttributes
// which simply lets the developers tweak the attribute as it is set on
// the model, such as "json_encoding" an listing of data for storage.
if ($this->hasSetMutator($key)) {
- $method = 'set'.Str::studly($key).'Attribute';
-
- return $this->{$method}($value);
+ return $this->setMutatedAttributeValue($key, $value);
}
// If an attribute is listed as a "date", we'll convert it from a DateTime
@@ -553,6 +603,18 @@ trait HasAttributes
return method_exists($this, 'set'.Str::studly($key).'Attribute');
}
+ /**
+ * Set the value of an attribute using its mutator.
+ *
+ * @param string $key
+ * @param mixed $value
+ * @return mixed
+ */
+ protected function setMutatedAttributeValue($key, $value)
+ {
+ return $this->{'set'.Str::studly($key).'Attribute'}($value);
+ }
+
/**
* Determine if the given attribute is a date or date castable.
*
@@ -561,7 +623,7 @@ trait HasAttributes
*/
protected function isDateAttribute($key)
{
- return in_array($key, $this->getDates()) ||
+ return in_array($key, $this->getDates(), true) ||
$this->isDateCastable($key);
}
@@ -574,7 +636,7 @@ trait HasAttributes
*/
public function fillJsonAttribute($key, $value)
{
- list($key, $path) = explode('->', $key, 2);
+ [$key, $path] = explode('->', $key, 2);
$this->attributes[$key] = $this->asJson($this->getArrayAttributeWithValue(
$path, $key, $value
@@ -653,11 +715,43 @@ trait HasAttributes
return json_decode($value, ! $asObject);
}
+ /**
+ * Decode the given float.
+ *
+ * @param mixed $value
+ * @return mixed
+ */
+ public function fromFloat($value)
+ {
+ switch ((string) $value) {
+ case 'Infinity':
+ return INF;
+ case '-Infinity':
+ return -INF;
+ case 'NaN':
+ return NAN;
+ default:
+ return (float) $value;
+ }
+ }
+
+ /**
+ * Return a decimal as string.
+ *
+ * @param float $value
+ * @param int $decimals
+ * @return string
+ */
+ protected function asDecimal($value, $decimals)
+ {
+ return number_format($value, $decimals, '.', '');
+ }
+
/**
* Return a timestamp as DateTime object with time set to 00:00:00.
*
* @param mixed $value
- * @return \Carbon\Carbon
+ * @return \Illuminate\Support\Carbon
*/
protected function asDate($value)
{
@@ -668,22 +762,22 @@ trait HasAttributes
* Return a timestamp as DateTime object.
*
* @param mixed $value
- * @return \Carbon\Carbon
+ * @return \Illuminate\Support\Carbon
*/
protected function asDateTime($value)
{
// If this value is already a Carbon instance, we shall just return it as is.
// This prevents us having to re-instantiate a Carbon instance when we know
// it already is one, which wouldn't be fulfilled by the DateTime check.
- if ($value instanceof Carbon) {
- return $value;
+ if ($value instanceof Carbon || $value instanceof CarbonInterface) {
+ return Date::instance($value);
}
// If the value is already a DateTime instance, we will just skip the rest of
// these checks since they will be a waste of time, and hinder performance
// when checking the field. We will just return the DateTime right away.
if ($value instanceof DateTimeInterface) {
- return new Carbon(
+ return Date::parse(
$value->format('Y-m-d H:i:s.u'), $value->getTimezone()
);
}
@@ -692,22 +786,27 @@ trait HasAttributes
// and format a Carbon object from this timestamp. This allows flexibility
// when defining your date fields as they might be UNIX timestamps here.
if (is_numeric($value)) {
- return Carbon::createFromTimestamp($value);
+ return Date::createFromTimestamp($value);
}
// If the value is in simply year, month, day format, we will instantiate the
// Carbon instances from that format. Again, this provides for simple date
// fields on the database, while still supporting Carbonized conversion.
if ($this->isStandardDateFormat($value)) {
- return Carbon::createFromFormat('Y-m-d', $value)->startOfDay();
+ return Date::instance(Carbon::createFromFormat('Y-m-d', $value)->startOfDay());
+ }
+
+ $format = $this->getDateFormat();
+
+ // https://bugs.php.net/bug.php?id=75577
+ if (version_compare(PHP_VERSION, '7.3.0-dev', '<')) {
+ $format = str_replace('.v', '.u', $format);
}
// Finally, we will just assume this date is in the format used by default on
// the database connection and use that format to create the Carbon object
// that is returned back out to the developers after we convert it here.
- return Carbon::createFromFormat(
- $this->getDateFormat(), $value
- );
+ return Date::createFromFormat($format, $value);
}
/**
@@ -724,12 +823,12 @@ trait HasAttributes
/**
* Convert a DateTime to a storable string.
*
- * @param \DateTime|int $value
- * @return string
+ * @param mixed $value
+ * @return string|null
*/
public function fromDateTime($value)
{
- return $this->asDateTime($value)->format(
+ return empty($value) ? $value : $this->asDateTime($value)->format(
$this->getDateFormat()
);
}
@@ -775,7 +874,7 @@ trait HasAttributes
*
* @return string
*/
- protected function getDateFormat()
+ public function getDateFormat()
{
return $this->dateFormat ?: $this->getConnection()->getQueryGrammar()->getDateFormat();
}
@@ -885,6 +984,23 @@ trait HasAttributes
return Arr::get($this->original, $key, $default);
}
+ /**
+ * Get a subset of the model's attributes.
+ *
+ * @param array|mixed $attributes
+ * @return array
+ */
+ public function only($attributes)
+ {
+ $results = [];
+
+ foreach (is_array($attributes) ? $attributes : func_get_args() as $attribute) {
+ $results[$attribute] = $this->getAttribute($attribute);
+ }
+
+ return $results;
+ }
+
/**
* Sync the original attributes with the current.
*
@@ -905,45 +1021,53 @@ trait HasAttributes
*/
public function syncOriginalAttribute($attribute)
{
- $this->original[$attribute] = $this->attributes[$attribute];
+ return $this->syncOriginalAttributes($attribute);
+ }
+
+ /**
+ * Sync multiple original attribute with their current values.
+ *
+ * @param array|string $attributes
+ * @return $this
+ */
+ public function syncOriginalAttributes($attributes)
+ {
+ $attributes = is_array($attributes) ? $attributes : func_get_args();
+
+ foreach ($attributes as $attribute) {
+ $this->original[$attribute] = $this->attributes[$attribute];
+ }
return $this;
}
/**
- * Determine if the model or given attribute(s) have been modified.
+ * Sync the changed attributes.
+ *
+ * @return $this
+ */
+ public function syncChanges()
+ {
+ $this->changes = $this->getDirty();
+
+ return $this;
+ }
+
+ /**
+ * Determine if the model or any of the given attribute(s) have been modified.
*
* @param array|string|null $attributes
* @return bool
*/
public function isDirty($attributes = null)
{
- $dirty = $this->getDirty();
-
- // If no specific attributes were provided, we will just see if the dirty array
- // already contains any attributes. If it does we will just return that this
- // count is greater than zero. Else, we need to check specific attributes.
- if (is_null($attributes)) {
- return count($dirty) > 0;
- }
-
- $attributes = is_array($attributes)
- ? $attributes : func_get_args();
-
- // Here we will spin through every attribute and see if this is in the array of
- // dirty attributes. If it is, we will return true and if we make it through
- // all of the attributes for the entire array we will return false at end.
- foreach ($attributes as $attribute) {
- if (array_key_exists($attribute, $dirty)) {
- return true;
- }
- }
-
- return false;
+ return $this->hasChanges(
+ $this->getDirty(), is_array($attributes) ? $attributes : func_get_args()
+ );
}
/**
- * Determine if the model or given attribute(s) have remained the same.
+ * Determine if the model and all the given attribute(s) have remained the same.
*
* @param array|string|null $attributes
* @return bool
@@ -953,6 +1077,47 @@ trait HasAttributes
return ! $this->isDirty(...func_get_args());
}
+ /**
+ * Determine if the model or any of the given attribute(s) have been modified.
+ *
+ * @param array|string|null $attributes
+ * @return bool
+ */
+ public function wasChanged($attributes = null)
+ {
+ return $this->hasChanges(
+ $this->getChanges(), is_array($attributes) ? $attributes : func_get_args()
+ );
+ }
+
+ /**
+ * Determine if any of the given attributes were changed.
+ *
+ * @param array $changes
+ * @param array|string|null $attributes
+ * @return bool
+ */
+ protected function hasChanges($changes, $attributes = null)
+ {
+ // If no specific attributes were provided, we will just see if the dirty array
+ // already contains any attributes. If it does we will just return that this
+ // count is greater than zero. Else, we need to check specific attributes.
+ if (empty($attributes)) {
+ return count($changes) > 0;
+ }
+
+ // Here we will spin through every attribute and see if this is in the array of
+ // dirty attributes. If it is, we will return true and if we make it through
+ // all of the attributes for the entire array we will return false at end.
+ foreach (Arr::wrap($attributes) as $attribute) {
+ if (array_key_exists($attribute, $changes)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
/**
* Get the attributes that have been changed since last sync.
*
@@ -962,11 +1127,8 @@ trait HasAttributes
{
$dirty = [];
- foreach ($this->attributes as $key => $value) {
- if (! array_key_exists($key, $this->original)) {
- $dirty[$key] = $value;
- } elseif ($value !== $this->original[$key] &&
- ! $this->originalIsNumericallyEquivalent($key)) {
+ foreach ($this->getAttributes() as $key => $value) {
+ if (! $this->originalIsEquivalent($key, $value)) {
$dirty[$key] = $value;
}
}
@@ -975,22 +1137,44 @@ trait HasAttributes
}
/**
- * Determine if the new and old values for a given key are numerically equivalent.
+ * Get the attributes that were changed.
*
- * @param string $key
+ * @return array
+ */
+ public function getChanges()
+ {
+ return $this->changes;
+ }
+
+ /**
+ * Determine if the new and old values for a given key are equivalent.
+ *
+ * @param string $key
+ * @param mixed $current
* @return bool
*/
- protected function originalIsNumericallyEquivalent($key)
+ public function originalIsEquivalent($key, $current)
{
- $current = $this->attributes[$key];
+ if (! array_key_exists($key, $this->original)) {
+ return false;
+ }
- $original = $this->original[$key];
+ $original = $this->getOriginal($key);
+
+ if ($current === $original) {
+ return true;
+ } elseif (is_null($current)) {
+ return false;
+ } elseif ($this->isDateAttribute($key)) {
+ return $this->fromDateTime($current) ===
+ $this->fromDateTime($original);
+ } elseif ($this->hasCast($key)) {
+ return $this->castAttribute($key, $current) ===
+ $this->castAttribute($key, $original);
+ }
- // This method checks if the two values are numerically equivalent even if they
- // are different types. This is in case the two values are not the same type
- // we can do a fair comparison of the two values to know if this is dirty.
return is_numeric($current) && is_numeric($original)
- && strcmp((string) $current, (string) $original) === 0;
+ && strcmp((string) $current, (string) $original) === 0;
}
/**
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasEvents.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasEvents.php
index 14874e84..3c9d2a1d 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasEvents.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasEvents.php
@@ -2,6 +2,8 @@
namespace Illuminate\Database\Eloquent\Concerns;
+use Illuminate\Support\Arr;
+use InvalidArgumentException;
use Illuminate\Contracts\Events\Dispatcher;
trait HasEvents
@@ -13,7 +15,7 @@ trait HasEvents
*
* @var array
*/
- protected $events = [];
+ protected $dispatchesEvents = [];
/**
* User exposed observable events.
@@ -25,27 +27,65 @@ trait HasEvents
protected $observables = [];
/**
- * Register an observer with the Model.
+ * Register observers with the model.
*
- * @param object|string $class
+ * @param object|array|string $classes
* @return void
+ *
+ * @throws \RuntimeException
*/
- public static function observe($class)
+ public static function observe($classes)
{
$instance = new static;
- $className = is_string($class) ? $class : get_class($class);
+ foreach (Arr::wrap($classes) as $class) {
+ $instance->registerObserver($class);
+ }
+ }
+
+ /**
+ * Register a single observer with the model.
+ *
+ * @param object|string $class
+ * @return void
+ *
+ * @throws \RuntimeException
+ */
+ protected function registerObserver($class)
+ {
+ $className = $this->resolveObserverClassName($class);
// When registering a model observer, we will spin through the possible events
// and determine if this observer has that method. If it does, we will hook
// it into the model's event system, making it convenient to watch these.
- foreach ($instance->getObservableEvents() as $event) {
+ foreach ($this->getObservableEvents() as $event) {
if (method_exists($class, $event)) {
static::registerModelEvent($event, $className.'@'.$event);
}
}
}
+ /**
+ * Resolve the observer's class name from an object or string.
+ *
+ * @param object|string $class
+ * @return string
+ *
+ * @throws \InvalidArgumentException
+ */
+ private function resolveObserverClassName($class)
+ {
+ if (is_object($class)) {
+ return get_class($class);
+ }
+
+ if (class_exists($class)) {
+ return $class;
+ }
+
+ throw new InvalidArgumentException('Unable to find observer: '.$class);
+ }
+
/**
* Get the observable event names.
*
@@ -55,9 +95,9 @@ trait HasEvents
{
return array_merge(
[
- 'creating', 'created', 'updating', 'updated',
- 'deleting', 'deleted', 'saving', 'saved',
- 'restoring', 'restored',
+ 'retrieved', 'creating', 'created', 'updating', 'updated',
+ 'saving', 'saved', 'restoring', 'restored', 'replicating',
+ 'deleting', 'deleted', 'forceDeleted',
],
$this->observables
);
@@ -134,7 +174,7 @@ trait HasEvents
// First, we will get the proper method to call on the event dispatcher, and then we
// will attempt to fire a custom, object based event for the given event. If that
// returns a result we can return that result, or we'll call the string events.
- $method = $halt ? 'until' : 'fire';
+ $method = $halt ? 'until' : 'dispatch';
$result = $this->filterModelEventResults(
$this->fireCustomModelEvent($event, $method)
@@ -158,11 +198,11 @@ trait HasEvents
*/
protected function fireCustomModelEvent($event, $method)
{
- if (! isset($this->events[$event])) {
+ if (! isset($this->dispatchesEvents[$event])) {
return;
}
- $result = static::$dispatcher->$method(new $this->events[$event]($this));
+ $result = static::$dispatcher->$method(new $this->dispatchesEvents[$event]($this));
if (! is_null($result)) {
return $result;
@@ -186,6 +226,17 @@ trait HasEvents
return $result;
}
+ /**
+ * Register a retrieved model event with the dispatcher.
+ *
+ * @param \Closure|string $callback
+ * @return void
+ */
+ public static function retrieved($callback)
+ {
+ static::registerModelEvent('retrieved', $callback);
+ }
+
/**
* Register a saving model event with the dispatcher.
*
@@ -252,6 +303,17 @@ trait HasEvents
static::registerModelEvent('created', $callback);
}
+ /**
+ * Register a replicating model event with the dispatcher.
+ *
+ * @param \Closure|string $callback
+ * @return void
+ */
+ public static function replicating($callback)
+ {
+ static::registerModelEvent('replicating', $callback);
+ }
+
/**
* Register a deleting model event with the dispatcher.
*
@@ -290,6 +352,10 @@ trait HasEvents
foreach ($instance->getObservableEvents() as $event) {
static::$dispatcher->forget("eloquent.{$event}: ".static::class);
}
+
+ foreach (array_values($instance->dispatchesEvents) as $event) {
+ static::$dispatcher->forget($event);
+ }
}
/**
@@ -322,4 +388,25 @@ trait HasEvents
{
static::$dispatcher = null;
}
+
+ /**
+ * Execute a callback without firing any model events for any model type.
+ *
+ * @param callable $callback
+ * @return mixed
+ */
+ public static function withoutEvents(callable $callback)
+ {
+ $dispatcher = static::getEventDispatcher();
+
+ static::unsetEventDispatcher();
+
+ try {
+ return $callback();
+ } finally {
+ if ($dispatcher) {
+ static::setEventDispatcher($dispatcher);
+ }
+ }
+ }
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasRelationships.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasRelationships.php
index 703a3fcc..cb202f99 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasRelationships.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasRelationships.php
@@ -5,6 +5,7 @@ namespace Illuminate\Database\Eloquent\Concerns;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
use Illuminate\Database\Eloquent\Model;
+use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Relations\HasOne;
use Illuminate\Database\Eloquent\Relations\HasMany;
@@ -15,6 +16,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\MorphMany;
use Illuminate\Database\Eloquent\Relations\MorphToMany;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
+use Illuminate\Database\Eloquent\Relations\HasOneThrough;
use Illuminate\Database\Eloquent\Relations\HasManyThrough;
trait HasRelationships
@@ -40,7 +42,6 @@ trait HasRelationships
*/
public static $manyMethods = [
'belongsToMany', 'morphToMany', 'morphedByMany',
- 'guessBelongsToManyRelation', 'findFirstMethodThatIsntRelation',
];
/**
@@ -59,7 +60,64 @@ trait HasRelationships
$localKey = $localKey ?: $this->getKeyName();
- return new HasOne($instance->newQuery(), $this, $instance->getTable().'.'.$foreignKey, $localKey);
+ return $this->newHasOne($instance->newQuery(), $this, $instance->getTable().'.'.$foreignKey, $localKey);
+ }
+
+ /**
+ * Instantiate a new HasOne relationship.
+ *
+ * @param \Illuminate\Database\Eloquent\Builder $query
+ * @param \Illuminate\Database\Eloquent\Model $parent
+ * @param string $foreignKey
+ * @param string $localKey
+ * @return \Illuminate\Database\Eloquent\Relations\HasOne
+ */
+ protected function newHasOne(Builder $query, Model $parent, $foreignKey, $localKey)
+ {
+ return new HasOne($query, $parent, $foreignKey, $localKey);
+ }
+
+ /**
+ * Define a has-one-through relationship.
+ *
+ * @param string $related
+ * @param string $through
+ * @param string|null $firstKey
+ * @param string|null $secondKey
+ * @param string|null $localKey
+ * @param string|null $secondLocalKey
+ * @return \Illuminate\Database\Eloquent\Relations\HasOneThrough
+ */
+ public function hasOneThrough($related, $through, $firstKey = null, $secondKey = null, $localKey = null, $secondLocalKey = null)
+ {
+ $through = new $through;
+
+ $firstKey = $firstKey ?: $this->getForeignKey();
+
+ $secondKey = $secondKey ?: $through->getForeignKey();
+
+ return $this->newHasOneThrough(
+ $this->newRelatedInstance($related)->newQuery(), $this, $through,
+ $firstKey, $secondKey, $localKey ?: $this->getKeyName(),
+ $secondLocalKey ?: $through->getKeyName()
+ );
+ }
+
+ /**
+ * Instantiate a new HasOneThrough relationship.
+ *
+ * @param \Illuminate\Database\Eloquent\Builder $query
+ * @param \Illuminate\Database\Eloquent\Model $farParent
+ * @param \Illuminate\Database\Eloquent\Model $throughParent
+ * @param string $firstKey
+ * @param string $secondKey
+ * @param string $localKey
+ * @param string $secondLocalKey
+ * @return \Illuminate\Database\Eloquent\Relations\HasOneThrough
+ */
+ protected function newHasOneThrough(Builder $query, Model $farParent, Model $throughParent, $firstKey, $secondKey, $localKey, $secondLocalKey)
+ {
+ return new HasOneThrough($query, $farParent, $throughParent, $firstKey, $secondKey, $localKey, $secondLocalKey);
}
/**
@@ -76,13 +134,28 @@ trait HasRelationships
{
$instance = $this->newRelatedInstance($related);
- list($type, $id) = $this->getMorphs($name, $type, $id);
+ [$type, $id] = $this->getMorphs($name, $type, $id);
$table = $instance->getTable();
$localKey = $localKey ?: $this->getKeyName();
- return new MorphOne($instance->newQuery(), $this, $table.'.'.$type, $table.'.'.$id, $localKey);
+ return $this->newMorphOne($instance->newQuery(), $this, $table.'.'.$type, $table.'.'.$id, $localKey);
+ }
+
+ /**
+ * Instantiate a new MorphOne relationship.
+ *
+ * @param \Illuminate\Database\Eloquent\Builder $query
+ * @param \Illuminate\Database\Eloquent\Model $parent
+ * @param string $type
+ * @param string $id
+ * @param string $localKey
+ * @return \Illuminate\Database\Eloquent\Relations\MorphOne
+ */
+ protected function newMorphOne(Builder $query, Model $parent, $type, $id, $localKey)
+ {
+ return new MorphOne($query, $parent, $type, $id, $localKey);
}
/**
@@ -117,27 +190,43 @@ trait HasRelationships
// actually be responsible for retrieving and hydrating every relations.
$ownerKey = $ownerKey ?: $instance->getKeyName();
- return new BelongsTo(
+ return $this->newBelongsTo(
$instance->newQuery(), $this, $foreignKey, $ownerKey, $relation
);
}
+ /**
+ * Instantiate a new BelongsTo relationship.
+ *
+ * @param \Illuminate\Database\Eloquent\Builder $query
+ * @param \Illuminate\Database\Eloquent\Model $child
+ * @param string $foreignKey
+ * @param string $ownerKey
+ * @param string $relation
+ * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
+ */
+ protected function newBelongsTo(Builder $query, Model $child, $foreignKey, $ownerKey, $relation)
+ {
+ return new BelongsTo($query, $child, $foreignKey, $ownerKey, $relation);
+ }
+
/**
* Define a polymorphic, inverse one-to-one or many relationship.
*
* @param string $name
* @param string $type
* @param string $id
+ * @param string $ownerKey
* @return \Illuminate\Database\Eloquent\Relations\MorphTo
*/
- public function morphTo($name = null, $type = null, $id = null)
+ public function morphTo($name = null, $type = null, $id = null, $ownerKey = null)
{
// If no name is provided, we will use the backtrace to get the function name
// since that is most likely the name of the polymorphic interface. We can
// use that to get both the class and foreign key that will be utilized.
$name = $name ?: $this->guessBelongsToRelation();
- list($type, $id) = $this->getMorphs(
+ [$type, $id] = $this->getMorphs(
Str::snake($name), $type, $id
);
@@ -145,8 +234,8 @@ trait HasRelationships
// the relationship. In this case we'll just pass in a dummy query where we
// need to remove any eager loads that may already be defined on a model.
return empty($class = $this->{$type})
- ? $this->morphEagerTo($name, $type, $id)
- : $this->morphInstanceTo($class, $name, $type, $id);
+ ? $this->morphEagerTo($name, $type, $id, $ownerKey)
+ : $this->morphInstanceTo($class, $name, $type, $id, $ownerKey);
}
/**
@@ -155,12 +244,13 @@ trait HasRelationships
* @param string $name
* @param string $type
* @param string $id
+ * @param string $ownerKey
* @return \Illuminate\Database\Eloquent\Relations\MorphTo
*/
- protected function morphEagerTo($name, $type, $id)
+ protected function morphEagerTo($name, $type, $id, $ownerKey)
{
- return new MorphTo(
- $this->newQuery()->setEagerLoads([]), $this, $id, null, $type, $name
+ return $this->newMorphTo(
+ $this->newQuery()->setEagerLoads([]), $this, $id, $ownerKey, $type, $name
);
}
@@ -171,19 +261,36 @@ trait HasRelationships
* @param string $name
* @param string $type
* @param string $id
+ * @param string $ownerKey
* @return \Illuminate\Database\Eloquent\Relations\MorphTo
*/
- protected function morphInstanceTo($target, $name, $type, $id)
+ protected function morphInstanceTo($target, $name, $type, $id, $ownerKey)
{
$instance = $this->newRelatedInstance(
static::getActualClassNameForMorph($target)
);
- return new MorphTo(
- $instance->newQuery(), $this, $id, $instance->getKeyName(), $type, $name
+ return $this->newMorphTo(
+ $instance->newQuery(), $this, $id, $ownerKey ?? $instance->getKeyName(), $type, $name
);
}
+ /**
+ * Instantiate a new MorphTo relationship.
+ *
+ * @param \Illuminate\Database\Eloquent\Builder $query
+ * @param \Illuminate\Database\Eloquent\Model $parent
+ * @param string $foreignKey
+ * @param string $ownerKey
+ * @param string $type
+ * @param string $relation
+ * @return \Illuminate\Database\Eloquent\Relations\MorphTo
+ */
+ protected function newMorphTo(Builder $query, Model $parent, $foreignKey, $ownerKey, $type, $relation)
+ {
+ return new MorphTo($query, $parent, $foreignKey, $ownerKey, $type, $relation);
+ }
+
/**
* Retrieve the actual class name for a given morph class.
*
@@ -202,7 +309,7 @@ trait HasRelationships
*/
protected function guessBelongsToRelation()
{
- list($one, $two, $caller) = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 3);
+ [$one, $two, $caller] = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 3);
return $caller['function'];
}
@@ -223,11 +330,25 @@ trait HasRelationships
$localKey = $localKey ?: $this->getKeyName();
- return new HasMany(
+ return $this->newHasMany(
$instance->newQuery(), $this, $instance->getTable().'.'.$foreignKey, $localKey
);
}
+ /**
+ * Instantiate a new HasMany relationship.
+ *
+ * @param \Illuminate\Database\Eloquent\Builder $query
+ * @param \Illuminate\Database\Eloquent\Model $parent
+ * @param string $foreignKey
+ * @param string $localKey
+ * @return \Illuminate\Database\Eloquent\Relations\HasMany
+ */
+ protected function newHasMany(Builder $query, Model $parent, $foreignKey, $localKey)
+ {
+ return new HasMany($query, $parent, $foreignKey, $localKey);
+ }
+
/**
* Define a has-many-through relationship.
*
@@ -236,9 +357,10 @@ trait HasRelationships
* @param string|null $firstKey
* @param string|null $secondKey
* @param string|null $localKey
+ * @param string|null $secondLocalKey
* @return \Illuminate\Database\Eloquent\Relations\HasManyThrough
*/
- public function hasManyThrough($related, $through, $firstKey = null, $secondKey = null, $localKey = null)
+ public function hasManyThrough($related, $through, $firstKey = null, $secondKey = null, $localKey = null, $secondLocalKey = null)
{
$through = new $through;
@@ -246,11 +368,28 @@ trait HasRelationships
$secondKey = $secondKey ?: $through->getForeignKey();
- $localKey = $localKey ?: $this->getKeyName();
+ return $this->newHasManyThrough(
+ $this->newRelatedInstance($related)->newQuery(), $this, $through,
+ $firstKey, $secondKey, $localKey ?: $this->getKeyName(),
+ $secondLocalKey ?: $through->getKeyName()
+ );
+ }
- $instance = $this->newRelatedInstance($related);
-
- return new HasManyThrough($instance->newQuery(), $this, $through, $firstKey, $secondKey, $localKey);
+ /**
+ * Instantiate a new HasManyThrough relationship.
+ *
+ * @param \Illuminate\Database\Eloquent\Builder $query
+ * @param \Illuminate\Database\Eloquent\Model $farParent
+ * @param \Illuminate\Database\Eloquent\Model $throughParent
+ * @param string $firstKey
+ * @param string $secondKey
+ * @param string $localKey
+ * @param string $secondLocalKey
+ * @return \Illuminate\Database\Eloquent\Relations\HasManyThrough
+ */
+ protected function newHasManyThrough(Builder $query, Model $farParent, Model $throughParent, $firstKey, $secondKey, $localKey, $secondLocalKey)
+ {
+ return new HasManyThrough($query, $farParent, $throughParent, $firstKey, $secondKey, $localKey, $secondLocalKey);
}
/**
@@ -270,13 +409,28 @@ trait HasRelationships
// Here we will gather up the morph type and ID for the relationship so that we
// can properly query the intermediate table of a relation. Finally, we will
// get the table and create the relationship instances for the developers.
- list($type, $id) = $this->getMorphs($name, $type, $id);
+ [$type, $id] = $this->getMorphs($name, $type, $id);
$table = $instance->getTable();
$localKey = $localKey ?: $this->getKeyName();
- return new MorphMany($instance->newQuery(), $this, $table.'.'.$type, $table.'.'.$id, $localKey);
+ return $this->newMorphMany($instance->newQuery(), $this, $table.'.'.$type, $table.'.'.$id, $localKey);
+ }
+
+ /**
+ * Instantiate a new MorphMany relationship.
+ *
+ * @param \Illuminate\Database\Eloquent\Builder $query
+ * @param \Illuminate\Database\Eloquent\Model $parent
+ * @param string $type
+ * @param string $id
+ * @param string $localKey
+ * @return \Illuminate\Database\Eloquent\Relations\MorphMany
+ */
+ protected function newMorphMany(Builder $query, Model $parent, $type, $id, $localKey)
+ {
+ return new MorphMany($query, $parent, $type, $id, $localKey);
}
/**
@@ -284,12 +438,15 @@ trait HasRelationships
*
* @param string $related
* @param string $table
- * @param string $foreignKey
+ * @param string $foreignPivotKey
+ * @param string $relatedPivotKey
+ * @param string $parentKey
* @param string $relatedKey
* @param string $relation
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
*/
- public function belongsToMany($related, $table = null, $foreignKey = null, $relatedKey = null, $relation = null)
+ public function belongsToMany($related, $table = null, $foreignPivotKey = null, $relatedPivotKey = null,
+ $parentKey = null, $relatedKey = null, $relation = null)
{
// If no relationship name was passed, we will pull backtraces to get the
// name of the calling function. We will use that function name as the
@@ -303,34 +460,59 @@ trait HasRelationships
// instances as well as the relationship instances we need for this.
$instance = $this->newRelatedInstance($related);
- $foreignKey = $foreignKey ?: $this->getForeignKey();
+ $foreignPivotKey = $foreignPivotKey ?: $this->getForeignKey();
- $relatedKey = $relatedKey ?: $instance->getForeignKey();
+ $relatedPivotKey = $relatedPivotKey ?: $instance->getForeignKey();
// If no table name was provided, we can guess it by concatenating the two
// models using underscores in alphabetical order. The two model names
// are transformed to snake case from their default CamelCase also.
if (is_null($table)) {
- $table = $this->joiningTable($related);
+ $table = $this->joiningTable($related, $instance);
}
- return new BelongsToMany(
- $instance->newQuery(), $this, $table, $foreignKey, $relatedKey, $relation
+ return $this->newBelongsToMany(
+ $instance->newQuery(), $this, $table, $foreignPivotKey,
+ $relatedPivotKey, $parentKey ?: $this->getKeyName(),
+ $relatedKey ?: $instance->getKeyName(), $relation
);
}
+ /**
+ * Instantiate a new BelongsToMany relationship.
+ *
+ * @param \Illuminate\Database\Eloquent\Builder $query
+ * @param \Illuminate\Database\Eloquent\Model $parent
+ * @param string $table
+ * @param string $foreignPivotKey
+ * @param string $relatedPivotKey
+ * @param string $parentKey
+ * @param string $relatedKey
+ * @param string $relationName
+ * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
+ */
+ protected function newBelongsToMany(Builder $query, Model $parent, $table, $foreignPivotKey, $relatedPivotKey,
+ $parentKey, $relatedKey, $relationName = null)
+ {
+ return new BelongsToMany($query, $parent, $table, $foreignPivotKey, $relatedPivotKey, $parentKey, $relatedKey, $relationName);
+ }
+
/**
* Define a polymorphic many-to-many relationship.
*
* @param string $related
* @param string $name
* @param string $table
- * @param string $foreignKey
+ * @param string $foreignPivotKey
+ * @param string $relatedPivotKey
+ * @param string $parentKey
* @param string $relatedKey
* @param bool $inverse
* @return \Illuminate\Database\Eloquent\Relations\MorphToMany
*/
- public function morphToMany($related, $name, $table = null, $foreignKey = null, $relatedKey = null, $inverse = false)
+ public function morphToMany($related, $name, $table = null, $foreignPivotKey = null,
+ $relatedPivotKey = null, $parentKey = null,
+ $relatedKey = null, $inverse = false)
{
$caller = $this->guessBelongsToManyRelation();
@@ -339,52 +521,91 @@ trait HasRelationships
// instances, as well as the relationship instances we need for these.
$instance = $this->newRelatedInstance($related);
- $foreignKey = $foreignKey ?: $name.'_id';
+ $foreignPivotKey = $foreignPivotKey ?: $name.'_id';
- $relatedKey = $relatedKey ?: $instance->getForeignKey();
+ $relatedPivotKey = $relatedPivotKey ?: $instance->getForeignKey();
// Now we're ready to create a new query builder for this related model and
// the relationship instances for this relation. This relations will set
// appropriate query constraints then entirely manages the hydrations.
- $table = $table ?: Str::plural($name);
+ if (! $table) {
+ $words = preg_split('/(_)/u', $name, -1, PREG_SPLIT_DELIM_CAPTURE);
- return new MorphToMany(
+ $lastWord = array_pop($words);
+
+ $table = implode('', $words).Str::plural($lastWord);
+ }
+
+ return $this->newMorphToMany(
$instance->newQuery(), $this, $name, $table,
- $foreignKey, $relatedKey, $caller, $inverse
+ $foreignPivotKey, $relatedPivotKey, $parentKey ?: $this->getKeyName(),
+ $relatedKey ?: $instance->getKeyName(), $caller, $inverse
);
}
+ /**
+ * Instantiate a new MorphToMany relationship.
+ *
+ * @param \Illuminate\Database\Eloquent\Builder $query
+ * @param \Illuminate\Database\Eloquent\Model $parent
+ * @param string $name
+ * @param string $table
+ * @param string $foreignPivotKey
+ * @param string $relatedPivotKey
+ * @param string $parentKey
+ * @param string $relatedKey
+ * @param string $relationName
+ * @param bool $inverse
+ * @return \Illuminate\Database\Eloquent\Relations\MorphToMany
+ */
+ protected function newMorphToMany(Builder $query, Model $parent, $name, $table, $foreignPivotKey,
+ $relatedPivotKey, $parentKey, $relatedKey,
+ $relationName = null, $inverse = false)
+ {
+ return new MorphToMany($query, $parent, $name, $table, $foreignPivotKey, $relatedPivotKey, $parentKey, $relatedKey,
+ $relationName, $inverse);
+ }
+
/**
* Define a polymorphic, inverse many-to-many relationship.
*
* @param string $related
* @param string $name
* @param string $table
- * @param string $foreignKey
+ * @param string $foreignPivotKey
+ * @param string $relatedPivotKey
+ * @param string $parentKey
* @param string $relatedKey
* @return \Illuminate\Database\Eloquent\Relations\MorphToMany
*/
- public function morphedByMany($related, $name, $table = null, $foreignKey = null, $relatedKey = null)
+ public function morphedByMany($related, $name, $table = null, $foreignPivotKey = null,
+ $relatedPivotKey = null, $parentKey = null, $relatedKey = null)
{
- $foreignKey = $foreignKey ?: $this->getForeignKey();
+ $foreignPivotKey = $foreignPivotKey ?: $this->getForeignKey();
// For the inverse of the polymorphic many-to-many relations, we will change
// the way we determine the foreign and other keys, as it is the opposite
// of the morph-to-many method since we're figuring out these inverses.
- $relatedKey = $relatedKey ?: $name.'_id';
+ $relatedPivotKey = $relatedPivotKey ?: $name.'_id';
- return $this->morphToMany($related, $name, $table, $foreignKey, $relatedKey, true);
+ return $this->morphToMany(
+ $related, $name, $table, $foreignPivotKey,
+ $relatedPivotKey, $parentKey, $relatedKey, true
+ );
}
/**
- * Get the relationship name of the belongs to many.
+ * Get the relationship name of the belongsToMany relationship.
*
- * @return string
+ * @return string|null
*/
protected function guessBelongsToManyRelation()
{
$caller = Arr::first(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS), function ($trace) {
- return ! in_array($trace['function'], Model::$manyMethods);
+ return ! in_array(
+ $trace['function'],
+ array_merge(static::$manyMethods, ['guessBelongsToManyRelation'])
+ );
});
return ! is_null($caller) ? $caller['function'] : null;
@@ -394,24 +615,36 @@ trait HasRelationships
* Get the joining table name for a many-to-many relation.
*
* @param string $related
+ * @param \Illuminate\Database\Eloquent\Model|null $instance
* @return string
*/
- public function joiningTable($related)
+ public function joiningTable($related, $instance = null)
{
// The joining table name, by convention, is simply the snake cased models
// sorted alphabetically and concatenated with an underscore, so we can
// just sort the models and join them together to get the table name.
- $models = [
- Str::snake(class_basename($related)),
- Str::snake(class_basename($this)),
+ $segments = [
+ $instance ? $instance->joiningTableSegment()
+ : Str::snake(class_basename($related)),
+ $this->joiningTableSegment(),
];
// Now that we have the model names in an array we can just sort them and
// use the implode function to join them together with an underscores,
// which is typically used by convention within the database system.
- sort($models);
+ sort($segments);
- return strtolower(implode('_', $models));
+ return strtolower(implode('_', $segments));
+ }
+
+ /**
+ * Get this model's half of the intermediate table name for belongsToMany relationships.
+ *
+ * @return string
+ */
+ public function joiningTableSegment()
+ {
+ return Str::snake(class_basename($this));
}
/**
@@ -524,7 +757,7 @@ trait HasRelationships
}
/**
- * Set the specific relationship in the model.
+ * Set the given relationship on the model.
*
* @param string $relation
* @param mixed $value
@@ -537,6 +770,19 @@ trait HasRelationships
return $this;
}
+ /**
+ * Unset a loaded relationship.
+ *
+ * @param string $relation
+ * @return $this
+ */
+ public function unsetRelation($relation)
+ {
+ unset($this->relations[$relation]);
+
+ return $this;
+ }
+
/**
* Set the entire relations array on the model.
*
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasTimestamps.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasTimestamps.php
index ba640fe4..6c44a73d 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasTimestamps.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasTimestamps.php
@@ -2,7 +2,7 @@
namespace Illuminate\Database\Eloquent\Concerns;
-use Carbon\Carbon;
+use Illuminate\Support\Facades\Date;
trait HasTimestamps
{
@@ -38,11 +38,12 @@ trait HasTimestamps
{
$time = $this->freshTimestamp();
- if (! $this->isDirty(static::UPDATED_AT)) {
+ if (! is_null(static::UPDATED_AT) && ! $this->isDirty(static::UPDATED_AT)) {
$this->setUpdatedAt($time);
}
- if (! $this->exists && ! $this->isDirty(static::CREATED_AT)) {
+ if (! $this->exists && ! is_null(static::CREATED_AT) &&
+ ! $this->isDirty(static::CREATED_AT)) {
$this->setCreatedAt($time);
}
}
@@ -76,11 +77,11 @@ trait HasTimestamps
/**
* Get a fresh timestamp for the model.
*
- * @return \Carbon\Carbon
+ * @return \Illuminate\Support\Carbon
*/
public function freshTimestamp()
{
- return new Carbon;
+ return Date::now();
}
/**
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/QueriesRelationships.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/QueriesRelationships.php
index ffae137e..c7173a85 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/QueriesRelationships.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/QueriesRelationships.php
@@ -3,10 +3,11 @@
namespace Illuminate\Database\Eloquent\Concerns;
use Closure;
-use Illuminate\Support\Arr;
+use RuntimeException;
use Illuminate\Support\Str;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Query\Expression;
+use Illuminate\Database\Eloquent\Relations\MorphTo;
use Illuminate\Database\Eloquent\Relations\Relation;
use Illuminate\Database\Query\Builder as QueryBuilder;
@@ -15,7 +16,7 @@ trait QueriesRelationships
/**
* Add a relationship count / exists condition to the query.
*
- * @param string $relation
+ * @param string|\Illuminate\Database\Eloquent\Relations\Relation $relation
* @param string $operator
* @param int $count
* @param string $boolean
@@ -24,11 +25,17 @@ trait QueriesRelationships
*/
public function has($relation, $operator = '>=', $count = 1, $boolean = 'and', Closure $callback = null)
{
- if (strpos($relation, '.') !== false) {
- return $this->hasNested($relation, $operator, $count, $boolean, $callback);
+ if (is_string($relation)) {
+ if (strpos($relation, '.') !== false) {
+ return $this->hasNested($relation, $operator, $count, $boolean, $callback);
+ }
+
+ $relation = $this->getRelationWithoutConstraints($relation);
}
- $relation = $this->getRelationWithoutConstraints($relation);
+ if ($relation instanceof MorphTo) {
+ throw new RuntimeException('Please use whereHasMorph() for MorphTo relationships.');
+ }
// If we only need to check for the existence of the relation, then we can optimize
// the subquery to only run a "where exists" clause instead of this full "count"
@@ -38,7 +45,7 @@ trait QueriesRelationships
: 'getRelationExistenceCountQuery';
$hasQuery = $relation->{$method}(
- $relation->getRelated()->newQuery(), $this
+ $relation->getRelated()->newQueryWithoutRelationships(), $this
);
// Next we will call any given callback as an "anonymous" scope so they can get the
@@ -69,7 +76,14 @@ trait QueriesRelationships
{
$relations = explode('.', $relations);
- $closure = function ($q) use (&$closure, &$relations, $operator, $count, $boolean, $callback) {
+ $doesntHave = $operator === '<' && $count === 1;
+
+ if ($doesntHave) {
+ $operator = '>=';
+ $count = 1;
+ }
+
+ $closure = function ($q) use (&$closure, &$relations, $operator, $count, $callback) {
// 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.
@@ -78,7 +92,7 @@ trait QueriesRelationships
: $q->has(array_shift($relations), $operator, $count, 'and', $callback);
};
- return $this->has(array_shift($relations), '>=', 1, $boolean, $closure);
+ return $this->has(array_shift($relations), $doesntHave ? '<' : '>=', 1, $boolean, $closure);
}
/**
@@ -170,6 +184,167 @@ trait QueriesRelationships
return $this->doesntHave($relation, 'or', $callback);
}
+ /**
+ * Add a polymorphic relationship count / exists condition to the query.
+ *
+ * @param string $relation
+ * @param string|array $types
+ * @param string $operator
+ * @param int $count
+ * @param string $boolean
+ * @param \Closure|null $callback
+ * @return \Illuminate\Database\Eloquent\Builder|static
+ */
+ public function hasMorph($relation, $types, $operator = '>=', $count = 1, $boolean = 'and', Closure $callback = null)
+ {
+ $relation = $this->getRelationWithoutConstraints($relation);
+
+ $types = (array) $types;
+
+ if ($types === ['*']) {
+ $types = $this->model->newModelQuery()->distinct()->pluck($relation->getMorphType())->all();
+
+ foreach ($types as &$type) {
+ $type = Relation::getMorphedModel($type) ?? $type;
+ }
+ }
+
+ return $this->where(function ($query) use ($relation, $callback, $operator, $count, $types) {
+ foreach ($types as $type) {
+ $query->orWhere(function ($query) use ($relation, $callback, $operator, $count, $type) {
+ $belongsTo = $this->getBelongsToRelation($relation, $type);
+
+ if ($callback) {
+ $callback = function ($query) use ($callback, $type) {
+ return $callback($query, $type);
+ };
+ }
+
+ $query->where($relation->getMorphType(), '=', (new $type)->getMorphClass())
+ ->whereHas($belongsTo, $callback, $operator, $count);
+ });
+ }
+ }, null, null, $boolean);
+ }
+
+ /**
+ * Get the BelongsTo relationship for a single polymorphic type.
+ *
+ * @param \Illuminate\Database\Eloquent\Relations\MorphTo $relation
+ * @param string $type
+ * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
+ */
+ protected function getBelongsToRelation(MorphTo $relation, $type)
+ {
+ $belongsTo = Relation::noConstraints(function () use ($relation, $type) {
+ return $this->model->belongsTo(
+ $type,
+ $relation->getForeignKeyName(),
+ $relation->getOwnerKeyName()
+ );
+ });
+
+ $belongsTo->getQuery()->mergeConstraintsFrom($relation->getQuery());
+
+ return $belongsTo;
+ }
+
+ /**
+ * Add a polymorphic relationship count / exists condition to the query with an "or".
+ *
+ * @param string $relation
+ * @param string|array $types
+ * @param string $operator
+ * @param int $count
+ * @return \Illuminate\Database\Eloquent\Builder|static
+ */
+ public function orHasMorph($relation, $types, $operator = '>=', $count = 1)
+ {
+ return $this->hasMorph($relation, $types, $operator, $count, 'or');
+ }
+
+ /**
+ * Add a polymorphic relationship count / exists condition to the query.
+ *
+ * @param string $relation
+ * @param string|array $types
+ * @param string $boolean
+ * @param \Closure|null $callback
+ * @return \Illuminate\Database\Eloquent\Builder|static
+ */
+ public function doesntHaveMorph($relation, $types, $boolean = 'and', Closure $callback = null)
+ {
+ return $this->hasMorph($relation, $types, '<', 1, $boolean, $callback);
+ }
+
+ /**
+ * Add a polymorphic relationship count / exists condition to the query with an "or".
+ *
+ * @param string $relation
+ * @param string|array $types
+ * @return \Illuminate\Database\Eloquent\Builder|static
+ */
+ public function orDoesntHaveMorph($relation, $types)
+ {
+ return $this->doesntHaveMorph($relation, $types, 'or');
+ }
+
+ /**
+ * Add a polymorphic relationship count / exists condition to the query with where clauses.
+ *
+ * @param string $relation
+ * @param string|array $types
+ * @param \Closure|null $callback
+ * @param string $operator
+ * @param int $count
+ * @return \Illuminate\Database\Eloquent\Builder|static
+ */
+ public function whereHasMorph($relation, $types, Closure $callback = null, $operator = '>=', $count = 1)
+ {
+ return $this->hasMorph($relation, $types, $operator, $count, 'and', $callback);
+ }
+
+ /**
+ * Add a polymorphic relationship count / exists condition to the query with where clauses and an "or".
+ *
+ * @param string $relation
+ * @param string|array $types
+ * @param \Closure $callback
+ * @param string $operator
+ * @param int $count
+ * @return \Illuminate\Database\Eloquent\Builder|static
+ */
+ public function orWhereHasMorph($relation, $types, Closure $callback = null, $operator = '>=', $count = 1)
+ {
+ return $this->hasMorph($relation, $types, $operator, $count, 'or', $callback);
+ }
+
+ /**
+ * Add a polymorphic relationship count / exists condition to the query with where clauses.
+ *
+ * @param string $relation
+ * @param string|array $types
+ * @param \Closure|null $callback
+ * @return \Illuminate\Database\Eloquent\Builder|static
+ */
+ public function whereDoesntHaveMorph($relation, $types, Closure $callback = null)
+ {
+ return $this->doesntHaveMorph($relation, $types, 'and', $callback);
+ }
+
+ /**
+ * Add a polymorphic relationship count / exists condition to the query with where clauses and an "or".
+ *
+ * @param string $relation
+ * @param string|array $types
+ * @param \Closure $callback
+ * @return \Illuminate\Database\Eloquent\Builder|static
+ */
+ public function orWhereDoesntHaveMorph($relation, $types, Closure $callback = null)
+ {
+ return $this->doesntHaveMorph($relation, $types, 'or', $callback);
+ }
+
/**
* Add subselect queries to count the relations.
*
@@ -196,8 +371,8 @@ trait QueriesRelationships
unset($alias);
- if (count($segments) == 3 && Str::lower($segments[1]) == 'as') {
- list($name, $alias) = [$segments[0], $segments[2]];
+ if (count($segments) === 3 && Str::lower($segments[1]) === 'as') {
+ [$name, $alias] = [$segments[0], $segments[2]];
}
$relation = $this->getRelationWithoutConstraints($name);
@@ -211,14 +386,18 @@ trait QueriesRelationships
$query->callScope($constraints);
- $query->mergeConstraintsFrom($relation->getQuery());
+ $query = $query->mergeConstraintsFrom($relation->getQuery())->toBase();
+
+ if (count($query->columns) > 1) {
+ $query->columns = [$query->columns[0]];
+ }
// Finally we will add the proper result column alias to the query and run the subselect
// statement against the query builder. Then we will return the builder instance back
// to the developer for further constraint chaining that needs to take place on it.
- $column = snake_case(isset($alias) ? $alias : $name).'_count';
+ $column = $alias ?? Str::snake($name.'_count');
- $this->selectSub($query->toBase(), $column);
+ $this->selectSub($query, $column);
}
return $this;
@@ -239,7 +418,7 @@ trait QueriesRelationships
$hasQuery->mergeConstraintsFrom($relation->getQuery());
return $this->canUseExistsForExistenceCheck($operator, $count)
- ? $this->addWhereExistsQuery($hasQuery->toBase(), $boolean, $not = ($operator === '<' && $count === 1))
+ ? $this->addWhereExistsQuery($hasQuery->toBase(), $boolean, $operator === '<' && $count === 1)
: $this->addWhereCountQuery($hasQuery->toBase(), $operator, $count, $boolean);
}
@@ -251,9 +430,7 @@ trait QueriesRelationships
*/
public function mergeConstraintsFrom(Builder $from)
{
- $whereBindings = Arr::get(
- $from->getQuery()->getRawBindings(), 'where', []
- );
+ $whereBindings = $from->getQuery()->getRawBindings()['where'] ?? [];
// Here we have some other query that we want to merge the where constraints from. We will
// copy over any where constraints on the query as well as remove any global scopes the
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Factory.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Factory.php
index 0b57576e..4ca3d62f 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Factory.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Factory.php
@@ -22,6 +22,20 @@ class Factory implements ArrayAccess
*/
protected $states = [];
+ /**
+ * The registered after making callbacks.
+ *
+ * @var array
+ */
+ protected $afterMaking = [];
+
+ /**
+ * The registered after creating callbacks.
+ *
+ * @var array
+ */
+ protected $afterCreating = [];
+
/**
* The Faker instance for the builder.
*
@@ -87,16 +101,72 @@ class Factory implements ArrayAccess
*
* @param string $class
* @param string $state
- * @param callable $attributes
+ * @param callable|array $attributes
* @return $this
*/
- public function state($class, $state, callable $attributes)
+ public function state($class, $state, $attributes)
{
$this->states[$class][$state] = $attributes;
return $this;
}
+ /**
+ * Define a callback to run after making a model.
+ *
+ * @param string $class
+ * @param callable $callback
+ * @param string $name
+ * @return $this
+ */
+ public function afterMaking($class, callable $callback, $name = 'default')
+ {
+ $this->afterMaking[$class][$name][] = $callback;
+
+ return $this;
+ }
+
+ /**
+ * Define a callback to run after making a model with given state.
+ *
+ * @param string $class
+ * @param string $state
+ * @param callable $callback
+ * @return $this
+ */
+ public function afterMakingState($class, $state, callable $callback)
+ {
+ return $this->afterMaking($class, $callback, $state);
+ }
+
+ /**
+ * Define a callback to run after creating a model.
+ *
+ * @param string $class
+ * @param callable $callback
+ * @param string $name
+ * @return $this
+ */
+ public function afterCreating($class, callable $callback, $name = 'default')
+ {
+ $this->afterCreating[$class][$name][] = $callback;
+
+ return $this;
+ }
+
+ /**
+ * Define a callback to run after creating a model with given state.
+ *
+ * @param string $class
+ * @param string $state
+ * @param callable $callback
+ * @return $this
+ */
+ public function afterCreatingState($class, $state, callable $callback)
+ {
+ return $this->afterCreating($class, $callback, $state);
+ }
+
/**
* Create an instance of the given model and persist it to the database.
*
@@ -184,7 +254,10 @@ class Factory implements ArrayAccess
*/
public function of($class, $name = 'default')
{
- return new FactoryBuilder($class, $name, $this->definitions, $this->states, $this->faker);
+ return new FactoryBuilder(
+ $class, $name, $this->definitions, $this->states,
+ $this->afterMaking, $this->afterCreating, $this->faker
+ );
}
/**
@@ -237,7 +310,7 @@ class Factory implements ArrayAccess
*/
public function offsetSet($offset, $value)
{
- return $this->define($offset, $value);
+ $this->define($offset, $value);
}
/**
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/FactoryBuilder.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/FactoryBuilder.php
index ffa4789e..87bb0d87 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/FactoryBuilder.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/FactoryBuilder.php
@@ -31,6 +31,13 @@ class FactoryBuilder
*/
protected $name = 'default';
+ /**
+ * The database connection on which the model instance should be persisted.
+ *
+ * @var string
+ */
+ protected $connection;
+
/**
* The model states.
*
@@ -38,6 +45,20 @@ class FactoryBuilder
*/
protected $states;
+ /**
+ * The model after making callbacks.
+ *
+ * @var array
+ */
+ protected $afterMaking = [];
+
+ /**
+ * The model after creating callbacks.
+ *
+ * @var array
+ */
+ protected $afterCreating = [];
+
/**
* The states to apply.
*
@@ -66,16 +87,21 @@ class FactoryBuilder
* @param string $name
* @param array $definitions
* @param array $states
+ * @param array $afterMaking
+ * @param array $afterCreating
* @param \Faker\Generator $faker
* @return void
*/
- public function __construct($class, $name, array $definitions, array $states, Faker $faker)
+ public function __construct($class, $name, array $definitions, array $states,
+ array $afterMaking, array $afterCreating, Faker $faker)
{
$this->name = $name;
$this->class = $class;
$this->faker = $faker;
$this->states = $states;
$this->definitions = $definitions;
+ $this->afterMaking = $afterMaking;
+ $this->afterCreating = $afterCreating;
}
/**
@@ -91,6 +117,17 @@ class FactoryBuilder
return $this;
}
+ /**
+ * Set the state to be applied to the model.
+ *
+ * @param string $state
+ * @return $this
+ */
+ public function state($state)
+ {
+ return $this->states([$state]);
+ }
+
/**
* Set the states to be applied to the model.
*
@@ -104,6 +141,19 @@ class FactoryBuilder
return $this;
}
+ /**
+ * Set the database connection on which the model instance should be persisted.
+ *
+ * @param string $name
+ * @return $this
+ */
+ public function connection($name)
+ {
+ $this->connection = $name;
+
+ return $this;
+ }
+
/**
* Create a model and persist it in the database if requested.
*
@@ -129,8 +179,12 @@ class FactoryBuilder
if ($results instanceof Model) {
$this->store(collect([$results]));
+
+ $this->callAfterCreating(collect([$results]));
} else {
$this->store($results);
+
+ $this->callAfterCreating($results);
}
return $results;
@@ -145,7 +199,9 @@ class FactoryBuilder
protected function store($results)
{
$results->each(function ($model) {
- $model->setConnection($model->newQueryWithoutScopes()->getConnection()->getName());
+ if (! isset($this->connection)) {
+ $model->setConnection($model->newQueryWithoutScopes()->getConnection()->getName());
+ }
$model->save();
});
@@ -160,16 +216,22 @@ class FactoryBuilder
public function make(array $attributes = [])
{
if ($this->amount === null) {
- return $this->makeInstance($attributes);
+ return tap($this->makeInstance($attributes), function ($instance) {
+ $this->callAfterMaking(collect([$instance]));
+ });
}
if ($this->amount < 1) {
return (new $this->class)->newCollection();
}
- return (new $this->class)->newCollection(array_map(function () use ($attributes) {
+ $instances = (new $this->class)->newCollection(array_map(function () use ($attributes) {
return $this->makeInstance($attributes);
}, range(1, $this->amount)));
+
+ $this->callAfterMaking($instances);
+
+ return $instances;
}
/**
@@ -198,9 +260,15 @@ class FactoryBuilder
*
* @param array $attributes
* @return mixed
+ *
+ * @throws \InvalidArgumentException
*/
protected function getRawAttributes(array $attributes = [])
{
+ if (! isset($this->definitions[$this->class][$this->name])) {
+ throw new InvalidArgumentException("Unable to locate factory with name [{$this->name}] [{$this->class}].");
+ }
+
$definition = call_user_func(
$this->definitions[$this->class][$this->name],
$this->faker, $attributes
@@ -216,19 +284,19 @@ class FactoryBuilder
*
* @param array $attributes
* @return \Illuminate\Database\Eloquent\Model
- *
- * @throws \InvalidArgumentException
*/
protected function makeInstance(array $attributes = [])
{
return Model::unguarded(function () use ($attributes) {
- if (! isset($this->definitions[$this->class][$this->name])) {
- throw new InvalidArgumentException("Unable to locate factory with name [{$this->name}] [{$this->class}].");
- }
-
- return new $this->class(
+ $instance = new $this->class(
$this->getRawAttributes($attributes)
);
+
+ if (isset($this->connection)) {
+ $instance->setConnection($this->connection);
+ }
+
+ return $instance;
});
}
@@ -238,23 +306,50 @@ class FactoryBuilder
* @param array $definition
* @param array $attributes
* @return array
+ *
+ * @throws \InvalidArgumentException
*/
protected function applyStates(array $definition, array $attributes = [])
{
foreach ($this->activeStates as $state) {
if (! isset($this->states[$this->class][$state])) {
+ if ($this->stateHasAfterCallback($state)) {
+ continue;
+ }
+
throw new InvalidArgumentException("Unable to locate [{$state}] state for [{$this->class}].");
}
- $definition = array_merge($definition, call_user_func(
- $this->states[$this->class][$state],
- $this->faker, $attributes
- ));
+ $definition = array_merge(
+ $definition,
+ $this->stateAttributes($state, $attributes)
+ );
}
return $definition;
}
+ /**
+ * Get the state attributes.
+ *
+ * @param string $state
+ * @param array $attributes
+ * @return array
+ */
+ protected function stateAttributes($state, array $attributes)
+ {
+ $stateAttributes = $this->states[$this->class][$state];
+
+ if (! is_callable($stateAttributes)) {
+ return $stateAttributes;
+ }
+
+ return call_user_func(
+ $stateAttributes,
+ $this->faker, $attributes
+ );
+ }
+
/**
* Expand all attributes to their underlying values.
*
@@ -264,7 +359,7 @@ class FactoryBuilder
protected function expandAttributes(array $attributes)
{
foreach ($attributes as &$attribute) {
- if (is_callable($attribute) && ! is_string($attribute)) {
+ if (is_callable($attribute) && ! is_string($attribute) && ! is_array($attribute)) {
$attribute = $attribute($attributes);
}
@@ -279,4 +374,75 @@ class FactoryBuilder
return $attributes;
}
+
+ /**
+ * Run after making callbacks on a collection of models.
+ *
+ * @param \Illuminate\Support\Collection $models
+ * @return void
+ */
+ public function callAfterMaking($models)
+ {
+ $this->callAfter($this->afterMaking, $models);
+ }
+
+ /**
+ * Run after creating callbacks on a collection of models.
+ *
+ * @param \Illuminate\Support\Collection $models
+ * @return void
+ */
+ public function callAfterCreating($models)
+ {
+ $this->callAfter($this->afterCreating, $models);
+ }
+
+ /**
+ * Call after callbacks for each model and state.
+ *
+ * @param array $afterCallbacks
+ * @param \Illuminate\Support\Collection $models
+ * @return void
+ */
+ protected function callAfter(array $afterCallbacks, $models)
+ {
+ $states = array_merge([$this->name], $this->activeStates);
+
+ $models->each(function ($model) use ($states, $afterCallbacks) {
+ foreach ($states as $state) {
+ $this->callAfterCallbacks($afterCallbacks, $model, $state);
+ }
+ });
+ }
+
+ /**
+ * Call after callbacks for each model and state.
+ *
+ * @param array $afterCallbacks
+ * @param \Illuminate\Database\Eloquent\Model $model
+ * @param string $state
+ * @return void
+ */
+ protected function callAfterCallbacks(array $afterCallbacks, $model, $state)
+ {
+ if (! isset($afterCallbacks[$this->class][$state])) {
+ return;
+ }
+
+ foreach ($afterCallbacks[$this->class][$state] as $callback) {
+ $callback($model, $this->faker);
+ }
+ }
+
+ /**
+ * Determine if the given state has an "after" callback.
+ *
+ * @param string $state
+ * @return bool
+ */
+ protected function stateHasAfterCallback($state)
+ {
+ return isset($this->afterMaking[$this->class][$state]) ||
+ isset($this->afterCreating[$this->class][$state]);
+ }
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php
index 563628b3..a6d2fa9c 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php
@@ -9,16 +9,14 @@ use Illuminate\Support\Arr;
use Illuminate\Support\Str;
use Illuminate\Contracts\Support\Jsonable;
use Illuminate\Contracts\Support\Arrayable;
+use Illuminate\Support\Traits\ForwardsCalls;
use Illuminate\Contracts\Routing\UrlRoutable;
use Illuminate\Contracts\Queue\QueueableEntity;
use Illuminate\Database\Eloquent\Relations\Pivot;
-use Illuminate\Database\Query\Builder as QueryBuilder;
+use Illuminate\Contracts\Queue\QueueableCollection;
+use Illuminate\Support\Collection as BaseCollection;
use Illuminate\Database\ConnectionResolverInterface as Resolver;
-/**
- * @mixin \Illuminate\Database\Eloquent\Builder
- * @mixin \Illuminate\Database\Query\Builder
- */
abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializable, QueueableEntity, UrlRoutable
{
use Concerns\HasAttributes,
@@ -27,12 +25,13 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab
Concerns\HasRelationships,
Concerns\HasTimestamps,
Concerns\HidesAttributes,
- Concerns\GuardsAttributes;
+ Concerns\GuardsAttributes,
+ ForwardsCalls;
/**
* The connection name for the model.
*
- * @var string
+ * @var string|null
*/
protected $connection;
@@ -51,7 +50,7 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab
protected $primaryKey = 'id';
/**
- * The "type" of the auto-incrementing ID.
+ * The "type" of the primary key ID.
*
* @var string
*/
@@ -120,6 +119,13 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab
*/
protected static $booted = [];
+ /**
+ * The array of trait initializers that will be called on each new instance.
+ *
+ * @var array
+ */
+ protected static $traitInitializers = [];
+
/**
* The array of global scopes on the model.
*
@@ -127,6 +133,13 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab
*/
protected static $globalScopes = [];
+ /**
+ * The list of models classes that should not be affected with touch.
+ *
+ * @var array
+ */
+ protected static $ignoreOnTouch = [];
+
/**
* The name of the "created at" column.
*
@@ -151,6 +164,8 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab
{
$this->bootIfNotBooted();
+ $this->initializeTraits();
+
$this->syncOriginal();
$this->fill($attributes);
@@ -193,10 +208,38 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab
{
$class = static::class;
+ $booted = [];
+
+ static::$traitInitializers[$class] = [];
+
foreach (class_uses_recursive($class) as $trait) {
- if (method_exists($class, $method = 'boot'.class_basename($trait))) {
+ $method = 'boot'.class_basename($trait);
+
+ if (method_exists($class, $method) && ! in_array($method, $booted)) {
forward_static_call([$class, $method]);
+
+ $booted[] = $method;
}
+
+ if (method_exists($class, $method = 'initialize'.class_basename($trait))) {
+ static::$traitInitializers[$class][] = $method;
+
+ static::$traitInitializers[$class] = array_unique(
+ static::$traitInitializers[$class]
+ );
+ }
+ }
+ }
+
+ /**
+ * Initialize any initializable traits on the model.
+ *
+ * @return void
+ */
+ protected function initializeTraits()
+ {
+ foreach (static::$traitInitializers[static::class] as $method) {
+ $this->{$method}();
}
}
@@ -212,6 +255,58 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab
static::$globalScopes = [];
}
+ /**
+ * Disables relationship model touching for the current class during given callback scope.
+ *
+ * @param callable $callback
+ * @return void
+ */
+ public static function withoutTouching(callable $callback)
+ {
+ static::withoutTouchingOn([static::class], $callback);
+ }
+
+ /**
+ * Disables relationship model touching for the given model classes during given callback scope.
+ *
+ * @param array $models
+ * @param callable $callback
+ * @return void
+ */
+ public static function withoutTouchingOn(array $models, callable $callback)
+ {
+ static::$ignoreOnTouch = array_values(array_merge(static::$ignoreOnTouch, $models));
+
+ try {
+ call_user_func($callback);
+ } finally {
+ static::$ignoreOnTouch = array_values(array_diff(static::$ignoreOnTouch, $models));
+ }
+ }
+
+ /**
+ * Determine if the given model is ignoring touches.
+ *
+ * @param string|null $class
+ * @return bool
+ */
+ public static function isIgnoringTouch($class = null)
+ {
+ $class = $class ?: static::class;
+
+ if (! get_class_vars($class)['timestamps'] || ! $class::UPDATED_AT) {
+ return true;
+ }
+
+ foreach (static::$ignoreOnTouch as $ignoredClass) {
+ if ($class === $ignoredClass || is_subclass_of($class, $ignoredClass)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
/**
* Fill the model with an array of attributes.
*
@@ -233,7 +328,10 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab
if ($this->isFillable($key)) {
$this->setAttribute($key, $value);
} elseif ($totallyGuarded) {
- throw new MassAssignmentException($key);
+ throw new MassAssignmentException(sprintf(
+ 'Add [%s] to fillable property to allow mass assignment on [%s].',
+ $key, get_class($this)
+ ));
}
}
@@ -253,6 +351,21 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab
});
}
+ /**
+ * Qualify the given column name by the model's table.
+ *
+ * @param string $column
+ * @return string
+ */
+ public function qualifyColumn($column)
+ {
+ if (Str::contains($column, '.')) {
+ return $column;
+ }
+
+ return $this->getTable().'.'.$column;
+ }
+
/**
* Remove the table name from a given key.
*
@@ -284,6 +397,8 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab
$this->getConnectionName()
);
+ $model->setTable($this->getTable());
+
return $model;
}
@@ -302,6 +417,8 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab
$model->setConnection($connection ?: $this->getConnectionName());
+ $model->fireModelEvent('retrieved', false);
+
return $model;
}
@@ -313,9 +430,9 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab
*/
public static function on($connection = null)
{
- // First we will just create a fresh instance of this model, and then we can
- // set the connection on the model so that it is be used for the queries
- // we execute, as well as being set on each relationship we retrieve.
+ // First we will just create a fresh instance of this model, and then we can set the
+ // connection on the model so that it is used for the queries we execute, as well
+ // as being set on every relation we retrieve without a custom connection name.
$instance = new static;
$instance->setConnection($connection);
@@ -330,9 +447,7 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab
*/
public static function onWriteConnection()
{
- $instance = new static;
-
- return $instance->newQuery()->useWritePdo();
+ return static::query()->useWritePdo();
}
/**
@@ -343,7 +458,7 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab
*/
public static function all($columns = ['*'])
{
- return (new static)->newQuery()->get(
+ return static::query()->get(
is_array($columns) ? $columns : func_get_args()
);
}
@@ -356,7 +471,7 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab
*/
public static function with($relations)
{
- return (new static)->newQuery()->with(
+ return static::query()->with(
is_string($relations) ? func_get_args() : $relations
);
}
@@ -369,7 +484,7 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab
*/
public function load($relations)
{
- $query = $this->newQuery()->with(
+ $query = $this->newQueryWithoutRelationships()->with(
is_string($relations) ? func_get_args() : $relations
);
@@ -378,11 +493,41 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab
return $this;
}
+ /**
+ * Eager load relations on the model if they are not already eager loaded.
+ *
+ * @param array|string $relations
+ * @return $this
+ */
+ public function loadMissing($relations)
+ {
+ $relations = is_string($relations) ? func_get_args() : $relations;
+
+ $this->newCollection([$this])->loadMissing($relations);
+
+ return $this;
+ }
+
+ /**
+ * Eager load relation counts on the model.
+ *
+ * @param array|string $relations
+ * @return $this
+ */
+ public function loadCount($relations)
+ {
+ $relations = is_string($relations) ? func_get_args() : $relations;
+
+ $this->newCollection([$this])->loadCount($relations);
+
+ return $this;
+ }
+
/**
* Increment a column's value by a given amount.
*
* @param string $column
- * @param int $amount
+ * @param float|int $amount
* @param array $extra
* @return int
*/
@@ -395,7 +540,7 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab
* Decrement a column's value by a given amount.
*
* @param string $column
- * @param int $amount
+ * @param float|int $amount
* @param array $extra
* @return int
*/
@@ -408,14 +553,14 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab
* Run the increment or decrement method on the model.
*
* @param string $column
- * @param int $amount
+ * @param float|int $amount
* @param array $extra
* @param string $method
* @return int
*/
protected function incrementOrDecrement($column, $amount, $extra, $method)
{
- $query = $this->newQuery();
+ $query = $this->newQueryWithoutRelationships();
if (! $this->exists) {
return $query->{$method}($column, $amount, $extra);
@@ -432,14 +577,14 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab
* Increment the underlying attribute value and sync with original.
*
* @param string $column
- * @param int $amount
+ * @param float|int $amount
* @param array $extra
* @param string $method
* @return void
*/
protected function incrementOrDecrementAttributeValue($column, $amount, $extra, $method)
{
- $this->{$column} = $this->{$column} + ($method == 'increment' ? $amount : $amount * -1);
+ $this->{$column} = $this->{$column} + ($method === 'increment' ? $amount : $amount * -1);
$this->forceFill($extra);
@@ -498,7 +643,7 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab
*/
public function save(array $options = [])
{
- $query = $this->newQueryWithoutScopes();
+ $query = $this->newModelQuery();
// If the "saving" event returns false we'll bail out of the save and return
// false, indicating that the save failed. This provides a chance for any
@@ -520,6 +665,11 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab
// which is typically an auto-increment value managed by the database.
else {
$saved = $this->performInsert($query);
+
+ if (! $this->getConnectionName() &&
+ $connection = $query->getConnection()) {
+ $this->setConnection($connection->getName());
+ }
}
// If the model is successfully saved, we need to do a few more things once
@@ -557,11 +707,11 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab
{
$this->fireModelEvent('saved', false);
- $this->syncOriginal();
-
- if (Arr::get($options, 'touch', true)) {
+ if ($this->isDirty() && ($options['touch'] ?? true)) {
$this->touchOwners();
}
+
+ $this->syncOriginal();
}
/**
@@ -594,6 +744,8 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab
if (count($dirty) > 0) {
$this->setKeysForSaveQuery($query)->update($dirty);
+ $this->syncChanges();
+
$this->fireModelEvent('updated', false);
}
@@ -620,9 +772,8 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab
*/
protected function getKeyForSaveQuery()
{
- return isset($this->original[$this->getKeyName()])
- ? $this->original[$this->getKeyName()]
- : $this->getAttribute($this->getKeyName());
+ return $this->original[$this->getKeyName()]
+ ?? $this->getKey();
}
/**
@@ -647,7 +798,7 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab
// If the model has an incrementing key, we can use the "insertGetId" method on
// the query builder, which will give us back the final inserted ID for this
// table from the database. Not all tables have to be incrementing though.
- $attributes = $this->attributes;
+ $attributes = $this->getAttributes();
if ($this->getIncrementing()) {
$this->insertAndSetId($query, $attributes);
@@ -693,7 +844,7 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab
/**
* Destroy the models for the given IDs.
*
- * @param array|int $ids
+ * @param \Illuminate\Support\Collection|array|int $ids
* @return int
*/
public static function destroy($ids)
@@ -703,12 +854,16 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab
// type value or get this total count of records deleted for logging, etc.
$count = 0;
+ if ($ids instanceof BaseCollection) {
+ $ids = $ids->all();
+ }
+
$ids = is_array($ids) ? $ids : func_get_args();
// We will actually pull the models from the database table and call delete on
// each of them individually so that their events get fired properly with a
// correct set of attributes in case the developers wants to check these.
- $key = with($instance = new static)->getKeyName();
+ $key = ($instance = new static)->getKeyName();
foreach ($instance->whereIn($key, $ids)->get() as $model) {
if ($model->delete()) {
@@ -750,8 +905,6 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab
$this->performDeleteOnModel();
- $this->exists = false;
-
// Once the model has been deleted, we will fire off the deleted event so that
// the developers may hook into post-delete operations. We will then return
// a boolean true as the delete is presumably successful on the database.
@@ -779,7 +932,9 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab
*/
protected function performDeleteOnModel()
{
- $this->setKeysForSaveQuery($this->newQueryWithoutScopes())->delete();
+ $this->setKeysForSaveQuery($this->newModelQuery())->delete();
+
+ $this->exists = false;
}
/**
@@ -799,8 +954,39 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab
*/
public function newQuery()
{
- $builder = $this->newQueryWithoutScopes();
+ return $this->registerGlobalScopes($this->newQueryWithoutScopes());
+ }
+ /**
+ * Get a new query builder that doesn't have any global scopes or eager loading.
+ *
+ * @return \Illuminate\Database\Eloquent\Builder|static
+ */
+ public function newModelQuery()
+ {
+ return $this->newEloquentBuilder(
+ $this->newBaseQueryBuilder()
+ )->setModel($this);
+ }
+
+ /**
+ * Get a new query builder with no relationships loaded.
+ *
+ * @return \Illuminate\Database\Eloquent\Builder
+ */
+ public function newQueryWithoutRelationships()
+ {
+ return $this->registerGlobalScopes($this->newModelQuery());
+ }
+
+ /**
+ * Register the global scopes for this builder instance.
+ *
+ * @param \Illuminate\Database\Eloquent\Builder $builder
+ * @return \Illuminate\Database\Eloquent\Builder
+ */
+ public function registerGlobalScopes($builder)
+ {
foreach ($this->getGlobalScopes() as $identifier => $scope) {
$builder->withGlobalScope($identifier, $scope);
}
@@ -815,12 +1001,7 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab
*/
public function newQueryWithoutScopes()
{
- $builder = $this->newEloquentBuilder($this->newBaseQueryBuilder());
-
- // Once we have the query builders, we will set the model instances so the
- // builder can easily access any information it may need from the model
- // while it is constructing and executing various queries against it.
- return $builder->setModel($this)
+ return $this->newModelQuery()
->with($this->with)
->withCount($this->withCount);
}
@@ -833,9 +1014,20 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab
*/
public function newQueryWithoutScope($scope)
{
- $builder = $this->newQuery();
+ return $this->newQuery()->withoutGlobalScope($scope);
+ }
- return $builder->withoutGlobalScope($scope);
+ /**
+ * Get a new query to restore one or more models by their queueable IDs.
+ *
+ * @param array|int $ids
+ * @return \Illuminate\Database\Eloquent\Builder
+ */
+ public function newQueryForRestoration($ids)
+ {
+ return is_array($ids)
+ ? $this->newQueryWithoutScopes()->whereIn($this->getQualifiedKeyName(), $ids)
+ : $this->newQueryWithoutScopes()->whereKey($ids);
}
/**
@@ -856,11 +1048,7 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab
*/
protected function newBaseQueryBuilder()
{
- $connection = $this->getConnection();
-
- return new QueryBuilder(
- $connection, $connection->getQueryGrammar(), $connection->getPostProcessor()
- );
+ return $this->getConnection()->query();
}
/**
@@ -884,10 +1072,10 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab
* @param string|null $using
* @return \Illuminate\Database\Eloquent\Relations\Pivot
*/
- public function newPivot(Model $parent, array $attributes, $table, $exists, $using = null)
+ public function newPivot(self $parent, array $attributes, $table, $exists, $using = null)
{
return $using ? $using::fromRawAttributes($parent, $attributes, $table, $exists)
- : new Pivot($parent, $attributes, $table, $exists);
+ : Pivot::fromAttributes($parent, $attributes, $table, $exists);
}
/**
@@ -958,9 +1146,13 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab
return $this;
}
- $this->load(array_keys($this->relations));
+ $this->setRawAttributes(
+ static::newQueryWithoutScopes()->findOrFail($this->getKey())->attributes
+ );
- $this->setRawAttributes(static::findOrFail($this->getKey())->attributes);
+ $this->load(collect($this->relations)->except('pivot')->keys()->toArray());
+
+ $this->syncOriginal();
return $this;
}
@@ -969,7 +1161,7 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab
* Clone the model into a new, non-existing instance.
*
* @param array|null $except
- * @return \Illuminate\Database\Eloquent\Model
+ * @return static
*/
public function replicate(array $except = null)
{
@@ -987,18 +1179,21 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab
$instance->setRawAttributes($attributes);
$instance->setRelations($this->relations);
+
+ $instance->fireModelEvent('replicating', false);
});
}
/**
* Determine if two models have the same ID and belong to the same table.
*
- * @param \Illuminate\Database\Eloquent\Model $model
+ * @param \Illuminate\Database\Eloquent\Model|null $model
* @return bool
*/
- public function is(Model $model)
+ public function is($model)
{
- return $this->getKey() === $model->getKey() &&
+ return ! is_null($model) &&
+ $this->getKey() === $model->getKey() &&
$this->getTable() === $model->getTable() &&
$this->getConnectionName() === $model->getConnectionName();
}
@@ -1006,10 +1201,10 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab
/**
* Determine if two models are not the same.
*
- * @param \Illuminate\Database\Eloquent\Model $model
+ * @param \Illuminate\Database\Eloquent\Model|null $model
* @return bool
*/
- public function isNot(Model $model)
+ public function isNot($model)
{
return ! $this->is($model);
}
@@ -1027,7 +1222,7 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab
/**
* Get the current connection name for the model.
*
- * @return string
+ * @return string|null
*/
public function getConnectionName()
{
@@ -1037,7 +1232,7 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab
/**
* Set the connection associated with the model.
*
- * @param string $name
+ * @param string|null $name
* @return $this
*/
public function setConnection($name)
@@ -1096,11 +1291,7 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab
*/
public function getTable()
{
- if (! isset($this->table)) {
- return str_replace('\\', '', Str::snake(Str::plural(class_basename($this))));
- }
-
- return $this->table;
+ return $this->table ?? Str::snake(Str::pluralStudly(class_basename($this)));
}
/**
@@ -1146,7 +1337,7 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab
*/
public function getQualifiedKeyName()
{
- return $this->getTable().'.'.$this->getKeyName();
+ return $this->qualifyColumn($this->getKeyName());
}
/**
@@ -1215,6 +1406,48 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab
return $this->getKey();
}
+ /**
+ * Get the queueable relationships for the entity.
+ *
+ * @return array
+ */
+ public function getQueueableRelations()
+ {
+ $relations = [];
+
+ foreach ($this->getRelations() as $key => $relation) {
+ if (! method_exists($this, $key)) {
+ continue;
+ }
+
+ $relations[] = $key;
+
+ if ($relation instanceof QueueableCollection) {
+ foreach ($relation->getQueueableRelations() as $collectionValue) {
+ $relations[] = $key.'.'.$collectionValue;
+ }
+ }
+
+ if ($relation instanceof QueueableEntity) {
+ foreach ($relation->getQueueableRelations() as $entityKey => $entityValue) {
+ $relations[] = $key.'.'.$entityValue;
+ }
+ }
+ }
+
+ return array_unique($relations);
+ }
+
+ /**
+ * Get the queueable connection for the entity.
+ *
+ * @return string|null
+ */
+ public function getQueueableConnection()
+ {
+ return $this->getConnectionName();
+ }
+
/**
* Get the value of the model's route key.
*
@@ -1235,6 +1468,17 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab
return $this->getKeyName();
}
+ /**
+ * Retrieve the model for a bound value.
+ *
+ * @param mixed $value
+ * @return \Illuminate\Database\Eloquent\Model|null
+ */
+ public function resolveRouteBinding($value)
+ {
+ return $this->where($this->getRouteKeyName(), $value)->first();
+ }
+
/**
* Get the default foreign key name for the model.
*
@@ -1242,7 +1486,7 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab
*/
public function getForeignKey()
{
- return Str::snake(class_basename($this)).'_'.$this->primaryKey;
+ return Str::snake(class_basename($this)).'_'.$this->getKeyName();
}
/**
@@ -1299,7 +1543,7 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab
*/
public function offsetExists($offset)
{
- return isset($this->$offset);
+ return ! is_null($this->getAttribute($offset));
}
/**
@@ -1310,7 +1554,7 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab
*/
public function offsetGet($offset)
{
- return $this->$offset;
+ return $this->getAttribute($offset);
}
/**
@@ -1322,7 +1566,7 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab
*/
public function offsetSet($offset, $value)
{
- $this->$offset = $value;
+ $this->setAttribute($offset, $value);
}
/**
@@ -1333,7 +1577,7 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab
*/
public function offsetUnset($offset)
{
- unset($this->$offset);
+ unset($this->attributes[$offset], $this->relations[$offset]);
}
/**
@@ -1344,7 +1588,7 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab
*/
public function __isset($key)
{
- return ! is_null($this->getAttribute($key));
+ return $this->offsetExists($key);
}
/**
@@ -1355,7 +1599,7 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab
*/
public function __unset($key)
{
- unset($this->attributes[$key], $this->relations[$key]);
+ $this->offsetUnset($key);
}
/**
@@ -1371,7 +1615,7 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab
return $this->$method(...$parameters);
}
- return $this->newQuery()->$method(...$parameters);
+ return $this->forwardCallTo($this->newQuery(), $method, $parameters);
}
/**
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/ModelNotFoundException.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/ModelNotFoundException.php
index a18724d2..c3db8242 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/ModelNotFoundException.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/ModelNotFoundException.php
@@ -3,6 +3,7 @@
namespace Illuminate\Database\Eloquent;
use RuntimeException;
+use Illuminate\Support\Arr;
class ModelNotFoundException extends RuntimeException
{
@@ -30,7 +31,7 @@ class ModelNotFoundException extends RuntimeException
public function setModel($model, $ids = [])
{
$this->model = $model;
- $this->ids = array_wrap($ids);
+ $this->ids = Arr::wrap($ids);
$this->message = "No query results for model [{$model}]";
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/RelationNotFoundException.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/RelationNotFoundException.php
index 5026ac9c..088429cc 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/RelationNotFoundException.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/RelationNotFoundException.php
@@ -6,6 +6,20 @@ use RuntimeException;
class RelationNotFoundException extends RuntimeException
{
+ /**
+ * The name of the affected Eloquent model.
+ *
+ * @var string
+ */
+ public $model;
+
+ /**
+ * The name of the relation.
+ *
+ * @var string
+ */
+ public $relation;
+
/**
* Create a new exception instance.
*
@@ -17,6 +31,11 @@ class RelationNotFoundException extends RuntimeException
{
$class = get_class($model);
- return new static("Call to undefined relationship [{$relation}] on model [{$class}].");
+ $instance = new static("Call to undefined relationship [{$relation}] on model [{$class}].");
+
+ $instance->model = $model;
+ $instance->relation = $relation;
+
+ return $instance;
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/BelongsTo.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/BelongsTo.php
index 26c4fba0..a4989248 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/BelongsTo.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/BelongsTo.php
@@ -7,9 +7,6 @@ use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Relations\Concerns\SupportsDefaultModels;
-/**
- * @mixin \Illuminate\Database\Eloquent\Builder
- */
class BelongsTo extends Relation
{
use SupportsDefaultModels;
@@ -38,7 +35,7 @@ class BelongsTo extends Relation
*
* @var string
*/
- protected $relation;
+ protected $relationName;
/**
* The count of self joins.
@@ -54,13 +51,14 @@ class BelongsTo extends Relation
* @param \Illuminate\Database\Eloquent\Model $child
* @param string $foreignKey
* @param string $ownerKey
- * @param string $relation
+ * @param string $relationName
+ *
* @return void
*/
- public function __construct(Builder $query, Model $child, $foreignKey, $ownerKey, $relation)
+ public function __construct(Builder $query, Model $child, $foreignKey, $ownerKey, $relationName)
{
$this->ownerKey = $ownerKey;
- $this->relation = $relation;
+ $this->relationName = $relationName;
$this->foreignKey = $foreignKey;
// In the underlying base relationship class, this variable is referred to as
@@ -78,6 +76,10 @@ class BelongsTo extends Relation
*/
public function getResults()
{
+ if (is_null($this->child->{$this->foreignKey})) {
+ return $this->getDefaultFor($this->parent);
+ }
+
return $this->query->first() ?: $this->getDefaultFor($this->parent);
}
@@ -111,7 +113,9 @@ class BelongsTo extends Relation
// our eagerly loading query so it returns the proper models from execution.
$key = $this->related->getTable().'.'.$this->ownerKey;
- $this->query->whereIn($key, $this->getEagerModelKeys($models));
+ $whereIn = $this->whereInMethod($this->related, $this->ownerKey);
+
+ $this->query->{$whereIn}($key, $this->getEagerModelKeys($models));
}
/**
@@ -133,13 +137,6 @@ class BelongsTo extends Relation
}
}
- // If there are no keys that were not null we will just return an array with null
- // so this query wont fail plus returns zero results, which should be what the
- // developer expects to happen in this situation. Otherwise we'll sort them.
- if (count($keys) === 0) {
- return [null];
- }
-
sort($keys);
return array_values(array_unique($keys));
@@ -220,7 +217,9 @@ class BelongsTo extends Relation
$this->child->setAttribute($this->foreignKey, $ownerKey);
if ($model instanceof Model) {
- $this->child->setRelation($this->relation, $model);
+ $this->child->setRelation($this->relationName, $model);
+ } elseif ($this->child->isDirty($this->foreignKey)) {
+ $this->child->unsetRelation($this->relationName);
}
return $this->child;
@@ -235,7 +234,7 @@ class BelongsTo extends Relation
{
$this->child->setAttribute($this->foreignKey, null);
- return $this->child->setRelation($this->relation, null);
+ return $this->child->setRelation($this->relationName, null);
}
/**
@@ -253,7 +252,7 @@ class BelongsTo extends Relation
}
return $query->select($columns)->whereColumn(
- $this->getQualifiedForeignKey(), '=', $query->getModel()->getTable().'.'.$this->ownerKey
+ $this->getQualifiedForeignKeyName(), '=', $query->qualifyColumn($this->ownerKey)
);
}
@@ -274,7 +273,7 @@ class BelongsTo extends Relation
$query->getModel()->setTable($hash);
return $query->whereColumn(
- $hash.'.'.$query->getModel()->getKeyName(), '=', $this->getQualifiedForeignKey()
+ $hash.'.'.$this->ownerKey, '=', $this->getQualifiedForeignKeyName()
);
}
@@ -310,12 +309,22 @@ class BelongsTo extends Relation
return $this->related->newInstance();
}
+ /**
+ * Get the child of the relationship.
+ *
+ * @return \Illuminate\Database\Eloquent\Model
+ */
+ public function getChild()
+ {
+ return $this->child;
+ }
+
/**
* Get the foreign key of the relationship.
*
* @return string
*/
- public function getForeignKey()
+ public function getForeignKeyName()
{
return $this->foreignKey;
}
@@ -325,9 +334,9 @@ class BelongsTo extends Relation
*
* @return string
*/
- public function getQualifiedForeignKey()
+ public function getQualifiedForeignKeyName()
{
- return $this->child->getTable().'.'.$this->foreignKey;
+ return $this->child->qualifyColumn($this->foreignKey);
}
/**
@@ -335,7 +344,7 @@ class BelongsTo extends Relation
*
* @return string
*/
- public function getOwnerKey()
+ public function getOwnerKeyName()
{
return $this->ownerKey;
}
@@ -347,7 +356,7 @@ class BelongsTo extends Relation
*/
public function getQualifiedOwnerKeyName()
{
- return $this->related->getTable().'.'.$this->ownerKey;
+ return $this->related->qualifyColumn($this->ownerKey);
}
/**
@@ -355,8 +364,19 @@ class BelongsTo extends Relation
*
* @return string
*/
+ public function getRelationName()
+ {
+ return $this->relationName;
+ }
+
+ /**
+ * Get the name of the relationship.
+ *
+ * @return string
+ * @deprecated The getRelationName() method should be used instead. Will be removed in Laravel 6.0.
+ */
public function getRelation()
{
- return $this->relation;
+ return $this->relationName;
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/BelongsToMany.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/BelongsToMany.php
index 4c9fac59..17164818 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/BelongsToMany.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/BelongsToMany.php
@@ -2,8 +2,8 @@
namespace Illuminate\Database\Eloquent\Relations;
-use Illuminate\Support\Arr;
use Illuminate\Support\Str;
+use InvalidArgumentException;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Collection;
@@ -25,13 +25,27 @@ class BelongsToMany extends Relation
*
* @var string
*/
- protected $foreignKey;
+ protected $foreignPivotKey;
/**
* The associated key of the relation.
*
* @var string
*/
+ protected $relatedPivotKey;
+
+ /**
+ * The key name of the parent model.
+ *
+ * @var string
+ */
+ protected $parentKey;
+
+ /**
+ * The key name of the related model.
+ *
+ * @var string
+ */
protected $relatedKey;
/**
@@ -62,6 +76,20 @@ class BelongsToMany extends Relation
*/
protected $pivotWhereIns = [];
+ /**
+ * The default values for the pivot columns.
+ *
+ * @var array
+ */
+ protected $pivotValues = [];
+
+ /**
+ * Indicates if timestamps are available on the pivot table.
+ *
+ * @var bool
+ */
+ public $withTimestamps = false;
+
/**
* The custom pivot table column for the created_at timestamp.
*
@@ -83,6 +111,13 @@ class BelongsToMany extends Relation
*/
protected $using;
+ /**
+ * The name of the accessor to use for the "pivot" relationship.
+ *
+ * @var string
+ */
+ protected $accessor = 'pivot';
+
/**
* The count of self joins.
*
@@ -96,21 +131,51 @@ class BelongsToMany extends Relation
* @param \Illuminate\Database\Eloquent\Builder $query
* @param \Illuminate\Database\Eloquent\Model $parent
* @param string $table
- * @param string $foreignKey
+ * @param string $foreignPivotKey
+ * @param string $relatedPivotKey
+ * @param string $parentKey
* @param string $relatedKey
* @param string $relationName
* @return void
*/
- public function __construct(Builder $query, Model $parent, $table, $foreignKey, $relatedKey, $relationName = null)
+ public function __construct(Builder $query, Model $parent, $table, $foreignPivotKey,
+ $relatedPivotKey, $parentKey, $relatedKey, $relationName = null)
{
- $this->table = $table;
+ $this->parentKey = $parentKey;
$this->relatedKey = $relatedKey;
- $this->foreignKey = $foreignKey;
$this->relationName = $relationName;
+ $this->relatedPivotKey = $relatedPivotKey;
+ $this->foreignPivotKey = $foreignPivotKey;
+ $this->table = $this->resolveTableName($table);
parent::__construct($query, $parent);
}
+ /**
+ * Attempt to resolve the intermediate table name from the given string.
+ *
+ * @param string $table
+ * @return string
+ */
+ protected function resolveTableName($table)
+ {
+ if (! Str::contains($table, '\\') || ! class_exists($table)) {
+ return $table;
+ }
+
+ $model = new $table;
+
+ if (! $model instanceof Model) {
+ return $table;
+ }
+
+ if ($model instanceof Pivot) {
+ $this->using($table);
+ }
+
+ return $model->getTable();
+ }
+
/**
* Set the base constraints on the relation query.
*
@@ -140,9 +205,9 @@ class BelongsToMany extends Relation
// model instance. Then we can set the "where" for the parent models.
$baseTable = $this->related->getTable();
- $key = $baseTable.'.'.$this->related->getKeyName();
+ $key = $baseTable.'.'.$this->relatedKey;
- $query->join($this->table, $key, '=', $this->getQualifiedRelatedKeyName());
+ $query->join($this->table, $key, '=', $this->getQualifiedRelatedPivotKeyName());
return $this;
}
@@ -155,7 +220,7 @@ class BelongsToMany extends Relation
protected function addWhereConstraints()
{
$this->query->where(
- $this->getQualifiedForeignKeyName(), '=', $this->parent->getKey()
+ $this->getQualifiedForeignPivotKeyName(), '=', $this->parent->{$this->parentKey}
);
return $this;
@@ -169,7 +234,12 @@ class BelongsToMany extends Relation
*/
public function addEagerConstraints(array $models)
{
- $this->query->whereIn($this->getQualifiedForeignKeyName(), $this->getKeys($models));
+ $whereIn = $this->whereInMethod($this->parent, $this->parentKey);
+
+ $this->query->{$whereIn}(
+ $this->getQualifiedForeignPivotKeyName(),
+ $this->getKeys($models, $this->parentKey)
+ );
}
/**
@@ -204,7 +274,7 @@ class BelongsToMany extends Relation
// children back to their parent using the dictionary and the keys on the
// the parent models. Then we will return the hydrated models back out.
foreach ($models as $model) {
- if (isset($dictionary[$key = $model->getKey()])) {
+ if (isset($dictionary[$key = $model->{$this->parentKey}])) {
$model->setRelation(
$relation, $this->related->newCollection($dictionary[$key])
);
@@ -228,17 +298,27 @@ class BelongsToMany extends Relation
$dictionary = [];
foreach ($results as $result) {
- $dictionary[$result->pivot->{$this->foreignKey}][] = $result;
+ $dictionary[$result->{$this->accessor}->{$this->foreignPivotKey}][] = $result;
}
return $dictionary;
}
+ /**
+ * Get the class being used for pivot models.
+ *
+ * @return string
+ */
+ public function getPivotClass()
+ {
+ return $this->using ?? Pivot::class;
+ }
+
/**
* Specify the custom pivot model to use for the relationship.
*
* @param string $class
- * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
+ * @return $this
*/
public function using($class)
{
@@ -247,6 +327,19 @@ class BelongsToMany extends Relation
return $this;
}
+ /**
+ * Specify the custom pivot accessor to use for the relationship.
+ *
+ * @param string $accessor
+ * @return $this
+ */
+ public function as($accessor)
+ {
+ $this->accessor = $accessor;
+
+ return $this;
+ }
+
/**
* Set a where clause for a pivot table column.
*
@@ -254,7 +347,7 @@ class BelongsToMany extends Relation
* @param string $operator
* @param mixed $value
* @param string $boolean
- * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
+ * @return $this
*/
public function wherePivot($column, $operator = null, $value = null, $boolean = 'and')
{
@@ -270,7 +363,7 @@ class BelongsToMany extends Relation
* @param mixed $values
* @param string $boolean
* @param bool $not
- * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
+ * @return $this
*/
public function wherePivotIn($column, $values, $boolean = 'and', $not = false)
{
@@ -285,19 +378,47 @@ class BelongsToMany extends Relation
* @param string $column
* @param string $operator
* @param mixed $value
- * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
+ * @return $this
*/
public function orWherePivot($column, $operator = null, $value = null)
{
return $this->wherePivot($column, $operator, $value, 'or');
}
+ /**
+ * Set a where clause for a pivot table column.
+ *
+ * In addition, new pivot records will receive this value.
+ *
+ * @param string|array $column
+ * @param mixed $value
+ * @return $this
+ */
+ public function withPivotValue($column, $value = null)
+ {
+ if (is_array($column)) {
+ foreach ($column as $name => $value) {
+ $this->withPivotValue($name, $value);
+ }
+
+ return $this;
+ }
+
+ if (is_null($value)) {
+ throw new InvalidArgumentException('The provided value may not be null.');
+ }
+
+ $this->pivotValues[] = compact('column', 'value');
+
+ return $this->wherePivot($column, '=', $value);
+ }
+
/**
* Set an "or where in" clause for a pivot table column.
*
* @param string $column
* @param mixed $values
- * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
+ * @return $this
*/
public function orWherePivotIn($column, $values)
{
@@ -416,14 +537,14 @@ class BelongsToMany extends Relation
$result = $this->find($id, $columns);
if (is_array($id)) {
- if (count($result) == count(array_unique($id))) {
+ if (count($result) === count(array_unique($id))) {
return $result;
}
} elseif (! is_null($result)) {
return $result;
}
- throw (new ModelNotFoundException)->setModel(get_class($this->related));
+ throw (new ModelNotFoundException)->setModel(get_class($this->related), $id);
}
/**
@@ -463,7 +584,9 @@ class BelongsToMany extends Relation
*/
public function getResults()
{
- return $this->get();
+ return ! is_null($this->parent->{$this->parentKey})
+ ? $this->get()
+ : $this->related->newCollection();
}
/**
@@ -477,10 +600,10 @@ class BelongsToMany extends Relation
// First we'll add the proper select columns onto the query so it is run with
// the proper columns. Then, we will get the results and hydrate out pivot
// models with the result of those columns as a separate model relation.
- $columns = $this->query->getQuery()->columns ? [] : $columns;
-
$builder = $this->query->applyScopes();
+ $columns = $builder->getQuery()->columns ? [] : $columns;
+
$models = $builder->addSelect(
$this->shouldSelect($columns)
)->getModels();
@@ -501,7 +624,7 @@ class BelongsToMany extends Relation
* Get the select columns for the relation query.
*
* @param array $columns
- * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
+ * @return array
*/
protected function shouldSelect(array $columns = ['*'])
{
@@ -521,7 +644,7 @@ class BelongsToMany extends Relation
*/
protected function aliasedPivotColumns()
{
- $defaults = [$this->foreignKey, $this->relatedKey];
+ $defaults = [$this->foreignPivotKey, $this->relatedPivotKey];
return collect(array_merge($defaults, $this->pivotColumns))->map(function ($column) {
return $this->table.'.'.$column.' as pivot_'.$column;
@@ -582,6 +705,50 @@ class BelongsToMany extends Relation
});
}
+ /**
+ * Chunk the results of a query by comparing numeric IDs.
+ *
+ * @param int $count
+ * @param callable $callback
+ * @param string|null $column
+ * @param string|null $alias
+ * @return bool
+ */
+ public function chunkById($count, callable $callback, $column = null, $alias = null)
+ {
+ $this->query->addSelect($this->shouldSelect());
+
+ $column = $column ?? $this->getRelated()->qualifyColumn(
+ $this->getRelatedKeyName()
+ );
+
+ $alias = $alias ?? $this->getRelatedKeyName();
+
+ return $this->query->chunkById($count, function ($results) use ($callback) {
+ $this->hydratePivotRelation($results->all());
+
+ return $callback($results);
+ }, $column, $alias);
+ }
+
+ /**
+ * Execute a callback over each item while chunking.
+ *
+ * @param callable $callback
+ * @param int $count
+ * @return bool
+ */
+ public function each(callable $callback, $count = 1000)
+ {
+ return $this->chunk($count, function ($results) use ($callback) {
+ foreach ($results as $key => $value) {
+ if ($callback($value, $key) === false) {
+ return false;
+ }
+ }
+ });
+ }
+
/**
* Hydrate the pivot table relationship on the models.
*
@@ -594,7 +761,7 @@ class BelongsToMany extends Relation
// and create a new Pivot model, which is basically a dynamic model that we
// will set the attributes, table, and connections on it so it will work.
foreach ($models as $model) {
- $model->setRelation('pivot', $this->newExistingPivot(
+ $model->setRelation($this->accessor, $this->newExistingPivot(
$this->migratePivotAttributes($model)
));
}
@@ -657,7 +824,7 @@ class BelongsToMany extends Relation
*/
protected function guessInverseRelation()
{
- return Str::camel(Str::plural(class_basename($this->getParent())));
+ return Str::camel(Str::pluralStudly(class_basename($this->getParent())));
}
/**
@@ -679,7 +846,7 @@ class BelongsToMany extends Relation
// the related model's timestamps, to make sure these all reflect the changes
// to the parent models. This will help us keep any caching synced up here.
if (count($ids = $this->allRelatedIds()) > 0) {
- $this->getRelated()->newQuery()->whereIn($key, $ids)->update($columns);
+ $this->getRelated()->newQueryWithoutRelationships()->whereIn($key, $ids)->update($columns);
}
}
@@ -690,11 +857,7 @@ class BelongsToMany extends Relation
*/
public function allRelatedIds()
{
- $related = $this->getRelated();
-
- return $this->getQuery()->select(
- $related->getQualifiedKeyName()
- )->pluck($related->getKeyName());
+ return $this->newPivotQuery()->pluck($this->relatedPivotKey);
}
/**
@@ -709,7 +872,7 @@ class BelongsToMany extends Relation
{
$model->save(['touch' => false]);
- $this->attach($model->getKey(), $pivotAttributes, $touch);
+ $this->attach($model, $pivotAttributes, $touch);
return $model;
}
@@ -724,7 +887,7 @@ class BelongsToMany extends Relation
public function saveMany($models, array $pivotAttributes = [])
{
foreach ($models as $key => $model) {
- $this->save($model, (array) Arr::get($pivotAttributes, $key), false);
+ $this->save($model, (array) ($pivotAttributes[$key] ?? []), false);
}
$this->touchIfTouching();
@@ -740,7 +903,7 @@ class BelongsToMany extends Relation
* @param bool $touch
* @return \Illuminate\Database\Eloquent\Model
*/
- public function create(array $attributes, array $joining = [], $touch = true)
+ public function create(array $attributes = [], array $joining = [], $touch = true)
{
$instance = $this->related->newInstance($attributes);
@@ -749,7 +912,7 @@ class BelongsToMany extends Relation
// accomplish this which will insert the record and any more attributes.
$instance->save(['touch' => false]);
- $this->attach($instance->getKey(), $joining, $touch);
+ $this->attach($instance, $joining, $touch);
return $instance;
}
@@ -766,7 +929,7 @@ class BelongsToMany extends Relation
$instances = [];
foreach ($records as $key => $record) {
- $instances[] = $this->create($record, (array) Arr::get($joinings, $key), false);
+ $instances[] = $this->create($record, (array) ($joinings[$key] ?? []), false);
}
$this->touchIfTouching();
@@ -821,7 +984,7 @@ class BelongsToMany extends Relation
*/
public function getExistenceCompareKey()
{
- return $this->getQualifiedForeignKeyName();
+ return $this->getQualifiedForeignPivotKeyName();
}
/**
@@ -839,10 +1002,12 @@ class BelongsToMany extends Relation
*
* @param mixed $createdAt
* @param mixed $updatedAt
- * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
+ * @return $this
*/
public function withTimestamps($createdAt = null, $updatedAt = null)
{
+ $this->withTimestamps = true;
+
$this->pivotCreatedAt = $createdAt;
$this->pivotUpdatedAt = $updatedAt;
@@ -869,14 +1034,34 @@ class BelongsToMany extends Relation
return $this->pivotUpdatedAt ?: $this->parent->getUpdatedAtColumn();
}
+ /**
+ * Get the foreign key for the relation.
+ *
+ * @return string
+ */
+ public function getForeignPivotKeyName()
+ {
+ return $this->foreignPivotKey;
+ }
+
/**
* Get the fully qualified foreign key for the relation.
*
* @return string
*/
- public function getQualifiedForeignKeyName()
+ public function getQualifiedForeignPivotKeyName()
{
- return $this->table.'.'.$this->foreignKey;
+ return $this->table.'.'.$this->foreignPivotKey;
+ }
+
+ /**
+ * Get the "related key" for the relation.
+ *
+ * @return string
+ */
+ public function getRelatedPivotKeyName()
+ {
+ return $this->relatedPivotKey;
}
/**
@@ -884,9 +1069,39 @@ class BelongsToMany extends Relation
*
* @return string
*/
- public function getQualifiedRelatedKeyName()
+ public function getQualifiedRelatedPivotKeyName()
{
- return $this->table.'.'.$this->relatedKey;
+ return $this->table.'.'.$this->relatedPivotKey;
+ }
+
+ /**
+ * Get the parent key for the relationship.
+ *
+ * @return string
+ */
+ public function getParentKeyName()
+ {
+ return $this->parentKey;
+ }
+
+ /**
+ * Get the fully qualified parent key name for the relation.
+ *
+ * @return string
+ */
+ public function getQualifiedParentKeyName()
+ {
+ return $this->parent->qualifyColumn($this->parentKey);
+ }
+
+ /**
+ * Get the related key for the relationship.
+ *
+ * @return string
+ */
+ public function getRelatedKeyName()
+ {
+ return $this->relatedKey;
}
/**
@@ -908,4 +1123,14 @@ class BelongsToMany extends Relation
{
return $this->relationName;
}
+
+ /**
+ * Get the name of the pivot accessor for this relationship.
+ *
+ * @return string
+ */
+ public function getPivotAccessor()
+ {
+ return $this->accessor;
+ }
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/Concerns/InteractsWithPivotTable.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/Concerns/InteractsWithPivotTable.php
index 9d4c73f2..70cf998a 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/Concerns/InteractsWithPivotTable.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/Concerns/InteractsWithPivotTable.php
@@ -4,10 +4,18 @@ namespace Illuminate\Database\Eloquent\Relations\Concerns;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Collection;
+use Illuminate\Database\Eloquent\Relations\Pivot;
use Illuminate\Support\Collection as BaseCollection;
trait InteractsWithPivotTable
{
+ /**
+ * The cached copy of the currently attached pivot models.
+ *
+ * @var Collection
+ */
+ private $currentlyAttached;
+
/**
* Toggles a model (or models) from the parent.
*
@@ -29,7 +37,7 @@ trait InteractsWithPivotTable
// checking which of the given ID/records is in the list of current records
// and removing all of those rows from this "intermediate" joining table.
$detach = array_values(array_intersect(
- $this->newPivotQuery()->pluck($this->relatedKey)->all(),
+ $this->newPivotQuery()->pluck($this->relatedPivotKey)->all(),
array_keys($records)
));
@@ -64,7 +72,7 @@ trait InteractsWithPivotTable
/**
* Sync the intermediate tables with a list of IDs without detaching.
*
- * @param \Illuminate\Database\Eloquent\Collection|array $ids
+ * @param \Illuminate\Support\Collection|\Illuminate\Database\Eloquent\Model|array $ids
* @return array
*/
public function syncWithoutDetaching($ids)
@@ -75,7 +83,7 @@ trait InteractsWithPivotTable
/**
* Sync the intermediate tables with a list of IDs or collection of models.
*
- * @param \Illuminate\Database\Eloquent\Collection|\Illuminate\Support\Collection|array $ids
+ * @param \Illuminate\Support\Collection|\Illuminate\Database\Eloquent\Model|array $ids
* @param bool $detaching
* @return array
*/
@@ -88,9 +96,8 @@ trait InteractsWithPivotTable
// First we need to attach any of the associated models that are not currently
// in this joining table. We'll spin through the given IDs, checking to see
// if they exist in the array of current ones, and if not we will insert.
- $current = $this->newPivotQuery()->pluck(
- $this->relatedKey
- )->all();
+ $current = $this->getCurrentlyAttachedPivots()
+ ->pluck($this->relatedPivotKey)->all();
$detach = array_diff($current, array_keys(
$records = $this->formatRecordsList($this->parseIds($ids))
@@ -133,7 +140,7 @@ trait InteractsWithPivotTable
{
return collect($records)->mapWithKeys(function ($attributes, $id) {
if (! is_array($attributes)) {
- list($id, $attributes) = [$attributes, []];
+ [$id, $attributes] = [$attributes, []];
}
return [$id => $attributes];
@@ -184,11 +191,17 @@ trait InteractsWithPivotTable
*/
public function updateExistingPivot($id, array $attributes, $touch = true)
{
+ if ($this->using && empty($this->pivotWheres) && empty($this->pivotWhereIns)) {
+ return $this->updateExistingPivotUsingCustomClass($id, $attributes, $touch);
+ }
+
if (in_array($this->updatedAt(), $this->pivotColumns)) {
$attributes = $this->addTimestampsToAttachment($attributes, true);
}
- $updated = $this->newPivotStatementForId($id)->update($attributes);
+ $updated = $this->newPivotStatementForId($this->parseId($id))->update(
+ $this->castAttributes($attributes)
+ );
if ($touch) {
$this->touchIfTouching();
@@ -197,6 +210,35 @@ trait InteractsWithPivotTable
return $updated;
}
+ /**
+ * Update an existing pivot record on the table via a custom class.
+ *
+ * @param mixed $id
+ * @param array $attributes
+ * @param bool $touch
+ * @return int
+ */
+ protected function updateExistingPivotUsingCustomClass($id, array $attributes, $touch)
+ {
+ $pivot = $this->getCurrentlyAttachedPivots()
+ ->where($this->foreignPivotKey, $this->parent->{$this->parentKey})
+ ->where($this->relatedPivotKey, $this->parseId($id))
+ ->first();
+
+ $updated = $pivot ? $pivot->fill($attributes)->isDirty() : false;
+
+ $this->newPivot([
+ $this->foreignPivotKey => $this->parent->{$this->parentKey},
+ $this->relatedPivotKey => $this->parseId($id),
+ ], true)->fill($attributes)->save();
+
+ if ($touch) {
+ $this->touchIfTouching();
+ }
+
+ return (int) $updated;
+ }
+
/**
* Attach a model to the parent.
*
@@ -207,18 +249,40 @@ trait InteractsWithPivotTable
*/
public function attach($id, array $attributes = [], $touch = true)
{
- // Here we will insert the attachment records into the pivot table. Once we have
- // inserted the records, we will touch the relationships if necessary and the
- // function will return. We can parse the IDs before inserting the records.
- $this->newPivotStatement()->insert($this->formatAttachRecords(
- $this->parseIds($id), $attributes
- ));
+ if ($this->using) {
+ $this->attachUsingCustomClass($id, $attributes);
+ } else {
+ // Here we will insert the attachment records into the pivot table. Once we have
+ // inserted the records, we will touch the relationships if necessary and the
+ // function will return. We can parse the IDs before inserting the records.
+ $this->newPivotStatement()->insert($this->formatAttachRecords(
+ $this->parseIds($id), $attributes
+ ));
+ }
if ($touch) {
$this->touchIfTouching();
}
}
+ /**
+ * Attach a model to the parent using a custom class.
+ *
+ * @param mixed $id
+ * @param array $attributes
+ * @return void
+ */
+ protected function attachUsingCustomClass($id, array $attributes)
+ {
+ $records = $this->formatAttachRecords(
+ $this->parseIds($id), $attributes
+ );
+
+ foreach ($records as $record) {
+ $this->newPivot($record, false)->save();
+ }
+ }
+
/**
* Create an array of records to insert into the pivot table.
*
@@ -256,10 +320,10 @@ trait InteractsWithPivotTable
*/
protected function formatAttachRecord($key, $value, $attributes, $hasTimestamps)
{
- list($id, $attributes) = $this->extractAttachIdAndAttributes($key, $value, $attributes);
+ [$id, $attributes] = $this->extractAttachIdAndAttributes($key, $value, $attributes);
return array_merge(
- $this->baseAttachRecord($id, $hasTimestamps), $attributes
+ $this->baseAttachRecord($id, $hasTimestamps), $this->castAttributes($attributes)
);
}
@@ -287,9 +351,9 @@ trait InteractsWithPivotTable
*/
protected function baseAttachRecord($id, $timed)
{
- $record[$this->relatedKey] = $id;
+ $record[$this->relatedPivotKey] = $id;
- $record[$this->foreignKey] = $this->parent->getKey();
+ $record[$this->foreignPivotKey] = $this->parent->{$this->parentKey};
// If the record needs to have creation and update timestamps, we will make
// them by calling the parent model's "freshTimestamp" method which will
@@ -298,6 +362,10 @@ trait InteractsWithPivotTable
$record = $this->addTimestampsToAttachment($record);
}
+ foreach ($this->pivotValues as $value) {
+ $record[$value['column']] = $value['value'];
+ }
+
return $record;
}
@@ -312,6 +380,12 @@ trait InteractsWithPivotTable
{
$fresh = $this->parent->freshTimestamp();
+ if ($this->using) {
+ $pivotModel = new $this->using;
+
+ $fresh = $fresh->format($pivotModel->getDateFormat());
+ }
+
if (! $exists && $this->hasPivotColumn($this->createdAt())) {
$record[$this->createdAt()] = $fresh;
}
@@ -329,7 +403,7 @@ trait InteractsWithPivotTable
* @param string $column
* @return bool
*/
- protected function hasPivotColumn($column)
+ public function hasPivotColumn($column)
{
return in_array($column, $this->pivotColumns);
}
@@ -343,26 +417,30 @@ trait InteractsWithPivotTable
*/
public function detach($ids = null, $touch = true)
{
- $query = $this->newPivotQuery();
+ if ($this->using && ! empty($ids) && empty($this->pivotWheres) && empty($this->pivotWhereIns)) {
+ $results = $this->detachUsingCustomClass($ids);
+ } else {
+ $query = $this->newPivotQuery();
- // If associated IDs were passed to the method we will only delete those
- // associations, otherwise all of the association ties will be broken.
- // We'll return the numbers of affected rows when we do the deletes.
- if (! is_null($ids)) {
- $ids = $this->parseIds($ids);
+ // If associated IDs were passed to the method we will only delete those
+ // associations, otherwise all of the association ties will be broken.
+ // We'll return the numbers of affected rows when we do the deletes.
+ if (! is_null($ids)) {
+ $ids = $this->parseIds($ids);
- if (empty($ids)) {
- return 0;
+ if (empty($ids)) {
+ return 0;
+ }
+
+ $query->whereIn($this->relatedPivotKey, (array) $ids);
}
- $query->whereIn($this->relatedKey, $ids);
+ // Once we have all of the conditions set on the statement, we are ready
+ // to run the delete on the pivot table. Then, if the touch parameter
+ // is true, we will go ahead and touch all related models to sync.
+ $results = $query->delete();
}
- // Once we have all of the conditions set on the statement, we are ready
- // to run the delete on the pivot table. Then, if the touch parameter
- // is true, we will go ahead and touch all related models to sync.
- $results = $query->delete();
-
if ($touch) {
$this->touchIfTouching();
}
@@ -370,6 +448,40 @@ trait InteractsWithPivotTable
return $results;
}
+ /**
+ * Detach models from the relationship using a custom class.
+ *
+ * @param mixed $ids
+ * @return int
+ */
+ protected function detachUsingCustomClass($ids)
+ {
+ $results = 0;
+
+ foreach ($this->parseIds($ids) as $id) {
+ $results += $this->newPivot([
+ $this->foreignPivotKey => $this->parent->{$this->parentKey},
+ $this->relatedPivotKey => $id,
+ ], true)->delete();
+ }
+
+ return $results;
+ }
+
+ /**
+ * Get the pivot models that are currently attached.
+ *
+ * @return \Illuminate\Support\Collection
+ */
+ protected function getCurrentlyAttachedPivots()
+ {
+ return $this->currentlyAttached ?: $this->newPivotQuery()->get()->map(function ($record) {
+ $class = $this->using ? $this->using : Pivot::class;
+
+ return (new $class)->setRawAttributes((array) $record, true);
+ });
+ }
+
/**
* Create a new pivot model instance.
*
@@ -383,7 +495,7 @@ trait InteractsWithPivotTable
$this->parent, $attributes, $this->table, $exists, $this->using
);
- return $pivot->setPivotKeys($this->foreignKey, $this->relatedKey);
+ return $pivot->setPivotKeys($this->foreignPivotKey, $this->relatedPivotKey);
}
/**
@@ -415,7 +527,7 @@ trait InteractsWithPivotTable
*/
public function newPivotStatementForId($id)
{
- return $this->newPivotQuery()->where($this->relatedKey, $id);
+ return $this->newPivotQuery()->whereIn($this->relatedPivotKey, $this->parseIds($id));
}
/**
@@ -435,7 +547,7 @@ trait InteractsWithPivotTable
call_user_func_array([$query, 'whereIn'], $arguments);
}
- return $query->where($this->foreignKey, $this->parent->getKey());
+ return $query->where($this->foreignPivotKey, $this->parent->{$this->parentKey});
}
/**
@@ -462,11 +574,11 @@ trait InteractsWithPivotTable
protected function parseIds($value)
{
if ($value instanceof Model) {
- return [$value->getKey()];
+ return [$value->{$this->relatedKey}];
}
if ($value instanceof Collection) {
- return $value->modelKeys();
+ return $value->pluck($this->relatedKey)->all();
}
if ($value instanceof BaseCollection) {
@@ -476,6 +588,17 @@ trait InteractsWithPivotTable
return (array) $value;
}
+ /**
+ * Get the ID from the given mixed value.
+ *
+ * @param mixed $value
+ * @return mixed
+ */
+ protected function parseId($value)
+ {
+ return $value instanceof Model ? $value->{$this->relatedKey} : $value;
+ }
+
/**
* Cast the given keys to integers if they are numeric and string otherwise.
*
@@ -484,19 +607,59 @@ trait InteractsWithPivotTable
*/
protected function castKeys(array $keys)
{
- return (array) array_map(function ($v) {
+ return array_map(function ($v) {
return $this->castKey($v);
}, $keys);
}
/**
- * Cast the given key to an integer if it is numeric.
+ * Cast the given key to convert to primary key type.
*
* @param mixed $key
* @return mixed
*/
protected function castKey($key)
{
- return is_numeric($key) ? (int) $key : (string) $key;
+ return $this->getTypeSwapValue(
+ $this->related->getKeyType(),
+ $key
+ );
+ }
+
+ /**
+ * Cast the given pivot attributes.
+ *
+ * @param array $attributes
+ * @return array
+ */
+ protected function castAttributes($attributes)
+ {
+ return $this->using
+ ? $this->newPivot()->fill($attributes)->getAttributes()
+ : $attributes;
+ }
+
+ /**
+ * Converts a given value to a given type value.
+ *
+ * @param string $type
+ * @param mixed $value
+ * @return mixed
+ */
+ protected function getTypeSwapValue($type, $value)
+ {
+ switch (strtolower($type)) {
+ case 'int':
+ case 'integer':
+ return (int) $value;
+ case 'real':
+ case 'float':
+ case 'double':
+ return (float) $value;
+ case 'string':
+ return (string) $value;
+ default:
+ return $value;
+ }
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/Concerns/SupportsDefaultModels.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/Concerns/SupportsDefaultModels.php
index 00efd507..74e758f5 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/Concerns/SupportsDefaultModels.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/Concerns/SupportsDefaultModels.php
@@ -51,7 +51,7 @@ trait SupportsDefaultModels
$instance = $this->newRelatedInstanceFor($parent);
if (is_callable($this->withDefault)) {
- return call_user_func($this->withDefault, $instance) ?: $instance;
+ return call_user_func($this->withDefault, $instance, $parent) ?: $instance;
}
if (is_array($this->withDefault)) {
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/HasMany.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/HasMany.php
index 6149e475..8971a7d2 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/HasMany.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/HasMany.php
@@ -13,7 +13,9 @@ class HasMany extends HasOneOrMany
*/
public function getResults()
{
- return $this->query->get();
+ return ! is_null($this->getParentKey())
+ ? $this->query->get()
+ : $this->related->newCollection();
}
/**
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/HasManyThrough.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/HasManyThrough.php
index 3fb7a7cc..873ea893 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/HasManyThrough.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/HasManyThrough.php
@@ -45,6 +45,20 @@ class HasManyThrough extends Relation
*/
protected $localKey;
+ /**
+ * The local key on the intermediary model.
+ *
+ * @var string
+ */
+ protected $secondLocalKey;
+
+ /**
+ * The count of self joins.
+ *
+ * @var int
+ */
+ protected static $selfJoinCount = 0;
+
/**
* Create a new has many through relationship instance.
*
@@ -54,15 +68,17 @@ class HasManyThrough extends Relation
* @param string $firstKey
* @param string $secondKey
* @param string $localKey
+ * @param string $secondLocalKey
* @return void
*/
- public function __construct(Builder $query, Model $farParent, Model $throughParent, $firstKey, $secondKey, $localKey)
+ public function __construct(Builder $query, Model $farParent, Model $throughParent, $firstKey, $secondKey, $localKey, $secondLocalKey)
{
$this->localKey = $localKey;
$this->firstKey = $firstKey;
$this->secondKey = $secondKey;
$this->farParent = $farParent;
$this->throughParent = $throughParent;
+ $this->secondLocalKey = $secondLocalKey;
parent::__construct($query, $throughParent);
}
@@ -102,6 +118,16 @@ class HasManyThrough extends Relation
}
}
+ /**
+ * Get the fully qualified parent key name.
+ *
+ * @return string
+ */
+ public function getQualifiedParentKeyName()
+ {
+ return $this->parent->qualifyColumn($this->secondLocalKey);
+ }
+
/**
* Determine whether "through" parent of the relation uses Soft Deletes.
*
@@ -109,9 +135,7 @@ class HasManyThrough extends Relation
*/
public function throughParentSoftDeletes()
{
- return in_array(SoftDeletes::class, class_uses_recursive(
- get_class($this->throughParent)
- ));
+ return in_array(SoftDeletes::class, class_uses_recursive($this->throughParent));
}
/**
@@ -122,7 +146,9 @@ class HasManyThrough extends Relation
*/
public function addEagerConstraints(array $models)
{
- $this->query->whereIn(
+ $whereIn = $this->whereInMethod($this->farParent, $this->localKey);
+
+ $this->query->{$whereIn}(
$this->getQualifiedFirstKeyName(), $this->getKeys($models, $this->localKey)
);
}
@@ -159,7 +185,7 @@ class HasManyThrough extends Relation
// link them up with their children using the keyed dictionary to make the
// matching very convenient and easy work. Then we'll just return them.
foreach ($models as $model) {
- if (isset($dictionary[$key = $model->getKey()])) {
+ if (isset($dictionary[$key = $model->getAttribute($this->localKey)])) {
$model->setRelation(
$relation, $this->related->newCollection($dictionary[$key])
);
@@ -183,7 +209,7 @@ class HasManyThrough extends Relation
// relationship as this will allow us to quickly access all of the related
// models without having to do nested looping which will be quite slow.
foreach ($results as $result) {
- $dictionary[$result->{$this->firstKey}][] = $result;
+ $dictionary[$result->laravel_through_key][] = $result;
}
return $dictionary;
@@ -300,14 +326,14 @@ class HasManyThrough extends Relation
$result = $this->find($id, $columns);
if (is_array($id)) {
- if (count($result) == count(array_unique($id))) {
+ if (count($result) === count(array_unique($id))) {
return $result;
}
} elseif (! is_null($result)) {
return $result;
}
- throw (new ModelNotFoundException)->setModel(get_class($this->related));
+ throw (new ModelNotFoundException)->setModel(get_class($this->related), $id);
}
/**
@@ -317,7 +343,9 @@ class HasManyThrough extends Relation
*/
public function getResults()
{
- return $this->get();
+ return ! is_null($this->farParent->{$this->localKey})
+ ? $this->get()
+ : $this->related->newCollection();
}
/**
@@ -328,16 +356,9 @@ class HasManyThrough extends Relation
*/
public function get($columns = ['*'])
{
- // First we'll add the proper select columns onto the query so it is run with
- // the proper columns. Then, we will get the results and hydrate out pivot
- // models with the result of those columns as a separate model relation.
- $columns = $this->query->getQuery()->columns ? [] : $columns;
+ $builder = $this->prepareQueryBuilder($columns);
- $builder = $this->query->applyScopes();
-
- $models = $builder->addSelect(
- $this->shouldSelect($columns)
- )->getModels();
+ $models = $builder->getModels();
// If we actually found models we will also eager load any relationships that
// have been specified as needing to be eager loaded. This will solve the
@@ -393,7 +414,80 @@ class HasManyThrough extends Relation
$columns = [$this->related->getTable().'.*'];
}
- return array_merge($columns, [$this->getQualifiedFirstKeyName()]);
+ return array_merge($columns, [$this->getQualifiedFirstKeyName().' as laravel_through_key']);
+ }
+
+ /**
+ * Chunk the results of the query.
+ *
+ * @param int $count
+ * @param callable $callback
+ * @return bool
+ */
+ public function chunk($count, callable $callback)
+ {
+ return $this->prepareQueryBuilder()->chunk($count, $callback);
+ }
+
+ /**
+ * Chunk the results of a query by comparing numeric IDs.
+ *
+ * @param int $count
+ * @param callable $callback
+ * @param string|null $column
+ * @param string|null $alias
+ * @return bool
+ */
+ public function chunkById($count, callable $callback, $column = null, $alias = null)
+ {
+ $column = $column ?? $this->getRelated()->getQualifiedKeyName();
+
+ $alias = $alias ?? $this->getRelated()->getKeyName();
+
+ return $this->prepareQueryBuilder()->chunkById($count, $callback, $column, $alias);
+ }
+
+ /**
+ * Get a generator for the given query.
+ *
+ * @return \Generator
+ */
+ public function cursor()
+ {
+ return $this->prepareQueryBuilder()->cursor();
+ }
+
+ /**
+ * Execute a callback over each item while chunking.
+ *
+ * @param callable $callback
+ * @param int $count
+ * @return bool
+ */
+ public function each(callable $callback, $count = 1000)
+ {
+ return $this->chunk($count, function ($results) use ($callback) {
+ foreach ($results as $key => $value) {
+ if ($callback($value, $key) === false) {
+ return false;
+ }
+ }
+ });
+ }
+
+ /**
+ * Prepare the query builder for query execution.
+ *
+ * @param array $columns
+ * @return \Illuminate\Database\Eloquent\Builder
+ */
+ protected function prepareQueryBuilder($columns = ['*'])
+ {
+ $builder = $this->query->applyScopes();
+
+ return $builder->addSelect(
+ $this->shouldSelect($builder->getQuery()->columns ? [] : $columns)
+ );
}
/**
@@ -406,21 +500,77 @@ class HasManyThrough extends Relation
*/
public function getRelationExistenceQuery(Builder $query, Builder $parentQuery, $columns = ['*'])
{
+ if ($parentQuery->getQuery()->from === $query->getQuery()->from) {
+ return $this->getRelationExistenceQueryForSelfRelation($query, $parentQuery, $columns);
+ }
+
+ if ($parentQuery->getQuery()->from === $this->throughParent->getTable()) {
+ return $this->getRelationExistenceQueryForThroughSelfRelation($query, $parentQuery, $columns);
+ }
+
$this->performJoin($query);
return $query->select($columns)->whereColumn(
- $this->getExistenceCompareKey(), '=', $this->getQualifiedFirstKeyName()
+ $this->getQualifiedLocalKeyName(), '=', $this->getQualifiedFirstKeyName()
);
}
/**
- * Get the key for comparing against the parent key in "has" query.
+ * Add the constraints for a relationship query on the same table.
+ *
+ * @param \Illuminate\Database\Eloquent\Builder $query
+ * @param \Illuminate\Database\Eloquent\Builder $parentQuery
+ * @param array|mixed $columns
+ * @return \Illuminate\Database\Eloquent\Builder
+ */
+ public function getRelationExistenceQueryForSelfRelation(Builder $query, Builder $parentQuery, $columns = ['*'])
+ {
+ $query->from($query->getModel()->getTable().' as '.$hash = $this->getRelationCountHash());
+
+ $query->join($this->throughParent->getTable(), $this->getQualifiedParentKeyName(), '=', $hash.'.'.$this->secondKey);
+
+ if ($this->throughParentSoftDeletes()) {
+ $query->whereNull($this->throughParent->getQualifiedDeletedAtColumn());
+ }
+
+ $query->getModel()->setTable($hash);
+
+ return $query->select($columns)->whereColumn(
+ $parentQuery->getQuery()->from.'.'.$this->localKey, '=', $this->getQualifiedFirstKeyName()
+ );
+ }
+
+ /**
+ * Add the constraints for a relationship query on the same table as the through parent.
+ *
+ * @param \Illuminate\Database\Eloquent\Builder $query
+ * @param \Illuminate\Database\Eloquent\Builder $parentQuery
+ * @param array|mixed $columns
+ * @return \Illuminate\Database\Eloquent\Builder
+ */
+ public function getRelationExistenceQueryForThroughSelfRelation(Builder $query, Builder $parentQuery, $columns = ['*'])
+ {
+ $table = $this->throughParent->getTable().' as '.$hash = $this->getRelationCountHash();
+
+ $query->join($table, $hash.'.'.$this->secondLocalKey, '=', $this->getQualifiedFarKeyName());
+
+ if ($this->throughParentSoftDeletes()) {
+ $query->whereNull($hash.'.'.$this->throughParent->getDeletedAtColumn());
+ }
+
+ return $query->select($columns)->whereColumn(
+ $parentQuery->getQuery()->from.'.'.$this->localKey, '=', $hash.'.'.$this->firstKey
+ );
+ }
+
+ /**
+ * Get a relationship join table hash.
*
* @return string
*/
- public function getExistenceCompareKey()
+ public function getRelationCountHash()
{
- return $this->farParent->getQualifiedKeyName();
+ return 'laravel_reserved_'.static::$selfJoinCount++;
}
/**
@@ -434,13 +584,13 @@ class HasManyThrough extends Relation
}
/**
- * Get the qualified foreign key on the related model.
+ * Get the foreign key on the "through" model.
*
* @return string
*/
- public function getQualifiedForeignKeyName()
+ public function getFirstKeyName()
{
- return $this->related->getTable().'.'.$this->secondKey;
+ return $this->firstKey;
}
/**
@@ -450,6 +600,56 @@ class HasManyThrough extends Relation
*/
public function getQualifiedFirstKeyName()
{
- return $this->throughParent->getTable().'.'.$this->firstKey;
+ return $this->throughParent->qualifyColumn($this->firstKey);
+ }
+
+ /**
+ * Get the foreign key on the related model.
+ *
+ * @return string
+ */
+ public function getForeignKeyName()
+ {
+ return $this->secondKey;
+ }
+
+ /**
+ * Get the qualified foreign key on the related model.
+ *
+ * @return string
+ */
+ public function getQualifiedForeignKeyName()
+ {
+ return $this->related->qualifyColumn($this->secondKey);
+ }
+
+ /**
+ * Get the local key on the far parent model.
+ *
+ * @return string
+ */
+ public function getLocalKeyName()
+ {
+ return $this->localKey;
+ }
+
+ /**
+ * Get the qualified local key on the far parent model.
+ *
+ * @return string
+ */
+ public function getQualifiedLocalKeyName()
+ {
+ return $this->farParent->qualifyColumn($this->localKey);
+ }
+
+ /**
+ * Get the local key on the intermediary model.
+ *
+ * @return string
+ */
+ public function getSecondLocalKeyName()
+ {
+ return $this->secondLocalKey;
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/HasOne.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/HasOne.php
index 858e5d07..e4763ff4 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/HasOne.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/HasOne.php
@@ -17,6 +17,10 @@ class HasOne extends HasOneOrMany
*/
public function getResults()
{
+ if (is_null($this->getParentKey())) {
+ return $this->getDefaultFor($this->parent);
+ }
+
return $this->query->first() ?: $this->getDefaultFor($this->parent);
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/HasOneOrMany.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/HasOneOrMany.php
index c6e1ba83..af59df96 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/HasOneOrMany.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/HasOneOrMany.php
@@ -55,7 +55,7 @@ abstract class HasOneOrMany extends Relation
public function make(array $attributes = [])
{
return tap($this->related->newInstance($attributes), function ($instance) {
- $instance->setAttribute($this->getForeignKeyName(), $this->getParentKey());
+ $this->setForeignAttributesForCreate($instance);
});
}
@@ -81,7 +81,9 @@ abstract class HasOneOrMany extends Relation
*/
public function addEagerConstraints(array $models)
{
- $this->query->whereIn(
+ $whereIn = $this->whereInMethod($this->parent, $this->localKey);
+
+ $this->query->{$whereIn}(
$this->foreignKey, $this->getKeys($models, $this->localKey)
);
}
@@ -151,7 +153,7 @@ abstract class HasOneOrMany extends Relation
{
$value = $dictionary[$key];
- return $type == 'one' ? reset($value) : $this->related->newCollection($value);
+ return $type === 'one' ? reset($value) : $this->related->newCollection($value);
}
/**
@@ -162,18 +164,11 @@ abstract class HasOneOrMany extends Relation
*/
protected function buildDictionary(Collection $results)
{
- $dictionary = [];
-
$foreign = $this->getForeignKeyName();
- // First we will create a dictionary of models keyed by the foreign key of the
- // relationship as this will allow us to quickly access all of the related
- // models without having to do nested looping which will be quite slow.
- foreach ($results as $result) {
- $dictionary[$result->{$foreign}][] = $result;
- }
-
- return $dictionary;
+ return $results->mapToDictionary(function ($result) use ($foreign) {
+ return [$result->{$foreign} => $result];
+ })->all();
}
/**
@@ -188,7 +183,7 @@ abstract class HasOneOrMany extends Relation
if (is_null($instance = $this->find($id, $columns))) {
$instance = $this->related->newInstance();
- $instance->setAttribute($this->getForeignKeyName(), $this->getParentKey());
+ $this->setForeignAttributesForCreate($instance);
}
return $instance;
@@ -198,14 +193,15 @@ abstract class HasOneOrMany extends Relation
* Get the first related model record matching the attributes or instantiate it.
*
* @param array $attributes
+ * @param array $values
* @return \Illuminate\Database\Eloquent\Model
*/
- public function firstOrNew(array $attributes)
+ public function firstOrNew(array $attributes, array $values = [])
{
if (is_null($instance = $this->where($attributes)->first())) {
- $instance = $this->related->newInstance($attributes);
+ $instance = $this->related->newInstance($attributes + $values);
- $instance->setAttribute($this->getForeignKeyName(), $this->getParentKey());
+ $this->setForeignAttributesForCreate($instance);
}
return $instance;
@@ -215,12 +211,13 @@ abstract class HasOneOrMany extends Relation
* Get the first related record matching the attributes or create it.
*
* @param array $attributes
+ * @param array $values
* @return \Illuminate\Database\Eloquent\Model
*/
- public function firstOrCreate(array $attributes)
+ public function firstOrCreate(array $attributes, array $values = [])
{
if (is_null($instance = $this->where($attributes)->first())) {
- $instance = $this->create($attributes);
+ $instance = $this->create($attributes + $values);
}
return $instance;
@@ -250,7 +247,7 @@ abstract class HasOneOrMany extends Relation
*/
public function save(Model $model)
{
- $model->setAttribute($this->getForeignKeyName(), $this->getParentKey());
+ $this->setForeignAttributesForCreate($model);
return $model->save() ? $model : false;
}
@@ -258,8 +255,8 @@ abstract class HasOneOrMany extends Relation
/**
* Attach a collection of models to the parent instance.
*
- * @param \Traversable|array $models
- * @return \Traversable|array
+ * @param iterable $models
+ * @return iterable
*/
public function saveMany($models)
{
@@ -276,10 +273,10 @@ abstract class HasOneOrMany extends Relation
* @param array $attributes
* @return \Illuminate\Database\Eloquent\Model
*/
- public function create(array $attributes)
+ public function create(array $attributes = [])
{
return tap($this->related->newInstance($attributes), function ($instance) {
- $instance->setAttribute($this->getForeignKeyName(), $this->getParentKey());
+ $this->setForeignAttributesForCreate($instance);
$instance->save();
});
@@ -303,18 +300,14 @@ abstract class HasOneOrMany extends Relation
}
/**
- * Perform an update on all the related models.
+ * Set the foreign ID for creating a related model.
*
- * @param array $attributes
- * @return int
+ * @param \Illuminate\Database\Eloquent\Model $model
+ * @return void
*/
- public function update(array $attributes)
+ protected function setForeignAttributesForCreate(Model $model)
{
- if ($this->related->usesTimestamps()) {
- $attributes[$this->relatedUpdatedAt()] = $this->related->freshTimestampString();
- }
-
- return $this->query->update($attributes);
+ $model->setAttribute($this->getForeignKeyName(), $this->getParentKey());
}
/**
@@ -390,7 +383,7 @@ abstract class HasOneOrMany extends Relation
*/
public function getQualifiedParentKeyName()
{
- return $this->parent->getTable().'.'.$this->localKey;
+ return $this->parent->qualifyColumn($this->localKey);
}
/**
@@ -402,7 +395,7 @@ abstract class HasOneOrMany extends Relation
{
$segments = explode('.', $this->getQualifiedForeignKeyName());
- return $segments[count($segments) - 1];
+ return end($segments);
}
/**
@@ -414,4 +407,14 @@ abstract class HasOneOrMany extends Relation
{
return $this->foreignKey;
}
+
+ /**
+ * Get the local key for the relationship.
+ *
+ * @return string
+ */
+ public function getLocalKeyName()
+ {
+ return $this->localKey;
+ }
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/MorphMany.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/MorphMany.php
index e2a5c5a3..a4c63763 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/MorphMany.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/MorphMany.php
@@ -13,7 +13,9 @@ class MorphMany extends MorphOneOrMany
*/
public function getResults()
{
- return $this->query->get();
+ return ! is_null($this->getParentKey())
+ ? $this->query->get()
+ : $this->related->newCollection();
}
/**
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/MorphOne.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/MorphOne.php
index 520a7ec9..0327ffae 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/MorphOne.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/MorphOne.php
@@ -17,6 +17,10 @@ class MorphOne extends MorphOneOrMany
*/
public function getResults()
{
+ if (is_null($this->getParentKey())) {
+ return $this->getDefaultFor($this->parent);
+ }
+
return $this->query->first() ?: $this->getDefaultFor($this->parent);
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/MorphOneOrMany.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/MorphOneOrMany.php
index 42f1239d..03a776bf 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/MorphOneOrMany.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/MorphOneOrMany.php
@@ -40,22 +40,6 @@ abstract class MorphOneOrMany extends HasOneOrMany
parent::__construct($query, $parent, $id, $localKey);
}
- /**
- * Create and return an un-saved instance of the related model.
- *
- * @param array $attributes
- * @return \Illuminate\Database\Eloquent\Model
- */
- public function make(array $attributes = [])
- {
- return tap($this->related->newInstance($attributes), function ($instance) {
- // When saving a polymorphic relationship, we need to set not only the foreign
- // key, but also the foreign key type, which is typically the class name of
- // the parent model. This makes the polymorphic item unique in the table.
- $this->setForeignAttributesForCreate($instance);
- });
- }
-
/**
* Set the base constraints on the relation query.
*
@@ -83,111 +67,6 @@ abstract class MorphOneOrMany extends HasOneOrMany
$this->query->where($this->morphType, $this->morphClass);
}
- /**
- * Find a related model by its primary key or return new instance of the related model.
- *
- * @param mixed $id
- * @param array $columns
- * @return \Illuminate\Support\Collection|\Illuminate\Database\Eloquent\Model
- */
- public function findOrNew($id, $columns = ['*'])
- {
- if (is_null($instance = $this->find($id, $columns))) {
- $instance = $this->related->newInstance();
-
- // When saving a polymorphic relationship, we need to set not only the foreign
- // key, but also the foreign key type, which is typically the class name of
- // the parent model. This makes the polymorphic item unique in the table.
- $this->setForeignAttributesForCreate($instance);
- }
-
- return $instance;
- }
-
- /**
- * Get the first related model record matching the attributes or instantiate it.
- *
- * @param array $attributes
- * @return \Illuminate\Database\Eloquent\Model
- */
- public function firstOrNew(array $attributes)
- {
- if (is_null($instance = $this->where($attributes)->first())) {
- $instance = $this->related->newInstance($attributes);
-
- // When saving a polymorphic relationship, we need to set not only the foreign
- // key, but also the foreign key type, which is typically the class name of
- // the parent model. This makes the polymorphic item unique in the table.
- $this->setForeignAttributesForCreate($instance);
- }
-
- return $instance;
- }
-
- /**
- * Get the first related record matching the attributes or create it.
- *
- * @param array $attributes
- * @return \Illuminate\Database\Eloquent\Model
- */
- public function firstOrCreate(array $attributes)
- {
- if (is_null($instance = $this->where($attributes)->first())) {
- $instance = $this->create($attributes);
- }
-
- return $instance;
- }
-
- /**
- * Create or update a related record matching the attributes, and fill it with values.
- *
- * @param array $attributes
- * @param array $values
- * @return \Illuminate\Database\Eloquent\Model
- */
- public function updateOrCreate(array $attributes, array $values = [])
- {
- return tap($this->firstOrNew($attributes), function ($instance) use ($values) {
- $instance->fill($values);
-
- $instance->save();
- });
- }
-
- /**
- * Attach a model instance to the parent model.
- *
- * @param \Illuminate\Database\Eloquent\Model $model
- * @return \Illuminate\Database\Eloquent\Model
- */
- public function save(Model $model)
- {
- $model->setAttribute($this->getMorphType(), $this->morphClass);
-
- return parent::save($model);
- }
-
- /**
- * Create a new instance of the related model.
- *
- * @param array $attributes
- * @return \Illuminate\Database\Eloquent\Model
- */
- public function create(array $attributes)
- {
- $instance = $this->related->newInstance($attributes);
-
- // When saving a polymorphic relationship, we need to set not only the foreign
- // key, but also the foreign key type, which is typically the class name of
- // the parent model. This makes the polymorphic item unique in the table.
- $this->setForeignAttributesForCreate($instance);
-
- $instance->save();
-
- return $instance;
- }
-
/**
* Set the foreign ID and type for creating a related model.
*
@@ -212,7 +91,7 @@ abstract class MorphOneOrMany extends HasOneOrMany
public function getRelationExistenceQuery(Builder $query, Builder $parentQuery, $columns = ['*'])
{
return parent::getRelationExistenceQuery($query, $parentQuery, $columns)->where(
- $this->morphType, $this->morphClass
+ $query->qualifyColumn($this->getMorphType()), $this->morphClass
);
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/MorphPivot.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/MorphPivot.php
index b7a2f341..d649554c 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/MorphPivot.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/MorphPivot.php
@@ -2,6 +2,7 @@
namespace Illuminate\Database\Eloquent\Relations;
+use Illuminate\Support\Str;
use Illuminate\Database\Eloquent\Builder;
class MorphPivot extends Pivot
@@ -76,4 +77,74 @@ class MorphPivot extends Pivot
return $this;
}
+
+ /**
+ * Get the queueable identity for the entity.
+ *
+ * @return mixed
+ */
+ public function getQueueableId()
+ {
+ if (isset($this->attributes[$this->getKeyName()])) {
+ return $this->getKey();
+ }
+
+ return sprintf(
+ '%s:%s:%s:%s:%s:%s',
+ $this->foreignKey, $this->getAttribute($this->foreignKey),
+ $this->relatedKey, $this->getAttribute($this->relatedKey),
+ $this->morphType, $this->morphClass
+ );
+ }
+
+ /**
+ * Get a new query to restore one or more models by their queueable IDs.
+ *
+ * @param array|int $ids
+ * @return \Illuminate\Database\Eloquent\Builder
+ */
+ public function newQueryForRestoration($ids)
+ {
+ if (is_array($ids)) {
+ return $this->newQueryForCollectionRestoration($ids);
+ }
+
+ if (! Str::contains($ids, ':')) {
+ return parent::newQueryForRestoration($ids);
+ }
+
+ $segments = explode(':', $ids);
+
+ return $this->newQueryWithoutScopes()
+ ->where($segments[0], $segments[1])
+ ->where($segments[2], $segments[3])
+ ->where($segments[4], $segments[5]);
+ }
+
+ /**
+ * Get a new query to restore multiple models by their queueable IDs.
+ *
+ * @param array $ids
+ * @return \Illuminate\Database\Eloquent\Builder
+ */
+ protected function newQueryForCollectionRestoration(array $ids)
+ {
+ if (! Str::contains($ids[0], ':')) {
+ return parent::newQueryForRestoration($ids);
+ }
+
+ $query = $this->newQueryWithoutScopes();
+
+ foreach ($ids as $id) {
+ $segments = explode(':', $id);
+
+ $query->orWhere(function ($query) use ($segments) {
+ return $query->where($segments[0], $segments[1])
+ ->where($segments[2], $segments[3])
+ ->where($segments[4], $segments[5]);
+ });
+ }
+
+ return $query;
+ }
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/MorphTo.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/MorphTo.php
index 2739786d..521730b3 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/MorphTo.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/MorphTo.php
@@ -7,9 +7,6 @@ use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Collection;
-/**
- * @mixin \Illuminate\Database\Eloquent\Builder
- */
class MorphTo extends BelongsTo
{
/**
@@ -40,6 +37,13 @@ class MorphTo extends BelongsTo
*/
protected $macroBuffer = [];
+ /**
+ * A map of relations to load for each individual morph type.
+ *
+ * @var array
+ */
+ protected $morphableEagerLoads = [];
+
/**
* Create a new morph to relationship instance.
*
@@ -84,16 +88,6 @@ class MorphTo extends BelongsTo
}
}
- /**
- * Get the results of the relationship.
- *
- * @return mixed
- */
- public function getResults()
- {
- return $this->ownerKey ? $this->query->first() : null;
- }
-
/**
* Get the results of the relationship.
*
@@ -120,12 +114,19 @@ class MorphTo extends BelongsTo
{
$instance = $this->createModelByType($type);
+ $ownerKey = $this->ownerKey ?? $instance->getKeyName();
+
$query = $this->replayMacros($instance->newQuery())
->mergeConstraintsFrom($this->getQuery())
- ->with($this->getQuery()->getEagerLoads());
+ ->with(array_merge(
+ $this->getQuery()->getEagerLoads(),
+ (array) ($this->morphableEagerLoads[get_class($instance)] ?? [])
+ ));
- return $query->whereIn(
- $instance->getTable().'.'.$instance->getKeyName(), $this->gatherKeysByType($type)
+ $whereIn = $this->whereInMethod($instance, $ownerKey);
+
+ return $query->{$whereIn}(
+ $instance->getTable().'.'.$ownerKey, $this->gatherKeysByType($type)
)->get();
}
@@ -178,9 +179,11 @@ class MorphTo extends BelongsTo
protected function matchToMorphParents($type, Collection $results)
{
foreach ($results as $result) {
- if (isset($this->dictionary[$type][$result->getKey()])) {
- foreach ($this->dictionary[$type][$result->getKey()] as $model) {
- $model->setRelation($this->relation, $result);
+ $ownerKey = ! is_null($this->ownerKey) ? $result->{$this->ownerKey} : $result->getKey();
+
+ if (isset($this->dictionary[$type][$ownerKey])) {
+ foreach ($this->dictionary[$type][$ownerKey] as $model) {
+ $model->setRelation($this->relationName, $result);
}
}
}
@@ -194,11 +197,15 @@ class MorphTo extends BelongsTo
*/
public function associate($model)
{
- $this->parent->setAttribute($this->foreignKey, $model->getKey());
+ $this->parent->setAttribute(
+ $this->foreignKey, $model instanceof Model ? $model->getKey() : null
+ );
- $this->parent->setAttribute($this->morphType, $model->getMorphClass());
+ $this->parent->setAttribute(
+ $this->morphType, $model instanceof Model ? $model->getMorphClass() : null
+ );
- return $this->parent->setRelation($this->relation, $model);
+ return $this->parent->setRelation($this->relationName, $model);
}
/**
@@ -212,7 +219,30 @@ class MorphTo extends BelongsTo
$this->parent->setAttribute($this->morphType, null);
- return $this->parent->setRelation($this->relation, null);
+ return $this->parent->setRelation($this->relationName, null);
+ }
+
+ /**
+ * Touch all of the related models for the relationship.
+ *
+ * @return void
+ */
+ public function touch()
+ {
+ if (! is_null($this->child->{$this->foreignKey})) {
+ parent::touch();
+ }
+ }
+
+ /**
+ * Make a new related instance for the given model.
+ *
+ * @param \Illuminate\Database\Eloquent\Model $parent
+ * @return \Illuminate\Database\Eloquent\Model
+ */
+ protected function newRelatedInstanceFor(Model $parent)
+ {
+ return $parent->{$this->getRelationName()}()->getRelated()->newInstance();
}
/**
@@ -235,6 +265,21 @@ class MorphTo extends BelongsTo
return $this->dictionary;
}
+ /**
+ * Specify which relations to load for a given morph type.
+ *
+ * @param array $with
+ * @return \Illuminate\Database\Eloquent\Relations\MorphTo
+ */
+ public function morphWith(array $with)
+ {
+ $this->morphableEagerLoads = array_merge(
+ $this->morphableEagerLoads, $with
+ );
+
+ return $this;
+ }
+
/**
* Replay stored macro calls on the actual related instance.
*
@@ -260,7 +305,13 @@ class MorphTo extends BelongsTo
public function __call($method, $parameters)
{
try {
- return parent::__call($method, $parameters);
+ $result = parent::__call($method, $parameters);
+
+ if (in_array($method, ['select', 'selectRaw', 'selectSub', 'addSelect', 'withoutGlobalScopes'])) {
+ $this->macroBuffer[] = compact('method', 'parameters');
+ }
+
+ return $result;
}
// If we tried to call a method that does not exist on the parent Builder instance,
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/MorphToMany.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/MorphToMany.php
index 2ca44d82..e487af04 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/MorphToMany.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/MorphToMany.php
@@ -38,19 +38,25 @@ class MorphToMany extends BelongsToMany
* @param \Illuminate\Database\Eloquent\Model $parent
* @param string $name
* @param string $table
- * @param string $foreignKey
+ * @param string $foreignPivotKey
+ * @param string $relatedPivotKey
+ * @param string $parentKey
* @param string $relatedKey
* @param string $relationName
* @param bool $inverse
* @return void
*/
- public function __construct(Builder $query, Model $parent, $name, $table, $foreignKey, $relatedKey, $relationName = null, $inverse = false)
+ public function __construct(Builder $query, Model $parent, $name, $table, $foreignPivotKey,
+ $relatedPivotKey, $parentKey, $relatedKey, $relationName = null, $inverse = false)
{
$this->inverse = $inverse;
$this->morphType = $name.'_type';
$this->morphClass = $inverse ? $query->getModel()->getMorphClass() : $parent->getMorphClass();
- parent::__construct($query, $parent, $table, $foreignKey, $relatedKey, $relationName);
+ parent::__construct(
+ $query, $parent, $table, $foreignPivotKey,
+ $relatedPivotKey, $parentKey, $relatedKey, $relationName
+ );
}
/**
@@ -131,15 +137,31 @@ class MorphToMany extends BelongsToMany
$using = $this->using;
$pivot = $using ? $using::fromRawAttributes($this->parent, $attributes, $this->table, $exists)
- : new MorphPivot($this->parent, $attributes, $this->table, $exists);
+ : MorphPivot::fromAttributes($this->parent, $attributes, $this->table, $exists);
- $pivot->setPivotKeys($this->foreignKey, $this->relatedKey)
+ $pivot->setPivotKeys($this->foreignPivotKey, $this->relatedPivotKey)
->setMorphType($this->morphType)
->setMorphClass($this->morphClass);
return $pivot;
}
+ /**
+ * Get the pivot columns for the relation.
+ *
+ * "pivot_" is prefixed at each column for easy removal later.
+ *
+ * @return array
+ */
+ protected function aliasedPivotColumns()
+ {
+ $defaults = [$this->foreignPivotKey, $this->relatedPivotKey, $this->morphType];
+
+ return collect(array_merge($defaults, $this->pivotColumns))->map(function ($column) {
+ return $this->table.'.'.$column.' as pivot_'.$column;
+ })->unique()->all();
+ }
+
/**
* Get the foreign key "type" name.
*
@@ -159,4 +181,14 @@ class MorphToMany extends BelongsToMany
{
return $this->morphClass;
}
+
+ /**
+ * Get the indicator for a reverse relationship.
+ *
+ * @return bool
+ */
+ public function getInverse()
+ {
+ return $this->inverse;
+ }
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/Pivot.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/Pivot.php
index 84683d8b..a65ecdea 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/Pivot.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/Pivot.php
@@ -3,30 +3,18 @@
namespace Illuminate\Database\Eloquent\Relations;
use Illuminate\Database\Eloquent\Model;
-use Illuminate\Database\Eloquent\Builder;
+use Illuminate\Database\Eloquent\Relations\Concerns\AsPivot;
class Pivot extends Model
{
- /**
- * The parent model of the relationship.
- *
- * @var \Illuminate\Database\Eloquent\Model
- */
- public $parent;
+ use AsPivot;
/**
- * The name of the foreign key column.
+ * Indicates if the IDs are auto-incrementing.
*
- * @var string
+ * @var bool
*/
- protected $foreignKey;
-
- /**
- * The name of the "other key" column.
- *
- * @var string
- */
- protected $relatedKey;
+ public $incrementing = false;
/**
* The attributes that aren't mass assignable.
@@ -34,165 +22,4 @@ class Pivot extends Model
* @var array
*/
protected $guarded = [];
-
- /**
- * Create a new pivot model instance.
- *
- * @param \Illuminate\Database\Eloquent\Model $parent
- * @param array $attributes
- * @param string $table
- * @param bool $exists
- * @return void
- */
- public function __construct(Model $parent, $attributes, $table, $exists = false)
- {
- parent::__construct();
-
- // The pivot model is a "dynamic" model since we will set the tables dynamically
- // for the instance. This allows it work for any intermediate tables for the
- // many to many relationship that are defined by this developer's classes.
- $this->setConnection($parent->getConnectionName())
- ->setTable($table)
- ->forceFill($attributes)
- ->syncOriginal();
-
- // We store off the parent instance so we will access the timestamp column names
- // for the model, since the pivot model timestamps aren't easily configurable
- // from the developer's point of view. We can use the parents to get these.
- $this->parent = $parent;
-
- $this->exists = $exists;
-
- $this->timestamps = $this->hasTimestampAttributes();
- }
-
- /**
- * Create a new pivot model from raw values returned from a query.
- *
- * @param \Illuminate\Database\Eloquent\Model $parent
- * @param array $attributes
- * @param string $table
- * @param bool $exists
- * @return static
- */
- public static function fromRawAttributes(Model $parent, $attributes, $table, $exists = false)
- {
- $instance = new static($parent, $attributes, $table, $exists);
-
- $instance->setRawAttributes($attributes, true);
-
- return $instance;
- }
-
- /**
- * Set the keys for a save update query.
- *
- * @param \Illuminate\Database\Eloquent\Builder $query
- * @return \Illuminate\Database\Eloquent\Builder
- */
- protected function setKeysForSaveQuery(Builder $query)
- {
- $query->where($this->foreignKey, $this->getAttribute($this->foreignKey));
-
- return $query->where($this->relatedKey, $this->getAttribute($this->relatedKey));
- }
-
- /**
- * Delete the pivot model record from the database.
- *
- * @return int
- */
- public function delete()
- {
- return $this->getDeleteQuery()->delete();
- }
-
- /**
- * Get the query builder for a delete operation on the pivot.
- *
- * @return \Illuminate\Database\Eloquent\Builder
- */
- protected function getDeleteQuery()
- {
- return $this->newQuery()->where([
- $this->foreignKey => $this->getAttribute($this->foreignKey),
- $this->relatedKey => $this->getAttribute($this->relatedKey),
- ]);
- }
-
- /**
- * Get the foreign key column name.
- *
- * @return string
- */
- public function getForeignKey()
- {
- return $this->foreignKey;
- }
-
- /**
- * Get the "related key" column name.
- *
- * @return string
- */
- public function getRelatedKey()
- {
- return $this->relatedKey;
- }
-
- /**
- * Get the "related key" column name.
- *
- * @return string
- */
- public function getOtherKey()
- {
- return $this->getRelatedKey();
- }
-
- /**
- * Set the key names for the pivot model instance.
- *
- * @param string $foreignKey
- * @param string $relatedKey
- * @return $this
- */
- public function setPivotKeys($foreignKey, $relatedKey)
- {
- $this->foreignKey = $foreignKey;
-
- $this->relatedKey = $relatedKey;
-
- return $this;
- }
-
- /**
- * Determine if the pivot model has timestamp attributes.
- *
- * @return bool
- */
- public function hasTimestampAttributes()
- {
- return array_key_exists($this->getCreatedAtColumn(), $this->attributes);
- }
-
- /**
- * Get the name of the "created at" column.
- *
- * @return string
- */
- public function getCreatedAtColumn()
- {
- return $this->parent->getCreatedAtColumn();
- }
-
- /**
- * Get the name of the "updated at" column.
- *
- * @return string
- */
- public function getUpdatedAtColumn()
- {
- return $this->parent->getUpdatedAtColumn();
- }
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/Relation.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/Relation.php
index b4f62715..f4fa915a 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/Relation.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/Relation.php
@@ -9,13 +9,14 @@ use Illuminate\Support\Traits\Macroable;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Query\Expression;
use Illuminate\Database\Eloquent\Collection;
+use Illuminate\Support\Traits\ForwardsCalls;
/**
* @mixin \Illuminate\Database\Eloquent\Builder
*/
abstract class Relation
{
- use Macroable {
+ use ForwardsCalls, Macroable {
__call as macroCall;
}
@@ -52,7 +53,7 @@ abstract class Relation
*
* @var array
*/
- protected static $morphMap = [];
+ public static $morphMap = [];
/**
* Create a new relation instance.
@@ -143,6 +144,17 @@ abstract class Relation
return $this->get();
}
+ /**
+ * Execute the query as a "select" statement.
+ *
+ * @param array $columns
+ * @return \Illuminate\Database\Eloquent\Collection
+ */
+ public function get($columns = ['*'])
+ {
+ return $this->query->get($columns);
+ }
+
/**
* Touch all of the related models for the relationship.
*
@@ -150,9 +162,13 @@ abstract class Relation
*/
public function touch()
{
- $column = $this->getRelated()->getUpdatedAtColumn();
+ $model = $this->getRelated();
- $this->rawUpdate([$column => $this->getRelated()->freshTimestampString()]);
+ if (! $model::isIgnoringTouch()) {
+ $this->rawUpdate([
+ $model->getUpdatedAtColumn() => $model->freshTimestampString(),
+ ]);
+ }
}
/**
@@ -163,7 +179,7 @@ abstract class Relation
*/
public function rawUpdate(array $attributes = [])
{
- return $this->query->update($attributes);
+ return $this->query->withoutGlobalScopes()->update($attributes);
}
/**
@@ -177,7 +193,7 @@ abstract class Relation
{
return $this->getRelationExistenceQuery(
$query, $parentQuery, new Expression('count(*)')
- );
+ )->setBindings([], 'select');
}
/**
@@ -208,7 +224,7 @@ abstract class Relation
{
return collect($models)->map(function ($value) use ($key) {
return $key ? $value->getAttribute($key) : $value->getKey();
- })->values()->unique()->sort()->all();
+ })->values()->unique(null, true)->sort()->all();
}
/**
@@ -291,6 +307,22 @@ abstract class Relation
return $this->related->getUpdatedAtColumn();
}
+ /**
+ * Get the name of the "where in" method for eager loading.
+ *
+ * @param \Illuminate\Database\Eloquent\Model $model
+ * @param string $key
+ * @return string
+ */
+ protected function whereInMethod(Model $model, $key)
+ {
+ return $model->getKeyName() === last(explode('.', $key))
+ && $model->getIncrementing()
+ && in_array($model->getKeyType(), ['int', 'integer'])
+ ? 'whereIntegerInRaw'
+ : 'whereIn';
+ }
+
/**
* Set or get the morph map for polymorphic relations.
*
@@ -304,7 +336,7 @@ abstract class Relation
if (is_array($map)) {
static::$morphMap = $merge && static::$morphMap
- ? array_merge(static::$morphMap, $map) : $map;
+ ? $map + static::$morphMap : $map;
}
return static::$morphMap;
@@ -335,9 +367,7 @@ abstract class Relation
*/
public static function getMorphedModel($alias)
{
- return array_key_exists($alias, self::$morphMap)
- ? self::$morphMap[$alias]
- : null;
+ return static::$morphMap[$alias] ?? null;
}
/**
@@ -353,7 +383,7 @@ abstract class Relation
return $this->macroCall($method, $parameters);
}
- $result = call_user_func_array([$this->query, $method], $parameters);
+ $result = $this->forwardCallTo($this->query, $method, $parameters);
if ($result === $this->query) {
return $this;
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/SoftDeletes.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/SoftDeletes.php
index d6c31ba9..65b6cb66 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/SoftDeletes.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/SoftDeletes.php
@@ -2,6 +2,11 @@
namespace Illuminate\Database\Eloquent;
+/**
+ * @method static static|\Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder withTrashed()
+ * @method static static|\Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder onlyTrashed()
+ * @method static static|\Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder withoutTrashed()
+ */
trait SoftDeletes
{
/**
@@ -21,6 +26,16 @@ trait SoftDeletes
static::addGlobalScope(new SoftDeletingScope);
}
+ /**
+ * Initialize the soft deleting trait for an instance.
+ *
+ * @return void
+ */
+ public function initializeSoftDeletes()
+ {
+ $this->dates[] = $this->getDeletedAtColumn();
+ }
+
/**
* Force a hard delete on a soft deleted model.
*
@@ -30,11 +45,13 @@ trait SoftDeletes
{
$this->forceDeleting = true;
- $deleted = $this->delete();
+ return tap($this->delete(), function ($deleted) {
+ $this->forceDeleting = false;
- $this->forceDeleting = false;
-
- return $deleted;
+ if ($deleted) {
+ $this->fireModelEvent('forceDeleted', false);
+ }
+ });
}
/**
@@ -45,7 +62,9 @@ trait SoftDeletes
protected function performDeleteOnModel()
{
if ($this->forceDeleting) {
- return $this->newQueryWithoutScopes()->where($this->getKeyName(), $this->getKey())->forceDelete();
+ $this->exists = false;
+
+ return $this->setKeysForSaveQuery($this->newModelQuery())->forceDelete();
}
return $this->runSoftDelete();
@@ -58,7 +77,7 @@ trait SoftDeletes
*/
protected function runSoftDelete()
{
- $query = $this->newQueryWithoutScopes()->where($this->getKeyName(), $this->getKey());
+ $query = $this->setKeysForSaveQuery($this->newModelQuery());
$time = $this->freshTimestamp();
@@ -66,7 +85,7 @@ trait SoftDeletes
$this->{$this->getDeletedAtColumn()} = $time;
- if ($this->timestamps) {
+ if ($this->timestamps && ! is_null($this->getUpdatedAtColumn())) {
$this->{$this->getUpdatedAtColumn()} = $time;
$columns[$this->getUpdatedAtColumn()] = $this->fromDateTime($time);
@@ -162,6 +181,6 @@ trait SoftDeletes
*/
public function getQualifiedDeletedAtColumn()
{
- return $this->getTable().'.'.$this->getDeletedAtColumn();
+ return $this->qualifyColumn($this->getDeletedAtColumn());
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/SoftDeletingScope.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/SoftDeletingScope.php
index 6de963de..0d516966 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/SoftDeletingScope.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Eloquent/SoftDeletingScope.php
@@ -82,7 +82,11 @@ class SoftDeletingScope implements Scope
*/
protected function addWithTrashed(Builder $builder)
{
- $builder->macro('withTrashed', function (Builder $builder) {
+ $builder->macro('withTrashed', function (Builder $builder, $withTrashed = true) {
+ if (! $withTrashed) {
+ return $builder->withoutTrashed();
+ }
+
return $builder->withoutGlobalScope($this);
});
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Events/QueryExecuted.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Events/QueryExecuted.php
index d53473f8..833a21e6 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Events/QueryExecuted.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Events/QueryExecuted.php
@@ -44,8 +44,9 @@ class QueryExecuted
*
* @param string $sql
* @param array $bindings
- * @param float $time
- * @param
+ * @param float|null $time
+ * @param \Illuminate\Database\Connection $connection
+ * @return void
*/
public function __construct($sql, $bindings, $time, $connection)
{
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Grammar.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Grammar.php
index 243f07c3..38525653 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Grammar.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Grammar.php
@@ -2,10 +2,13 @@
namespace Illuminate\Database;
+use Illuminate\Support\Traits\Macroable;
use Illuminate\Database\Query\Expression;
abstract class Grammar
{
+ use Macroable;
+
/**
* The grammar table prefix.
*
@@ -53,9 +56,9 @@ abstract class Grammar
}
// If the value being wrapped has a column alias we will need to separate out
- // the pieces so we can wrap each of the segments of the expression on it
- // own, and then joins them both back together with the "as" connector.
- if (strpos(strtolower($value), ' as ') !== false) {
+ // the pieces so we can wrap each of the segments of the expression on its
+ // own, and then join these both back together using the "as" connector.
+ if (stripos($value, ' as ') !== false) {
return $this->wrapAliasedValue($value, $prefixAlias);
}
@@ -148,6 +151,21 @@ abstract class Grammar
return $this->isExpression($value) ? $this->getValue($value) : '?';
}
+ /**
+ * Quote the given string literal.
+ *
+ * @param string|array $value
+ * @return string
+ */
+ public function quoteString($value)
+ {
+ if (is_array($value)) {
+ return implode(', ', array_map([$this, __FUNCTION__], $value));
+ }
+
+ return "'$value'";
+ }
+
/**
* Determine if the given value is a raw expression.
*
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/MigrationServiceProvider.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/MigrationServiceProvider.php
index a8b92ab6..212827c7 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/MigrationServiceProvider.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/MigrationServiceProvider.php
@@ -4,18 +4,12 @@ namespace Illuminate\Database;
use Illuminate\Support\ServiceProvider;
use Illuminate\Database\Migrations\Migrator;
+use Illuminate\Contracts\Support\DeferrableProvider;
use Illuminate\Database\Migrations\MigrationCreator;
use Illuminate\Database\Migrations\DatabaseMigrationRepository;
-class MigrationServiceProvider extends ServiceProvider
+class MigrationServiceProvider extends ServiceProvider implements DeferrableProvider
{
- /**
- * Indicates if loading of the provider is deferred.
- *
- * @var bool
- */
- protected $defer = true;
-
/**
* Register the service provider.
*
@@ -57,7 +51,7 @@ class MigrationServiceProvider extends ServiceProvider
$this->app->singleton('migrator', function ($app) {
$repository = $app['migration.repository'];
- return new Migrator($repository, $app['db'], $app['files']);
+ return new Migrator($repository, $app['db'], $app['files'], $app['events']);
});
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Migrations/DatabaseMigrationRepository.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Migrations/DatabaseMigrationRepository.php
index 726cbda0..1ace1a6f 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Migrations/DatabaseMigrationRepository.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Migrations/DatabaseMigrationRepository.php
@@ -41,7 +41,7 @@ class DatabaseMigrationRepository implements MigrationRepositoryInterface
}
/**
- * Get the ran migrations.
+ * Get the completed migrations.
*
* @return array
*/
@@ -63,7 +63,9 @@ class DatabaseMigrationRepository implements MigrationRepositoryInterface
{
$query = $this->table()->where('batch', '>=', '1');
- return $query->orderBy('migration', 'desc')->take($steps)->get()->all();
+ return $query->orderBy('batch', 'desc')
+ ->orderBy('migration', 'desc')
+ ->take($steps)->get()->all();
}
/**
@@ -78,11 +80,24 @@ class DatabaseMigrationRepository implements MigrationRepositoryInterface
return $query->orderBy('migration', 'desc')->get()->all();
}
+ /**
+ * Get the completed migrations with their batch numbers.
+ *
+ * @return array
+ */
+ public function getMigrationBatches()
+ {
+ return $this->table()
+ ->orderBy('batch', 'asc')
+ ->orderBy('migration', 'asc')
+ ->pluck('batch', 'migration')->all();
+ }
+
/**
* Log that a migration was run.
*
* @param string $file
- * @param int $batch
+ * @param int $batch
* @return void
*/
public function log($file, $batch)
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migration.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migration.php
index 699154c9..a58f7848 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migration.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migration.php
@@ -7,14 +7,21 @@ abstract class Migration
/**
* The name of the database connection to use.
*
- * @var string
+ * @var string|null
*/
protected $connection;
+ /**
+ * Enables, if supported, wrapping the migration within a transaction.
+ *
+ * @var bool
+ */
+ public $withinTransaction = true;
+
/**
* Get the migration connection name.
*
- * @return string
+ * @return string|null
*/
public function getConnection()
{
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Migrations/MigrationCreator.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Migrations/MigrationCreator.php
index 29bae7ad..015a0dde 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Migrations/MigrationCreator.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Migrations/MigrationCreator.php
@@ -39,9 +39,10 @@ class MigrationCreator
*
* @param string $name
* @param string $path
- * @param string $table
+ * @param string|null $table
* @param bool $create
* @return string
+ *
* @throws \Exception
*/
public function create($name, $path, $table = null, $create = false)
@@ -61,7 +62,7 @@ class MigrationCreator
// Next, we will fire any hooks that are supposed to fire after a migration is
// created. Once that is done we'll be ready to return the full path to the
// migration file so it can be used however it's needed by the developer.
- $this->firePostCreateHooks();
+ $this->firePostCreateHooks($table);
return $path;
}
@@ -77,14 +78,14 @@ class MigrationCreator
protected function ensureMigrationDoesntAlreadyExist($name)
{
if (class_exists($className = $this->getClassName($name))) {
- throw new InvalidArgumentException("A {$className} migration already exists.");
+ throw new InvalidArgumentException("A {$className} class already exists.");
}
}
/**
* Get the migration stub file.
*
- * @param string $table
+ * @param string|null $table
* @param bool $create
* @return string
*/
@@ -97,11 +98,9 @@ class MigrationCreator
// We also have stubs for creating new tables and modifying existing tables
// to save the developer some typing when they are creating a new tables
// or modifying existing tables. We'll grab the appropriate stub here.
- else {
- $stub = $create ? 'create.stub' : 'update.stub';
+ $stub = $create ? 'create.stub' : 'update.stub';
- return $this->files->get($this->stubPath()."/{$stub}");
- }
+ return $this->files->get($this->stubPath()."/{$stub}");
}
/**
@@ -109,7 +108,7 @@ class MigrationCreator
*
* @param string $name
* @param string $stub
- * @param string $table
+ * @param string|null $table
* @return string
*/
protected function populateStub($name, $stub, $table)
@@ -152,12 +151,13 @@ class MigrationCreator
/**
* Fire the registered post create hooks.
*
+ * @param string|null $table
* @return void
*/
- protected function firePostCreateHooks()
+ protected function firePostCreateHooks($table)
{
foreach ($this->postCreate as $callback) {
- call_user_func($callback);
+ call_user_func($callback, $table);
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Migrations/MigrationRepositoryInterface.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Migrations/MigrationRepositoryInterface.php
index 60bc921f..410326a9 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Migrations/MigrationRepositoryInterface.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Migrations/MigrationRepositoryInterface.php
@@ -5,7 +5,7 @@ namespace Illuminate\Database\Migrations;
interface MigrationRepositoryInterface
{
/**
- * Get the ran migrations for a given package.
+ * Get the completed migrations.
*
* @return array
*/
@@ -26,11 +26,18 @@ interface MigrationRepositoryInterface
*/
public function getLast();
+ /**
+ * Get the completed migrations with their batch numbers.
+ *
+ * @return array
+ */
+ public function getMigrationBatches();
+
/**
* Log that a migration was run.
*
* @param string $file
- * @param int $batch
+ * @param int $batch
* @return void
*/
public function log($file, $batch);
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php
index 18c30f4d..2bf3a15d 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php
@@ -5,11 +5,24 @@ namespace Illuminate\Database\Migrations;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
use Illuminate\Support\Collection;
+use Illuminate\Console\OutputStyle;
use Illuminate\Filesystem\Filesystem;
+use Illuminate\Contracts\Events\Dispatcher;
+use Illuminate\Database\Events\MigrationEnded;
+use Illuminate\Database\Events\MigrationsEnded;
+use Illuminate\Database\Events\MigrationStarted;
+use Illuminate\Database\Events\MigrationsStarted;
use Illuminate\Database\ConnectionResolverInterface as Resolver;
class Migrator
{
+ /**
+ * The event dispatcher instance.
+ *
+ * @var \Illuminate\Contracts\Events\Dispatcher
+ */
+ protected $events;
+
/**
* The migration repository implementation.
*
@@ -38,13 +51,6 @@ class Migrator
*/
protected $connection;
- /**
- * The notes for the current operation.
- *
- * @var array
- */
- protected $notes = [];
-
/**
* The paths to all of the migration files.
*
@@ -52,19 +58,29 @@ class Migrator
*/
protected $paths = [];
+ /**
+ * The output interface implementation.
+ *
+ * @var \Illuminate\Console\OutputStyle
+ */
+ protected $output;
+
/**
* Create a new migrator instance.
*
* @param \Illuminate\Database\Migrations\MigrationRepositoryInterface $repository
* @param \Illuminate\Database\ConnectionResolverInterface $resolver
* @param \Illuminate\Filesystem\Filesystem $files
+ * @param \Illuminate\Contracts\Events\Dispatcher|null $dispatcher
* @return void
*/
public function __construct(MigrationRepositoryInterface $repository,
Resolver $resolver,
- Filesystem $files)
+ Filesystem $files,
+ Dispatcher $dispatcher = null)
{
$this->files = $files;
+ $this->events = $dispatcher;
$this->resolver = $resolver;
$this->repository = $repository;
}
@@ -78,8 +94,6 @@ class Migrator
*/
public function run($paths = [], array $options = [])
{
- $this->notes = [];
-
// Once we grab all of the migration files for the path, we will compare them
// against the migrations that have already been run for this package then
// run each of the outstanding migrations against a database connection.
@@ -124,7 +138,7 @@ class Migrator
// First we will just make sure that there are any migrations to run. If there
// aren't, we will just make a note of it to the developer so they're aware
// that all of the migrations have been run against this database system.
- if (count($migrations) == 0) {
+ if (count($migrations) === 0) {
$this->note('
Nothing to migrate.');
return;
@@ -135,9 +149,11 @@ class Migrator
// each migration's execution. We will also extract a few of the options.
$batch = $this->repository->getNextBatchNumber();
- $pretend = Arr::get($options, 'pretend', false);
+ $pretend = $options['pretend'] ?? false;
- $step = Arr::get($options, 'step', false);
+ $step = $options['step'] ?? false;
+
+ $this->fireMigrationEvent(new MigrationsStarted);
// Once we have the array of migrations, we will spin through them and run the
// migrations "up" so the changes are made to the databases. We'll then log
@@ -149,6 +165,8 @@ class Migrator
$batch++;
}
}
+
+ $this->fireMigrationEvent(new MigrationsEnded);
}
/**
@@ -174,14 +192,18 @@ class Migrator
$this->note("
Migrating: {$name}");
+ $startTime = microtime(true);
+
$this->runMigration($migration, 'up');
+ $runTime = round(microtime(true) - $startTime, 2);
+
// Once we have run a migrations class, we will log that it was run in this
// repository so that we don't try to run it next time we do a migration
// in the application. A migration repository keeps the migrate order.
$this->repository->log($name, $batch);
- $this->note("
Migrated: {$name}");
+ $this->note("
Migrated: {$name} ({$runTime} seconds)");
}
/**
@@ -193,8 +215,6 @@ class Migrator
*/
public function rollback($paths = [], array $options = [])
{
- $this->notes = [];
-
// We want to pull in the last batch of migrations that ran on the previous
// migration operation. We'll then reverse those migrations and run each
// of them "down" to reverse the last migration "operation" which ran.
@@ -204,9 +224,9 @@ class Migrator
$this->note('
Nothing to rollback.');
return [];
- } else {
- return $this->rollbackMigrations($migrations, $paths, $options);
}
+
+ return $this->rollbackMigrations($migrations, $paths, $options);
}
/**
@@ -217,11 +237,11 @@ class Migrator
*/
protected function getMigrationsForRollback(array $options)
{
- if (($steps = Arr::get($options, 'step', 0)) > 0) {
+ if (($steps = $options['step'] ?? 0) > 0) {
return $this->repository->getMigrations($steps);
- } else {
- return $this->repository->getLast();
}
+
+ return $this->repository->getLast();
}
/**
@@ -238,6 +258,8 @@ class Migrator
$this->requireFiles($files = $this->getMigrationFiles($paths));
+ $this->fireMigrationEvent(new MigrationsStarted);
+
// Next we will run through all of the migrations and call the "down" method
// which will reverse each migration in order. This getLast method on the
// repository already returns these migration's names in reverse order.
@@ -254,10 +276,12 @@ class Migrator
$this->runDown(
$file, $migration,
- Arr::get($options, 'pretend', false)
+ $options['pretend'] ?? false
);
}
+ $this->fireMigrationEvent(new MigrationsEnded);
+
return $rolledBack;
}
@@ -270,8 +294,6 @@ class Migrator
*/
public function reset($paths = [], $pretend = false)
{
- $this->notes = [];
-
// Next, we will reverse the migration list so we can run them back in the
// correct order for resetting this database. This will allow us to get
// the database back into its "empty" state ready for the migrations.
@@ -281,9 +303,9 @@ class Migrator
$this->note('
Nothing to rollback.');
return [];
- } else {
- return $this->resetMigrations($migrations, $paths, $pretend);
}
+
+ return $this->resetMigrations($migrations, $paths, $pretend);
}
/**
@@ -331,14 +353,18 @@ class Migrator
return $this->pretendToRun($instance, 'down');
}
+ $startTime = microtime(true);
+
$this->runMigration($instance, 'down');
+ $runTime = round(microtime(true) - $startTime, 2);
+
// Once we have successfully run the migration "down" we will remove it from
// the migration repository so it will be considered to have not been run
// by the application then will be able to fire by any later operation.
$this->repository->delete($migration);
- $this->note("
Rolled back: {$name}");
+ $this->note("
Rolled back: {$name} ({$runTime} seconds)");
}
/**
@@ -356,11 +382,16 @@ class Migrator
$callback = function () use ($migration, $method) {
if (method_exists($migration, $method)) {
+ $this->fireMigrationEvent(new MigrationStarted($migration, $method));
+
$migration->{$method}();
+
+ $this->fireMigrationEvent(new MigrationEnded($migration, $method));
}
};
$this->getSchemaGrammar($connection)->supportsSchemaTransactions()
+ && $migration->withinTransaction
? $connection->transaction($callback)
: $callback();
}
@@ -394,7 +425,7 @@ class Migrator
// queries against the database returning the array of raw SQL statements
// that would get fired against the database system for this migration.
$db = $this->resolveConnection(
- $connection = $migration->getConnection()
+ $migration->getConnection()
);
return $db->pretend(function () use ($migration, $method) {
@@ -426,7 +457,7 @@ class Migrator
public function getMigrationFiles($paths)
{
return Collection::make($paths)->flatMap(function ($path) {
- return $this->files->glob($path.'/*_*.php');
+ return Str::endsWith($path, '.php') ? [$path] : $this->files->glob($path.'/*_*.php');
})->filter()->sortBy(function ($file) {
return $this->getMigrationName($file);
})->values()->keyBy(function ($file) {
@@ -479,6 +510,16 @@ class Migrator
return $this->paths;
}
+ /**
+ * Get the default connection name.
+ *
+ * @return string
+ */
+ public function getConnection()
+ {
+ return $this->connection;
+ }
+
/**
* Set the default connection name.
*
@@ -555,23 +596,41 @@ class Migrator
}
/**
- * Raise a note event for the migrator.
+ * Set the output implementation that should be used by the console.
+ *
+ * @param \Illuminate\Console\OutputStyle $output
+ * @return $this
+ */
+ public function setOutput(OutputStyle $output)
+ {
+ $this->output = $output;
+
+ return $this;
+ }
+
+ /**
+ * Write a note to the console's output.
*
* @param string $message
* @return void
*/
protected function note($message)
{
- $this->notes[] = $message;
+ if ($this->output) {
+ $this->output->writeln($message);
+ }
}
/**
- * Get the notes for the last operation.
+ * Fire the given event for the migration.
*
- * @return array
+ * @param \Illuminate\Contracts\Database\Events\MigrationEvent $event
+ * @return void
*/
- public function getNotes()
+ public function fireMigrationEvent($event)
{
- return $this->notes;
+ if ($this->events) {
+ $this->events->dispatch($event);
+ }
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Migrations/stubs/create.stub b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Migrations/stubs/create.stub
index a98c4749..08e171bc 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Migrations/stubs/create.stub
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Migrations/stubs/create.stub
@@ -14,7 +14,7 @@ class DummyClass extends Migration
public function up()
{
Schema::create('DummyTable', function (Blueprint $table) {
- $table->increments('id');
+ $table->bigIncrements('id');
$table->timestamps();
});
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php
index c57d73d5..9d2cea5a 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php
@@ -4,7 +4,7 @@ namespace Illuminate\Database\Query;
use Closure;
use RuntimeException;
-use BadMethodCallException;
+use DateTimeInterface;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
use InvalidArgumentException;
@@ -13,6 +13,7 @@ use Illuminate\Pagination\Paginator;
use Illuminate\Support\Traits\Macroable;
use Illuminate\Contracts\Support\Arrayable;
use Illuminate\Database\ConnectionInterface;
+use Illuminate\Support\Traits\ForwardsCalls;
use Illuminate\Database\Concerns\BuildsQueries;
use Illuminate\Database\Query\Grammars\Grammar;
use Illuminate\Database\Query\Processors\Processor;
@@ -20,14 +21,14 @@ use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
class Builder
{
- use BuildsQueries, Macroable {
+ use BuildsQueries, ForwardsCalls, Macroable {
__call as macroCall;
}
/**
* The database connection instance.
*
- * @var \Illuminate\Database\Connection
+ * @var \Illuminate\Database\ConnectionInterface
*/
public $connection;
@@ -52,6 +53,7 @@ class Builder
*/
public $bindings = [
'select' => [],
+ 'from' => [],
'join' => [],
'where' => [],
'having' => [],
@@ -178,9 +180,9 @@ class Builder
*/
public $operators = [
'=', '<', '>', '<=', '>=', '<>', '!=', '<=>',
- 'like', 'like binary', 'not like', 'between', 'ilike',
+ 'like', 'like binary', 'not like', 'ilike',
'&', '|', '^', '<<', '>>',
- 'rlike', 'regexp', 'not regexp',
+ 'rlike', 'not rlike', 'regexp', 'not regexp',
'~', '~*', '!~', '!~*', 'similar to',
'not similar to', 'not ilike', '~~*', '!~~*',
];
@@ -196,8 +198,8 @@ class Builder
* Create a new query builder instance.
*
* @param \Illuminate\Database\ConnectionInterface $connection
- * @param \Illuminate\Database\Query\Grammars\Grammar $grammar
- * @param \Illuminate\Database\Query\Processors\Processor $processor
+ * @param \Illuminate\Database\Query\Grammars\Grammar|null $grammar
+ * @param \Illuminate\Database\Query\Processors\Processor|null $processor
* @return void
*/
public function __construct(ConnectionInterface $connection,
@@ -222,6 +224,24 @@ class Builder
return $this;
}
+ /**
+ * Add a subselect expression to the query.
+ *
+ * @param \Closure|\Illuminate\Database\Query\Builder|string $query
+ * @param string $as
+ * @return \Illuminate\Database\Query\Builder|static
+ *
+ * @throws \InvalidArgumentException
+ */
+ public function selectSub($query, $as)
+ {
+ [$query, $bindings] = $this->createSub($query);
+
+ return $this->selectRaw(
+ '('.$query.') as '.$this->grammar->wrap($as), $bindings
+ );
+ }
+
/**
* Add a new "raw" select expression to the query.
*
@@ -241,7 +261,7 @@ class Builder
}
/**
- * Add a subselect expression to the query.
+ * Makes "from" fetch from a subquery.
*
* @param \Closure|\Illuminate\Database\Query\Builder|string $query
* @param string $as
@@ -249,7 +269,36 @@ class Builder
*
* @throws \InvalidArgumentException
*/
- public function selectSub($query, $as)
+ public function fromSub($query, $as)
+ {
+ [$query, $bindings] = $this->createSub($query);
+
+ return $this->fromRaw('('.$query.') as '.$this->grammar->wrapTable($as), $bindings);
+ }
+
+ /**
+ * Add a raw from clause to the query.
+ *
+ * @param string $expression
+ * @param mixed $bindings
+ * @return \Illuminate\Database\Query\Builder|static
+ */
+ public function fromRaw($expression, $bindings = [])
+ {
+ $this->from = new Expression($expression);
+
+ $this->addBinding($bindings, 'from');
+
+ return $this;
+ }
+
+ /**
+ * Creates a subquery and parse it.
+ *
+ * @param \Closure|\Illuminate\Database\Query\Builder|string $query
+ * @return array
+ */
+ protected function createSub($query)
{
// If the given query is a Closure, we will execute it while passing in a new
// query instance to the Closure. This will give the developer a chance to
@@ -257,30 +306,21 @@ class Builder
if ($query instanceof Closure) {
$callback = $query;
- $callback($query = $this->newQuery());
+ $callback($query = $this->forSubQuery());
}
- // Here, we will parse this query into an SQL string and an array of bindings
- // so we can add it to the query builder using the selectRaw method so the
- // query is included in the real SQL generated by this builder instance.
- list($query, $bindings) = $this->parseSubSelect($query);
-
- return $this->selectRaw(
- '('.$query.') as '.$this->grammar->wrap($as), $bindings
- );
+ return $this->parseSub($query);
}
/**
- * Parse the sub-select query into SQL and bindings.
+ * Parse the subquery into SQL and bindings.
*
* @param mixed $query
* @return array
*/
- protected function parseSubSelect($query)
+ protected function parseSub($query)
{
- if ($query instanceof self) {
- $query->columns = [$query->columns[0]];
-
+ if ($query instanceof self || $query instanceof EloquentBuilder) {
return [$query->toSql(), $query->getBindings()];
} elseif (is_string($query)) {
return [$query, []];
@@ -333,16 +373,16 @@ class Builder
* Add a join clause to the query.
*
* @param string $table
- * @param string $first
- * @param string $operator
- * @param string $second
+ * @param \Closure|string $first
+ * @param string|null $operator
+ * @param string|null $second
* @param string $type
* @param bool $where
* @return $this
*/
public function join($table, $first, $operator = null, $second = null, $type = 'inner', $where = false)
{
- $join = new JoinClause($this, $type, $table);
+ $join = $this->newJoinClause($this, $type, $table);
// If the first "column" of the join is really a Closure instance the developer
// is trying to build a join with a complex "on" clause containing more than
@@ -373,7 +413,7 @@ class Builder
* Add a "join where" clause to the query.
*
* @param string $table
- * @param string $first
+ * @param \Closure|string $first
* @param string $operator
* @param string $second
* @param string $type
@@ -384,13 +424,38 @@ class Builder
return $this->join($table, $first, $operator, $second, $type, true);
}
+ /**
+ * Add a subquery join clause to the query.
+ *
+ * @param \Closure|\Illuminate\Database\Query\Builder|string $query
+ * @param string $as
+ * @param \Closure|string $first
+ * @param string|null $operator
+ * @param string|null $second
+ * @param string $type
+ * @param bool $where
+ * @return \Illuminate\Database\Query\Builder|static
+ *
+ * @throws \InvalidArgumentException
+ */
+ public function joinSub($query, $as, $first, $operator = null, $second = null, $type = 'inner', $where = false)
+ {
+ [$query, $bindings] = $this->createSub($query);
+
+ $expression = '('.$query.') as '.$this->grammar->wrapTable($as);
+
+ $this->addBinding($bindings, 'join');
+
+ return $this->join(new Expression($expression), $first, $operator, $second, $type, $where);
+ }
+
/**
* Add a left join to the query.
*
* @param string $table
- * @param string $first
- * @param string $operator
- * @param string $second
+ * @param \Closure|string $first
+ * @param string|null $operator
+ * @param string|null $second
* @return \Illuminate\Database\Query\Builder|static
*/
public function leftJoin($table, $first, $operator = null, $second = null)
@@ -402,7 +467,7 @@ class Builder
* Add a "join where" clause to the query.
*
* @param string $table
- * @param string $first
+ * @param \Closure|string $first
* @param string $operator
* @param string $second
* @return \Illuminate\Database\Query\Builder|static
@@ -412,13 +477,28 @@ class Builder
return $this->joinWhere($table, $first, $operator, $second, 'left');
}
+ /**
+ * Add a subquery left join to the query.
+ *
+ * @param \Closure|\Illuminate\Database\Query\Builder|string $query
+ * @param string $as
+ * @param \Closure|string $first
+ * @param string|null $operator
+ * @param string|null $second
+ * @return \Illuminate\Database\Query\Builder|static
+ */
+ public function leftJoinSub($query, $as, $first, $operator = null, $second = null)
+ {
+ return $this->joinSub($query, $as, $first, $operator, $second, 'left');
+ }
+
/**
* Add a right join to the query.
*
* @param string $table
- * @param string $first
- * @param string $operator
- * @param string $second
+ * @param \Closure|string $first
+ * @param string|null $operator
+ * @param string|null $second
* @return \Illuminate\Database\Query\Builder|static
*/
public function rightJoin($table, $first, $operator = null, $second = null)
@@ -430,7 +510,7 @@ class Builder
* Add a "right join where" clause to the query.
*
* @param string $table
- * @param string $first
+ * @param \Closure|string $first
* @param string $operator
* @param string $second
* @return \Illuminate\Database\Query\Builder|static
@@ -440,13 +520,28 @@ class Builder
return $this->joinWhere($table, $first, $operator, $second, 'right');
}
+ /**
+ * Add a subquery right join to the query.
+ *
+ * @param \Closure|\Illuminate\Database\Query\Builder|string $query
+ * @param string $as
+ * @param \Closure|string $first
+ * @param string|null $operator
+ * @param string|null $second
+ * @return \Illuminate\Database\Query\Builder|static
+ */
+ public function rightJoinSub($query, $as, $first, $operator = null, $second = null)
+ {
+ return $this->joinSub($query, $as, $first, $operator, $second, 'right');
+ }
+
/**
* Add a "cross join" clause to the query.
*
* @param string $table
- * @param string $first
- * @param string $operator
- * @param string $second
+ * @param \Closure|string|null $first
+ * @param string|null $operator
+ * @param string|null $second
* @return \Illuminate\Database\Query\Builder|static
*/
public function crossJoin($table, $first = null, $operator = null, $second = null)
@@ -455,11 +550,24 @@ class Builder
return $this->join($table, $first, $operator, $second, 'cross');
}
- $this->joins[] = new JoinClause($this, 'cross', $table);
+ $this->joins[] = $this->newJoinClause($this, 'cross', $table);
return $this;
}
+ /**
+ * Get a new join clause.
+ *
+ * @param \Illuminate\Database\Query\Builder $parentQuery
+ * @param string $type
+ * @param string $table
+ * @return \Illuminate\Database\Query\JoinClause
+ */
+ protected function newJoinClause(self $parentQuery, $type, $table)
+ {
+ return new JoinClause($parentQuery, $type, $table);
+ }
+
/**
* Merge an array of where clauses and bindings.
*
@@ -480,7 +588,7 @@ class Builder
* Add a basic where clause to the query.
*
* @param string|array|\Closure $column
- * @param string $operator
+ * @param mixed $operator
* @param mixed $value
* @param string $boolean
* @return $this
@@ -497,8 +605,8 @@ class Builder
// Here we will make some assumptions about the operator. If only 2 values are
// passed to the method, we will assume that the operator is an equals sign
// and keep going. Otherwise, we'll require the operator to be passed in.
- list($value, $operator) = $this->prepareValueAndOperator(
- $value, $operator, func_num_args() == 2
+ [$value, $operator] = $this->prepareValueAndOperator(
+ $value, $operator, func_num_args() === 2
);
// If the columns is actually a Closure instance, we will assume the developer
@@ -512,7 +620,7 @@ class Builder
// assume that the developer is just short-cutting the '=' operators and
// we will set the operators to '=' and set the values appropriately.
if ($this->invalidOperator($operator)) {
- list($value, $operator) = [$operator, '='];
+ [$value, $operator] = [$operator, '='];
}
// If the value is a Closure, it means the developer is performing an entire
@@ -526,21 +634,25 @@ class Builder
// where null clause to the query. So, we will allow a short-cut here to
// that method for convenience so the developer doesn't have to check.
if (is_null($value)) {
- return $this->whereNull($column, $boolean, $operator != '=');
+ return $this->whereNull($column, $boolean, $operator !== '=');
}
+ $type = 'Basic';
+
// If the column is making a JSON reference we'll check to see if the value
// is a boolean. If it is, we'll add the raw boolean string as an actual
// value to the query to ensure this is properly handled by the query.
if (Str::contains($column, '->') && is_bool($value)) {
$value = new Expression($value ? 'true' : 'false');
+
+ if (is_string($column)) {
+ $type = 'JsonBoolean';
+ }
}
// Now that we are working with just a simple query we can put the elements
// in our array and add the query binding to our array of bindings that
// will be bound to each SQL statements when it is finally executed.
- $type = 'Basic';
-
$this->wheres[] = compact(
'type', 'column', 'operator', 'value', 'boolean'
);
@@ -583,7 +695,7 @@ class Builder
*
* @throws \InvalidArgumentException
*/
- protected function prepareValueAndOperator($value, $operator, $useDefault = false)
+ public function prepareValueAndOperator($value, $operator, $useDefault = false)
{
if ($useDefault) {
return [$operator, '='];
@@ -625,12 +737,16 @@ class Builder
* Add an "or where" clause to the query.
*
* @param string|array|\Closure $column
- * @param string $operator
- * @param mixed $value
+ * @param mixed $operator
+ * @param mixed $value
* @return \Illuminate\Database\Query\Builder|static
*/
public function orWhere($column, $operator = null, $value = null)
{
+ [$value, $operator] = $this->prepareValueAndOperator(
+ $value, $operator, func_num_args() === 2
+ );
+
return $this->where($column, $operator, $value, 'or');
}
@@ -656,7 +772,7 @@ class Builder
// assume that the developer is just short-cutting the '=' operators and
// we will set the operators to '=' and set the values appropriately.
if ($this->invalidOperator($operator)) {
- list($second, $operator) = [$operator, '='];
+ [$second, $operator] = [$operator, '='];
}
// Finally, we will add this where clause into this array of clauses that we
@@ -726,24 +842,17 @@ class Builder
{
$type = $not ? 'NotIn' : 'In';
- if ($values instanceof EloquentBuilder) {
- $values = $values->getQuery();
- }
-
// If the value is a query builder instance we will assume the developer wants to
// look for any values that exists within this given query. So we will add the
// query accordingly so that this query is properly executed when it is run.
- if ($values instanceof self) {
- return $this->whereInExistingQuery(
- $column, $values, $boolean, $not
- );
- }
+ if ($values instanceof self ||
+ $values instanceof EloquentBuilder ||
+ $values instanceof Closure) {
+ [$query, $bindings] = $this->createSub($values);
- // If the value of the where in clause is actually a Closure, we will assume that
- // the developer is using a full sub-select for this "in" statement, and will
- // execute those Closures, then we can re-construct the entire sub-selects.
- if ($values instanceof Closure) {
- return $this->whereInSub($column, $values, $boolean, $not);
+ $values = [new Expression($query)];
+
+ $this->addBinding($bindings, 'where');
}
// Next, if the value is Arrayable we need to cast it to its raw array form so we
@@ -758,11 +867,7 @@ class Builder
// Finally we'll add a binding for each values unless that value is an expression
// in which case we will just skip over it since it will be the query as a raw
// string and not as a parameterized place-holder to be replaced by the PDO.
- foreach ($values as $value) {
- if (! $value instanceof Expression) {
- $this->addBinding($value, 'where');
- }
- }
+ $this->addBinding($this->cleanBindings($values), 'where');
return $this;
}
@@ -820,7 +925,7 @@ class Builder
// To create the exists sub-select, we will actually create a query and call the
// provided callback with the query so the developer may set any of the query
// conditions they want for the in clause, then we'll put it in this array.
- call_user_func($callback, $query = $this->newQuery());
+ call_user_func($callback, $query = $this->forSubQuery());
$this->wheres[] = compact('type', 'column', 'query', 'boolean');
@@ -850,18 +955,59 @@ class Builder
}
/**
- * Add a "where null" clause to the query.
+ * Add a "where in raw" clause for integer values to the query.
*
* @param string $column
+ * @param \Illuminate\Contracts\Support\Arrayable|array $values
+ * @param string $boolean
+ * @param bool $not
+ * @return $this
+ */
+ public function whereIntegerInRaw($column, $values, $boolean = 'and', $not = false)
+ {
+ $type = $not ? 'NotInRaw' : 'InRaw';
+
+ if ($values instanceof Arrayable) {
+ $values = $values->toArray();
+ }
+
+ foreach ($values as &$value) {
+ $value = (int) $value;
+ }
+
+ $this->wheres[] = compact('type', 'column', 'values', 'boolean');
+
+ return $this;
+ }
+
+ /**
+ * Add a "where not in raw" clause for integer values to the query.
+ *
+ * @param string $column
+ * @param \Illuminate\Contracts\Support\Arrayable|array $values
+ * @param string $boolean
+ * @return $this
+ */
+ public function whereIntegerNotInRaw($column, $values, $boolean = 'and')
+ {
+ return $this->whereIntegerInRaw($column, $values, $boolean, true);
+ }
+
+ /**
+ * Add a "where null" clause to the query.
+ *
+ * @param string|array $columns
* @param string $boolean
* @param bool $not
* @return $this
*/
- public function whereNull($column, $boolean = 'and', $not = false)
+ public function whereNull($columns, $boolean = 'and', $not = false)
{
$type = $not ? 'NotNull' : 'Null';
- $this->wheres[] = compact('type', 'column', 'boolean');
+ foreach (Arr::wrap($columns) as $column) {
+ $this->wheres[] = compact('type', 'column', 'boolean');
+ }
return $this;
}
@@ -902,9 +1048,9 @@ class Builder
{
$type = 'between';
- $this->wheres[] = compact('column', 'type', 'boolean', 'not');
+ $this->wheres[] = compact('type', 'column', 'values', 'boolean', 'not');
- $this->addBinding($values, 'where');
+ $this->addBinding($this->cleanBindings($values), 'where');
return $this;
}
@@ -962,16 +1108,20 @@ class Builder
*
* @param string $column
* @param string $operator
- * @param mixed $value
+ * @param \DateTimeInterface|string|null $value
* @param string $boolean
* @return \Illuminate\Database\Query\Builder|static
*/
public function whereDate($column, $operator, $value = null, $boolean = 'and')
{
- list($value, $operator) = $this->prepareValueAndOperator(
- $value, $operator, func_num_args() == 2
+ [$value, $operator] = $this->prepareValueAndOperator(
+ $value, $operator, func_num_args() === 2
);
+ if ($value instanceof DateTimeInterface) {
+ $value = $value->format('Y-m-d');
+ }
+
return $this->addDateBasedWhere('Date', $column, $operator, $value, $boolean);
}
@@ -980,11 +1130,15 @@ class Builder
*
* @param string $column
* @param string $operator
- * @param string $value
+ * @param \DateTimeInterface|string|null $value
* @return \Illuminate\Database\Query\Builder|static
*/
- public function orWhereDate($column, $operator, $value)
+ public function orWhereDate($column, $operator, $value = null)
{
+ [$value, $operator] = $this->prepareValueAndOperator(
+ $value, $operator, func_num_args() === 2
+ );
+
return $this->whereDate($column, $operator, $value, 'or');
}
@@ -993,12 +1147,20 @@ class Builder
*
* @param string $column
* @param string $operator
- * @param int $value
+ * @param \DateTimeInterface|string|null $value
* @param string $boolean
* @return \Illuminate\Database\Query\Builder|static
*/
- public function whereTime($column, $operator, $value, $boolean = 'and')
+ public function whereTime($column, $operator, $value = null, $boolean = 'and')
{
+ [$value, $operator] = $this->prepareValueAndOperator(
+ $value, $operator, func_num_args() === 2
+ );
+
+ if ($value instanceof DateTimeInterface) {
+ $value = $value->format('H:i:s');
+ }
+
return $this->addDateBasedWhere('Time', $column, $operator, $value, $boolean);
}
@@ -1007,11 +1169,15 @@ class Builder
*
* @param string $column
* @param string $operator
- * @param int $value
+ * @param \DateTimeInterface|string|null $value
* @return \Illuminate\Database\Query\Builder|static
*/
- public function orWhereTime($column, $operator, $value)
+ public function orWhereTime($column, $operator, $value = null)
{
+ [$value, $operator] = $this->prepareValueAndOperator(
+ $value, $operator, func_num_args() === 2
+ );
+
return $this->whereTime($column, $operator, $value, 'or');
}
@@ -1020,62 +1186,133 @@ class Builder
*
* @param string $column
* @param string $operator
- * @param mixed $value
+ * @param \DateTimeInterface|string|null $value
* @param string $boolean
* @return \Illuminate\Database\Query\Builder|static
*/
public function whereDay($column, $operator, $value = null, $boolean = 'and')
{
- list($value, $operator) = $this->prepareValueAndOperator(
- $value, $operator, func_num_args() == 2
+ [$value, $operator] = $this->prepareValueAndOperator(
+ $value, $operator, func_num_args() === 2
);
+ if ($value instanceof DateTimeInterface) {
+ $value = $value->format('d');
+ }
+
+ if (! $value instanceof Expression) {
+ $value = str_pad($value, 2, '0', STR_PAD_LEFT);
+ }
+
return $this->addDateBasedWhere('Day', $column, $operator, $value, $boolean);
}
+ /**
+ * Add an "or where day" statement to the query.
+ *
+ * @param string $column
+ * @param string $operator
+ * @param \DateTimeInterface|string|null $value
+ * @return \Illuminate\Database\Query\Builder|static
+ */
+ public function orWhereDay($column, $operator, $value = null)
+ {
+ [$value, $operator] = $this->prepareValueAndOperator(
+ $value, $operator, func_num_args() === 2
+ );
+
+ return $this->whereDay($column, $operator, $value, 'or');
+ }
+
/**
* Add a "where month" statement to the query.
*
* @param string $column
* @param string $operator
- * @param mixed $value
+ * @param \DateTimeInterface|string|null $value
* @param string $boolean
* @return \Illuminate\Database\Query\Builder|static
*/
public function whereMonth($column, $operator, $value = null, $boolean = 'and')
{
- list($value, $operator) = $this->prepareValueAndOperator(
- $value, $operator, func_num_args() == 2
+ [$value, $operator] = $this->prepareValueAndOperator(
+ $value, $operator, func_num_args() === 2
);
+ if ($value instanceof DateTimeInterface) {
+ $value = $value->format('m');
+ }
+
+ if (! $value instanceof Expression) {
+ $value = str_pad($value, 2, '0', STR_PAD_LEFT);
+ }
+
return $this->addDateBasedWhere('Month', $column, $operator, $value, $boolean);
}
+ /**
+ * Add an "or where month" statement to the query.
+ *
+ * @param string $column
+ * @param string $operator
+ * @param \DateTimeInterface|string|null $value
+ * @return \Illuminate\Database\Query\Builder|static
+ */
+ public function orWhereMonth($column, $operator, $value = null)
+ {
+ [$value, $operator] = $this->prepareValueAndOperator(
+ $value, $operator, func_num_args() === 2
+ );
+
+ return $this->whereMonth($column, $operator, $value, 'or');
+ }
+
/**
* Add a "where year" statement to the query.
*
* @param string $column
* @param string $operator
- * @param mixed $value
+ * @param \DateTimeInterface|string|int|null $value
* @param string $boolean
* @return \Illuminate\Database\Query\Builder|static
*/
public function whereYear($column, $operator, $value = null, $boolean = 'and')
{
- list($value, $operator) = $this->prepareValueAndOperator(
- $value, $operator, func_num_args() == 2
+ [$value, $operator] = $this->prepareValueAndOperator(
+ $value, $operator, func_num_args() === 2
);
+ if ($value instanceof DateTimeInterface) {
+ $value = $value->format('Y');
+ }
+
return $this->addDateBasedWhere('Year', $column, $operator, $value, $boolean);
}
+ /**
+ * Add an "or where year" statement to the query.
+ *
+ * @param string $column
+ * @param string $operator
+ * @param \DateTimeInterface|string|int|null $value
+ * @return \Illuminate\Database\Query\Builder|static
+ */
+ public function orWhereYear($column, $operator, $value = null)
+ {
+ [$value, $operator] = $this->prepareValueAndOperator(
+ $value, $operator, func_num_args() === 2
+ );
+
+ return $this->whereYear($column, $operator, $value, 'or');
+ }
+
/**
* Add a date based (year, month, day, time) statement to the query.
*
* @param string $type
* @param string $column
* @param string $operator
- * @param int $value
+ * @param mixed $value
* @param string $boolean
* @return $this
*/
@@ -1083,7 +1320,9 @@ class Builder
{
$this->wheres[] = compact('column', 'type', 'boolean', 'operator', 'value');
- $this->addBinding($value, 'where');
+ if (! $value instanceof Expression) {
+ $this->addBinding($value, 'where');
+ }
return $this;
}
@@ -1126,7 +1365,7 @@ class Builder
$this->wheres[] = compact('type', 'query', 'boolean');
- $this->addBinding($query->getBindings(), 'where');
+ $this->addBinding($query->getRawBindings()['where'], 'where');
}
return $this;
@@ -1148,7 +1387,7 @@ class Builder
// Once we have the query instance we can simply execute it so it can add all
// of the sub-select's conditions to itself, and then we can cache it off
// in the array of where clauses for the "main" parent query instance.
- call_user_func($callback, $query = $this->newQuery());
+ call_user_func($callback, $query = $this->forSubQuery());
$this->wheres[] = compact(
'type', 'column', 'operator', 'query', 'boolean'
@@ -1169,7 +1408,7 @@ class Builder
*/
public function whereExists(Closure $callback, $boolean = 'and', $not = false)
{
- $query = $this->newQuery();
+ $query = $this->forSubQuery();
// Similar to the sub-select clause, we will create a new query instance so
// the developer may cleanly specify the entire exists query and we will
@@ -1222,22 +1461,161 @@ class Builder
* @param bool $not
* @return $this
*/
- public function addWhereExistsQuery(Builder $query, $boolean = 'and', $not = false)
+ public function addWhereExistsQuery(self $query, $boolean = 'and', $not = false)
{
$type = $not ? 'NotExists' : 'Exists';
- $this->wheres[] = compact('type', 'operator', 'query', 'boolean');
+ $this->wheres[] = compact('type', 'query', 'boolean');
$this->addBinding($query->getBindings(), 'where');
return $this;
}
+ /**
+ * Adds a where condition using row values.
+ *
+ * @param array $columns
+ * @param string $operator
+ * @param array $values
+ * @param string $boolean
+ * @return $this
+ */
+ public function whereRowValues($columns, $operator, $values, $boolean = 'and')
+ {
+ if (count($columns) !== count($values)) {
+ throw new InvalidArgumentException('The number of columns must match the number of values');
+ }
+
+ $type = 'RowValues';
+
+ $this->wheres[] = compact('type', 'columns', 'operator', 'values', 'boolean');
+
+ $this->addBinding($this->cleanBindings($values));
+
+ return $this;
+ }
+
+ /**
+ * Adds a or where condition using row values.
+ *
+ * @param array $columns
+ * @param string $operator
+ * @param array $values
+ * @return $this
+ */
+ public function orWhereRowValues($columns, $operator, $values)
+ {
+ return $this->whereRowValues($columns, $operator, $values, 'or');
+ }
+
+ /**
+ * Add a "where JSON contains" clause to the query.
+ *
+ * @param string $column
+ * @param mixed $value
+ * @param string $boolean
+ * @param bool $not
+ * @return $this
+ */
+ public function whereJsonContains($column, $value, $boolean = 'and', $not = false)
+ {
+ $type = 'JsonContains';
+
+ $this->wheres[] = compact('type', 'column', 'value', 'boolean', 'not');
+
+ if (! $value instanceof Expression) {
+ $this->addBinding($this->grammar->prepareBindingForJsonContains($value));
+ }
+
+ return $this;
+ }
+
+ /**
+ * Add a "or where JSON contains" clause to the query.
+ *
+ * @param string $column
+ * @param mixed $value
+ * @return $this
+ */
+ public function orWhereJsonContains($column, $value)
+ {
+ return $this->whereJsonContains($column, $value, 'or');
+ }
+
+ /**
+ * Add a "where JSON not contains" clause to the query.
+ *
+ * @param string $column
+ * @param mixed $value
+ * @param string $boolean
+ * @return $this
+ */
+ public function whereJsonDoesntContain($column, $value, $boolean = 'and')
+ {
+ return $this->whereJsonContains($column, $value, $boolean, true);
+ }
+
+ /**
+ * Add a "or where JSON not contains" clause to the query.
+ *
+ * @param string $column
+ * @param mixed $value
+ * @return $this
+ */
+ public function orWhereJsonDoesntContain($column, $value)
+ {
+ return $this->whereJsonDoesntContain($column, $value, 'or');
+ }
+
+ /**
+ * Add a "where JSON length" clause to the query.
+ *
+ * @param string $column
+ * @param mixed $operator
+ * @param mixed $value
+ * @param string $boolean
+ * @return $this
+ */
+ public function whereJsonLength($column, $operator, $value = null, $boolean = 'and')
+ {
+ $type = 'JsonLength';
+
+ [$value, $operator] = $this->prepareValueAndOperator(
+ $value, $operator, func_num_args() === 2
+ );
+
+ $this->wheres[] = compact('type', 'column', 'operator', 'value', 'boolean');
+
+ if (! $value instanceof Expression) {
+ $this->addBinding($value);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Add a "or where JSON length" clause to the query.
+ *
+ * @param string $column
+ * @param mixed $operator
+ * @param mixed $value
+ * @return $this
+ */
+ public function orWhereJsonLength($column, $operator, $value = null)
+ {
+ [$value, $operator] = $this->prepareValueAndOperator(
+ $value, $operator, func_num_args() === 2
+ );
+
+ return $this->whereJsonLength($column, $operator, $value, 'or');
+ }
+
/**
* Handles dynamic "where" clauses to the query.
*
* @param string $method
- * @param string $parameters
+ * @param array $parameters
* @return $this
*/
public function dynamicWhere($method, $parameters)
@@ -1259,7 +1637,7 @@ class Builder
// If the segment is not a boolean connector, we can assume it is a column's name
// and we will add it to the query as a new constraint as a where clause, then
// we can keep iterating through the dynamic method string's segments again.
- if ($segment != 'And' && $segment != 'Or') {
+ if ($segment !== 'And' && $segment !== 'Or') {
$this->addDynamic($segment, $connector, $parameters, $index);
$index++;
@@ -1306,7 +1684,7 @@ class Builder
foreach ($groups as $group) {
$this->groups = array_merge(
(array) $this->groups,
- array_wrap($group)
+ Arr::wrap($group)
);
}
@@ -1317,8 +1695,8 @@ class Builder
* Add a "having" clause to the query.
*
* @param string $column
- * @param string $operator
- * @param string $value
+ * @param string|null $operator
+ * @param string|null $value
* @param string $boolean
* @return $this
*/
@@ -1329,15 +1707,15 @@ class Builder
// Here we will make some assumptions about the operator. If only 2 values are
// passed to the method, we will assume that the operator is an equals sign
// and keep going. Otherwise, we'll require the operator to be passed in.
- list($value, $operator) = $this->prepareValueAndOperator(
- $value, $operator, func_num_args() == 2
+ [$value, $operator] = $this->prepareValueAndOperator(
+ $value, $operator, func_num_args() === 2
);
// If the given operator is not found in the list of valid operators we will
// assume that the developer is just short-cutting the '=' operators and
// we will set the operators to '=' and set the values appropriately.
if ($this->invalidOperator($operator)) {
- list($value, $operator) = [$operator, '='];
+ [$value, $operator] = [$operator, '='];
}
$this->havings[] = compact('type', 'column', 'operator', 'value', 'boolean');
@@ -1353,15 +1731,39 @@ class Builder
* Add a "or having" clause to the query.
*
* @param string $column
- * @param string $operator
- * @param string $value
+ * @param string|null $operator
+ * @param string|null $value
* @return \Illuminate\Database\Query\Builder|static
*/
public function orHaving($column, $operator = null, $value = null)
{
+ [$value, $operator] = $this->prepareValueAndOperator(
+ $value, $operator, func_num_args() === 2
+ );
+
return $this->having($column, $operator, $value, 'or');
}
+ /**
+ * Add a "having between " clause to the query.
+ *
+ * @param string $column
+ * @param array $values
+ * @param string $boolean
+ * @param bool $not
+ * @return \Illuminate\Database\Query\Builder|static
+ */
+ public function havingBetween($column, array $values, $boolean = 'and', $not = false)
+ {
+ $type = 'between';
+
+ $this->havings[] = compact('type', 'column', 'values', 'boolean', 'not');
+
+ $this->addBinding($this->cleanBindings($values), 'having');
+
+ return $this;
+ }
+
/**
* Add a raw having clause to the query.
*
@@ -1399,12 +1801,20 @@ class Builder
* @param string $column
* @param string $direction
* @return $this
+ *
+ * @throws \InvalidArgumentException
*/
public function orderBy($column, $direction = 'asc')
{
+ $direction = strtolower($direction);
+
+ if (! in_array($direction, ['asc', 'desc'], true)) {
+ throw new InvalidArgumentException('Order direction must be "asc" or "desc".');
+ }
+
$this->{$this->unions ? 'unionOrders' : 'orders'}[] = [
'column' => $column,
- 'direction' => strtolower($direction) == 'asc' ? 'asc' : 'desc',
+ 'direction' => $direction,
];
return $this;
@@ -1538,11 +1948,31 @@ class Builder
return $this->skip(($page - 1) * $perPage)->take($perPage);
}
+ /**
+ * Constrain the query to the previous "page" of results before a given ID.
+ *
+ * @param int $perPage
+ * @param int|null $lastId
+ * @param string $column
+ * @return \Illuminate\Database\Query\Builder|static
+ */
+ public function forPageBeforeId($perPage = 15, $lastId = 0, $column = 'id')
+ {
+ $this->orders = $this->removeExistingOrdersFor($column);
+
+ if (! is_null($lastId)) {
+ $this->where($column, '<', $lastId);
+ }
+
+ return $this->orderBy($column, 'desc')
+ ->take($perPage);
+ }
+
/**
* Constrain the query to the next "page" of results after a given ID.
*
* @param int $perPage
- * @param int $lastId
+ * @param int|null $lastId
* @param string $column
* @return \Illuminate\Database\Query\Builder|static
*/
@@ -1550,8 +1980,11 @@ class Builder
{
$this->orders = $this->removeExistingOrdersFor($column);
- return $this->where($column, '>', $lastId)
- ->orderBy($column, 'asc')
+ if (! is_null($lastId)) {
+ $this->where($column, '>', $lastId);
+ }
+
+ return $this->orderBy($column, 'asc')
->take($perPage);
}
@@ -1651,7 +2084,7 @@ class Builder
/**
* Execute a query for a single record by ID.
*
- * @param int $id
+ * @param int|string $id
* @param array $columns
* @return mixed|static
*/
@@ -1676,22 +2109,14 @@ class Builder
/**
* Execute the query as a "select" statement.
*
- * @param array $columns
+ * @param array|string $columns
* @return \Illuminate\Support\Collection
*/
public function get($columns = ['*'])
{
- $original = $this->columns;
-
- if (is_null($original)) {
- $this->columns = $columns;
- }
-
- $results = $this->processor->processSelect($this, $this->runSelect());
-
- $this->columns = $original;
-
- return collect($results);
+ return collect($this->onceWithColumns(Arr::wrap($columns), function () {
+ return $this->processor->processSelect($this, $this->runSelect());
+ }));
}
/**
@@ -1719,7 +2144,7 @@ class Builder
{
$page = $page ?: Paginator::resolveCurrentPage($pageName);
- $total = $this->getCountForPagination($columns);
+ $total = $this->getCountForPagination();
$results = $total ? $this->forPage($page, $perPage)->get($columns) : collect();
@@ -1771,9 +2196,9 @@ class Builder
return 0;
} elseif (is_object($results[0])) {
return (int) $results[0]->aggregate;
- } else {
- return (int) array_change_key_case((array) $results[0])['aggregate'];
}
+
+ return (int) array_change_key_case((array) $results[0])['aggregate'];
}
/**
@@ -1784,8 +2209,10 @@ class Builder
*/
protected function runPaginationCountQuery($columns = ['*'])
{
- return $this->cloneWithout(['columns', 'orders', 'limit', 'offset'])
- ->cloneWithoutBindings(['select', 'order'])
+ $without = $this->unions ? ['orders', 'limit', 'offset'] : ['columns', 'orders', 'limit', 'offset'];
+
+ return $this->cloneWithout($without)
+ ->cloneWithoutBindings($this->unions ? ['order'] : ['select', 'order'])
->setAggregate('count', $this->withoutSelectAliases($columns))
->get()->all();
}
@@ -1799,7 +2226,7 @@ class Builder
protected function withoutSelectAliases(array $columns)
{
return array_map(function ($column) {
- return is_string($column) && ($aliasPosition = strpos(strtolower($column), ' as ')) !== false
+ return is_string($column) && ($aliasPosition = stripos($column, ' as ')) !== false
? substr($column, 0, $aliasPosition) : $column;
}, $columns);
}
@@ -1826,14 +2253,14 @@ class Builder
* @param int $count
* @param callable $callback
* @param string $column
- * @param string $alias
+ * @param string|null $alias
* @return bool
*/
public function chunkById($count, callable $callback, $column = 'id', $alias = null)
{
$alias = $alias ?: $column;
- $lastId = 0;
+ $lastId = null;
do {
$clone = clone $this;
@@ -1857,6 +2284,8 @@ class Builder
}
$lastId = $results->last()->{$alias};
+
+ unset($results);
} while ($countResults == $count);
return true;
@@ -1885,15 +2314,32 @@ class Builder
*/
public function pluck($column, $key = null)
{
- $results = $this->get(is_null($key) ? [$column] : [$column, $key]);
+ // First, we will need to select the results of the query accounting for the
+ // given columns / key. Once we have the results, we will be able to take
+ // the results and get the exact data that was requested for the query.
+ $queryResult = $this->onceWithColumns(
+ is_null($key) ? [$column] : [$column, $key],
+ function () {
+ return $this->processor->processSelect(
+ $this, $this->runSelect()
+ );
+ }
+ );
+
+ if (empty($queryResult)) {
+ return collect();
+ }
// If the columns are qualified with a table or have an alias, we cannot use
// those directly in the "pluck" operations since the results from the DB
// are only keyed by the column itself. We'll strip the table out here.
- return $results->pluck(
- $this->stripTableForPluck($column),
- $this->stripTableForPluck($key)
- );
+ $column = $this->stripTableForPluck($column);
+
+ $key = $this->stripTableForPluck($key);
+
+ return is_array($queryResult[0])
+ ? $this->pluckFromArrayColumn($queryResult, $column, $key)
+ : $this->pluckFromObjectColumn($queryResult, $column, $key);
}
/**
@@ -1907,6 +2353,56 @@ class Builder
return is_null($column) ? $column : last(preg_split('~\.| ~', $column));
}
+ /**
+ * Retrieve column values from rows represented as objects.
+ *
+ * @param array $queryResult
+ * @param string $column
+ * @param string $key
+ * @return \Illuminate\Support\Collection
+ */
+ protected function pluckFromObjectColumn($queryResult, $column, $key)
+ {
+ $results = [];
+
+ if (is_null($key)) {
+ foreach ($queryResult as $row) {
+ $results[] = $row->$column;
+ }
+ } else {
+ foreach ($queryResult as $row) {
+ $results[$row->$key] = $row->$column;
+ }
+ }
+
+ return collect($results);
+ }
+
+ /**
+ * Retrieve column values from rows represented as arrays.
+ *
+ * @param array $queryResult
+ * @param string $column
+ * @param string $key
+ * @return \Illuminate\Support\Collection
+ */
+ protected function pluckFromArrayColumn($queryResult, $column, $key)
+ {
+ $results = [];
+
+ if (is_null($key)) {
+ foreach ($queryResult as $row) {
+ $results[] = $row[$column];
+ }
+ } else {
+ foreach ($queryResult as $row) {
+ $results[$row[$key]] = $row[$column];
+ }
+ }
+
+ return collect($results);
+ }
+
/**
* Concatenate values of a given column as a string.
*
@@ -1942,6 +2438,16 @@ class Builder
return false;
}
+ /**
+ * Determine if no rows exist for the current query.
+ *
+ * @return bool
+ */
+ public function doesntExist()
+ {
+ return ! $this->exists();
+ }
+
/**
* Retrieve the "count" result of the query.
*
@@ -1950,7 +2456,7 @@ class Builder
*/
public function count($columns = '*')
{
- return (int) $this->aggregate(__FUNCTION__, array_wrap($columns));
+ return (int) $this->aggregate(__FUNCTION__, Arr::wrap($columns));
}
/**
@@ -2019,8 +2525,8 @@ class Builder
*/
public function aggregate($function, $columns = ['*'])
{
- $results = $this->cloneWithout(['columns'])
- ->cloneWithoutBindings(['select'])
+ $results = $this->cloneWithout($this->unions ? [] : ['columns'])
+ ->cloneWithoutBindings($this->unions ? [] : ['select'])
->setAggregate($function, $columns)
->get($columns);
@@ -2078,6 +2584,30 @@ class Builder
return $this;
}
+ /**
+ * Execute the given callback while selecting the given columns.
+ *
+ * After running the callback, the columns are reset to the original value.
+ *
+ * @param array $columns
+ * @param callable $callback
+ * @return mixed
+ */
+ protected function onceWithColumns($columns, $callback)
+ {
+ $original = $this->columns;
+
+ if (is_null($original)) {
+ $this->columns = $columns;
+ }
+
+ $result = $callback();
+
+ $this->columns = $original;
+
+ return $result;
+ }
+
/**
* Insert a new record into the database.
*
@@ -2117,11 +2647,38 @@ class Builder
);
}
+ /**
+ * Insert a new record into the database while ignoring errors.
+ *
+ * @param array $values
+ * @return int
+ */
+ public function insertOrIgnore(array $values)
+ {
+ if (empty($values)) {
+ return 0;
+ }
+
+ if (! is_array(reset($values))) {
+ $values = [$values];
+ } else {
+ foreach ($values as $key => $value) {
+ ksort($value);
+ $values[$key] = $value;
+ }
+ }
+
+ return $this->connection->affectingStatement(
+ $this->grammar->compileInsertOrIgnore($this, $values),
+ $this->cleanBindings(Arr::flatten($values, 1))
+ );
+ }
+
/**
* Insert a new record and get the value of the primary key.
*
- * @param array $values
- * @param string $sequence
+ * @param array $values
+ * @param string|null $sequence
* @return int
*/
public function insertGetId(array $values, $sequence = null)
@@ -2133,6 +2690,23 @@ class Builder
return $this->processor->processInsertGetId($this, $sql, $values, $sequence);
}
+ /**
+ * Insert new records into the table using a subquery.
+ *
+ * @param array $columns
+ * @param \Closure|\Illuminate\Database\Query\Builder|string $query
+ * @return bool
+ */
+ public function insertUsing(array $columns, $query)
+ {
+ [$sql, $bindings] = $this->createSub($query);
+
+ return $this->connection->insert(
+ $this->grammar->compileInsertUsing($this, $columns, $sql),
+ $this->cleanBindings($bindings)
+ );
+ }
+
/**
* Update a record in the database.
*
@@ -2161,6 +2735,10 @@ class Builder
return $this->insert(array_merge($attributes, $values));
}
+ if (empty($values)) {
+ return true;
+ }
+
return (bool) $this->take(1)->update($values);
}
@@ -2168,8 +2746,8 @@ class Builder
* Increment a column's value by a given amount.
*
* @param string $column
- * @param int $amount
- * @param array $extra
+ * @param float|int $amount
+ * @param array $extra
* @return int
*/
public function increment($column, $amount = 1, array $extra = [])
@@ -2189,8 +2767,8 @@ class Builder
* Decrement a column's value by a given amount.
*
* @param string $column
- * @param int $amount
- * @param array $extra
+ * @param float|int $amount
+ * @param array $extra
* @return int
*/
public function decrement($column, $amount = 1, array $extra = [])
@@ -2222,7 +2800,9 @@ class Builder
}
return $this->connection->delete(
- $this->grammar->compileDelete($this), $this->getBindings()
+ $this->grammar->compileDelete($this), $this->cleanBindings(
+ $this->grammar->prepareBindingsForDelete($this->bindings)
+ )
);
}
@@ -2248,6 +2828,16 @@ class Builder
return new static($this->connection, $this->grammar, $this->processor);
}
+ /**
+ * Create a new query instance for a sub-query.
+ *
+ * @return \Illuminate\Database\Query\Builder
+ */
+ protected function forSubQuery()
+ {
+ return $this->newQuery();
+ }
+
/**
* Create a raw database expression.
*
@@ -2329,7 +2919,7 @@ class Builder
* @param \Illuminate\Database\Query\Builder $query
* @return $this
*/
- public function mergeBindings(Builder $query)
+ public function mergeBindings(self $query)
{
$this->bindings = array_merge_recursive($this->bindings, $query->bindings);
@@ -2394,13 +2984,13 @@ class Builder
/**
* Clone the query without the given properties.
*
- * @param array $except
+ * @param array $properties
* @return static
*/
- public function cloneWithout(array $except)
+ public function cloneWithout(array $properties)
{
- return tap(clone $this, function ($clone) use ($except) {
- foreach ($except as $property) {
+ return tap(clone $this, function ($clone) use ($properties) {
+ foreach ($properties as $property) {
$clone->{$property} = null;
}
});
@@ -2421,6 +3011,28 @@ class Builder
});
}
+ /**
+ * Dump the current SQL and bindings.
+ *
+ * @return $this
+ */
+ public function dump()
+ {
+ dump($this->toSql(), $this->getBindings());
+
+ return $this;
+ }
+
+ /**
+ * Die and dump the current SQL and bindings.
+ *
+ * @return void
+ */
+ public function dd()
+ {
+ dd($this->toSql(), $this->getBindings());
+ }
+
/**
* Handle dynamic method calls into the method.
*
@@ -2440,8 +3052,6 @@ class Builder
return $this->dynamicWhere($method, $parameters);
}
- $className = static::class;
-
- throw new BadMethodCallException("Call to undefined method {$className}::{$method}()");
+ static::throwBadMethodCallException($method);
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Query/Grammars/Grammar.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Query/Grammars/Grammar.php
index b7e59733..0d8241fc 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Query/Grammars/Grammar.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Query/Grammars/Grammar.php
@@ -2,7 +2,9 @@
namespace Illuminate\Database\Query\Grammars;
+use RuntimeException;
use Illuminate\Support\Arr;
+use Illuminate\Support\Str;
use Illuminate\Database\Query\Builder;
use Illuminate\Database\Query\JoinClause;
use Illuminate\Database\Grammar as BaseGrammar;
@@ -44,6 +46,10 @@ class Grammar extends BaseGrammar
*/
public function compileSelect(Builder $query)
{
+ if ($query->unions && $query->aggregate) {
+ return $this->compileUnionAggregate($query);
+ }
+
// If the query does not have any columns set, we'll set the columns to the
// * character to just get all of the columns from the database. Then we
// can build the query and concatenate all the pieces together as one.
@@ -79,7 +85,7 @@ class Grammar extends BaseGrammar
// To compile the query, we'll spin through each component of the query and
// see if that component exists. If it does we'll just call the compiler
// function for the component which is responsible for making the SQL.
- if (! is_null($query->$component)) {
+ if (isset($query->$component) && ! is_null($query->$component)) {
$method = 'compile'.ucfirst($component);
$sql[$component] = $this->$method($query, $query->$component);
@@ -155,7 +161,11 @@ class Grammar extends BaseGrammar
return collect($joins)->map(function ($join) use ($query) {
$table = $this->wrapTable($join->table);
- return trim("{$join->type} join {$table} {$this->compileWheres($join)}");
+ $nestedJoins = is_null($join->joins) ? '' : ' '.$this->compileJoins($query, $join->joins);
+
+ $tableAndNestedJoins = is_null($join->joins) ? $table : '('.$table.$nestedJoins.')';
+
+ return trim("{$join->type} join {$tableAndNestedJoins} {$this->compileWheres($join)}");
})->implode(' ');
}
@@ -269,6 +279,24 @@ class Grammar extends BaseGrammar
return '1 = 1';
}
+ /**
+ * Compile a "where not in raw" clause.
+ *
+ * For safety, whereIntegerInRaw ensures this method is only used with integer values.
+ *
+ * @param \Illuminate\Database\Query\Builder $query
+ * @param array $where
+ * @return string
+ */
+ protected function whereNotInRaw(Builder $query, $where)
+ {
+ if (! empty($where['values'])) {
+ return $this->wrap($where['column']).' not in ('.implode(', ', $where['values']).')';
+ }
+
+ return '1 = 1';
+ }
+
/**
* Compile a where in sub-select clause.
*
@@ -293,6 +321,24 @@ class Grammar extends BaseGrammar
return $this->wrap($where['column']).' not in ('.$this->compileSelect($where['query']).')';
}
+ /**
+ * Compile a "where in raw" clause.
+ *
+ * For safety, whereIntegerInRaw ensures this method is only used with integer values.
+ *
+ * @param \Illuminate\Database\Query\Builder $query
+ * @param array $where
+ * @return string
+ */
+ protected function whereInRaw(Builder $query, $where)
+ {
+ if (! empty($where['values'])) {
+ return $this->wrap($where['column']).' in ('.implode(', ', $where['values']).')';
+ }
+
+ return '0 = 1';
+ }
+
/**
* Compile a "where null" clause.
*
@@ -328,7 +374,11 @@ class Grammar extends BaseGrammar
{
$between = $where['not'] ? 'not between' : 'between';
- return $this->wrap($where['column']).' '.$between.' ? and ?';
+ $min = $this->parameter(reset($where['values']));
+
+ $max = $this->parameter(end($where['values']));
+
+ return $this->wrap($where['column']).' '.$between.' '.$min.' and '.$max;
}
/**
@@ -473,6 +523,110 @@ class Grammar extends BaseGrammar
return 'not exists ('.$this->compileSelect($where['query']).')';
}
+ /**
+ * Compile a where row values condition.
+ *
+ * @param \Illuminate\Database\Query\Builder $query
+ * @param array $where
+ * @return string
+ */
+ protected function whereRowValues(Builder $query, $where)
+ {
+ $columns = $this->columnize($where['columns']);
+
+ $values = $this->parameterize($where['values']);
+
+ return '('.$columns.') '.$where['operator'].' ('.$values.')';
+ }
+
+ /**
+ * Compile a "where JSON boolean" clause.
+ *
+ * @param \Illuminate\Database\Query\Builder $query
+ * @param array $where
+ * @return string
+ */
+ protected function whereJsonBoolean(Builder $query, $where)
+ {
+ $column = $this->wrapJsonBooleanSelector($where['column']);
+
+ $value = $this->wrapJsonBooleanValue(
+ $this->parameter($where['value'])
+ );
+
+ return $column.' '.$where['operator'].' '.$value;
+ }
+
+ /**
+ * Compile a "where JSON contains" clause.
+ *
+ * @param \Illuminate\Database\Query\Builder $query
+ * @param array $where
+ * @return string
+ */
+ protected function whereJsonContains(Builder $query, $where)
+ {
+ $not = $where['not'] ? 'not ' : '';
+
+ return $not.$this->compileJsonContains(
+ $where['column'], $this->parameter($where['value'])
+ );
+ }
+
+ /**
+ * Compile a "JSON contains" statement into SQL.
+ *
+ * @param string $column
+ * @param string $value
+ * @return string
+ *
+ * @throws \RuntimeException
+ */
+ protected function compileJsonContains($column, $value)
+ {
+ throw new RuntimeException('This database engine does not support JSON contains operations.');
+ }
+
+ /**
+ * Prepare the binding for a "JSON contains" statement.
+ *
+ * @param mixed $binding
+ * @return string
+ */
+ public function prepareBindingForJsonContains($binding)
+ {
+ return json_encode($binding);
+ }
+
+ /**
+ * Compile a "where JSON length" clause.
+ *
+ * @param \Illuminate\Database\Query\Builder $query
+ * @param array $where
+ * @return string
+ */
+ protected function whereJsonLength(Builder $query, $where)
+ {
+ return $this->compileJsonLength(
+ $where['column'], $where['operator'], $this->parameter($where['value'])
+ );
+ }
+
+ /**
+ * Compile a "JSON length" statement into SQL.
+ *
+ * @param string $column
+ * @param string $operator
+ * @param string $value
+ * @return string
+ *
+ * @throws \RuntimeException
+ */
+ protected function compileJsonLength($column, $operator, $value)
+ {
+ throw new RuntimeException('This database engine does not support JSON length operations.');
+ }
+
/**
* Compile the "group by" portions of the query.
*
@@ -512,6 +666,8 @@ class Grammar extends BaseGrammar
// clause into SQL based on the components that make it up from builder.
if ($having['type'] === 'Raw') {
return $having['boolean'].' '.$having['sql'];
+ } elseif ($having['type'] === 'between') {
+ return $this->compileHavingBetween($having);
}
return $this->compileBasicHaving($having);
@@ -532,6 +688,25 @@ class Grammar extends BaseGrammar
return $having['boolean'].' '.$column.' '.$having['operator'].' '.$parameter;
}
+ /**
+ * Compile a "between" having clause.
+ *
+ * @param array $having
+ * @return string
+ */
+ protected function compileHavingBetween($having)
+ {
+ $between = $having['not'] ? 'not between' : 'between';
+
+ $column = $this->wrap($having['column']);
+
+ $min = $this->parameter(head($having['values']));
+
+ $max = $this->parameter(last($having['values']));
+
+ return $having['boolean'].' '.$column.' '.$between.' '.$min.' and '.$max;
+ }
+
/**
* Compile the "order by" portions of the query.
*
@@ -551,16 +726,14 @@ class Grammar extends BaseGrammar
/**
* Compile the query orders to an array.
*
- * @param \Illuminate\Database\Query\Builder
+ * @param \Illuminate\Database\Query\Builder $query
* @param array $orders
* @return array
*/
protected function compileOrdersToArray(Builder $query, $orders)
{
return array_map(function ($order) {
- return ! isset($order['sql'])
- ? $this->wrap($order['column']).' '.$order['direction']
- : $order['sql'];
+ return $order['sql'] ?? $this->wrap($order['column']).' '.$order['direction'];
}, $orders);
}
@@ -636,9 +809,24 @@ class Grammar extends BaseGrammar
*/
protected function compileUnion(array $union)
{
- $conjuction = $union['all'] ? ' union all ' : ' union ';
+ $conjunction = $union['all'] ? ' union all ' : ' union ';
- return $conjuction.$union['query']->toSql();
+ return $conjunction.$union['query']->toSql();
+ }
+
+ /**
+ * Compile a union aggregate query into SQL.
+ *
+ * @param \Illuminate\Database\Query\Builder $query
+ * @return string
+ */
+ protected function compileUnionAggregate(Builder $query)
+ {
+ $sql = $this->compileAggregate($query, $query->aggregate);
+
+ $query->aggregate = null;
+
+ return $sql.' from ('.$this->compileSelect($query).') as '.$this->wrapTable('temp_table');
}
/**
@@ -684,6 +872,18 @@ class Grammar extends BaseGrammar
return "insert into $table ($columns) values $parameters";
}
+ /**
+ * Compile an insert ignore statement into SQL.
+ *
+ * @param \Illuminate\Database\Query\Builder $query
+ * @param array $values
+ * @return string
+ */
+ public function compileInsertOrIgnore(Builder $query, array $values)
+ {
+ throw new RuntimeException('This database engine does not support inserting while ignoring errors.');
+ }
+
/**
* Compile an insert and get ID statement into SQL.
*
@@ -697,6 +897,19 @@ class Grammar extends BaseGrammar
return $this->compileInsert($query, $values);
}
+ /**
+ * Compile an insert statement using a subquery into SQL.
+ *
+ * @param \Illuminate\Database\Query\Builder $query
+ * @param array $columns
+ * @param string $sql
+ * @return string
+ */
+ public function compileInsertUsing(Builder $query, array $columns, string $sql)
+ {
+ return "insert into {$this->wrapTable($query->from)} ({$this->columnize($columns)}) $sql";
+ }
+
/**
* Compile an update statement into SQL.
*
@@ -741,10 +954,10 @@ class Grammar extends BaseGrammar
*/
public function prepareBindingsForUpdate(array $bindings, array $values)
{
- $bindingsWithoutJoin = Arr::except($bindings, 'join');
+ $cleanBindings = Arr::except($bindings, ['select', 'join']);
return array_values(
- array_merge($bindings['join'], $values, Arr::flatten($bindingsWithoutJoin))
+ array_merge($bindings['join'], $values, Arr::flatten($cleanBindings))
);
}
@@ -761,6 +974,19 @@ class Grammar extends BaseGrammar
return trim("delete from {$this->wrapTable($query->from)} $wheres");
}
+ /**
+ * Prepare the bindings for a delete statement.
+ *
+ * @param array $bindings
+ * @return array
+ */
+ public function prepareBindingsForDelete(array $bindings)
+ {
+ return Arr::flatten(
+ Arr::except($bindings, 'select')
+ );
+ }
+
/**
* Compile a truncate table statement into SQL.
*
@@ -816,6 +1042,111 @@ class Grammar extends BaseGrammar
return 'ROLLBACK TO SAVEPOINT '.$name;
}
+ /**
+ * Wrap a value in keyword identifiers.
+ *
+ * @param \Illuminate\Database\Query\Expression|string $value
+ * @param bool $prefixAlias
+ * @return string
+ */
+ public function wrap($value, $prefixAlias = false)
+ {
+ if ($this->isExpression($value)) {
+ return $this->getValue($value);
+ }
+
+ // If the value being wrapped has a column alias we will need to separate out
+ // the pieces so we can wrap each of the segments of the expression on its
+ // own, and then join these both back together using the "as" connector.
+ if (stripos($value, ' as ') !== false) {
+ return $this->wrapAliasedValue($value, $prefixAlias);
+ }
+
+ // If the given value is a JSON selector we will wrap it differently than a
+ // traditional value. We will need to split this path and wrap each part
+ // wrapped, etc. Otherwise, we will simply wrap the value as a string.
+ if ($this->isJsonSelector($value)) {
+ return $this->wrapJsonSelector($value);
+ }
+
+ return $this->wrapSegments(explode('.', $value));
+ }
+
+ /**
+ * Wrap the given JSON selector.
+ *
+ * @param string $value
+ * @return string
+ */
+ protected function wrapJsonSelector($value)
+ {
+ throw new RuntimeException('This database engine does not support JSON operations.');
+ }
+
+ /**
+ * Wrap the given JSON selector for boolean values.
+ *
+ * @param string $value
+ * @return string
+ */
+ protected function wrapJsonBooleanSelector($value)
+ {
+ return $this->wrapJsonSelector($value);
+ }
+
+ /**
+ * Wrap the given JSON boolean value.
+ *
+ * @param string $value
+ * @return string
+ */
+ protected function wrapJsonBooleanValue($value)
+ {
+ return $value;
+ }
+
+ /**
+ * Split the given JSON selector into the field and the optional path and wrap them separately.
+ *
+ * @param string $column
+ * @return array
+ */
+ protected function wrapJsonFieldAndPath($column)
+ {
+ $parts = explode('->', $column, 2);
+
+ $field = $this->wrap($parts[0]);
+
+ $path = count($parts) > 1 ? ', '.$this->wrapJsonPath($parts[1], '->') : '';
+
+ return [$field, $path];
+ }
+
+ /**
+ * Wrap the given JSON path.
+ *
+ * @param string $value
+ * @param string $delimiter
+ * @return string
+ */
+ protected function wrapJsonPath($value, $delimiter = '->')
+ {
+ $value = preg_replace("/([\\\\]+)?\\'/", "\\'", $value);
+
+ return '\'$."'.str_replace($delimiter, '"."', $value).'"\'';
+ }
+
+ /**
+ * Determine if the given string is a JSON selector.
+ *
+ * @param string $value
+ * @return bool
+ */
+ protected function isJsonSelector($value)
+ {
+ return Str::contains($value, '->');
+ }
+
/**
* Concatenate an array of segments, removing empties.
*
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Query/Grammars/MySqlGrammar.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Query/Grammars/MySqlGrammar.php
index 6943c147..3b6462a6 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Query/Grammars/MySqlGrammar.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Query/Grammars/MySqlGrammar.php
@@ -8,6 +8,13 @@ use Illuminate\Database\Query\JsonExpression;
class MySqlGrammar extends Grammar
{
+ /**
+ * The grammar specific operators.
+ *
+ * @var array
+ */
+ protected $operators = ['sounds like'];
+
/**
* The components that make up a select clause.
*
@@ -35,6 +42,10 @@ class MySqlGrammar extends Grammar
*/
public function compileSelect(Builder $query)
{
+ if ($query->unions && $query->aggregate) {
+ return $this->compileUnionAggregate($query);
+ }
+
$sql = parent::compileSelect($query);
if ($query->unions) {
@@ -44,6 +55,47 @@ class MySqlGrammar extends Grammar
return $sql;
}
+ /**
+ * Compile an insert ignore statement into SQL.
+ *
+ * @param \Illuminate\Database\Query\Builder $query
+ * @param array $values
+ * @return string
+ */
+ public function compileInsertOrIgnore(Builder $query, array $values)
+ {
+ return Str::replaceFirst('insert', 'insert ignore', $this->compileInsert($query, $values));
+ }
+
+ /**
+ * Compile a "JSON contains" statement into SQL.
+ *
+ * @param string $column
+ * @param string $value
+ * @return string
+ */
+ protected function compileJsonContains($column, $value)
+ {
+ [$field, $path] = $this->wrapJsonFieldAndPath($column);
+
+ return 'json_contains('.$field.', '.$value.$path.')';
+ }
+
+ /**
+ * Compile a "JSON length" statement into SQL.
+ *
+ * @param string $column
+ * @param string $operator
+ * @param string $value
+ * @return string
+ */
+ protected function compileJsonLength($column, $operator, $value)
+ {
+ [$field, $path] = $this->wrapJsonFieldAndPath($column);
+
+ return 'json_length('.$field.$path.') '.$operator.' '.$value;
+ }
+
/**
* Compile a single union statement.
*
@@ -52,9 +104,9 @@ class MySqlGrammar extends Grammar
*/
protected function compileUnion(array $union)
{
- $conjuction = $union['all'] ? ' union all ' : ' union ';
+ $conjunction = $union['all'] ? ' union all ' : ' union ';
- return $conjuction.'('.$union['query']->toSql().')';
+ return $conjunction.'('.$union['query']->toSql().')';
}
/**
@@ -144,9 +196,9 @@ class MySqlGrammar extends Grammar
return collect($values)->map(function ($value, $key) {
if ($this->isJsonSelector($key)) {
return $this->compileJsonUpdateColumn($key, new JsonExpression($value));
- } else {
- return $this->wrap($key).' = '.$this->parameter($value);
}
+
+ return $this->wrap($key).' = '.$this->parameter($value);
})->implode(', ');
}
@@ -159,13 +211,9 @@ class MySqlGrammar extends Grammar
*/
protected function compileJsonUpdateColumn($key, JsonExpression $value)
{
- $path = explode('->', $key);
+ [$field, $path] = $this->wrapJsonFieldAndPath($key);
- $field = $this->wrapValue(array_shift($path));
-
- $accessor = '"$.'.implode('.', $path).'"';
-
- return "{$field} = json_set({$field}, {$accessor}, {$value->getValue()})";
+ return "{$field} = json_set({$field}{$path}, {$value->getValue()})";
}
/**
@@ -180,8 +228,7 @@ class MySqlGrammar extends Grammar
public function prepareBindingsForUpdate(array $bindings, array $values)
{
$values = collect($values)->reject(function ($value, $column) {
- return $this->isJsonSelector($column) &&
- in_array(gettype($value), ['boolean', 'integer', 'double']);
+ return $this->isJsonSelector($column) && is_bool($value);
})->all();
return parent::prepareBindingsForUpdate($bindings, $values);
@@ -209,7 +256,7 @@ class MySqlGrammar extends Grammar
*
* @param \Illuminate\Database\Query\Builder $query
* @param string $table
- * @param array $where
+ * @param string $where
* @return string
*/
protected function compileDeleteWithoutJoins($query, $table, $where)
@@ -235,14 +282,14 @@ class MySqlGrammar extends Grammar
*
* @param \Illuminate\Database\Query\Builder $query
* @param string $table
- * @param array $where
+ * @param string $where
* @return string
*/
protected function compileDeleteWithJoins($query, $table, $where)
{
$joins = ' '.$this->compileJoins($query, $query->joins);
- $alias = strpos(strtolower($table), ' as ') !== false
+ $alias = stripos($table, ' as ') !== false
? explode(' as ', $table)[1] : $table;
return trim("delete {$alias} from {$table}{$joins} {$where}");
@@ -256,18 +303,7 @@ class MySqlGrammar extends Grammar
*/
protected function wrapValue($value)
{
- if ($value === '*') {
- return $value;
- }
-
- // If the given value is a JSON selector we will wrap it differently than a
- // traditional value. We will need to split this path and wrap each part
- // wrapped, etc. Otherwise, we will simply wrap the value as a string.
- if ($this->isJsonSelector($value)) {
- return $this->wrapJsonSelector($value);
- }
-
- return '`'.str_replace('`', '``', $value).'`';
+ return $value === '*' ? $value : '`'.str_replace('`', '``', $value).'`';
}
/**
@@ -278,23 +314,21 @@ class MySqlGrammar extends Grammar
*/
protected function wrapJsonSelector($value)
{
- $path = explode('->', $value);
+ [$field, $path] = $this->wrapJsonFieldAndPath($value);
- $field = $this->wrapValue(array_shift($path));
-
- return sprintf('%s->\'$.%s\'', $field, collect($path)->map(function ($part) {
- return '"'.$part.'"';
- })->implode('.'));
+ return 'json_unquote(json_extract('.$field.$path.'))';
}
/**
- * Determine if the given string is a JSON selector.
+ * Wrap the given JSON selector for boolean values.
*
* @param string $value
- * @return bool
+ * @return string
*/
- protected function isJsonSelector($value)
+ protected function wrapJsonBooleanSelector($value)
{
- return Str::contains($value, '->');
+ [$field, $path] = $this->wrapJsonFieldAndPath($value);
+
+ return 'json_extract('.$field.$path.')';
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Query/Grammars/PostgresGrammar.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Query/Grammars/PostgresGrammar.php
index 77123fe3..839d6e5b 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Query/Grammars/PostgresGrammar.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Query/Grammars/PostgresGrammar.php
@@ -8,6 +8,25 @@ use Illuminate\Database\Query\Builder;
class PostgresGrammar extends Grammar
{
+ /**
+ * The components that make up a select clause.
+ *
+ * @var array
+ */
+ protected $selectComponents = [
+ 'aggregate',
+ 'columns',
+ 'from',
+ 'joins',
+ 'wheres',
+ 'groups',
+ 'havings',
+ 'orders',
+ 'limit',
+ 'offset',
+ 'lock',
+ ];
+
/**
* All of the available clause operators.
*
@@ -15,11 +34,33 @@ class PostgresGrammar extends Grammar
*/
protected $operators = [
'=', '<', '>', '<=', '>=', '<>', '!=',
- 'like', 'not like', 'between', 'ilike',
- '&', '|', '#', '<<', '>>',
- '@>', '<@', '?', '?|', '?&', '||', '-', '-', '#-',
+ 'like', 'not like', 'between', 'ilike', 'not ilike',
+ '~', '&', '|', '#', '<<', '>>', '<<=', '>>=',
+ '&&', '@>', '<@', '?', '?|', '?&', '||', '-', '-', '#-',
+ 'is distinct from', 'is not distinct from',
];
+ /**
+ * {@inheritdoc}
+ *
+ * @param \Illuminate\Database\Query\Builder $query
+ * @param array $where
+ * @return string
+ */
+ protected function whereBasic(Builder $query, $where)
+ {
+ if (Str::contains(strtolower($where['operator']), 'like')) {
+ return sprintf(
+ '%s::text %s %s',
+ $this->wrap($where['column']),
+ $where['operator'],
+ $this->parameter($where['value'])
+ );
+ }
+
+ return parent::whereBasic($query, $where);
+ }
+
/**
* Compile a "where date" clause.
*
@@ -34,6 +75,20 @@ class PostgresGrammar extends Grammar
return $this->wrap($where['column']).'::date '.$where['operator'].' '.$value;
}
+ /**
+ * Compile a "where time" clause.
+ *
+ * @param \Illuminate\Database\Query\Builder $query
+ * @param array $where
+ * @return string
+ */
+ protected function whereTime(Builder $query, $where)
+ {
+ $value = $this->parameter($where['value']);
+
+ return $this->wrap($where['column']).'::time '.$where['operator'].' '.$value;
+ }
+
/**
* Compile a date based where clause.
*
@@ -49,6 +104,69 @@ class PostgresGrammar extends Grammar
return 'extract('.$type.' from '.$this->wrap($where['column']).') '.$where['operator'].' '.$value;
}
+ /**
+ * Compile a select query into SQL.
+ *
+ * @param \Illuminate\Database\Query\Builder $query
+ * @return string
+ */
+ public function compileSelect(Builder $query)
+ {
+ if ($query->unions && $query->aggregate) {
+ return $this->compileUnionAggregate($query);
+ }
+
+ $sql = parent::compileSelect($query);
+
+ if ($query->unions) {
+ $sql = '('.$sql.') '.$this->compileUnions($query);
+ }
+
+ return $sql;
+ }
+
+ /**
+ * Compile a single union statement.
+ *
+ * @param array $union
+ * @return string
+ */
+ protected function compileUnion(array $union)
+ {
+ $conjunction = $union['all'] ? ' union all ' : ' union ';
+
+ return $conjunction.'('.$union['query']->toSql().')';
+ }
+
+ /**
+ * Compile a "JSON contains" statement into SQL.
+ *
+ * @param string $column
+ * @param string $value
+ * @return string
+ */
+ protected function compileJsonContains($column, $value)
+ {
+ $column = str_replace('->>', '->', $this->wrap($column));
+
+ return '('.$column.')::jsonb @> '.$value;
+ }
+
+ /**
+ * Compile a "JSON length" statement into SQL.
+ *
+ * @param string $column
+ * @param string $operator
+ * @param string $value
+ * @return string
+ */
+ protected function compileJsonLength($column, $operator, $value)
+ {
+ $column = str_replace('->>', '->', $this->wrap($column));
+
+ return 'json_array_length(('.$column.')::json) '.$operator.' '.$value;
+ }
+
/**
* Compile the lock into SQL.
*
@@ -77,6 +195,18 @@ class PostgresGrammar extends Grammar
: parent::compileInsert($query, $values);
}
+ /**
+ * Compile an insert ignore statement into SQL.
+ *
+ * @param \Illuminate\Database\Query\Builder $query
+ * @param array $values
+ * @return string
+ */
+ public function compileInsertOrIgnore(Builder $query, array $values)
+ {
+ return $this->compileInsert($query, $values).' on conflict do nothing';
+ }
+
/**
* Compile an insert and get ID statement into SQL.
*
@@ -87,11 +217,7 @@ class PostgresGrammar extends Grammar
*/
public function compileInsertGetId(Builder $query, $values, $sequence)
{
- if (is_null($sequence)) {
- $sequence = 'id';
- }
-
- return $this->compileInsert($query, $values).' returning '.$this->wrap($sequence);
+ return $this->compileInsert($query, $values).' returning '.$this->wrap($sequence ?: 'id');
}
/**
@@ -108,7 +234,7 @@ class PostgresGrammar extends Grammar
// Each one of the columns in the update statements needs to be wrapped in the
// keyword identifiers, also a place-holder needs to be created for each of
// the values in the list of bindings so we can make the sets statements.
- $columns = $this->compileUpdateColumns($values);
+ $columns = $this->compileUpdateColumns($query, $values);
$from = $this->compileUpdateFrom($query);
@@ -120,19 +246,44 @@ class PostgresGrammar extends Grammar
/**
* Compile the columns for the update statement.
*
+ * @param \Illuminate\Database\Query\Builder $query
* @param array $values
* @return string
*/
- protected function compileUpdateColumns($values)
+ protected function compileUpdateColumns($query, $values)
{
// When gathering the columns for an update statement, we'll wrap each of the
// columns and convert it to a parameter value. Then we will concatenate a
// list of the columns that can be added into this update query clauses.
return collect($values)->map(function ($value, $key) {
- return $this->wrap($key).' = '.$this->parameter($value);
+ $column = last(explode('.', $key));
+
+ if ($this->isJsonSelector($key)) {
+ return $this->compileJsonUpdateColumn($column, $value);
+ }
+
+ return $this->wrap($column).' = '.$this->parameter($value);
})->implode(', ');
}
+ /**
+ * Prepares a JSON column being updated using the JSONB_SET function.
+ *
+ * @param string $key
+ * @param mixed $value
+ * @return string
+ */
+ protected function compileJsonUpdateColumn($key, $value)
+ {
+ $parts = explode('->', $key);
+
+ $field = $this->wrap(array_shift($parts));
+
+ $path = '\'{"'.implode('","', $parts).'"}\'';
+
+ return "{$field} = jsonb_set({$field}::jsonb, {$path}, {$this->parameter($value)})";
+ }
+
/**
* Compile the "from" clause for an update with a join.
*
@@ -216,13 +367,16 @@ class PostgresGrammar extends Grammar
*/
public function prepareBindingsForUpdate(array $bindings, array $values)
{
- // Update statements with "joins" in Postgres use an interesting syntax. We need to
- // take all of the bindings and put them on the end of this array since they are
- // added to the end of the "where" clause statements as typical where clauses.
- $bindingsWithoutJoin = Arr::except($bindings, 'join');
+ $values = collect($values)->map(function ($value, $column) {
+ return $this->isJsonSelector($column) && ! $this->isExpression($value)
+ ? json_encode($value)
+ : $value;
+ })->all();
+
+ $bindingsWithoutWhere = Arr::except($bindings, ['select', 'where']);
return array_values(
- array_merge($values, $bindings['join'], Arr::flatten($bindingsWithoutJoin))
+ array_merge($values, $bindings['where'], Arr::flatten($bindingsWithoutWhere))
);
}
@@ -246,7 +400,6 @@ class PostgresGrammar extends Grammar
*
* @param \Illuminate\Database\Query\Builder $query
* @param string $table
- * @param array $where
* @return string
*/
protected function compileDeleteWithJoins($query, $table)
@@ -255,9 +408,24 @@ class PostgresGrammar extends Grammar
return $this->wrapTable($join->table);
})->implode(', ');
- $where = count($query->wheres) > 0 ? ' '.$this->compileUpdateWheres($query) : '';
+ $where = $this->compileUpdateWheres($query);
- return trim("delete from {$table}{$using}{$where}");
+ return trim("delete from {$table}{$using} {$where}");
+ }
+
+ /**
+ * Prepare the bindings for a delete statement.
+ *
+ * @param array $bindings
+ * @return array
+ */
+ public function prepareBindingsForDelete(array $bindings)
+ {
+ $bindingsWithoutWhere = Arr::except($bindings, ['select', 'where']);
+
+ return array_values(
+ array_merge($bindings['where'], Arr::flatten($bindingsWithoutWhere))
+ );
}
/**
@@ -268,29 +436,7 @@ class PostgresGrammar extends Grammar
*/
public function compileTruncate(Builder $query)
{
- return ['truncate '.$this->wrapTable($query->from).' restart identity' => []];
- }
-
- /**
- * Wrap a single string in keyword identifiers.
- *
- * @param string $value
- * @return string
- */
- protected function wrapValue($value)
- {
- if ($value === '*') {
- return $value;
- }
-
- // If the given value is a JSON selector we will wrap it differently than a
- // traditional value. We will need to split this path and wrap each part
- // wrapped, etc. Otherwise, we will simply wrap the value as a string.
- if (Str::contains($value, '->')) {
- return $this->wrapJsonSelector($value);
- }
-
- return '"'.str_replace('"', '""', $value).'"';
+ return ['truncate '.$this->wrapTable($query->from).' restart identity cascade' => []];
}
/**
@@ -303,7 +449,7 @@ class PostgresGrammar extends Grammar
{
$path = explode('->', $value);
- $field = $this->wrapValue(array_shift($path));
+ $field = $this->wrapSegments(explode('.', array_shift($path)));
$wrappedPath = $this->wrapJsonPathAttributes($path);
@@ -316,6 +462,33 @@ class PostgresGrammar extends Grammar
return $field.'->>'.$attribute;
}
+ /**
+ *Wrap the given JSON selector for boolean values.
+ *
+ * @param string $value
+ * @return string
+ */
+ protected function wrapJsonBooleanSelector($value)
+ {
+ $selector = str_replace(
+ '->>', '->',
+ $this->wrapJsonSelector($value)
+ );
+
+ return '('.$selector.')::jsonb';
+ }
+
+ /**
+ * Wrap the given JSON boolean value.
+ *
+ * @param string $value
+ * @return string
+ */
+ protected function wrapJsonBooleanValue($value)
+ {
+ return "'".$value."'::jsonb";
+ }
+
/**
* Wrap the attributes of the give JSON path.
*
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Query/Grammars/SQLiteGrammar.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Query/Grammars/SQLiteGrammar.php
index 03dfd510..a6782138 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Query/Grammars/SQLiteGrammar.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Query/Grammars/SQLiteGrammar.php
@@ -2,6 +2,8 @@
namespace Illuminate\Database\Query\Grammars;
+use Illuminate\Support\Arr;
+use Illuminate\Support\Str;
use Illuminate\Database\Query\Builder;
class SQLiteGrammar extends Grammar
@@ -32,7 +34,7 @@ class SQLiteGrammar extends Grammar
*/
protected $operators = [
'=', '<', '>', '<=', '>=', '<>', '!=',
- 'like', 'not like', 'between', 'ilike',
+ 'like', 'not like', 'ilike',
'&', '|', '<<', '>>',
];
@@ -44,6 +46,10 @@ class SQLiteGrammar extends Grammar
*/
public function compileSelect(Builder $query)
{
+ if ($query->unions && $query->aggregate) {
+ return $this->compileUnionAggregate($query);
+ }
+
$sql = parent::compileSelect($query);
if ($query->unions) {
@@ -61,9 +67,9 @@ class SQLiteGrammar extends Grammar
*/
protected function compileUnion(array $union)
{
- $conjuction = $union['all'] ? ' union all ' : ' union ';
+ $conjunction = $union['all'] ? ' union all ' : ' union ';
- return $conjuction.'select * from ('.$union['query']->toSql().')';
+ return $conjunction.'select * from ('.$union['query']->toSql().')';
}
/**
@@ -114,6 +120,18 @@ class SQLiteGrammar extends Grammar
return $this->dateBasedWhere('%Y', $query, $where);
}
+ /**
+ * Compile a "where time" clause.
+ *
+ * @param \Illuminate\Database\Query\Builder $query
+ * @param array $where
+ * @return string
+ */
+ protected function whereTime(Builder $query, $where)
+ {
+ return $this->dateBasedWhere('%H:%M:%S', $query, $where);
+ }
+
/**
* Compile a date based where clause.
*
@@ -124,11 +142,24 @@ class SQLiteGrammar extends Grammar
*/
protected function dateBasedWhere($type, Builder $query, $where)
{
- $value = str_pad($where['value'], 2, '0', STR_PAD_LEFT);
+ $value = $this->parameter($where['value']);
- $value = $this->parameter($value);
+ return "strftime('{$type}', {$this->wrap($where['column'])}) {$where['operator']} cast({$value} as text)";
+ }
- return "strftime('{$type}', {$this->wrap($where['column'])}) {$where['operator']} {$value}";
+ /**
+ * Compile a "JSON length" statement into SQL.
+ *
+ * @param string $column
+ * @param string $operator
+ * @param string $value
+ * @return string
+ */
+ protected function compileJsonLength($column, $operator, $value)
+ {
+ [$field, $path] = $this->wrapJsonFieldAndPath($column);
+
+ return 'json_array_length('.$field.$path.') '.$operator.' '.$value;
}
/**
@@ -140,38 +171,113 @@ class SQLiteGrammar extends Grammar
*/
public function compileInsert(Builder $query, array $values)
{
- // Essentially we will force every insert to be treated as a batch insert which
- // simply makes creating the SQL easier for us since we can utilize the same
- // basic routine regardless of an amount of records given to us to insert.
$table = $this->wrapTable($query->from);
- if (! is_array(reset($values))) {
- $values = [$values];
+ return empty($values)
+ ? "insert into {$table} DEFAULT VALUES"
+ : parent::compileInsert($query, $values);
+ }
+
+ /**
+ * Compile an insert ignore statement into SQL.
+ *
+ * @param \Illuminate\Database\Query\Builder $query
+ * @param array $values
+ * @return string
+ */
+ public function compileInsertOrIgnore(Builder $query, array $values)
+ {
+ return Str::replaceFirst('insert', 'insert or ignore', $this->compileInsert($query, $values));
+ }
+
+ /**
+ * Compile an update statement into SQL.
+ *
+ * @param \Illuminate\Database\Query\Builder $query
+ * @param array $values
+ * @return string
+ */
+ public function compileUpdate(Builder $query, $values)
+ {
+ $table = $this->wrapTable($query->from);
+
+ $columns = collect($values)->map(function ($value, $key) {
+ return $this->wrap(Str::after($key, '.')).' = '.$this->parameter($value);
+ })->implode(', ');
+
+ if (isset($query->joins) || isset($query->limit)) {
+ return $this->compileUpdateWithJoinsOrLimit($query, $columns);
}
- // If there is only one record being inserted, we will just use the usual query
- // grammar insert builder because no special syntax is needed for the single
- // row inserts in SQLite. However, if there are multiples, we'll continue.
- if (count($values) == 1) {
- return empty(reset($values))
- ? "insert into $table default values"
- : parent::compileInsert($query, reset($values));
+ return trim("update {$table} set {$columns} {$this->compileWheres($query)}");
+ }
+
+ /**
+ * Compile an update statement with joins or limit into SQL.
+ *
+ * @param \Illuminate\Database\Query\Builder $query
+ * @param string $columns
+ * @return string
+ */
+ protected function compileUpdateWithJoinsOrLimit(Builder $query, $columns)
+ {
+ $segments = preg_split('/\s+as\s+/i', $query->from);
+
+ $alias = $segments[1] ?? $segments[0];
+
+ $selectSql = parent::compileSelect($query->select($alias.'.rowid'));
+
+ return "update {$this->wrapTable($query->from)} set {$columns} where {$this->wrap('rowid')} in ({$selectSql})";
+ }
+
+ /**
+ * Prepare the bindings for an update statement.
+ *
+ * @param array $bindings
+ * @param array $values
+ * @return array
+ */
+ public function prepareBindingsForUpdate(array $bindings, array $values)
+ {
+ $cleanBindings = Arr::except($bindings, 'select');
+
+ return array_values(
+ array_merge($values, Arr::flatten($cleanBindings))
+ );
+ }
+
+ /**
+ * Compile a delete statement into SQL.
+ *
+ * @param \Illuminate\Database\Query\Builder $query
+ * @return string
+ */
+ public function compileDelete(Builder $query)
+ {
+ if (isset($query->joins) || isset($query->limit)) {
+ return $this->compileDeleteWithJoinsOrLimit($query);
}
- $names = $this->columnize(array_keys(reset($values)));
+ $wheres = is_array($query->wheres) ? $this->compileWheres($query) : '';
- $columns = [];
+ return trim("delete from {$this->wrapTable($query->from)} $wheres");
+ }
- // SQLite requires us to build the multi-row insert as a listing of select with
- // unions joining them together. So we'll build out this list of columns and
- // then join them all together with select unions to complete the queries.
- foreach (array_keys(reset($values)) as $column) {
- $columns[] = '? as '.$this->wrap($column);
- }
+ /**
+ * Compile a delete statement with joins or limit into SQL.
+ *
+ * @param \Illuminate\Database\Query\Builder $query
+ * @return string
+ */
+ protected function compileDeleteWithJoinsOrLimit(Builder $query)
+ {
+ $segments = preg_split('/\s+as\s+/i', $query->from);
- $columns = array_fill(0, count($values), implode(', ', $columns));
+ $alias = $segments[1] ?? $segments[0];
- return "insert into $table ($names) select ".implode(' union all select ', $columns);
+ $selectSql = parent::compileSelect($query->select($alias.'.rowid'));
+
+ return "delete from {$this->wrapTable($query->from)} where {$this->wrap('rowid')} in ({$selectSql})";
}
/**
@@ -187,4 +293,17 @@ class SQLiteGrammar extends Grammar
'delete from '.$this->wrapTable($query->from) => [],
];
}
+
+ /**
+ * Wrap the given JSON selector.
+ *
+ * @param string $value
+ * @return string
+ */
+ protected function wrapJsonSelector($value)
+ {
+ [$field, $path] = $this->wrapJsonFieldAndPath($value);
+
+ return 'json_extract('.$field.$path.')';
+ }
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Query/Grammars/SqlServerGrammar.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Query/Grammars/SqlServerGrammar.php
index 858fd465..56f917a9 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Query/Grammars/SqlServerGrammar.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Query/Grammars/SqlServerGrammar.php
@@ -14,7 +14,7 @@ class SqlServerGrammar extends Grammar
*/
protected $operators = [
'=', '<', '>', '<=', '>=', '!<', '!>', '<>', '!=',
- 'like', 'not like', 'between', 'ilike',
+ 'like', 'not like', 'ilike',
'&', '&=', '|', '|=', '^', '^=',
];
@@ -103,6 +103,60 @@ class SqlServerGrammar extends Grammar
return 'cast('.$this->wrap($where['column']).' as date) '.$where['operator'].' '.$value;
}
+ /**
+ * Compile a "where time" clause.
+ *
+ * @param \Illuminate\Database\Query\Builder $query
+ * @param array $where
+ * @return string
+ */
+ protected function whereTime(Builder $query, $where)
+ {
+ $value = $this->parameter($where['value']);
+
+ return 'cast('.$this->wrap($where['column']).' as time) '.$where['operator'].' '.$value;
+ }
+
+ /**
+ * Compile a "JSON contains" statement into SQL.
+ *
+ * @param string $column
+ * @param string $value
+ * @return string
+ */
+ protected function compileJsonContains($column, $value)
+ {
+ [$field, $path] = $this->wrapJsonFieldAndPath($column);
+
+ return $value.' in (select [value] from openjson('.$field.$path.'))';
+ }
+
+ /**
+ * Prepare the binding for a "JSON contains" statement.
+ *
+ * @param mixed $binding
+ * @return string
+ */
+ public function prepareBindingForJsonContains($binding)
+ {
+ return is_bool($binding) ? json_encode($binding) : $binding;
+ }
+
+ /**
+ * Compile a "JSON length" statement into SQL.
+ *
+ * @param string $column
+ * @param string $operator
+ * @param string $value
+ * @return string
+ */
+ protected function compileJsonLength($column, $operator, $value)
+ {
+ [$field, $path] = $this->wrapJsonFieldAndPath($column);
+
+ return '(select count(*) from openjson('.$field.$path.')) '.$operator.' '.$value;
+ }
+
/**
* Create a full ANSI offset clause for the query.
*
@@ -156,7 +210,7 @@ class SqlServerGrammar extends Grammar
{
$constraint = $this->compileRowConstraint($query);
- return "select * from ({$sql}) as temp_table where row_num {$constraint}";
+ return "select * from ({$sql}) as temp_table where row_num {$constraint} order by row_num";
}
/**
@@ -269,7 +323,7 @@ class SqlServerGrammar extends Grammar
{
$joins = ' '.$this->compileJoins($query, $query->joins);
- $alias = strpos(strtolower($table), ' as ') !== false
+ $alias = stripos($table, ' as ') !== false
? explode(' as ', $table)[1] : $table;
return trim("delete {$alias} from {$table}{$joins} {$where}");
@@ -295,7 +349,7 @@ class SqlServerGrammar extends Grammar
*/
public function compileUpdate(Builder $query, $values)
{
- list($table, $alias) = $this->parseUpdateTable($query->from);
+ [$table, $alias] = $this->parseUpdateTable($query->from);
// Each one of the columns in the update statements needs to be wrapped in the
// keyword identifiers, also a place-holder needs to be created for each of
@@ -335,7 +389,7 @@ class SqlServerGrammar extends Grammar
{
$table = $alias = $this->wrapTable($table);
- if (strpos(strtolower($table), '] as [') !== false) {
+ if (stripos($table, '] as [') !== false) {
$alias = '['.explode('] as [', $table)[1];
}
@@ -351,26 +405,13 @@ class SqlServerGrammar extends Grammar
*/
public function prepareBindingsForUpdate(array $bindings, array $values)
{
- // Update statements with joins in SQL Servers utilize an unique syntax. We need to
- // take all of the bindings and put them on the end of this array since they are
- // added to the end of the "where" clause statements as typical where clauses.
- $bindingsWithoutJoin = Arr::except($bindings, 'join');
+ $cleanBindings = Arr::except($bindings, 'select');
return array_values(
- array_merge($values, $bindings['join'], Arr::flatten($bindingsWithoutJoin))
+ array_merge($values, Arr::flatten($cleanBindings))
);
}
- /**
- * Determine if the grammar supports savepoints.
- *
- * @return bool
- */
- public function supportsSavepoints()
- {
- return true;
- }
-
/**
* Compile the SQL statement to define a savepoint.
*
@@ -400,7 +441,7 @@ class SqlServerGrammar extends Grammar
*/
public function getDateFormat()
{
- return 'Y-m-d H:i:s.000';
+ return 'Y-m-d H:i:s.v';
}
/**
@@ -414,6 +455,30 @@ class SqlServerGrammar extends Grammar
return $value === '*' ? $value : '['.str_replace(']', ']]', $value).']';
}
+ /**
+ * Wrap the given JSON selector.
+ *
+ * @param string $value
+ * @return string
+ */
+ protected function wrapJsonSelector($value)
+ {
+ [$field, $path] = $this->wrapJsonFieldAndPath($value);
+
+ return 'json_value('.$field.$path.')';
+ }
+
+ /**
+ * Wrap the given JSON boolean value.
+ *
+ * @param string $value
+ * @return string
+ */
+ protected function wrapJsonBooleanValue($value)
+ {
+ return "'".$value."'";
+ }
+
/**
* Wrap a table in keyword identifiers.
*
@@ -422,7 +487,11 @@ class SqlServerGrammar extends Grammar
*/
public function wrapTable($table)
{
- return $this->wrapTableValuedFunction(parent::wrapTable($table));
+ if (! $this->isExpression($table)) {
+ return $this->wrapTableValuedFunction(parent::wrapTable($table));
+ }
+
+ return $this->getValue($table);
}
/**
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Query/JoinClause.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Query/JoinClause.php
index ca7b4d45..4e17842b 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Query/JoinClause.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Query/JoinClause.php
@@ -21,11 +21,32 @@ class JoinClause extends Builder
public $table;
/**
- * The parent query builder instance.
+ * The connection of the parent query builder.
*
- * @var \Illuminate\Database\Query\Builder
+ * @var \Illuminate\Database\ConnectionInterface
*/
- private $parentQuery;
+ protected $parentConnection;
+
+ /**
+ * The grammar of the parent query builder.
+ *
+ * @var \Illuminate\Database\Query\Grammars\Grammar
+ */
+ protected $parentGrammar;
+
+ /**
+ * The processor of the parent query builder.
+ *
+ * @var \Illuminate\Database\Query\Processors\Processor
+ */
+ protected $parentProcessor;
+
+ /**
+ * The class name of the parent query builder.
+ *
+ * @var string
+ */
+ protected $parentClass;
/**
* Create a new join clause instance.
@@ -39,10 +60,13 @@ class JoinClause extends Builder
{
$this->type = $type;
$this->table = $table;
- $this->parentQuery = $parentQuery;
+ $this->parentClass = get_class($parentQuery);
+ $this->parentGrammar = $parentQuery->getGrammar();
+ $this->parentProcessor = $parentQuery->getProcessor();
+ $this->parentConnection = $parentQuery->getConnection();
parent::__construct(
- $parentQuery->getConnection(), $parentQuery->getGrammar(), $parentQuery->getProcessor()
+ $this->parentConnection, $this->parentGrammar, $this->parentProcessor
);
}
@@ -56,7 +80,7 @@ class JoinClause extends Builder
*
* will produce the following SQL:
*
- * on `contacts`.`user_id` = `users`.`id` and `contacts`.`info_id` = `info`.`id`
+ * on `contacts`.`user_id` = `users`.`id` and `contacts`.`info_id` = `info`.`id`
*
* @param \Closure|string $first
* @param string|null $operator
@@ -95,6 +119,28 @@ class JoinClause extends Builder
*/
public function newQuery()
{
- return new static($this->parentQuery, $this->type, $this->table);
+ return new static($this->newParentQuery(), $this->type, $this->table);
+ }
+
+ /**
+ * Create a new query instance for sub-query.
+ *
+ * @return \Illuminate\Database\Query\Builder
+ */
+ protected function forSubQuery()
+ {
+ return $this->newParentQuery()->newQuery();
+ }
+
+ /**
+ * Create a new parent query instance.
+ *
+ * @return \Illuminate\Database\Query\Builder
+ */
+ protected function newParentQuery()
+ {
+ $class = $this->parentClass;
+
+ return new $class($this->parentConnection, $this->parentGrammar, $this->parentProcessor);
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Query/JsonExpression.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Query/JsonExpression.php
index 648a7da1..3d68ee61 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Query/JsonExpression.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Query/JsonExpression.php
@@ -6,13 +6,6 @@ use InvalidArgumentException;
class JsonExpression extends Expression
{
- /**
- * The value of the expression.
- *
- * @var mixed
- */
- protected $value;
-
/**
* Create a new raw query expression.
*
@@ -21,7 +14,9 @@ class JsonExpression extends Expression
*/
public function __construct($value)
{
- $this->value = $this->getJsonBindingParameter($value);
+ parent::__construct(
+ $this->getJsonBindingParameter($value)
+ );
}
/**
@@ -29,15 +24,21 @@ class JsonExpression extends Expression
*
* @param mixed $value
* @return string
+ *
+ * @throws \InvalidArgumentException
*/
protected function getJsonBindingParameter($value)
{
+ if ($value instanceof Expression) {
+ return $value->getValue();
+ }
+
switch ($type = gettype($value)) {
case 'boolean':
return $value ? 'true' : 'false';
+ case 'NULL':
case 'integer':
case 'double':
- return $value;
case 'string':
return '?';
case 'object':
@@ -45,26 +46,6 @@ class JsonExpression extends Expression
return '?';
}
- throw new InvalidArgumentException('JSON value is of illegal type: '.$type);
- }
-
- /**
- * Get the value of the expression.
- *
- * @return mixed
- */
- public function getValue()
- {
- return $this->value;
- }
-
- /**
- * Get the value of the expression.
- *
- * @return string
- */
- public function __toString()
- {
- return (string) $this->getValue();
+ throw new InvalidArgumentException("JSON value is of illegal type: {$type}");
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Query/Processors/MySqlProcessor.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Query/Processors/MySqlProcessor.php
index eeb07b06..ce918385 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Query/Processors/MySqlProcessor.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Query/Processors/MySqlProcessor.php
@@ -13,7 +13,7 @@ class MySqlProcessor extends Processor
public function processColumnListing($results)
{
return array_map(function ($result) {
- return with((object) $result)->column_name;
+ return ((object) $result)->column_name;
}, $results);
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Query/Processors/PostgresProcessor.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Query/Processors/PostgresProcessor.php
index dcaee9f2..356f0ca0 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Query/Processors/PostgresProcessor.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Query/Processors/PostgresProcessor.php
@@ -12,7 +12,7 @@ class PostgresProcessor extends Processor
* @param \Illuminate\Database\Query\Builder $query
* @param string $sql
* @param array $values
- * @param string $sequence
+ * @param string|null $sequence
* @return int
*/
public function processInsertGetId(Builder $query, $sql, $values, $sequence = null)
@@ -35,7 +35,7 @@ class PostgresProcessor extends Processor
public function processColumnListing($results)
{
return array_map(function ($result) {
- return with((object) $result)->column_name;
+ return ((object) $result)->column_name;
}, $results);
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Query/Processors/Processor.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Query/Processors/Processor.php
index f78429fb..5e318d30 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Query/Processors/Processor.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Query/Processors/Processor.php
@@ -24,7 +24,7 @@ class Processor
* @param \Illuminate\Database\Query\Builder $query
* @param string $sql
* @param array $values
- * @param string $sequence
+ * @param string|null $sequence
* @return int
*/
public function processInsertGetId(Builder $query, $sql, $values, $sequence = null)
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Query/Processors/SQLiteProcessor.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Query/Processors/SQLiteProcessor.php
index ef9cb5ab..65da1dff 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Query/Processors/SQLiteProcessor.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Query/Processors/SQLiteProcessor.php
@@ -13,7 +13,7 @@ class SQLiteProcessor extends Processor
public function processColumnListing($results)
{
return array_map(function ($result) {
- return with((object) $result)->name;
+ return ((object) $result)->name;
}, $results);
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Query/Processors/SqlServerProcessor.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Query/Processors/SqlServerProcessor.php
index b5314c80..fab071d9 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Query/Processors/SqlServerProcessor.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Query/Processors/SqlServerProcessor.php
@@ -14,7 +14,7 @@ class SqlServerProcessor extends Processor
* @param \Illuminate\Database\Query\Builder $query
* @param string $sql
* @param array $values
- * @param string $sequence
+ * @param string|null $sequence
* @return int
*/
public function processInsertGetId(Builder $query, $sql, $values, $sequence = null)
@@ -37,6 +37,7 @@ class SqlServerProcessor extends Processor
*
* @param \Illuminate\Database\Connection $connection
* @return int
+ *
* @throws \Exception
*/
protected function processInsertGetIdForOdbc(Connection $connection)
@@ -63,7 +64,7 @@ class SqlServerProcessor extends Processor
public function processColumnListing($results)
{
return array_map(function ($result) {
- return with((object) $result)->name;
+ return ((object) $result)->name;
}, $results);
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/README.md b/pfosten/vendor/laravel/framework/src/Illuminate/Database/README.md
index b3014b08..7d59ab7d 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/README.md
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/README.md
@@ -45,7 +45,7 @@ $users = Capsule::table('users')->where('votes', '>', 100)->get();
```
Other core methods may be accessed directly from the Capsule in the same manner as from the DB facade:
```PHP
-$results = Capsule::select('select * from users where id = ?', array(1));
+$results = Capsule::select('select * from users where id = ?', [1]);
```
**Using The Schema Builder**
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/SQLiteConnection.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/SQLiteConnection.php
index b32786c1..21f890db 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/SQLiteConnection.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/SQLiteConnection.php
@@ -2,6 +2,7 @@
namespace Illuminate\Database;
+use Illuminate\Database\Schema\SQLiteBuilder;
use Illuminate\Database\Query\Processors\SQLiteProcessor;
use Doctrine\DBAL\Driver\PDOSqlite\Driver as DoctrineDriver;
use Illuminate\Database\Query\Grammars\SQLiteGrammar as QueryGrammar;
@@ -9,6 +10,30 @@ use Illuminate\Database\Schema\Grammars\SQLiteGrammar as SchemaGrammar;
class SQLiteConnection extends Connection
{
+ /**
+ * Create a new database connection instance.
+ *
+ * @param \PDO|\Closure $pdo
+ * @param string $database
+ * @param string $tablePrefix
+ * @param array $config
+ * @return void
+ */
+ public function __construct($pdo, $database = '', $tablePrefix = '', array $config = [])
+ {
+ parent::__construct($pdo, $database, $tablePrefix, $config);
+
+ $enableForeignKeyConstraints = $this->getForeignKeyConstraintsConfigurationValue();
+
+ if ($enableForeignKeyConstraints === null) {
+ return;
+ }
+
+ $enableForeignKeyConstraints
+ ? $this->getSchemaBuilder()->enableForeignKeyConstraints()
+ : $this->getSchemaBuilder()->disableForeignKeyConstraints();
+ }
+
/**
* Get the default query grammar instance.
*
@@ -19,6 +44,20 @@ class SQLiteConnection extends Connection
return $this->withTablePrefix(new QueryGrammar);
}
+ /**
+ * Get a schema builder instance for the connection.
+ *
+ * @return \Illuminate\Database\Schema\SQLiteBuilder
+ */
+ public function getSchemaBuilder()
+ {
+ if (is_null($this->schemaGrammar)) {
+ $this->useDefaultSchemaGrammar();
+ }
+
+ return new SQLiteBuilder($this);
+ }
+
/**
* Get the default schema grammar instance.
*
@@ -48,4 +87,14 @@ class SQLiteConnection extends Connection
{
return new DoctrineDriver;
}
+
+ /**
+ * Get the database connection foreign key constraints configuration option.
+ *
+ * @return bool|null
+ */
+ protected function getForeignKeyConstraintsConfigurationValue()
+ {
+ return $this->getConfig('foreign_key_constraints');
+ }
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Schema/Blueprint.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Schema/Blueprint.php
index e3274101..f555c44b 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Schema/Blueprint.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Schema/Blueprint.php
@@ -3,9 +3,11 @@
namespace Illuminate\Database\Schema;
use Closure;
+use BadMethodCallException;
use Illuminate\Support\Fluent;
use Illuminate\Database\Connection;
use Illuminate\Support\Traits\Macroable;
+use Illuminate\Database\SQLiteConnection;
use Illuminate\Database\Schema\Grammars\Grammar;
class Blueprint
@@ -19,17 +21,24 @@ class Blueprint
*/
protected $table;
+ /**
+ * The prefix of the table.
+ *
+ * @var string
+ */
+ protected $prefix;
+
/**
* The columns that should be added to the table.
*
- * @var array
+ * @var \Illuminate\Database\Schema\ColumnDefinition[]
*/
protected $columns = [];
/**
* The commands that should be run for the table.
*
- * @var array
+ * @var \Illuminate\Support\Fluent[]
*/
protected $commands = [];
@@ -62,11 +71,13 @@ class Blueprint
*
* @param string $table
* @param \Closure|null $callback
+ * @param string $prefix
* @return void
*/
- public function __construct($table, Closure $callback = null)
+ public function __construct($table, Closure $callback = null, $prefix = '')
{
$this->table = $table;
+ $this->prefix = $prefix;
if (! is_null($callback)) {
$callback($this);
@@ -77,7 +88,7 @@ class Blueprint
* Execute the blueprint against the database.
*
* @param \Illuminate\Database\Connection $connection
- * @param \Illuminate\Database\Schema\Grammars\Grammar $grammar
+ * @param \Illuminate\Database\Schema\Grammars\Grammar $grammar
* @return void
*/
public function build(Connection $connection, Grammar $grammar)
@@ -96,13 +107,15 @@ class Blueprint
*/
public function toSql(Connection $connection, Grammar $grammar)
{
- $this->addImpliedCommands();
+ $this->addImpliedCommands($grammar);
$statements = [];
// Each type of command has a corresponding compiler function on the schema
// grammar which is used to build the necessary SQL statements to build
// the blueprint element, so we'll just call that compilers function.
+ $this->ensureCommandsAreValid($connection);
+
foreach ($this->commands as $command) {
$method = 'compile'.ucfirst($command->name);
@@ -116,12 +129,51 @@ class Blueprint
return $statements;
}
+ /**
+ * Ensure the commands on the blueprint are valid for the connection type.
+ *
+ * @param \Illuminate\Database\Connection $connection
+ * @return void
+ *
+ * @throws \BadMethodCallException
+ */
+ protected function ensureCommandsAreValid(Connection $connection)
+ {
+ if ($connection instanceof SQLiteConnection) {
+ if ($this->commandsNamed(['dropColumn', 'renameColumn'])->count() > 1) {
+ throw new BadMethodCallException(
+ "SQLite doesn't support multiple calls to dropColumn / renameColumn in a single modification."
+ );
+ }
+
+ if ($this->commandsNamed(['dropForeign'])->count() > 0) {
+ throw new BadMethodCallException(
+ "SQLite doesn't support dropping foreign keys (you would need to re-create the table)."
+ );
+ }
+ }
+ }
+
+ /**
+ * Get all of the commands matching the given names.
+ *
+ * @param array $names
+ * @return \Illuminate\Support\Collection
+ */
+ protected function commandsNamed(array $names)
+ {
+ return collect($this->commands)->filter(function ($command) use ($names) {
+ return in_array($command->name, $names);
+ });
+ }
+
/**
* Add the commands that are implied by the blueprint's state.
*
+ * @param \Illuminate\Database\Schema\Grammars\Grammar $grammar
* @return void
*/
- protected function addImpliedCommands()
+ protected function addImpliedCommands(Grammar $grammar)
{
if (count($this->getAddedColumns()) > 0 && ! $this->creating()) {
array_unshift($this->commands, $this->createCommand('add'));
@@ -132,6 +184,8 @@ class Blueprint
}
$this->addFluentIndexes();
+
+ $this->addFluentCommands($grammar);
}
/**
@@ -142,7 +196,7 @@ class Blueprint
protected function addFluentIndexes()
{
foreach ($this->columns as $column) {
- foreach (['primary', 'unique', 'index'] as $index) {
+ foreach (['primary', 'unique', 'index', 'spatialIndex'] as $index) {
// If the index has been specified on the given column, but is simply equal
// to "true" (boolean), no name has been specified for this index so the
// index method can be called without a name and it will generate one.
@@ -164,6 +218,31 @@ class Blueprint
}
}
+ /**
+ * Add the fluent commands specified on any columns.
+ *
+ * @param \Illuminate\Database\Schema\Grammars\Grammar $grammar
+ * @return void
+ */
+ public function addFluentCommands(Grammar $grammar)
+ {
+ foreach ($this->columns as $column) {
+ foreach ($grammar->getFluentCommands() as $commandName) {
+ $attributeName = lcfirst($commandName);
+
+ if (! isset($column->{$attributeName})) {
+ continue;
+ }
+
+ $value = $column->{$attributeName};
+
+ $this->addCommand(
+ $commandName, compact('value', 'column')
+ );
+ }
+ }
+ }
+
/**
* Determine if the blueprint has a create command.
*
@@ -172,7 +251,7 @@ class Blueprint
protected function creating()
{
return collect($this->commands)->contains(function ($command) {
- return $command->name == 'create';
+ return $command->name === 'create';
});
}
@@ -224,7 +303,7 @@ class Blueprint
*/
public function dropColumn($columns)
{
- $columns = is_array($columns) ? $columns : (array) func_get_args();
+ $columns = is_array($columns) ? $columns : func_get_args();
return $this->addCommand('dropColumn', compact('columns'));
}
@@ -244,7 +323,7 @@ class Blueprint
/**
* Indicate that the given primary key should be dropped.
*
- * @param string|array $index
+ * @param string|array|null $index
* @return \Illuminate\Support\Fluent
*/
public function dropPrimary($index = null)
@@ -274,6 +353,17 @@ class Blueprint
return $this->dropIndexCommand('dropIndex', 'index', $index);
}
+ /**
+ * Indicate that the given spatial index should be dropped.
+ *
+ * @param string|array $index
+ * @return \Illuminate\Support\Fluent
+ */
+ public function dropSpatialIndex($index)
+ {
+ return $this->dropIndexCommand('dropSpatialIndex', 'spatialIndex', $index);
+ }
+
/**
* Indicate that the given foreign key should be dropped.
*
@@ -285,6 +375,18 @@ class Blueprint
return $this->dropIndexCommand('dropForeign', 'foreign', $index);
}
+ /**
+ * Indicate that the given indexes should be renamed.
+ *
+ * @param string $from
+ * @param string $to
+ * @return \Illuminate\Support\Fluent
+ */
+ public function renameIndex($from, $to)
+ {
+ return $this->addCommand('renameIndex', compact('from', 'to'));
+ }
+
/**
* Indicate that the timestamp columns should be dropped.
*
@@ -308,21 +410,23 @@ class Blueprint
/**
* Indicate that the soft delete column should be dropped.
*
+ * @param string $column
* @return void
*/
- public function dropSoftDeletes()
+ public function dropSoftDeletes($column = 'deleted_at')
{
- $this->dropColumn('deleted_at');
+ $this->dropColumn($column);
}
/**
* Indicate that the soft delete column should be dropped.
*
+ * @param string $column
* @return void
*/
- public function dropSoftDeletesTz()
+ public function dropSoftDeletesTz($column = 'deleted_at')
{
- $this->dropSoftDeletes();
+ $this->dropSoftDeletes($column);
}
/**
@@ -335,6 +439,20 @@ class Blueprint
$this->dropColumn('remember_token');
}
+ /**
+ * Indicate that the polymorphic columns should be dropped.
+ *
+ * @param string $name
+ * @param string|null $indexName
+ * @return void
+ */
+ public function dropMorphs($name, $indexName = null)
+ {
+ $this->dropIndex($indexName ?: $this->createIndexName('index', ["{$name}_type", "{$name}_id"]));
+
+ $this->dropColumn("{$name}_type", "{$name}_id");
+ }
+
/**
* Rename the table to a given name.
*
@@ -350,7 +468,7 @@ class Blueprint
* Specify the primary key(s) for the table.
*
* @param string|array $columns
- * @param string $name
+ * @param string|null $name
* @param string|null $algorithm
* @return \Illuminate\Support\Fluent
*/
@@ -363,7 +481,7 @@ class Blueprint
* Specify a unique index for the table.
*
* @param string|array $columns
- * @param string $name
+ * @param string|null $name
* @param string|null $algorithm
* @return \Illuminate\Support\Fluent
*/
@@ -376,7 +494,7 @@ class Blueprint
* Specify an index for the table.
*
* @param string|array $columns
- * @param string $name
+ * @param string|null $name
* @param string|null $algorithm
* @return \Illuminate\Support\Fluent
*/
@@ -385,12 +503,24 @@ class Blueprint
return $this->indexCommand('index', $columns, $name, $algorithm);
}
+ /**
+ * Specify a spatial index for the table.
+ *
+ * @param string|array $columns
+ * @param string|null $name
+ * @return \Illuminate\Support\Fluent
+ */
+ public function spatialIndex($columns, $name = null)
+ {
+ return $this->indexCommand('spatialIndex', $columns, $name);
+ }
+
/**
* Specify a foreign key for the table.
*
* @param string|array $columns
- * @param string $name
- * @return \Illuminate\Support\Fluent
+ * @param string|null $name
+ * @return \Illuminate\Support\Fluent|\Illuminate\Database\Schema\ForeignKeyDefinition
*/
public function foreign($columns, $name = null)
{
@@ -401,18 +531,29 @@ class Blueprint
* Create a new auto-incrementing integer (4-byte) column on the table.
*
* @param string $column
- * @return \Illuminate\Support\Fluent
+ * @return \Illuminate\Database\Schema\ColumnDefinition
*/
public function increments($column)
{
return $this->unsignedInteger($column, true);
}
+ /**
+ * Create a new auto-incrementing integer (4-byte) column on the table.
+ *
+ * @param string $column
+ * @return \Illuminate\Database\Schema\ColumnDefinition
+ */
+ public function integerIncrements($column)
+ {
+ return $this->unsignedInteger($column, true);
+ }
+
/**
* Create a new auto-incrementing tiny integer (1-byte) column on the table.
*
* @param string $column
- * @return \Illuminate\Support\Fluent
+ * @return \Illuminate\Database\Schema\ColumnDefinition
*/
public function tinyIncrements($column)
{
@@ -423,7 +564,7 @@ class Blueprint
* Create a new auto-incrementing small integer (2-byte) column on the table.
*
* @param string $column
- * @return \Illuminate\Support\Fluent
+ * @return \Illuminate\Database\Schema\ColumnDefinition
*/
public function smallIncrements($column)
{
@@ -434,7 +575,7 @@ class Blueprint
* Create a new auto-incrementing medium integer (3-byte) column on the table.
*
* @param string $column
- * @return \Illuminate\Support\Fluent
+ * @return \Illuminate\Database\Schema\ColumnDefinition
*/
public function mediumIncrements($column)
{
@@ -445,7 +586,7 @@ class Blueprint
* Create a new auto-incrementing big integer (8-byte) column on the table.
*
* @param string $column
- * @return \Illuminate\Support\Fluent
+ * @return \Illuminate\Database\Schema\ColumnDefinition
*/
public function bigIncrements($column)
{
@@ -456,8 +597,8 @@ class Blueprint
* Create a new char column on the table.
*
* @param string $column
- * @param int $length
- * @return \Illuminate\Support\Fluent
+ * @param int|null $length
+ * @return \Illuminate\Database\Schema\ColumnDefinition
*/
public function char($column, $length = null)
{
@@ -470,8 +611,8 @@ class Blueprint
* Create a new string column on the table.
*
* @param string $column
- * @param int $length
- * @return \Illuminate\Support\Fluent
+ * @param int|null $length
+ * @return \Illuminate\Database\Schema\ColumnDefinition
*/
public function string($column, $length = null)
{
@@ -484,7 +625,7 @@ class Blueprint
* Create a new text column on the table.
*
* @param string $column
- * @return \Illuminate\Support\Fluent
+ * @return \Illuminate\Database\Schema\ColumnDefinition
*/
public function text($column)
{
@@ -495,7 +636,7 @@ class Blueprint
* Create a new medium text column on the table.
*
* @param string $column
- * @return \Illuminate\Support\Fluent
+ * @return \Illuminate\Database\Schema\ColumnDefinition
*/
public function mediumText($column)
{
@@ -506,7 +647,7 @@ class Blueprint
* Create a new long text column on the table.
*
* @param string $column
- * @return \Illuminate\Support\Fluent
+ * @return \Illuminate\Database\Schema\ColumnDefinition
*/
public function longText($column)
{
@@ -519,7 +660,7 @@ class Blueprint
* @param string $column
* @param bool $autoIncrement
* @param bool $unsigned
- * @return \Illuminate\Support\Fluent
+ * @return \Illuminate\Database\Schema\ColumnDefinition
*/
public function integer($column, $autoIncrement = false, $unsigned = false)
{
@@ -532,7 +673,7 @@ class Blueprint
* @param string $column
* @param bool $autoIncrement
* @param bool $unsigned
- * @return \Illuminate\Support\Fluent
+ * @return \Illuminate\Database\Schema\ColumnDefinition
*/
public function tinyInteger($column, $autoIncrement = false, $unsigned = false)
{
@@ -545,7 +686,7 @@ class Blueprint
* @param string $column
* @param bool $autoIncrement
* @param bool $unsigned
- * @return \Illuminate\Support\Fluent
+ * @return \Illuminate\Database\Schema\ColumnDefinition
*/
public function smallInteger($column, $autoIncrement = false, $unsigned = false)
{
@@ -558,7 +699,7 @@ class Blueprint
* @param string $column
* @param bool $autoIncrement
* @param bool $unsigned
- * @return \Illuminate\Support\Fluent
+ * @return \Illuminate\Database\Schema\ColumnDefinition
*/
public function mediumInteger($column, $autoIncrement = false, $unsigned = false)
{
@@ -571,7 +712,7 @@ class Blueprint
* @param string $column
* @param bool $autoIncrement
* @param bool $unsigned
- * @return \Illuminate\Support\Fluent
+ * @return \Illuminate\Database\Schema\ColumnDefinition
*/
public function bigInteger($column, $autoIncrement = false, $unsigned = false)
{
@@ -583,7 +724,7 @@ class Blueprint
*
* @param string $column
* @param bool $autoIncrement
- * @return \Illuminate\Support\Fluent
+ * @return \Illuminate\Database\Schema\ColumnDefinition
*/
public function unsignedInteger($column, $autoIncrement = false)
{
@@ -595,7 +736,7 @@ class Blueprint
*
* @param string $column
* @param bool $autoIncrement
- * @return \Illuminate\Support\Fluent
+ * @return \Illuminate\Database\Schema\ColumnDefinition
*/
public function unsignedTinyInteger($column, $autoIncrement = false)
{
@@ -607,7 +748,7 @@ class Blueprint
*
* @param string $column
* @param bool $autoIncrement
- * @return \Illuminate\Support\Fluent
+ * @return \Illuminate\Database\Schema\ColumnDefinition
*/
public function unsignedSmallInteger($column, $autoIncrement = false)
{
@@ -619,7 +760,7 @@ class Blueprint
*
* @param string $column
* @param bool $autoIncrement
- * @return \Illuminate\Support\Fluent
+ * @return \Illuminate\Database\Schema\ColumnDefinition
*/
public function unsignedMediumInteger($column, $autoIncrement = false)
{
@@ -631,7 +772,7 @@ class Blueprint
*
* @param string $column
* @param bool $autoIncrement
- * @return \Illuminate\Support\Fluent
+ * @return \Illuminate\Database\Schema\ColumnDefinition
*/
public function unsignedBigInteger($column, $autoIncrement = false)
{
@@ -642,9 +783,9 @@ class Blueprint
* Create a new float column on the table.
*
* @param string $column
- * @param int $total
- * @param int $places
- * @return \Illuminate\Support\Fluent
+ * @param int $total
+ * @param int $places
+ * @return \Illuminate\Database\Schema\ColumnDefinition
*/
public function float($column, $total = 8, $places = 2)
{
@@ -654,10 +795,10 @@ class Blueprint
/**
* Create a new double column on the table.
*
- * @param string $column
- * @param int|null $total
- * @param int|null $places
- * @return \Illuminate\Support\Fluent
+ * @param string $column
+ * @param int|null $total
+ * @param int|null $places
+ * @return \Illuminate\Database\Schema\ColumnDefinition
*/
public function double($column, $total = null, $places = null)
{
@@ -668,9 +809,9 @@ class Blueprint
* Create a new decimal column on the table.
*
* @param string $column
- * @param int $total
- * @param int $places
- * @return \Illuminate\Support\Fluent
+ * @param int $total
+ * @param int $places
+ * @return \Illuminate\Database\Schema\ColumnDefinition
*/
public function decimal($column, $total = 8, $places = 2)
{
@@ -683,7 +824,7 @@ class Blueprint
* @param string $column
* @param int $total
* @param int $places
- * @return \Illuminate\Support\Fluent
+ * @return \Illuminate\Database\Schema\ColumnDefinition
*/
public function unsignedDecimal($column, $total = 8, $places = 2)
{
@@ -696,7 +837,7 @@ class Blueprint
* Create a new boolean column on the table.
*
* @param string $column
- * @return \Illuminate\Support\Fluent
+ * @return \Illuminate\Database\Schema\ColumnDefinition
*/
public function boolean($column)
{
@@ -707,19 +848,31 @@ class Blueprint
* Create a new enum column on the table.
*
* @param string $column
- * @param array $allowed
- * @return \Illuminate\Support\Fluent
+ * @param array $allowed
+ * @return \Illuminate\Database\Schema\ColumnDefinition
*/
public function enum($column, array $allowed)
{
return $this->addColumn('enum', $column, compact('allowed'));
}
+ /**
+ * Create a new set column on the table.
+ *
+ * @param string $column
+ * @param array $allowed
+ * @return \Illuminate\Database\Schema\ColumnDefinition
+ */
+ public function set($column, array $allowed)
+ {
+ return $this->addColumn('set', $column, compact('allowed'));
+ }
+
/**
* Create a new json column on the table.
*
* @param string $column
- * @return \Illuminate\Support\Fluent
+ * @return \Illuminate\Database\Schema\ColumnDefinition
*/
public function json($column)
{
@@ -730,7 +883,7 @@ class Blueprint
* Create a new jsonb column on the table.
*
* @param string $column
- * @return \Illuminate\Support\Fluent
+ * @return \Illuminate\Database\Schema\ColumnDefinition
*/
public function jsonb($column)
{
@@ -741,7 +894,7 @@ class Blueprint
* Create a new date column on the table.
*
* @param string $column
- * @return \Illuminate\Support\Fluent
+ * @return \Illuminate\Database\Schema\ColumnDefinition
*/
public function date($column)
{
@@ -752,78 +905,85 @@ class Blueprint
* Create a new date-time column on the table.
*
* @param string $column
- * @return \Illuminate\Support\Fluent
+ * @param int $precision
+ * @return \Illuminate\Database\Schema\ColumnDefinition
*/
- public function dateTime($column)
+ public function dateTime($column, $precision = 0)
{
- return $this->addColumn('dateTime', $column);
+ return $this->addColumn('dateTime', $column, compact('precision'));
}
/**
* Create a new date-time column (with time zone) on the table.
*
* @param string $column
- * @return \Illuminate\Support\Fluent
+ * @param int $precision
+ * @return \Illuminate\Database\Schema\ColumnDefinition
*/
- public function dateTimeTz($column)
+ public function dateTimeTz($column, $precision = 0)
{
- return $this->addColumn('dateTimeTz', $column);
+ return $this->addColumn('dateTimeTz', $column, compact('precision'));
}
/**
* Create a new time column on the table.
*
* @param string $column
- * @return \Illuminate\Support\Fluent
+ * @param int $precision
+ * @return \Illuminate\Database\Schema\ColumnDefinition
*/
- public function time($column)
+ public function time($column, $precision = 0)
{
- return $this->addColumn('time', $column);
+ return $this->addColumn('time', $column, compact('precision'));
}
/**
* Create a new time column (with time zone) on the table.
*
* @param string $column
- * @return \Illuminate\Support\Fluent
+ * @param int $precision
+ * @return \Illuminate\Database\Schema\ColumnDefinition
*/
- public function timeTz($column)
+ public function timeTz($column, $precision = 0)
{
- return $this->addColumn('timeTz', $column);
+ return $this->addColumn('timeTz', $column, compact('precision'));
}
/**
* Create a new timestamp column on the table.
*
* @param string $column
- * @return \Illuminate\Support\Fluent
+ * @param int $precision
+ * @return \Illuminate\Database\Schema\ColumnDefinition
*/
- public function timestamp($column)
+ public function timestamp($column, $precision = 0)
{
- return $this->addColumn('timestamp', $column);
+ return $this->addColumn('timestamp', $column, compact('precision'));
}
/**
* Create a new timestamp (with time zone) column on the table.
*
* @param string $column
- * @return \Illuminate\Support\Fluent
+ * @param int $precision
+ * @return \Illuminate\Database\Schema\ColumnDefinition
*/
- public function timestampTz($column)
+ public function timestampTz($column, $precision = 0)
{
- return $this->addColumn('timestampTz', $column);
+ return $this->addColumn('timestampTz', $column, compact('precision'));
}
/**
* Add nullable creation and update timestamps to the table.
*
+ * @param int $precision
* @return void
*/
- public function timestamps()
+ public function timestamps($precision = 0)
{
- $this->timestamp('created_at')->nullable();
+ $this->timestamp('created_at', $precision)->nullable();
- $this->timestamp('updated_at')->nullable();
+ $this->timestamp('updated_at', $precision)->nullable();
}
/**
@@ -831,51 +991,67 @@ class Blueprint
*
* Alias for self::timestamps().
*
+ * @param int $precision
* @return void
*/
- public function nullableTimestamps()
+ public function nullableTimestamps($precision = 0)
{
- $this->timestamps();
+ $this->timestamps($precision);
}
/**
* Add creation and update timestampTz columns to the table.
*
+ * @param int $precision
* @return void
*/
- public function timestampsTz()
+ public function timestampsTz($precision = 0)
{
- $this->timestampTz('created_at')->nullable();
+ $this->timestampTz('created_at', $precision)->nullable();
- $this->timestampTz('updated_at')->nullable();
+ $this->timestampTz('updated_at', $precision)->nullable();
}
/**
* Add a "deleted at" timestamp for the table.
*
* @param string $column
- * @return \Illuminate\Support\Fluent
+ * @param int $precision
+ * @return \Illuminate\Database\Schema\ColumnDefinition
*/
- public function softDeletes($column = 'deleted_at')
+ public function softDeletes($column = 'deleted_at', $precision = 0)
{
- return $this->timestamp($column)->nullable();
+ return $this->timestamp($column, $precision)->nullable();
}
/**
* Add a "deleted at" timestampTz for the table.
*
- * @return \Illuminate\Support\Fluent
+ * @param string $column
+ * @param int $precision
+ * @return \Illuminate\Database\Schema\ColumnDefinition
*/
- public function softDeletesTz()
+ public function softDeletesTz($column = 'deleted_at', $precision = 0)
{
- return $this->timestampTz('deleted_at')->nullable();
+ return $this->timestampTz($column, $precision)->nullable();
+ }
+
+ /**
+ * Create a new year column on the table.
+ *
+ * @param string $column
+ * @return \Illuminate\Database\Schema\ColumnDefinition
+ */
+ public function year($column)
+ {
+ return $this->addColumn('year', $column);
}
/**
* Create a new binary column on the table.
*
* @param string $column
- * @return \Illuminate\Support\Fluent
+ * @return \Illuminate\Database\Schema\ColumnDefinition
*/
public function binary($column)
{
@@ -886,7 +1062,7 @@ class Blueprint
* Create a new uuid column on the table.
*
* @param string $column
- * @return \Illuminate\Support\Fluent
+ * @return \Illuminate\Database\Schema\ColumnDefinition
*/
public function uuid($column)
{
@@ -897,7 +1073,7 @@ class Blueprint
* Create a new IP address column on the table.
*
* @param string $column
- * @return \Illuminate\Support\Fluent
+ * @return \Illuminate\Database\Schema\ColumnDefinition
*/
public function ipAddress($column)
{
@@ -908,13 +1084,125 @@ class Blueprint
* Create a new MAC address column on the table.
*
* @param string $column
- * @return \Illuminate\Support\Fluent
+ * @return \Illuminate\Database\Schema\ColumnDefinition
*/
public function macAddress($column)
{
return $this->addColumn('macAddress', $column);
}
+ /**
+ * Create a new geometry column on the table.
+ *
+ * @param string $column
+ * @return \Illuminate\Database\Schema\ColumnDefinition
+ */
+ public function geometry($column)
+ {
+ return $this->addColumn('geometry', $column);
+ }
+
+ /**
+ * Create a new point column on the table.
+ *
+ * @param string $column
+ * @param int|null $srid
+ * @return \Illuminate\Database\Schema\ColumnDefinition
+ */
+ public function point($column, $srid = null)
+ {
+ return $this->addColumn('point', $column, compact('srid'));
+ }
+
+ /**
+ * Create a new linestring column on the table.
+ *
+ * @param string $column
+ * @return \Illuminate\Database\Schema\ColumnDefinition
+ */
+ public function lineString($column)
+ {
+ return $this->addColumn('linestring', $column);
+ }
+
+ /**
+ * Create a new polygon column on the table.
+ *
+ * @param string $column
+ * @return \Illuminate\Database\Schema\ColumnDefinition
+ */
+ public function polygon($column)
+ {
+ return $this->addColumn('polygon', $column);
+ }
+
+ /**
+ * Create a new geometrycollection column on the table.
+ *
+ * @param string $column
+ * @return \Illuminate\Database\Schema\ColumnDefinition
+ */
+ public function geometryCollection($column)
+ {
+ return $this->addColumn('geometrycollection', $column);
+ }
+
+ /**
+ * Create a new multipoint column on the table.
+ *
+ * @param string $column
+ * @return \Illuminate\Database\Schema\ColumnDefinition
+ */
+ public function multiPoint($column)
+ {
+ return $this->addColumn('multipoint', $column);
+ }
+
+ /**
+ * Create a new multilinestring column on the table.
+ *
+ * @param string $column
+ * @return \Illuminate\Database\Schema\ColumnDefinition
+ */
+ public function multiLineString($column)
+ {
+ return $this->addColumn('multilinestring', $column);
+ }
+
+ /**
+ * Create a new multipolygon column on the table.
+ *
+ * @param string $column
+ * @return \Illuminate\Database\Schema\ColumnDefinition
+ */
+ public function multiPolygon($column)
+ {
+ return $this->addColumn('multipolygon', $column);
+ }
+
+ /**
+ * Create a new multipolygon column on the table.
+ *
+ * @param string $column
+ * @return \Illuminate\Database\Schema\ColumnDefinition
+ */
+ public function multiPolygonZ($column)
+ {
+ return $this->addColumn('multipolygonz', $column);
+ }
+
+ /**
+ * Create a new generated, computed column on the table.
+ *
+ * @param string $column
+ * @param string $expression
+ * @return \Illuminate\Database\Schema\ColumnDefinition
+ */
+ public function computed($column, $expression)
+ {
+ return $this->addColumn('computed', $column, compact('expression'));
+ }
+
/**
* Add the proper columns for a polymorphic table.
*
@@ -924,11 +1212,11 @@ class Blueprint
*/
public function morphs($name, $indexName = null)
{
- $this->unsignedInteger("{$name}_id");
-
$this->string("{$name}_type");
- $this->index(["{$name}_id", "{$name}_type"], $indexName);
+ $this->unsignedBigInteger("{$name}_id");
+
+ $this->index(["{$name}_type", "{$name}_id"], $indexName);
}
/**
@@ -940,17 +1228,49 @@ class Blueprint
*/
public function nullableMorphs($name, $indexName = null)
{
- $this->unsignedInteger("{$name}_id")->nullable();
-
$this->string("{$name}_type")->nullable();
- $this->index(["{$name}_id", "{$name}_type"], $indexName);
+ $this->unsignedBigInteger("{$name}_id")->nullable();
+
+ $this->index(["{$name}_type", "{$name}_id"], $indexName);
+ }
+
+ /**
+ * Add the proper columns for a polymorphic table using UUIDs.
+ *
+ * @param string $name
+ * @param string|null $indexName
+ * @return void
+ */
+ public function uuidMorphs($name, $indexName = null)
+ {
+ $this->string("{$name}_type");
+
+ $this->uuid("{$name}_id");
+
+ $this->index(["{$name}_type", "{$name}_id"], $indexName);
+ }
+
+ /**
+ * Add nullable columns for a polymorphic table using UUIDs.
+ *
+ * @param string $name
+ * @param string|null $indexName
+ * @return void
+ */
+ public function nullableUuidMorphs($name, $indexName = null)
+ {
+ $this->string("{$name}_type")->nullable();
+
+ $this->uuid("{$name}_id")->nullable();
+
+ $this->index(["{$name}_type", "{$name}_id"], $indexName);
}
/**
* Adds the `remember_token` column to the table.
*
- * @return \Illuminate\Support\Fluent
+ * @return \Illuminate\Database\Schema\ColumnDefinition
*/
public function rememberToken()
{
@@ -960,10 +1280,10 @@ class Blueprint
/**
* Add a new index command to the blueprint.
*
- * @param string $type
+ * @param string $type
* @param string|array $columns
- * @param string $index
- * @param string|null $algorithm
+ * @param string $index
+ * @param string|null $algorithm
* @return \Illuminate\Support\Fluent
*/
protected function indexCommand($type, $columns, $index, $algorithm = null)
@@ -1006,12 +1326,12 @@ class Blueprint
* Create a default index name for the table.
*
* @param string $type
- * @param array $columns
+ * @param array $columns
* @return string
*/
protected function createIndexName($type, array $columns)
{
- $index = strtolower($this->table.'_'.implode('_', $columns).'_'.$type);
+ $index = strtolower($this->prefix.$this->table.'_'.implode('_', $columns).'_'.$type);
return str_replace(['-', '.'], '_', $index);
}
@@ -1021,12 +1341,12 @@ class Blueprint
*
* @param string $type
* @param string $name
- * @param array $parameters
- * @return \Illuminate\Support\Fluent
+ * @param array $parameters
+ * @return \Illuminate\Database\Schema\ColumnDefinition
*/
public function addColumn($type, $name, array $parameters = [])
{
- $this->columns[] = $column = new Fluent(
+ $this->columns[] = $column = new ColumnDefinition(
array_merge(compact('type', 'name'), $parameters)
);
@@ -1042,7 +1362,7 @@ class Blueprint
public function removeColumn($name)
{
$this->columns = array_values(array_filter($this->columns, function ($c) use ($name) {
- return $c['attributes']['name'] != $name;
+ return $c['name'] != $name;
}));
return $this;
@@ -1066,7 +1386,7 @@ class Blueprint
* Create a new Fluent command.
*
* @param string $name
- * @param array $parameters
+ * @param array $parameters
* @return \Illuminate\Support\Fluent
*/
protected function createCommand($name, array $parameters = [])
@@ -1087,7 +1407,7 @@ class Blueprint
/**
* Get the columns on the blueprint.
*
- * @return array
+ * @return \Illuminate\Database\Schema\ColumnDefinition[]
*/
public function getColumns()
{
@@ -1097,7 +1417,7 @@ class Blueprint
/**
* Get the commands on the blueprint.
*
- * @return array
+ * @return \Illuminate\Support\Fluent[]
*/
public function getCommands()
{
@@ -1107,7 +1427,7 @@ class Blueprint
/**
* Get the columns on the blueprint that should be added.
*
- * @return array
+ * @return \Illuminate\Database\Schema\ColumnDefinition[]
*/
public function getAddedColumns()
{
@@ -1119,7 +1439,7 @@ class Blueprint
/**
* Get the columns on the blueprint that should be changed.
*
- * @return array
+ * @return \Illuminate\Database\Schema\ColumnDefinition[]
*/
public function getChangedColumns()
{
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Schema/Builder.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Schema/Builder.php
index 4f2fa386..8cdf0cfd 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Schema/Builder.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Schema/Builder.php
@@ -3,6 +3,9 @@
namespace Illuminate\Database\Schema;
use Closure;
+use LogicException;
+use RuntimeException;
+use Doctrine\DBAL\Types\Type;
use Illuminate\Database\Connection;
class Builder
@@ -68,7 +71,7 @@ class Builder
{
$table = $this->connection->getTablePrefix().$table;
- return count($this->connection->select(
+ return count($this->connection->selectFromWriteConnection(
$this->grammar->compileTableExists(), [$table]
)) > 0;
}
@@ -129,9 +132,9 @@ class Builder
*/
public function getColumnListing($table)
{
- $table = $this->connection->getTablePrefix().$table;
-
- $results = $this->connection->select($this->grammar->compileColumnListing($table));
+ $results = $this->connection->selectFromWriteConnection($this->grammar->compileColumnListing(
+ $this->connection->getTablePrefix().$table
+ ));
return $this->connection->getPostProcessor()->processColumnListing($results);
}
@@ -190,6 +193,42 @@ class Builder
}));
}
+ /**
+ * Drop all tables from the database.
+ *
+ * @return void
+ *
+ * @throws \LogicException
+ */
+ public function dropAllTables()
+ {
+ throw new LogicException('This database driver does not support dropping all tables.');
+ }
+
+ /**
+ * Drop all views from the database.
+ *
+ * @return void
+ *
+ * @throws \LogicException
+ */
+ public function dropAllViews()
+ {
+ throw new LogicException('This database driver does not support dropping all views.');
+ }
+
+ /**
+ * Drop all types from the database.
+ *
+ * @return void
+ *
+ * @throws \LogicException
+ */
+ public function dropAllTypes()
+ {
+ throw new LogicException('This database driver does not support dropping all types.');
+ }
+
/**
* Rename a table on the schema.
*
@@ -248,11 +287,43 @@ class Builder
*/
protected function createBlueprint($table, Closure $callback = null)
{
+ $prefix = $this->connection->getConfig('prefix_indexes')
+ ? $this->connection->getConfig('prefix')
+ : '';
+
if (isset($this->resolver)) {
- return call_user_func($this->resolver, $table, $callback);
+ return call_user_func($this->resolver, $table, $callback, $prefix);
}
- return new Blueprint($table, $callback);
+ return new Blueprint($table, $callback, $prefix);
+ }
+
+ /**
+ * Register a custom Doctrine mapping type.
+ *
+ * @param string $class
+ * @param string $name
+ * @param string $type
+ * @return void
+ *
+ * @throws \Doctrine\DBAL\DBALException
+ */
+ public function registerCustomDoctrineType($class, $name, $type)
+ {
+ if (! $this->connection->isDoctrineAvailable()) {
+ throw new RuntimeException(
+ 'Registering a custom Doctrine type requires Doctrine DBAL (doctrine/dbal).'
+ );
+ }
+
+ if (! Type::hasType($name)) {
+ Type::addType($name, $class);
+
+ $this->connection
+ ->getDoctrineSchemaManager()
+ ->getDatabasePlatform()
+ ->registerDoctrineTypeMapping($type, $name);
+ }
}
/**
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Schema/Grammars/ChangeColumn.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Schema/Grammars/ChangeColumn.php
index 4751ecbe..8fc3b8c8 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Schema/Grammars/ChangeColumn.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Schema/Grammars/ChangeColumn.php
@@ -82,7 +82,10 @@ class ChangeColumn
if (! is_null($option = static::mapFluentOptionToDoctrine($key))) {
if (method_exists($column, $method = 'set'.ucfirst($option))) {
$column->{$method}(static::mapFluentValueToDoctrine($option, $value));
+ continue;
}
+
+ $column->setCustomSchemaOption($option, static::mapFluentValueToDoctrine($option, $value));
}
}
}
@@ -118,6 +121,12 @@ class ChangeColumn
$options['length'] = static::calculateDoctrineTextLength($fluent['type']);
}
+ if (in_array($fluent['type'], ['json', 'binary'])) {
+ $options['customSchemaOptions'] = [
+ 'collation' => '',
+ ];
+ }
+
return $options;
}
@@ -200,6 +209,6 @@ class ChangeColumn
*/
protected static function mapFluentValueToDoctrine($option, $value)
{
- return $option == 'notnull' ? ! $value : $value;
+ return $option === 'notnull' ? ! $value : $value;
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Schema/Grammars/Grammar.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Schema/Grammars/Grammar.php
index 6e880aec..0f81731b 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Schema/Grammars/Grammar.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Schema/Grammars/Grammar.php
@@ -2,6 +2,7 @@
namespace Illuminate\Database\Schema\Grammars;
+use RuntimeException;
use Illuminate\Support\Fluent;
use Doctrine\DBAL\Schema\TableDiff;
use Illuminate\Database\Connection;
@@ -19,6 +20,13 @@ abstract class Grammar extends BaseGrammar
*/
protected $transactions = false;
+ /**
+ * The commands to be executed outside of create or alter command.
+ *
+ * @var array
+ */
+ protected $fluentCommands = [];
+
/**
* Compile a rename column command.
*
@@ -120,6 +128,19 @@ abstract class Grammar extends BaseGrammar
return $this->{'type'.ucfirst($column->type)}($column);
}
+ /**
+ * Create the column definition for a generated, computed column type.
+ *
+ * @param \Illuminate\Support\Fluent $column
+ * @return void
+ *
+ * @throws \RuntimeException
+ */
+ protected function typeComputed(Fluent $column)
+ {
+ throw new RuntimeException('This database driver does not support the computed type.');
+ }
+
/**
* Add the column modifiers to the definition.
*
@@ -224,7 +245,7 @@ abstract class Grammar extends BaseGrammar
return is_bool($value)
? "'".(int) $value."'"
- : "'".strval($value)."'";
+ : "'".(string) $value."'";
}
/**
@@ -243,6 +264,16 @@ abstract class Grammar extends BaseGrammar
});
}
+ /**
+ * Get the fluent commands for the grammar.
+ *
+ * @return array
+ */
+ public function getFluentCommands()
+ {
+ return $this->fluentCommands;
+ }
+
/**
* Check if this Grammar supports schema changes wrapped in a transaction.
*
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Schema/Grammars/MySqlGrammar.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Schema/Grammars/MySqlGrammar.php
index 4f8d6b3f..dc933c96 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Schema/Grammars/MySqlGrammar.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Schema/Grammars/MySqlGrammar.php
@@ -2,6 +2,7 @@
namespace Illuminate\Database\Schema\Grammars;
+use RuntimeException;
use Illuminate\Support\Fluent;
use Illuminate\Database\Connection;
use Illuminate\Database\Schema\Blueprint;
@@ -14,8 +15,8 @@ class MySqlGrammar extends Grammar
* @var array
*/
protected $modifiers = [
- 'VirtualAs', 'StoredAs', 'Unsigned', 'Charset', 'Collate', 'Nullable',
- 'Default', 'Increment', 'Comment', 'After', 'First',
+ 'Unsigned', 'Charset', 'Collate', 'VirtualAs', 'StoredAs', 'Nullable',
+ 'Default', 'Increment', 'Comment', 'After', 'First', 'Srid',
];
/**
@@ -32,7 +33,7 @@ class MySqlGrammar extends Grammar
*/
public function compileTableExists()
{
- return 'select * from information_schema.tables where table_schema = ? and table_name = ?';
+ return "select * from information_schema.tables where table_schema = ? and table_name = ? and table_type = 'BASE TABLE'";
}
/**
@@ -42,7 +43,7 @@ class MySqlGrammar extends Grammar
*/
public function compileColumnListing()
{
- return 'select column_name from information_schema.columns where table_schema = ? and table_name = ?';
+ return 'select column_name as `column_name` from information_schema.columns where table_schema = ? and table_name = ?';
}
/**
@@ -114,9 +115,9 @@ class MySqlGrammar extends Grammar
// added to either this create table blueprint or the configuration for this
// connection that the query is targeting. We'll add it to this SQL query.
if (isset($blueprint->collation)) {
- $sql .= ' collate '.$blueprint->collation;
+ $sql .= " collate '{$blueprint->collation}'";
} elseif (! is_null($collation = $connection->getConfig('collation'))) {
- $sql .= ' collate '.$collation;
+ $sql .= " collate '{$collation}'";
}
return $sql;
@@ -193,6 +194,18 @@ class MySqlGrammar extends Grammar
return $this->compileKey($blueprint, $command, 'index');
}
+ /**
+ * Compile a spatial index key command.
+ *
+ * @param \Illuminate\Database\Schema\Blueprint $blueprint
+ * @param \Illuminate\Support\Fluent $command
+ * @return string
+ */
+ public function compileSpatialIndex(Blueprint $blueprint, Fluent $command)
+ {
+ return $this->compileKey($blueprint, $command, 'spatial index');
+ }
+
/**
* Compile an index creation command.
*
@@ -290,6 +303,18 @@ class MySqlGrammar extends Grammar
return "alter table {$this->wrapTable($blueprint)} drop index {$index}";
}
+ /**
+ * Compile a drop spatial index command.
+ *
+ * @param \Illuminate\Database\Schema\Blueprint $blueprint
+ * @param \Illuminate\Support\Fluent $command
+ * @return string
+ */
+ public function compileDropSpatialIndex(Blueprint $blueprint, Fluent $command)
+ {
+ return $this->compileDropIndex($blueprint, $command);
+ }
+
/**
* Compile a drop foreign key command.
*
@@ -318,6 +343,64 @@ class MySqlGrammar extends Grammar
return "rename table {$from} to ".$this->wrapTable($command->to);
}
+ /**
+ * Compile a rename index command.
+ *
+ * @param \Illuminate\Database\Schema\Blueprint $blueprint
+ * @param \Illuminate\Support\Fluent $command
+ * @return string
+ */
+ public function compileRenameIndex(Blueprint $blueprint, Fluent $command)
+ {
+ return sprintf('alter table %s rename index %s to %s',
+ $this->wrapTable($blueprint),
+ $this->wrap($command->from),
+ $this->wrap($command->to)
+ );
+ }
+
+ /**
+ * Compile the SQL needed to drop all tables.
+ *
+ * @param array $tables
+ * @return string
+ */
+ public function compileDropAllTables($tables)
+ {
+ return 'drop table '.implode(',', $this->wrapArray($tables));
+ }
+
+ /**
+ * Compile the SQL needed to drop all views.
+ *
+ * @param array $views
+ * @return string
+ */
+ public function compileDropAllViews($views)
+ {
+ return 'drop view '.implode(',', $this->wrapArray($views));
+ }
+
+ /**
+ * Compile the SQL needed to retrieve all table names.
+ *
+ * @return string
+ */
+ public function compileGetAllTables()
+ {
+ return 'SHOW FULL TABLES WHERE table_type = \'BASE TABLE\'';
+ }
+
+ /**
+ * Compile the SQL needed to retrieve all view names.
+ *
+ * @return string
+ */
+ public function compileGetAllViews()
+ {
+ return 'SHOW FULL TABLES WHERE table_type = \'VIEW\'';
+ }
+
/**
* Compile the command to enable foreign key constraints.
*
@@ -497,14 +580,25 @@ class MySqlGrammar extends Grammar
}
/**
- * Create the column definition for an enum type.
+ * Create the column definition for an enumeration type.
*
* @param \Illuminate\Support\Fluent $column
* @return string
*/
protected function typeEnum(Fluent $column)
{
- return "enum('".implode("', '", $column->allowed)."')";
+ return sprintf('enum(%s)', $this->quoteString($column->allowed));
+ }
+
+ /**
+ * Create the column definition for a set enumeration type.
+ *
+ * @param \Illuminate\Support\Fluent $column
+ * @return string
+ */
+ protected function typeSet(Fluent $column)
+ {
+ return sprintf('set(%s)', $this->quoteString($column->allowed));
}
/**
@@ -548,18 +642,20 @@ class MySqlGrammar extends Grammar
*/
protected function typeDateTime(Fluent $column)
{
- return 'datetime';
+ $columnType = $column->precision ? "datetime($column->precision)" : 'datetime';
+
+ return $column->useCurrent ? "$columnType default CURRENT_TIMESTAMP" : $columnType;
}
/**
- * Create the column definition for a date-time type.
+ * Create the column definition for a date-time (with time zone) type.
*
* @param \Illuminate\Support\Fluent $column
* @return string
*/
protected function typeDateTimeTz(Fluent $column)
{
- return 'datetime';
+ return $this->typeDateTime($column);
}
/**
@@ -570,18 +666,18 @@ class MySqlGrammar extends Grammar
*/
protected function typeTime(Fluent $column)
{
- return 'time';
+ return $column->precision ? "time($column->precision)" : 'time';
}
/**
- * Create the column definition for a time type.
+ * Create the column definition for a time (with time zone) type.
*
* @param \Illuminate\Support\Fluent $column
* @return string
*/
protected function typeTimeTz(Fluent $column)
{
- return 'time';
+ return $this->typeTime($column);
}
/**
@@ -592,26 +688,31 @@ class MySqlGrammar extends Grammar
*/
protected function typeTimestamp(Fluent $column)
{
- if ($column->useCurrent) {
- return 'timestamp default CURRENT_TIMESTAMP';
- }
+ $columnType = $column->precision ? "timestamp($column->precision)" : 'timestamp';
- return 'timestamp';
+ return $column->useCurrent ? "$columnType default CURRENT_TIMESTAMP" : $columnType;
}
/**
- * Create the column definition for a timestamp type.
+ * Create the column definition for a timestamp (with time zone) type.
*
* @param \Illuminate\Support\Fluent $column
* @return string
*/
protected function typeTimestampTz(Fluent $column)
{
- if ($column->useCurrent) {
- return 'timestamp default CURRENT_TIMESTAMP';
- }
+ return $this->typeTimestamp($column);
+ }
- return 'timestamp';
+ /**
+ * Create the column definition for a year type.
+ *
+ * @param \Illuminate\Support\Fluent $column
+ * @return string
+ */
+ protected function typeYear(Fluent $column)
+ {
+ return 'year';
}
/**
@@ -658,6 +759,107 @@ class MySqlGrammar extends Grammar
return 'varchar(17)';
}
+ /**
+ * Create the column definition for a spatial Geometry type.
+ *
+ * @param \Illuminate\Support\Fluent $column
+ * @return string
+ */
+ public function typeGeometry(Fluent $column)
+ {
+ return 'geometry';
+ }
+
+ /**
+ * Create the column definition for a spatial Point type.
+ *
+ * @param \Illuminate\Support\Fluent $column
+ * @return string
+ */
+ public function typePoint(Fluent $column)
+ {
+ return 'point';
+ }
+
+ /**
+ * Create the column definition for a spatial LineString type.
+ *
+ * @param \Illuminate\Support\Fluent $column
+ * @return string
+ */
+ public function typeLineString(Fluent $column)
+ {
+ return 'linestring';
+ }
+
+ /**
+ * Create the column definition for a spatial Polygon type.
+ *
+ * @param \Illuminate\Support\Fluent $column
+ * @return string
+ */
+ public function typePolygon(Fluent $column)
+ {
+ return 'polygon';
+ }
+
+ /**
+ * Create the column definition for a spatial GeometryCollection type.
+ *
+ * @param \Illuminate\Support\Fluent $column
+ * @return string
+ */
+ public function typeGeometryCollection(Fluent $column)
+ {
+ return 'geometrycollection';
+ }
+
+ /**
+ * Create the column definition for a spatial MultiPoint type.
+ *
+ * @param \Illuminate\Support\Fluent $column
+ * @return string
+ */
+ public function typeMultiPoint(Fluent $column)
+ {
+ return 'multipoint';
+ }
+
+ /**
+ * Create the column definition for a spatial MultiLineString type.
+ *
+ * @param \Illuminate\Support\Fluent $column
+ * @return string
+ */
+ public function typeMultiLineString(Fluent $column)
+ {
+ return 'multilinestring';
+ }
+
+ /**
+ * Create the column definition for a spatial MultiPolygon type.
+ *
+ * @param \Illuminate\Support\Fluent $column
+ * @return string
+ */
+ public function typeMultiPolygon(Fluent $column)
+ {
+ return 'multipolygon';
+ }
+
+ /**
+ * Create the column definition for a generated, computed column type.
+ *
+ * @param \Illuminate\Support\Fluent $column
+ * @return void
+ *
+ * @throws \RuntimeException
+ */
+ protected function typeComputed(Fluent $column)
+ {
+ throw new RuntimeException('This database driver requires a type, see the virtualAs / storedAs modifiers.');
+ }
+
/**
* Get the SQL for a generated virtual column modifier.
*
@@ -724,7 +926,7 @@ class MySqlGrammar extends Grammar
protected function modifyCollate(Blueprint $blueprint, Fluent $column)
{
if (! is_null($column->collation)) {
- return ' collate '.$column->collation;
+ return " collate '{$column->collation}'";
}
}
@@ -812,6 +1014,20 @@ class MySqlGrammar extends Grammar
}
}
+ /**
+ * Get the SQL for a SRID column modifier.
+ *
+ * @param \Illuminate\Database\Schema\Blueprint $blueprint
+ * @param \Illuminate\Support\Fluent $column
+ * @return string|null
+ */
+ protected function modifySrid(Blueprint $blueprint, Fluent $column)
+ {
+ if (! is_null($column->srid) && is_int($column->srid) && $column->srid > 0) {
+ return ' srid '.$column->srid;
+ }
+ }
+
/**
* Wrap a single string in keyword identifiers.
*
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Schema/Grammars/PostgresGrammar.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Schema/Grammars/PostgresGrammar.php
index 882e2ddf..0f85bc96 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Schema/Grammars/PostgresGrammar.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Schema/Grammars/PostgresGrammar.php
@@ -19,7 +19,7 @@ class PostgresGrammar extends Grammar
*
* @var array
*/
- protected $modifiers = ['Increment', 'Nullable', 'Default'];
+ protected $modifiers = ['Collate', 'Increment', 'Nullable', 'Default'];
/**
* The columns available as serials.
@@ -28,6 +28,13 @@ class PostgresGrammar extends Grammar
*/
protected $serials = ['bigInteger', 'integer', 'mediumInteger', 'smallInteger', 'tinyInteger'];
+ /**
+ * The commands to be executed outside of create or alter command.
+ *
+ * @var array
+ */
+ protected $fluentCommands = ['Comment'];
+
/**
* Compile the query to determine if a table exists.
*
@@ -35,18 +42,17 @@ class PostgresGrammar extends Grammar
*/
public function compileTableExists()
{
- return 'select * from information_schema.tables where table_schema = ? and table_name = ?';
+ return "select * from information_schema.tables where table_schema = ? and table_name = ? and table_type = 'BASE TABLE'";
}
/**
* Compile the query to determine the list of columns.
*
- * @param string $table
* @return string
*/
- public function compileColumnListing($table)
+ public function compileColumnListing()
{
- return "select column_name from information_schema.columns where table_name = '$table'";
+ return 'select column_name from information_schema.columns where table_schema = ? and table_name = ?';
}
/**
@@ -127,6 +133,46 @@ class PostgresGrammar extends Grammar
);
}
+ /**
+ * Compile a spatial index key command.
+ *
+ * @param \Illuminate\Database\Schema\Blueprint $blueprint
+ * @param \Illuminate\Support\Fluent $command
+ * @return string
+ */
+ public function compileSpatialIndex(Blueprint $blueprint, Fluent $command)
+ {
+ $command->algorithm = 'gist';
+
+ return $this->compileIndex($blueprint, $command);
+ }
+
+ /**
+ * Compile a foreign key command.
+ *
+ * @param \Illuminate\Database\Schema\Blueprint $blueprint
+ * @param \Illuminate\Support\Fluent $command
+ * @return string
+ */
+ public function compileForeign(Blueprint $blueprint, Fluent $command)
+ {
+ $sql = parent::compileForeign($blueprint, $command);
+
+ if (! is_null($command->deferrable)) {
+ $sql .= $command->deferrable ? ' deferrable' : ' not deferrable';
+ }
+
+ if ($command->deferrable && ! is_null($command->initiallyImmediate)) {
+ $sql .= $command->initiallyImmediate ? ' initially immediate' : ' initially deferred';
+ }
+
+ if (! is_null($command->notValid)) {
+ $sql .= ' not valid';
+ }
+
+ return $sql;
+ }
+
/**
* Compile a drop table command.
*
@@ -151,6 +197,71 @@ class PostgresGrammar extends Grammar
return 'drop table if exists '.$this->wrapTable($blueprint);
}
+ /**
+ * Compile the SQL needed to drop all tables.
+ *
+ * @param array $tables
+ * @return string
+ */
+ public function compileDropAllTables($tables)
+ {
+ return 'drop table "'.implode('","', $tables).'" cascade';
+ }
+
+ /**
+ * Compile the SQL needed to drop all views.
+ *
+ * @param array $views
+ * @return string
+ */
+ public function compileDropAllViews($views)
+ {
+ return 'drop view "'.implode('","', $views).'" cascade';
+ }
+
+ /**
+ * Compile the SQL needed to drop all types.
+ *
+ * @param array $types
+ * @return string
+ */
+ public function compileDropAllTypes($types)
+ {
+ return 'drop type "'.implode('","', $types).'" cascade';
+ }
+
+ /**
+ * Compile the SQL needed to retrieve all table names.
+ *
+ * @param string $schema
+ * @return string
+ */
+ public function compileGetAllTables($schema)
+ {
+ return "select tablename from pg_catalog.pg_tables where schemaname = '{$schema}'";
+ }
+
+ /**
+ * Compile the SQL needed to retrieve all view names.
+ *
+ * @param string $schema
+ * @return string
+ */
+ public function compileGetAllViews($schema)
+ {
+ return "select viewname from pg_catalog.pg_views where schemaname = '{$schema}'";
+ }
+
+ /**
+ * Compile the SQL needed to retrieve all type names.
+ *
+ * @return string
+ */
+ public function compileGetAllTypes()
+ {
+ return 'select distinct pg_type.typname from pg_type inner join pg_enum on pg_enum.enumtypid = pg_type.oid';
+ }
+
/**
* Compile a drop column command.
*
@@ -205,6 +316,18 @@ class PostgresGrammar extends Grammar
return "drop index {$this->wrap($command->index)}";
}
+ /**
+ * Compile a drop spatial index command.
+ *
+ * @param \Illuminate\Database\Schema\Blueprint $blueprint
+ * @param \Illuminate\Support\Fluent $command
+ * @return string
+ */
+ public function compileDropSpatialIndex(Blueprint $blueprint, Fluent $command)
+ {
+ return $this->compileDropIndex($blueprint, $command);
+ }
+
/**
* Compile a drop foreign key command.
*
@@ -233,6 +356,21 @@ class PostgresGrammar extends Grammar
return "alter table {$from} rename to ".$this->wrapTable($command->to);
}
+ /**
+ * Compile a rename index command.
+ *
+ * @param \Illuminate\Database\Schema\Blueprint $blueprint
+ * @param \Illuminate\Support\Fluent $command
+ * @return string
+ */
+ public function compileRenameIndex(Blueprint $blueprint, Fluent $command)
+ {
+ return sprintf('alter index %s rename to %s',
+ $this->wrap($command->from),
+ $this->wrap($command->to)
+ );
+ }
+
/**
* Compile the command to enable foreign key constraints.
*
@@ -253,6 +391,22 @@ class PostgresGrammar extends Grammar
return 'SET CONSTRAINTS ALL DEFERRED;';
}
+ /**
+ * Compile a comment command.
+ *
+ * @param \Illuminate\Database\Schema\Blueprint $blueprint
+ * @param \Illuminate\Support\Fluent $command
+ * @return string
+ */
+ public function compileComment(Blueprint $blueprint, Fluent $command)
+ {
+ return sprintf('comment on column %s.%s is %s',
+ $this->wrapTable($blueprint),
+ $this->wrap($command->column->name),
+ "'".str_replace("'", "''", $command->value)."'"
+ );
+ }
+
/**
* Create the column definition for a char type.
*
@@ -316,7 +470,7 @@ class PostgresGrammar extends Grammar
*/
protected function typeInteger(Fluent $column)
{
- return $column->autoIncrement ? 'serial' : 'integer';
+ return $this->generatableColumn('integer', $column);
}
/**
@@ -327,7 +481,7 @@ class PostgresGrammar extends Grammar
*/
protected function typeBigInteger(Fluent $column)
{
- return $column->autoIncrement ? 'bigserial' : 'bigint';
+ return $this->generatableColumn('bigint', $column);
}
/**
@@ -338,7 +492,7 @@ class PostgresGrammar extends Grammar
*/
protected function typeMediumInteger(Fluent $column)
{
- return $column->autoIncrement ? 'serial' : 'integer';
+ return $this->generatableColumn('integer', $column);
}
/**
@@ -349,7 +503,7 @@ class PostgresGrammar extends Grammar
*/
protected function typeTinyInteger(Fluent $column)
{
- return $column->autoIncrement ? 'smallserial' : 'smallint';
+ return $this->generatableColumn('smallint', $column);
}
/**
@@ -360,7 +514,42 @@ class PostgresGrammar extends Grammar
*/
protected function typeSmallInteger(Fluent $column)
{
- return $column->autoIncrement ? 'smallserial' : 'smallint';
+ return $this->generatableColumn('smallint', $column);
+ }
+
+ /**
+ * Create the column definition for a generatable column.
+ *
+ * @param string $type
+ * @param \Illuminate\Support\Fluent $column
+ * @return string
+ */
+ protected function generatableColumn($type, Fluent $column)
+ {
+ if (! $column->autoIncrement && is_null($column->generatedAs)) {
+ return $type;
+ }
+
+ if ($column->autoIncrement && is_null($column->generatedAs)) {
+ return with([
+ 'integer' => 'serial',
+ 'bigint' => 'bigserial',
+ 'smallint' => 'smallserial',
+ ])[$type];
+ }
+
+ $options = '';
+
+ if (! is_bool($column->generatedAs) && ! empty($column->generatedAs)) {
+ $options = sprintf(' (%s)', $column->generatedAs);
+ }
+
+ return sprintf(
+ '%s generated %s as identity%s',
+ $type,
+ $column->always ? 'always' : 'by default',
+ $options
+ );
}
/**
@@ -419,18 +608,18 @@ class PostgresGrammar extends Grammar
}
/**
- * Create the column definition for an enum type.
+ * Create the column definition for an enumeration type.
*
* @param \Illuminate\Support\Fluent $column
* @return string
*/
protected function typeEnum(Fluent $column)
{
- $allowed = array_map(function ($a) {
- return "'{$a}'";
- }, $column->allowed);
-
- return "varchar(255) check (\"{$column->name}\" in (".implode(', ', $allowed).'))';
+ return sprintf(
+ 'varchar(255) check ("%s" in (%s))',
+ $column->name,
+ $this->quoteString($column->allowed)
+ );
}
/**
@@ -474,18 +663,18 @@ class PostgresGrammar extends Grammar
*/
protected function typeDateTime(Fluent $column)
{
- return 'timestamp(0) without time zone';
+ return $this->typeTimestamp($column);
}
/**
- * Create the column definition for a date-time type.
+ * Create the column definition for a date-time (with time zone) type.
*
* @param \Illuminate\Support\Fluent $column
* @return string
*/
protected function typeDateTimeTz(Fluent $column)
{
- return 'timestamp(0) with time zone';
+ return $this->typeTimestampTz($column);
}
/**
@@ -496,18 +685,18 @@ class PostgresGrammar extends Grammar
*/
protected function typeTime(Fluent $column)
{
- return 'time(0) without time zone';
+ return "time($column->precision) without time zone";
}
/**
- * Create the column definition for a time type.
+ * Create the column definition for a time (with time zone) type.
*
* @param \Illuminate\Support\Fluent $column
* @return string
*/
protected function typeTimeTz(Fluent $column)
{
- return 'time(0) with time zone';
+ return "time($column->precision) with time zone";
}
/**
@@ -518,26 +707,33 @@ class PostgresGrammar extends Grammar
*/
protected function typeTimestamp(Fluent $column)
{
- if ($column->useCurrent) {
- return 'timestamp(0) without time zone default CURRENT_TIMESTAMP(0)';
- }
+ $columnType = "timestamp($column->precision) without time zone";
- return 'timestamp(0) without time zone';
+ return $column->useCurrent ? "$columnType default CURRENT_TIMESTAMP" : $columnType;
}
/**
- * Create the column definition for a timestamp type.
+ * Create the column definition for a timestamp (with time zone) type.
*
* @param \Illuminate\Support\Fluent $column
* @return string
*/
protected function typeTimestampTz(Fluent $column)
{
- if ($column->useCurrent) {
- return 'timestamp(0) with time zone default CURRENT_TIMESTAMP(0)';
- }
+ $columnType = "timestamp($column->precision) with time zone";
- return 'timestamp(0) with time zone';
+ return $column->useCurrent ? "$columnType default CURRENT_TIMESTAMP" : $columnType;
+ }
+
+ /**
+ * Create the column definition for a year type.
+ *
+ * @param \Illuminate\Support\Fluent $column
+ * @return string
+ */
+ protected function typeYear(Fluent $column)
+ {
+ return $this->typeInteger($column);
}
/**
@@ -584,6 +780,130 @@ class PostgresGrammar extends Grammar
return 'macaddr';
}
+ /**
+ * Create the column definition for a spatial Geometry type.
+ *
+ * @param \Illuminate\Support\Fluent $column
+ * @return string
+ */
+ protected function typeGeometry(Fluent $column)
+ {
+ return $this->formatPostGisType('geometry');
+ }
+
+ /**
+ * Create the column definition for a spatial Point type.
+ *
+ * @param \Illuminate\Support\Fluent $column
+ * @return string
+ */
+ protected function typePoint(Fluent $column)
+ {
+ return $this->formatPostGisType('point');
+ }
+
+ /**
+ * Create the column definition for a spatial LineString type.
+ *
+ * @param \Illuminate\Support\Fluent $column
+ * @return string
+ */
+ protected function typeLineString(Fluent $column)
+ {
+ return $this->formatPostGisType('linestring');
+ }
+
+ /**
+ * Create the column definition for a spatial Polygon type.
+ *
+ * @param \Illuminate\Support\Fluent $column
+ * @return string
+ */
+ protected function typePolygon(Fluent $column)
+ {
+ return $this->formatPostGisType('polygon');
+ }
+
+ /**
+ * Create the column definition for a spatial GeometryCollection type.
+ *
+ * @param \Illuminate\Support\Fluent $column
+ * @return string
+ */
+ protected function typeGeometryCollection(Fluent $column)
+ {
+ return $this->formatPostGisType('geometrycollection');
+ }
+
+ /**
+ * Create the column definition for a spatial MultiPoint type.
+ *
+ * @param \Illuminate\Support\Fluent $column
+ * @return string
+ */
+ protected function typeMultiPoint(Fluent $column)
+ {
+ return $this->formatPostGisType('multipoint');
+ }
+
+ /**
+ * Create the column definition for a spatial MultiLineString type.
+ *
+ * @param \Illuminate\Support\Fluent $column
+ * @return string
+ */
+ public function typeMultiLineString(Fluent $column)
+ {
+ return $this->formatPostGisType('multilinestring');
+ }
+
+ /**
+ * Create the column definition for a spatial MultiPolygon type.
+ *
+ * @param \Illuminate\Support\Fluent $column
+ * @return string
+ */
+ protected function typeMultiPolygon(Fluent $column)
+ {
+ return $this->formatPostGisType('multipolygon');
+ }
+
+ /**
+ * Create the column definition for a spatial MultiPolygonZ type.
+ *
+ * @param \Illuminate\Support\Fluent $column
+ * @return string
+ */
+ protected function typeMultiPolygonZ(Fluent $column)
+ {
+ return $this->formatPostGisType('multipolygonz');
+ }
+
+ /**
+ * Format the column definition for a PostGIS spatial type.
+ *
+ * @param string $type
+ * @return string
+ */
+ private function formatPostGisType(string $type)
+ {
+ return "geography($type, 4326)";
+ }
+
+ /**
+ * Get the SQL for a collation column modifier.
+ *
+ * @param \Illuminate\Database\Schema\Blueprint $blueprint
+ * @param \Illuminate\Support\Fluent $column
+ * @return string|null
+ */
+ protected function modifyCollate(Blueprint $blueprint, Fluent $column)
+ {
+ if (! is_null($column->collation)) {
+ return ' collate '.$this->wrapValue($column->collation);
+ }
+ }
+
/**
* Get the SQL for a nullable column modifier.
*
@@ -619,7 +939,7 @@ class PostgresGrammar extends Grammar
*/
protected function modifyIncrement(Blueprint $blueprint, Fluent $column)
{
- if (in_array($column->type, $this->serials) && $column->autoIncrement) {
+ if ((in_array($column->type, $this->serials) || ($column->generatedAs !== null)) && $column->autoIncrement) {
return ' primary key';
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Schema/Grammars/SQLiteGrammar.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Schema/Grammars/SQLiteGrammar.php
index d96bfd66..ac825e73 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Schema/Grammars/SQLiteGrammar.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Schema/Grammars/SQLiteGrammar.php
@@ -2,7 +2,10 @@
namespace Illuminate\Database\Schema\Grammars;
+use RuntimeException;
+use Illuminate\Support\Arr;
use Illuminate\Support\Fluent;
+use Doctrine\DBAL\Schema\Index;
use Illuminate\Database\Connection;
use Illuminate\Database\Schema\Blueprint;
@@ -40,7 +43,7 @@ class SQLiteGrammar extends Grammar
*/
public function compileColumnListing($table)
{
- return 'pragma table_info('.$this->wrapTable(str_replace('.', '__', $table)).')';
+ return 'pragma table_info('.$this->wrap(str_replace('.', '__', $table)).')';
}
/**
@@ -83,7 +86,7 @@ class SQLiteGrammar extends Grammar
// If this foreign key specifies the action to be taken on update we will add
// that to the statement here. We'll append it to this SQL and then return
- // the SQL so we can keep adding any other foreign consraints onto this.
+ // the SQL so we can keep adding any other foreign constraints onto this.
if (! is_null($foreign->onUpdate)) {
$sql .= " on update {$foreign->onUpdate}";
}
@@ -171,6 +174,19 @@ class SQLiteGrammar extends Grammar
);
}
+ /**
+ * Compile a spatial index key command.
+ *
+ * @param \Illuminate\Database\Schema\Blueprint $blueprint
+ * @param \Illuminate\Support\Fluent $command
+ *
+ * @throws \RuntimeException
+ */
+ public function compileSpatialIndex(Blueprint $blueprint, Fluent $command)
+ {
+ throw new RuntimeException('The database driver in use does not support spatial indexes.');
+ }
+
/**
* Compile a foreign key command.
*
@@ -207,6 +223,36 @@ class SQLiteGrammar extends Grammar
return 'drop table if exists '.$this->wrapTable($blueprint);
}
+ /**
+ * Compile the SQL needed to drop all tables.
+ *
+ * @return string
+ */
+ public function compileDropAllTables()
+ {
+ return "delete from sqlite_master where type in ('table', 'index', 'trigger')";
+ }
+
+ /**
+ * Compile the SQL needed to drop all views.
+ *
+ * @return string
+ */
+ public function compileDropAllViews()
+ {
+ return "delete from sqlite_master where type in ('view')";
+ }
+
+ /**
+ * Compile the SQL needed to rebuild the database.
+ *
+ * @return string
+ */
+ public function compileRebuild()
+ {
+ return 'vacuum';
+ }
+
/**
* Compile a drop column command.
*
@@ -222,9 +268,9 @@ class SQLiteGrammar extends Grammar
);
foreach ($command->columns as $name) {
- $column = $connection->getDoctrineColumn($blueprint->getTable(), $name);
-
- $tableDiff->removedColumns[$name] = $column;
+ $tableDiff->removedColumns[$name] = $connection->getDoctrineColumn(
+ $this->getTablePrefix().$blueprint->getTable(), $name
+ );
}
return (array) $schema->getDatabasePlatform()->getAlterTableSQL($tableDiff);
@@ -258,6 +304,19 @@ class SQLiteGrammar extends Grammar
return "drop index {$index}";
}
+ /**
+ * Compile a drop spatial index command.
+ *
+ * @param \Illuminate\Database\Schema\Blueprint $blueprint
+ * @param \Illuminate\Support\Fluent $command
+ *
+ * @throws \RuntimeException
+ */
+ public function compileDropSpatialIndex(Blueprint $blueprint, Fluent $command)
+ {
+ throw new RuntimeException('The database driver in use does not support spatial indexes.');
+ }
+
/**
* Compile a rename table command.
*
@@ -272,6 +331,39 @@ class SQLiteGrammar extends Grammar
return "alter table {$from} rename to ".$this->wrapTable($command->to);
}
+ /**
+ * Compile a rename index command.
+ *
+ * @param \Illuminate\Database\Schema\Blueprint $blueprint
+ * @param \Illuminate\Support\Fluent $command
+ * @param \Illuminate\Database\Connection $connection
+ * @return array
+ */
+ public function compileRenameIndex(Blueprint $blueprint, Fluent $command, Connection $connection)
+ {
+ $schemaManager = $connection->getDoctrineSchemaManager();
+
+ $indexes = $schemaManager->listTableIndexes($this->getTablePrefix().$blueprint->getTable());
+
+ $index = Arr::get($indexes, $command->from);
+
+ if (! $index) {
+ throw new RuntimeException("Index [{$command->from}] does not exist.");
+ }
+
+ $newIndex = new Index(
+ $command->to, $index->getColumns(), $index->isUnique(),
+ $index->isPrimary(), $index->getFlags(), $index->getOptions()
+ );
+
+ $platform = $schemaManager->getDatabasePlatform();
+
+ return [
+ $platform->getDropIndexSQL($command->from, $this->getTablePrefix().$blueprint->getTable()),
+ $platform->getCreateIndexSQL($newIndex, $this->getTablePrefix().$blueprint->getTable()),
+ ];
+ }
+
/**
* Compile the command to enable foreign key constraints.
*
@@ -292,6 +384,26 @@ class SQLiteGrammar extends Grammar
return 'PRAGMA foreign_keys = OFF;';
}
+ /**
+ * Compile the SQL needed to enable a writable schema.
+ *
+ * @return string
+ */
+ public function compileEnableWriteableSchema()
+ {
+ return 'PRAGMA writable_schema = 1;';
+ }
+
+ /**
+ * Compile the SQL needed to disable a writable schema.
+ *
+ * @return string
+ */
+ public function compileDisableWriteableSchema()
+ {
+ return 'PRAGMA writable_schema = 0;';
+ }
+
/**
* Create the column definition for a char type.
*
@@ -447,14 +559,18 @@ class SQLiteGrammar extends Grammar
}
/**
- * Create the column definition for an enum type.
+ * Create the column definition for an enumeration type.
*
* @param \Illuminate\Support\Fluent $column
* @return string
*/
protected function typeEnum(Fluent $column)
{
- return 'varchar';
+ return sprintf(
+ 'varchar check ("%s" in (%s))',
+ $column->name,
+ $this->quoteString($column->allowed)
+ );
}
/**
@@ -498,11 +614,11 @@ class SQLiteGrammar extends Grammar
*/
protected function typeDateTime(Fluent $column)
{
- return 'datetime';
+ return $this->typeTimestamp($column);
}
/**
- * Create the column definition for a date-time type.
+ * Create the column definition for a date-time (with time zone) type.
*
* Note: "SQLite does not have a storage class set aside for storing dates and/or times."
* @link https://www.sqlite.org/datatype3.html
@@ -512,7 +628,7 @@ class SQLiteGrammar extends Grammar
*/
protected function typeDateTimeTz(Fluent $column)
{
- return 'datetime';
+ return $this->typeDateTime($column);
}
/**
@@ -527,14 +643,14 @@ class SQLiteGrammar extends Grammar
}
/**
- * Create the column definition for a time type.
+ * Create the column definition for a time (with time zone) type.
*
* @param \Illuminate\Support\Fluent $column
* @return string
*/
protected function typeTimeTz(Fluent $column)
{
- return 'time';
+ return $this->typeTime($column);
}
/**
@@ -545,26 +661,29 @@ class SQLiteGrammar extends Grammar
*/
protected function typeTimestamp(Fluent $column)
{
- if ($column->useCurrent) {
- return 'datetime default CURRENT_TIMESTAMP';
- }
-
- return 'datetime';
+ return $column->useCurrent ? 'datetime default CURRENT_TIMESTAMP' : 'datetime';
}
/**
- * Create the column definition for a timestamp type.
+ * Create the column definition for a timestamp (with time zone) type.
*
* @param \Illuminate\Support\Fluent $column
* @return string
*/
protected function typeTimestampTz(Fluent $column)
{
- if ($column->useCurrent) {
- return 'datetime default CURRENT_TIMESTAMP';
- }
+ return $this->typeTimestamp($column);
+ }
- return 'datetime';
+ /**
+ * Create the column definition for a year type.
+ *
+ * @param \Illuminate\Support\Fluent $column
+ * @return string
+ */
+ protected function typeYear(Fluent $column)
+ {
+ return $this->typeInteger($column);
}
/**
@@ -611,6 +730,94 @@ class SQLiteGrammar extends Grammar
return 'varchar';
}
+ /**
+ * Create the column definition for a spatial Geometry type.
+ *
+ * @param \Illuminate\Support\Fluent $column
+ * @return string
+ */
+ public function typeGeometry(Fluent $column)
+ {
+ return 'geometry';
+ }
+
+ /**
+ * Create the column definition for a spatial Point type.
+ *
+ * @param \Illuminate\Support\Fluent $column
+ * @return string
+ */
+ public function typePoint(Fluent $column)
+ {
+ return 'point';
+ }
+
+ /**
+ * Create the column definition for a spatial LineString type.
+ *
+ * @param \Illuminate\Support\Fluent $column
+ * @return string
+ */
+ public function typeLineString(Fluent $column)
+ {
+ return 'linestring';
+ }
+
+ /**
+ * Create the column definition for a spatial Polygon type.
+ *
+ * @param \Illuminate\Support\Fluent $column
+ * @return string
+ */
+ public function typePolygon(Fluent $column)
+ {
+ return 'polygon';
+ }
+
+ /**
+ * Create the column definition for a spatial GeometryCollection type.
+ *
+ * @param \Illuminate\Support\Fluent $column
+ * @return string
+ */
+ public function typeGeometryCollection(Fluent $column)
+ {
+ return 'geometrycollection';
+ }
+
+ /**
+ * Create the column definition for a spatial MultiPoint type.
+ *
+ * @param \Illuminate\Support\Fluent $column
+ * @return string
+ */
+ public function typeMultiPoint(Fluent $column)
+ {
+ return 'multipoint';
+ }
+
+ /**
+ * Create the column definition for a spatial MultiLineString type.
+ *
+ * @param \Illuminate\Support\Fluent $column
+ * @return string
+ */
+ public function typeMultiLineString(Fluent $column)
+ {
+ return 'multilinestring';
+ }
+
+ /**
+ * Create the column definition for a spatial MultiPolygon type.
+ *
+ * @param \Illuminate\Support\Fluent $column
+ * @return string
+ */
+ public function typeMultiPolygon(Fluent $column)
+ {
+ return 'multipolygon';
+ }
+
/**
* Get the SQL for a nullable column modifier.
*
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Schema/Grammars/SqlServerGrammar.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Schema/Grammars/SqlServerGrammar.php
index 4ba43bbc..0f1d0c47 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Schema/Grammars/SqlServerGrammar.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Schema/Grammars/SqlServerGrammar.php
@@ -7,12 +7,19 @@ use Illuminate\Database\Schema\Blueprint;
class SqlServerGrammar extends Grammar
{
+ /**
+ * If this Grammar supports schema changes wrapped in a transaction.
+ *
+ * @var bool
+ */
+ protected $transactions = true;
+
/**
* The possible column modifiers.
*
* @var array
*/
- protected $modifiers = ['Increment', 'Collate', 'Nullable', 'Default'];
+ protected $modifiers = ['Increment', 'Collate', 'Nullable', 'Default', 'Persisted'];
/**
* The columns available as serials.
@@ -121,6 +128,22 @@ class SqlServerGrammar extends Grammar
);
}
+ /**
+ * Compile a spatial index key command.
+ *
+ * @param \Illuminate\Database\Schema\Blueprint $blueprint
+ * @param \Illuminate\Support\Fluent $command
+ * @return string
+ */
+ public function compileSpatialIndex(Blueprint $blueprint, Fluent $command)
+ {
+ return sprintf('create spatial index %s on %s (%s)',
+ $this->wrap($command->index),
+ $this->wrapTable($blueprint),
+ $this->columnize($command->columns)
+ );
+ }
+
/**
* Compile a drop table command.
*
@@ -148,6 +171,16 @@ class SqlServerGrammar extends Grammar
);
}
+ /**
+ * Compile the SQL needed to drop all tables.
+ *
+ * @return string
+ */
+ public function compileDropAllTables()
+ {
+ return "EXEC sp_msforeachtable 'DROP TABLE ?'";
+ }
+
/**
* Compile a drop column command.
*
@@ -204,6 +237,18 @@ class SqlServerGrammar extends Grammar
return "drop index {$index} on {$this->wrapTable($blueprint)}";
}
+ /**
+ * Compile a drop spatial index command.
+ *
+ * @param \Illuminate\Database\Schema\Blueprint $blueprint
+ * @param \Illuminate\Support\Fluent $command
+ * @return string
+ */
+ public function compileDropSpatialIndex(Blueprint $blueprint, Fluent $command)
+ {
+ return $this->compileDropIndex($blueprint, $command);
+ }
+
/**
* Compile a drop foreign key command.
*
@@ -232,6 +277,21 @@ class SqlServerGrammar extends Grammar
return "sp_rename {$from}, ".$this->wrapTable($command->to);
}
+ /**
+ * Compile a rename index command.
+ *
+ * @param \Illuminate\Database\Schema\Blueprint $blueprint
+ * @param \Illuminate\Support\Fluent $command
+ * @return string
+ */
+ public function compileRenameIndex(Blueprint $blueprint, Fluent $command)
+ {
+ return sprintf("sp_rename N'%s', %s, N'INDEX'",
+ $this->wrap($blueprint->getTable().'.'.$command->from),
+ $this->wrap($command->to)
+ );
+ }
+
/**
* Compile the command to enable foreign key constraints.
*
@@ -252,6 +312,21 @@ class SqlServerGrammar extends Grammar
return 'EXEC sp_msforeachtable "ALTER TABLE ? NOCHECK CONSTRAINT all";';
}
+ /**
+ * Compile the command to drop all foreign keys.
+ *
+ * @return string
+ */
+ public function compileDropAllForeignKeys()
+ {
+ return "DECLARE @sql NVARCHAR(MAX) = N'';
+ SELECT @sql += 'ALTER TABLE ' + QUOTENAME(OBJECT_NAME(parent_object_id))
+ + ' DROP CONSTRAINT ' + QUOTENAME(name) + ';'
+ FROM sys.foreign_keys;
+
+ EXEC sp_executesql @sql;";
+ }
+
/**
* Create the column definition for a char type.
*
@@ -407,14 +482,18 @@ class SqlServerGrammar extends Grammar
}
/**
- * Create the column definition for an enum type.
+ * Create the column definition for an enumeration type.
*
* @param \Illuminate\Support\Fluent $column
* @return string
*/
protected function typeEnum(Fluent $column)
{
- return 'nvarchar(255)';
+ return sprintf(
+ 'nvarchar(255) check ("%s" in (%s))',
+ $column->name,
+ $this->quoteString($column->allowed)
+ );
}
/**
@@ -458,18 +537,18 @@ class SqlServerGrammar extends Grammar
*/
protected function typeDateTime(Fluent $column)
{
- return 'datetime';
+ return $this->typeTimestamp($column);
}
/**
- * Create the column definition for a date-time type.
+ * Create the column definition for a date-time (with time zone) type.
*
* @param \Illuminate\Support\Fluent $column
* @return string
*/
protected function typeDateTimeTz(Fluent $column)
{
- return 'datetimeoffset(0)';
+ return $this->typeTimestampTz($column);
}
/**
@@ -480,18 +559,18 @@ class SqlServerGrammar extends Grammar
*/
protected function typeTime(Fluent $column)
{
- return 'time';
+ return $column->precision ? "time($column->precision)" : 'time';
}
/**
- * Create the column definition for a time type.
+ * Create the column definition for a time (with time zone) type.
*
* @param \Illuminate\Support\Fluent $column
* @return string
*/
protected function typeTimeTz(Fluent $column)
{
- return 'time';
+ return $this->typeTime($column);
}
/**
@@ -502,15 +581,13 @@ class SqlServerGrammar extends Grammar
*/
protected function typeTimestamp(Fluent $column)
{
- if ($column->useCurrent) {
- return 'datetime default CURRENT_TIMESTAMP';
- }
+ $columnType = $column->precision ? "datetime2($column->precision)" : 'datetime';
- return 'datetime';
+ return $column->useCurrent ? "$columnType default CURRENT_TIMESTAMP" : $columnType;
}
/**
- * Create the column definition for a timestamp type.
+ * Create the column definition for a timestamp (with time zone) type.
*
* @link https://msdn.microsoft.com/en-us/library/bb630289(v=sql.120).aspx
*
@@ -519,11 +596,20 @@ class SqlServerGrammar extends Grammar
*/
protected function typeTimestampTz(Fluent $column)
{
- if ($column->useCurrent) {
- return 'datetimeoffset(0) default CURRENT_TIMESTAMP';
- }
+ $columnType = $column->precision ? "datetimeoffset($column->precision)" : 'datetimeoffset';
- return 'datetimeoffset(0)';
+ return $column->useCurrent ? "$columnType default CURRENT_TIMESTAMP" : $columnType;
+ }
+
+ /**
+ * Create the column definition for a year type.
+ *
+ * @param \Illuminate\Support\Fluent $column
+ * @return string
+ */
+ protected function typeYear(Fluent $column)
+ {
+ return $this->typeInteger($column);
}
/**
@@ -570,6 +656,105 @@ class SqlServerGrammar extends Grammar
return 'nvarchar(17)';
}
+ /**
+ * Create the column definition for a spatial Geometry type.
+ *
+ * @param \Illuminate\Support\Fluent $column
+ * @return string
+ */
+ public function typeGeometry(Fluent $column)
+ {
+ return 'geography';
+ }
+
+ /**
+ * Create the column definition for a spatial Point type.
+ *
+ * @param \Illuminate\Support\Fluent $column
+ * @return string
+ */
+ public function typePoint(Fluent $column)
+ {
+ return 'geography';
+ }
+
+ /**
+ * Create the column definition for a spatial LineString type.
+ *
+ * @param \Illuminate\Support\Fluent $column
+ * @return string
+ */
+ public function typeLineString(Fluent $column)
+ {
+ return 'geography';
+ }
+
+ /**
+ * Create the column definition for a spatial Polygon type.
+ *
+ * @param \Illuminate\Support\Fluent $column
+ * @return string
+ */
+ public function typePolygon(Fluent $column)
+ {
+ return 'geography';
+ }
+
+ /**
+ * Create the column definition for a spatial GeometryCollection type.
+ *
+ * @param \Illuminate\Support\Fluent $column
+ * @return string
+ */
+ public function typeGeometryCollection(Fluent $column)
+ {
+ return 'geography';
+ }
+
+ /**
+ * Create the column definition for a spatial MultiPoint type.
+ *
+ * @param \Illuminate\Support\Fluent $column
+ * @return string
+ */
+ public function typeMultiPoint(Fluent $column)
+ {
+ return 'geography';
+ }
+
+ /**
+ * Create the column definition for a spatial MultiLineString type.
+ *
+ * @param \Illuminate\Support\Fluent $column
+ * @return string
+ */
+ public function typeMultiLineString(Fluent $column)
+ {
+ return 'geography';
+ }
+
+ /**
+ * Create the column definition for a spatial MultiPolygon type.
+ *
+ * @param \Illuminate\Support\Fluent $column
+ * @return string
+ */
+ public function typeMultiPolygon(Fluent $column)
+ {
+ return 'geography';
+ }
+
+ /**
+ * Create the column definition for a generated, computed column type.
+ *
+ * @param \Illuminate\Support\Fluent $column
+ * @return string|null
+ */
+ protected function typeComputed(Fluent $column)
+ {
+ return "as ({$column->expression})";
+ }
+
/**
* Get the SQL for a collation column modifier.
*
@@ -593,7 +778,9 @@ class SqlServerGrammar extends Grammar
*/
protected function modifyNullable(Blueprint $blueprint, Fluent $column)
{
- return $column->nullable ? ' null' : ' not null';
+ if ($column->type !== 'computed') {
+ return $column->nullable ? ' null' : ' not null';
+ }
}
/**
@@ -623,4 +810,48 @@ class SqlServerGrammar extends Grammar
return ' identity primary key';
}
}
+
+ /**
+ * Get the SQL for a generated stored column modifier.
+ *
+ * @param \Illuminate\Database\Schema\Blueprint $blueprint
+ * @param \Illuminate\Support\Fluent $column
+ * @return string|null
+ */
+ protected function modifyPersisted(Blueprint $blueprint, Fluent $column)
+ {
+ if ($column->persisted) {
+ return ' persisted';
+ }
+ }
+
+ /**
+ * Wrap a table in keyword identifiers.
+ *
+ * @param \Illuminate\Database\Query\Expression|string $table
+ * @return string
+ */
+ public function wrapTable($table)
+ {
+ if ($table instanceof Blueprint && $table->temporary) {
+ $this->setTablePrefix('#');
+ }
+
+ return parent::wrapTable($table);
+ }
+
+ /**
+ * Quote the given string literal.
+ *
+ * @param string|array $value
+ * @return string
+ */
+ public function quoteString($value)
+ {
+ if (is_array($value)) {
+ return implode(', ', array_map([$this, __FUNCTION__], $value));
+ }
+
+ return "N'$value'";
+ }
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Schema/MySqlBuilder.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Schema/MySqlBuilder.php
index e8d4fe1c..85f3e92c 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Schema/MySqlBuilder.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Schema/MySqlBuilder.php
@@ -35,4 +35,80 @@ class MySqlBuilder extends Builder
return $this->connection->getPostProcessor()->processColumnListing($results);
}
+
+ /**
+ * Drop all tables from the database.
+ *
+ * @return void
+ */
+ public function dropAllTables()
+ {
+ $tables = [];
+
+ foreach ($this->getAllTables() as $row) {
+ $row = (array) $row;
+
+ $tables[] = reset($row);
+ }
+
+ if (empty($tables)) {
+ return;
+ }
+
+ $this->disableForeignKeyConstraints();
+
+ $this->connection->statement(
+ $this->grammar->compileDropAllTables($tables)
+ );
+
+ $this->enableForeignKeyConstraints();
+ }
+
+ /**
+ * Drop all views from the database.
+ *
+ * @return void
+ */
+ public function dropAllViews()
+ {
+ $views = [];
+
+ foreach ($this->getAllViews() as $row) {
+ $row = (array) $row;
+
+ $views[] = reset($row);
+ }
+
+ if (empty($views)) {
+ return;
+ }
+
+ $this->connection->statement(
+ $this->grammar->compileDropAllViews($views)
+ );
+ }
+
+ /**
+ * Get all of the table names for the database.
+ *
+ * @return array
+ */
+ protected function getAllTables()
+ {
+ return $this->connection->select(
+ $this->grammar->compileGetAllTables()
+ );
+ }
+
+ /**
+ * Get all of the view names for the database.
+ *
+ * @return array
+ */
+ protected function getAllViews()
+ {
+ return $this->connection->select(
+ $this->grammar->compileGetAllViews()
+ );
+ }
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Schema/PostgresBuilder.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Schema/PostgresBuilder.php
index fb73deae..af03af7e 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Schema/PostgresBuilder.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Schema/PostgresBuilder.php
@@ -12,11 +12,7 @@ class PostgresBuilder extends Builder
*/
public function hasTable($table)
{
- if (is_array($schema = $this->connection->getConfig('schema'))) {
- $schema = head($schema);
- }
-
- $schema = $schema ? $schema : 'public';
+ [$schema, $table] = $this->parseSchemaAndTable($table);
$table = $this->connection->getTablePrefix().$table;
@@ -24,4 +20,156 @@ class PostgresBuilder extends Builder
$this->grammar->compileTableExists(), [$schema, $table]
)) > 0;
}
+
+ /**
+ * Drop all tables from the database.
+ *
+ * @return void
+ */
+ public function dropAllTables()
+ {
+ $tables = [];
+
+ $excludedTables = ['spatial_ref_sys'];
+
+ foreach ($this->getAllTables() as $row) {
+ $row = (array) $row;
+
+ $table = reset($row);
+
+ if (! in_array($table, $excludedTables)) {
+ $tables[] = $table;
+ }
+ }
+
+ if (empty($tables)) {
+ return;
+ }
+
+ $this->connection->statement(
+ $this->grammar->compileDropAllTables($tables)
+ );
+ }
+
+ /**
+ * Drop all views from the database.
+ *
+ * @return void
+ */
+ public function dropAllViews()
+ {
+ $views = [];
+
+ foreach ($this->getAllViews() as $row) {
+ $row = (array) $row;
+
+ $views[] = reset($row);
+ }
+
+ if (empty($views)) {
+ return;
+ }
+
+ $this->connection->statement(
+ $this->grammar->compileDropAllViews($views)
+ );
+ }
+
+ /**
+ * Drop all types from the database.
+ */
+ public function dropAllTypes()
+ {
+ $types = [];
+
+ foreach ($this->getAllTypes() as $row) {
+ $row = (array) $row;
+
+ $types[] = reset($row);
+ }
+
+ if (empty($types)) {
+ return;
+ }
+
+ $this->connection->statement(
+ $this->grammar->compileDropAllTypes($types)
+ );
+ }
+
+ /**
+ * Get all of the table names for the database.
+ *
+ * @return array
+ */
+ protected function getAllTables()
+ {
+ return $this->connection->select(
+ $this->grammar->compileGetAllTables($this->connection->getConfig('schema'))
+ );
+ }
+
+ /**
+ * Get all of the view names for the database.
+ *
+ * @return array
+ */
+ protected function getAllViews()
+ {
+ return $this->connection->select(
+ $this->grammar->compileGetAllViews($this->connection->getConfig('schema'))
+ );
+ }
+
+ /**
+ * Get all of the type names for the database.
+ *
+ * @return array
+ */
+ protected function getAllTypes()
+ {
+ return $this->connection->select(
+ $this->grammar->compileGetAllTypes()
+ );
+ }
+
+ /**
+ * Get the column listing for a given table.
+ *
+ * @param string $table
+ * @return array
+ */
+ public function getColumnListing($table)
+ {
+ [$schema, $table] = $this->parseSchemaAndTable($table);
+
+ $table = $this->connection->getTablePrefix().$table;
+
+ $results = $this->connection->select(
+ $this->grammar->compileColumnListing(), [$schema, $table]
+ );
+
+ return $this->connection->getPostProcessor()->processColumnListing($results);
+ }
+
+ /**
+ * Parse the table name and extract the schema and table.
+ *
+ * @param string $table
+ * @return array
+ */
+ protected function parseSchemaAndTable($table)
+ {
+ $table = explode('.', $table);
+
+ if (is_array($schema = $this->connection->getConfig('schema'))) {
+ if (in_array($table[0], $schema)) {
+ return [array_shift($table), implode('.', $table)];
+ }
+
+ $schema = head($schema);
+ }
+
+ return [$schema ?: 'public', implode('.', $table)];
+ }
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Seeder.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Seeder.php
index 6f7c7356..c415c898 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/Seeder.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/Seeder.php
@@ -2,6 +2,7 @@
namespace Illuminate\Database;
+use Illuminate\Support\Arr;
use InvalidArgumentException;
use Illuminate\Console\Command;
use Illuminate\Container\Container;
@@ -25,27 +26,36 @@ abstract class Seeder
/**
* Seed the given connection from the given path.
*
- * @param string $class
- * @return void
+ * @param array|string $class
+ * @param bool $silent
+ * @return $this
*/
- public function call($class)
+ public function call($class, $silent = false)
{
- if (isset($this->command)) {
- $this->command->getOutput()->writeln("
Seeding: $class");
+ $classes = Arr::wrap($class);
+
+ foreach ($classes as $class) {
+ $seeder = $this->resolve($class);
+
+ if ($silent === false && isset($this->command)) {
+ $this->command->getOutput()->writeln('
Seeding: '.get_class($seeder));
+ }
+
+ $seeder->__invoke();
}
- $this->resolve($class)->__invoke();
+ return $this;
}
/**
* Silently seed the given connection from the given path.
*
- * @param string $class
+ * @param array|string $class
* @return void
*/
public function callSilent($class)
{
- $this->resolve($class)->__invoke();
+ $this->call($class, true);
}
/**
@@ -100,7 +110,7 @@ abstract class Seeder
/**
* Run the database seeds.
*
- * @return void
+ * @return mixed
*
* @throws \InvalidArgumentException
*/
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/SqlServerConnection.php b/pfosten/vendor/laravel/framework/src/Illuminate/Database/SqlServerConnection.php
index cdd172ae..db5a0bed 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/SqlServerConnection.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/SqlServerConnection.php
@@ -5,6 +5,7 @@ namespace Illuminate\Database;
use Closure;
use Exception;
use Throwable;
+use Illuminate\Database\Schema\SqlServerBuilder;
use Doctrine\DBAL\Driver\PDOSqlsrv\Driver as DoctrineDriver;
use Illuminate\Database\Query\Processors\SqlServerProcessor;
use Illuminate\Database\Query\Grammars\SqlServerGrammar as QueryGrammar;
@@ -24,7 +25,7 @@ class SqlServerConnection extends Connection
public function transaction(Closure $callback, $attempts = 1)
{
for ($a = 1; $a <= $attempts; $a++) {
- if ($this->getDriverName() == 'sqlsrv') {
+ if ($this->getDriverName() === 'sqlsrv') {
return parent::transaction($callback);
}
@@ -66,6 +67,20 @@ class SqlServerConnection extends Connection
return $this->withTablePrefix(new QueryGrammar);
}
+ /**
+ * Get a schema builder instance for the connection.
+ *
+ * @return \Illuminate\Database\Schema\SqlServerBuilder
+ */
+ public function getSchemaBuilder()
+ {
+ if (is_null($this->schemaGrammar)) {
+ $this->useDefaultSchemaGrammar();
+ }
+
+ return new SqlServerBuilder($this);
+ }
+
/**
* Get the default schema grammar instance.
*
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Database/composer.json b/pfosten/vendor/laravel/framework/src/Illuminate/Database/composer.json
index 46c1abe1..288dba5c 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Database/composer.json
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Database/composer.json
@@ -15,11 +15,11 @@
}
],
"require": {
- "php": ">=5.6.4",
- "illuminate/container": "5.4.*",
- "illuminate/contracts": "5.4.*",
- "illuminate/support": "5.4.*",
- "nesbot/carbon": "~1.20"
+ "php": "^7.1.3",
+ "ext-json": "*",
+ "illuminate/container": "5.8.*",
+ "illuminate/contracts": "5.8.*",
+ "illuminate/support": "5.8.*"
},
"autoload": {
"psr-4": {
@@ -28,16 +28,16 @@
},
"extra": {
"branch-alias": {
- "dev-master": "5.4-dev"
+ "dev-master": "5.8-dev"
}
},
"suggest": {
- "doctrine/dbal": "Required to rename columns and drop SQLite columns (~2.5).",
- "fzaninotto/faker": "Required to use the eloquent factory builder (~1.4).",
- "illuminate/console": "Required to use the database commands (5.4.*).",
- "illuminate/events": "Required to use the observers with Eloquent (5.4.*).",
- "illuminate/filesystem": "Required to use the migrations (5.4.*).",
- "illuminate/pagination": "Required to paginate the result set (5.4.*)."
+ "doctrine/dbal": "Required to rename columns and drop SQLite columns (^2.6).",
+ "fzaninotto/faker": "Required to use the eloquent factory builder (^1.4).",
+ "illuminate/console": "Required to use the database commands (5.8.*).",
+ "illuminate/events": "Required to use the observers with Eloquent (5.8.*).",
+ "illuminate/filesystem": "Required to use the migrations (5.8.*).",
+ "illuminate/pagination": "Required to paginate the result set (5.8.*)."
},
"config": {
"sort-packages": true
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Encryption/Encrypter.php b/pfosten/vendor/laravel/framework/src/Illuminate/Encryption/Encrypter.php
index 5f266a04..5aa16a08 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Encryption/Encrypter.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Encryption/Encrypter.php
@@ -59,6 +59,17 @@ class Encrypter implements EncrypterContract
($cipher === 'AES-256-CBC' && $length === 32);
}
+ /**
+ * Create a new encryption key for the given cipher.
+ *
+ * @param string $cipher
+ * @return string
+ */
+ public static function generateKey($cipher)
+ {
+ return random_bytes($cipher === 'AES-128-CBC' ? 16 : 32);
+ }
+
/**
* Encrypt the given value.
*
@@ -70,7 +81,7 @@ class Encrypter implements EncrypterContract
*/
public function encrypt($value, $serialize = true)
{
- $iv = random_bytes(16);
+ $iv = random_bytes(openssl_cipher_iv_length($this->cipher));
// First we will encrypt the value using OpenSSL. After this is encrypted we
// will proceed to calculating a MAC for the encrypted value so that this
@@ -91,7 +102,7 @@ class Encrypter implements EncrypterContract
$json = json_encode(compact('iv', 'value', 'mac'));
- if (! is_string($json)) {
+ if (json_last_error() !== JSON_ERROR_NONE) {
throw new EncryptException('Could not encrypt the data.');
}
@@ -103,6 +114,8 @@ class Encrypter implements EncrypterContract
*
* @param string $value
* @return string
+ *
+ * @throws \Illuminate\Contracts\Encryption\EncryptException
*/
public function encryptString($value)
{
@@ -112,9 +125,9 @@ class Encrypter implements EncrypterContract
/**
* Decrypt the given value.
*
- * @param mixed $payload
+ * @param string $payload
* @param bool $unserialize
- * @return string
+ * @return mixed
*
* @throws \Illuminate\Contracts\Encryption\DecryptException
*/
@@ -143,6 +156,8 @@ class Encrypter implements EncrypterContract
*
* @param string $payload
* @return string
+ *
+ * @throws \Illuminate\Contracts\Encryption\DecryptException
*/
public function decryptString($payload)
{
@@ -195,9 +210,8 @@ class Encrypter implements EncrypterContract
*/
protected function validPayload($payload)
{
- return is_array($payload) && isset(
- $payload['iv'], $payload['value'], $payload['mac']
- );
+ return is_array($payload) && isset($payload['iv'], $payload['value'], $payload['mac']) &&
+ strlen(base64_decode($payload['iv'], true)) === openssl_cipher_iv_length($this->cipher);
}
/**
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Encryption/EncryptionServiceProvider.php b/pfosten/vendor/laravel/framework/src/Illuminate/Encryption/EncryptionServiceProvider.php
index d27ed282..ad7b93d4 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Encryption/EncryptionServiceProvider.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Encryption/EncryptionServiceProvider.php
@@ -2,6 +2,7 @@
namespace Illuminate\Encryption;
+use RuntimeException;
use Illuminate\Support\Str;
use Illuminate\Support\ServiceProvider;
@@ -20,11 +21,30 @@ class EncryptionServiceProvider extends ServiceProvider
// If the key starts with "base64:", we will need to decode the key before handing
// it off to the encrypter. Keys may be base-64 encoded for presentation and we
// want to make sure to convert them back to the raw bytes before encrypting.
- if (Str::startsWith($key = $config['key'], 'base64:')) {
+ if (Str::startsWith($key = $this->key($config), 'base64:')) {
$key = base64_decode(substr($key, 7));
}
return new Encrypter($key, $config['cipher']);
});
}
+
+ /**
+ * Extract the encryption key from the given configuration.
+ *
+ * @param array $config
+ * @return string
+ *
+ * @throws \RuntimeException
+ */
+ protected function key(array $config)
+ {
+ return tap($config['key'], function ($key) {
+ if (empty($key)) {
+ throw new RuntimeException(
+ 'No application encryption key has been specified.'
+ );
+ }
+ });
+ }
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Encryption/composer.json b/pfosten/vendor/laravel/framework/src/Illuminate/Encryption/composer.json
index 05d24fbf..1421c269 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Encryption/composer.json
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Encryption/composer.json
@@ -14,12 +14,12 @@
}
],
"require": {
- "php": ">=5.6.4",
+ "php": "^7.1.3",
+ "ext-json": "*",
"ext-mbstring": "*",
"ext-openssl": "*",
- "illuminate/contracts": "5.4.*",
- "illuminate/support": "5.4.*",
- "paragonie/random_compat": "~1.4|~2.0"
+ "illuminate/contracts": "5.8.*",
+ "illuminate/support": "5.8.*"
},
"autoload": {
"psr-4": {
@@ -28,7 +28,7 @@
},
"extra": {
"branch-alias": {
- "dev-master": "5.4-dev"
+ "dev-master": "5.8-dev"
}
},
"config": {
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Events/CallQueuedHandler.php b/pfosten/vendor/laravel/framework/src/Illuminate/Events/CallQueuedHandler.php
deleted file mode 100644
index 4a21b64a..00000000
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Events/CallQueuedHandler.php
+++ /dev/null
@@ -1,86 +0,0 @@
-container = $container;
- }
-
- /**
- * Handle the queued job.
- *
- * @param \Illuminate\Contracts\Queue\Job $job
- * @param array $data
- * @return void
- */
- public function call(Job $job, array $data)
- {
- $handler = $this->setJobInstanceIfNecessary(
- $job, $this->container->make($data['class'])
- );
-
- call_user_func_array(
- [$handler, $data['method']], unserialize($data['data'])
- );
-
- if (! $job->isDeletedOrReleased()) {
- $job->delete();
- }
- }
-
- /**
- * Set the job instance of the given class if necessary.
- *
- * @param \Illuminate\Contracts\Queue\Job $job
- * @param mixed $instance
- * @return mixed
- */
- protected function setJobInstanceIfNecessary(Job $job, $instance)
- {
- if (in_array(InteractsWithQueue::class, class_uses_recursive(get_class($instance)))) {
- $instance->setJob($job);
- }
-
- return $instance;
- }
-
- /**
- * Call the failed method on the job instance.
- *
- * The event instance and the exception will be passed.
- *
- * @param array $data
- * @param \Exception $e
- * @return void
- */
- public function failed(array $data, $e)
- {
- $handler = $this->container->make($data['class']);
-
- $parameters = array_merge(unserialize($data['data']), [$e]);
-
- if (method_exists($handler, 'failed')) {
- call_user_func_array([$handler, 'failed'], $parameters);
- }
- }
-}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Events/CallQueuedListener.php b/pfosten/vendor/laravel/framework/src/Illuminate/Events/CallQueuedListener.php
index 381d5043..be0fee3a 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Events/CallQueuedListener.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Events/CallQueuedListener.php
@@ -39,6 +39,13 @@ class CallQueuedListener implements ShouldQueue
*/
public $tries;
+ /**
+ * The timestamp indicating when the job should timeout.
+ *
+ * @var int
+ */
+ public $timeoutAt;
+
/**
* The number of seconds the job can run before timing out.
*
@@ -89,7 +96,7 @@ class CallQueuedListener implements ShouldQueue
*/
protected function setJobInstanceIfNecessary(Job $job, $instance)
{
- if (in_array(InteractsWithQueue::class, class_uses_recursive(get_class($instance)))) {
+ if (in_array(InteractsWithQueue::class, class_uses_recursive($instance))) {
$instance->setJob($job);
}
@@ -138,4 +145,16 @@ class CallQueuedListener implements ShouldQueue
{
return $this->class;
}
+
+ /**
+ * Prepare the instance for cloning.
+ *
+ * @return void
+ */
+ public function __clone()
+ {
+ $this->data = array_map(function ($data) {
+ return is_object($data) ? clone $data : $data;
+ }, $this->data);
+ }
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php b/pfosten/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php
index 841f3326..95826c0d 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php
@@ -4,6 +4,7 @@ namespace Illuminate\Events;
use Exception;
use ReflectionClass;
+use Illuminate\Support\Arr;
use Illuminate\Support\Str;
use Illuminate\Container\Container;
use Illuminate\Contracts\Queue\ShouldQueue;
@@ -35,6 +36,13 @@ class Dispatcher implements DispatcherContract
*/
protected $wildcards = [];
+ /**
+ * The cached wildcard listeners.
+ *
+ * @var array
+ */
+ protected $wildcardsCache = [];
+
/**
* The queue resolver instance.
*
@@ -81,6 +89,8 @@ class Dispatcher implements DispatcherContract
protected function setupWildcardListen($event, $listener)
{
$this->wildcards[$event][] = $this->makeListener($listener, true);
+
+ $this->wildcardsCache = [];
}
/**
@@ -159,19 +169,6 @@ class Dispatcher implements DispatcherContract
return $this->dispatch($event, $payload, true);
}
- /**
- * 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 = [], $halt = false)
- {
- return $this->dispatch($event, $payload, $halt);
- }
-
/**
* Fire an event and call the listeners.
*
@@ -185,7 +182,7 @@ class Dispatcher implements DispatcherContract
// When the given "event" is actually an object we will assume it is an event
// object and use the class as the event name and this event itself as the
// payload to the handler, which makes object based events quite simple.
- list($event, $payload) = $this->parseEventAndPayload(
+ [$event, $payload] = $this->parseEventAndPayload(
$event, $payload
);
@@ -228,10 +225,10 @@ class Dispatcher implements DispatcherContract
protected function parseEventAndPayload($event, $payload)
{
if (is_object($event)) {
- list($payload, $event) = [[$event], get_class($event)];
+ [$payload, $event] = [[$event], get_class($event)];
}
- return [$event, array_wrap($payload)];
+ return [$event, Arr::wrap($payload)];
}
/**
@@ -278,10 +275,11 @@ class Dispatcher implements DispatcherContract
*/
public function getListeners($eventName)
{
- $listeners = isset($this->listeners[$eventName]) ? $this->listeners[$eventName] : [];
+ $listeners = $this->listeners[$eventName] ?? [];
$listeners = array_merge(
- $listeners, $this->getWildcardListeners($eventName)
+ $listeners,
+ $this->wildcardsCache[$eventName] ?? $this->getWildcardListeners($eventName)
);
return class_exists($eventName, false)
@@ -305,7 +303,7 @@ class Dispatcher implements DispatcherContract
}
}
- return $wildcards;
+ return $this->wildcardsCache[$eventName] = $wildcards;
}
/**
@@ -331,7 +329,7 @@ class Dispatcher implements DispatcherContract
/**
* Register an event listener with the dispatcher.
*
- * @param string|\Closure $listener
+ * @param \Closure|string $listener
* @param bool $wildcard
* @return \Closure
*/
@@ -344,9 +342,9 @@ class Dispatcher implements DispatcherContract
return function ($event, $payload) use ($listener, $wildcard) {
if ($wildcard) {
return $listener($event, $payload);
- } else {
- return $listener(...array_values($payload));
}
+
+ return $listener(...array_values($payload));
};
}
@@ -362,11 +360,11 @@ class Dispatcher implements DispatcherContract
return function ($event, $payload) use ($listener, $wildcard) {
if ($wildcard) {
return call_user_func($this->createClassCallable($listener), $event, $payload);
- } else {
- return call_user_func_array(
- $this->createClassCallable($listener), $payload
- );
}
+
+ return call_user_func_array(
+ $this->createClassCallable($listener), $payload
+ );
};
}
@@ -378,13 +376,13 @@ class Dispatcher implements DispatcherContract
*/
protected function createClassCallable($listener)
{
- list($class, $method) = $this->parseClassCallable($listener);
+ [$class, $method] = $this->parseClassCallable($listener);
if ($this->handlerShouldBeQueued($class)) {
return $this->createQueuedHandlerCallable($class, $method);
- } else {
- return [$this->container->make($class), $method];
}
+
+ return [$this->container->make($class), $method];
}
/**
@@ -429,29 +427,26 @@ class Dispatcher implements DispatcherContract
return is_object($a) ? clone $a : $a;
}, func_get_args());
- if (method_exists($class, 'queue')) {
- $this->callQueueMethodOnHandler($class, $method, $arguments);
- } else {
+ if ($this->handlerWantsToBeQueued($class, $arguments)) {
$this->queueHandler($class, $method, $arguments);
}
};
}
/**
- * Call the queue method on the handler class.
+ * Determine if the event handler wants to be queued.
*
* @param string $class
- * @param string $method
* @param array $arguments
- * @return void
+ * @return bool
*/
- protected function callQueueMethodOnHandler($class, $method, $arguments)
+ protected function handlerWantsToBeQueued($class, $arguments)
{
- $handler = (new ReflectionClass($class))->newInstanceWithoutConstructor();
+ if (method_exists($class, 'shouldQueue')) {
+ return $this->container->make($class)->shouldQueue($arguments[0]);
+ }
- $handler->queue($this->resolveQueue(), 'Illuminate\Events\CallQueuedHandler@call', [
- 'class' => $class, 'method' => $method, 'data' => serialize($arguments),
- ]);
+ return true;
}
/**
@@ -464,13 +459,13 @@ class Dispatcher implements DispatcherContract
*/
protected function queueHandler($class, $method, $arguments)
{
- list($listener, $job) = $this->createListenerAndJob($class, $method, $arguments);
+ [$listener, $job] = $this->createListenerAndJob($class, $method, $arguments);
$connection = $this->resolveQueue()->connection(
- isset($listener->connection) ? $listener->connection : null
+ $listener->connection ?? null
);
- $queue = isset($listener->queue) ? $listener->queue : null;
+ $queue = $listener->queue ?? null;
isset($listener->delay)
? $connection->laterOn($queue, $listener->delay, $job)
@@ -489,23 +484,25 @@ class Dispatcher implements DispatcherContract
{
$listener = (new ReflectionClass($class))->newInstanceWithoutConstructor();
- return [$listener, $this->propogateListenerOptions(
+ return [$listener, $this->propagateListenerOptions(
$listener, new CallQueuedListener($class, $method, $arguments)
)];
}
/**
- * Propogate listener options to the job.
+ * Propagate listener options to the job.
*
* @param mixed $listener
* @param mixed $job
* @return mixed
*/
- protected function propogateListenerOptions($listener, $job)
+ protected function propagateListenerOptions($listener, $job)
{
return tap($job, function ($job) use ($listener) {
- $job->tries = isset($listener->tries) ? $listener->tries : null;
- $job->timeout = isset($listener->timeout) ? $listener->timeout : null;
+ $job->tries = $listener->tries ?? null;
+ $job->timeout = $listener->timeout ?? null;
+ $job->timeoutAt = method_exists($listener, 'retryUntil')
+ ? $listener->retryUntil() : null;
});
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Events/composer.json b/pfosten/vendor/laravel/framework/src/Illuminate/Events/composer.json
index a5ed9158..d75f2c1e 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Events/composer.json
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Events/composer.json
@@ -14,10 +14,10 @@
}
],
"require": {
- "php": ">=5.6.4",
- "illuminate/container": "5.4.*",
- "illuminate/contracts": "5.4.*",
- "illuminate/support": "5.4.*"
+ "php": "^7.1.3",
+ "illuminate/container": "5.8.*",
+ "illuminate/contracts": "5.8.*",
+ "illuminate/support": "5.8.*"
},
"autoload": {
"psr-4": {
@@ -26,7 +26,7 @@
},
"extra": {
"branch-alias": {
- "dev-master": "5.4-dev"
+ "dev-master": "5.8-dev"
}
},
"config": {
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php b/pfosten/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php
index 9589c0f0..6ed474e4 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php
@@ -115,13 +115,37 @@ class Filesystem
* @param string $path
* @param string $contents
* @param bool $lock
- * @return int
+ * @return int|bool
*/
public function put($path, $contents, $lock = false)
{
return file_put_contents($path, $contents, $lock ? LOCK_EX : 0);
}
+ /**
+ * Write the contents of a file, replacing it atomically if it already exists.
+ *
+ * @param string $path
+ * @param string $content
+ * @return void
+ */
+ public function replace($path, $content)
+ {
+ // If the path already exists and is a symlink, get the real path...
+ clearstatcache(true, $path);
+
+ $path = realpath($path) ?: $path;
+
+ $tempPath = tempnam(dirname($path), basename($path));
+
+ // Fix permissions of tempPath because `tempnam()` creates it with permissions set to 0600...
+ chmod($tempPath, 0777 - umask());
+
+ file_put_contents($tempPath, $content);
+
+ rename($tempPath, $path);
+ }
+
/**
* Prepend to a file.
*
@@ -154,7 +178,7 @@ class Filesystem
* Get or set UNIX mode of a file or directory.
*
* @param string $path
- * @param int $mode
+ * @param int|null $mode
* @return mixed
*/
public function chmod($path, $mode = null)
@@ -230,7 +254,7 @@ class Filesystem
$mode = $this->isDirectory($target) ? 'J' : 'H';
- exec("mklink /{$mode} \"{$link}\" \"{$target}\"");
+ exec("mklink /{$mode} ".escapeshellarg($link).' '.escapeshellarg($target));
}
/**
@@ -381,22 +405,15 @@ class Filesystem
* Get an array of all files in a directory.
*
* @param string $directory
- * @return array
+ * @param bool $hidden
+ * @return \Symfony\Component\Finder\SplFileInfo[]
*/
- public function files($directory)
+ public function files($directory, $hidden = false)
{
- $glob = glob($directory.DIRECTORY_SEPARATOR.'*');
-
- if ($glob === false) {
- return [];
- }
-
- // To get the appropriate files, we'll simply glob the directory and filter
- // out any "files" that are not truly files so we do not end up with any
- // directories in our list, but only true files within the directory.
- return array_filter($glob, function ($file) {
- return filetype($file) == 'file';
- });
+ return iterator_to_array(
+ Finder::create()->files()->ignoreDotFiles(! $hidden)->in($directory)->depth(0)->sortByName(),
+ false
+ );
}
/**
@@ -404,11 +421,14 @@ class Filesystem
*
* @param string $directory
* @param bool $hidden
- * @return array
+ * @return \Symfony\Component\Finder\SplFileInfo[]
*/
public function allFiles($directory, $hidden = false)
{
- return iterator_to_array(Finder::create()->files()->ignoreDotFiles(! $hidden)->in($directory), false);
+ return iterator_to_array(
+ Finder::create()->files()->ignoreDotFiles(! $hidden)->in($directory)->sortByName(),
+ false
+ );
}
/**
@@ -421,7 +441,7 @@ class Filesystem
{
$directories = [];
- foreach (Finder::create()->in($directory)->directories()->depth(0) as $dir) {
+ foreach (Finder::create()->in($directory)->directories()->depth(0)->sortByName() as $dir) {
$directories[] = $dir->getPathname();
}
@@ -456,10 +476,8 @@ class Filesystem
*/
public function moveDirectory($from, $to, $overwrite = false)
{
- if ($overwrite && $this->isDirectory($to)) {
- if (! $this->deleteDirectory($to)) {
- return false;
- }
+ if ($overwrite && $this->isDirectory($to) && ! $this->deleteDirectory($to)) {
+ return false;
}
return @rename($from, $to) === true;
@@ -470,7 +488,7 @@ class Filesystem
*
* @param string $directory
* @param string $destination
- * @param int $options
+ * @param int|null $options
* @return bool
*/
public function copyDirectory($directory, $destination, $options = null)
@@ -557,6 +575,27 @@ class Filesystem
return true;
}
+ /**
+ * Remove all of the directories within a given directory.
+ *
+ * @param string $directory
+ * @return bool
+ */
+ public function deleteDirectories($directory)
+ {
+ $allDirectories = $this->directories($directory);
+
+ if (! empty($allDirectories)) {
+ foreach ($allDirectories as $directoryName) {
+ $this->deleteDirectory($directoryName);
+ }
+
+ return true;
+ }
+
+ return false;
+ }
+
/**
* Empty the specified directory of all files and folders.
*
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Filesystem/FilesystemAdapter.php b/pfosten/vendor/laravel/framework/src/Illuminate/Filesystem/FilesystemAdapter.php
index 410b02e2..9198c757 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Filesystem/FilesystemAdapter.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Filesystem/FilesystemAdapter.php
@@ -4,18 +4,25 @@ namespace Illuminate\Filesystem;
use RuntimeException;
use Illuminate\Http\File;
+use Illuminate\Support\Arr;
use Illuminate\Support\Str;
use InvalidArgumentException;
+use Illuminate\Support\Carbon;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Collection;
use League\Flysystem\AdapterInterface;
use PHPUnit\Framework\Assert as PHPUnit;
+use League\Flysystem\FileExistsException;
use League\Flysystem\FilesystemInterface;
use League\Flysystem\AwsS3v3\AwsS3Adapter;
+use League\Flysystem\Cached\CachedAdapter;
use League\Flysystem\FileNotFoundException;
+use League\Flysystem\Rackspace\RackspaceAdapter;
use League\Flysystem\Adapter\Local as LocalAdapter;
+use Symfony\Component\HttpFoundation\StreamedResponse;
use Illuminate\Contracts\Filesystem\Cloud as CloudFilesystemContract;
use Illuminate\Contracts\Filesystem\Filesystem as FilesystemContract;
+use Illuminate\Contracts\Filesystem\FileExistsException as ContractFileExistsException;
use Illuminate\Contracts\Filesystem\FileNotFoundException as ContractFileNotFoundException;
/**
@@ -44,27 +51,39 @@ class FilesystemAdapter implements FilesystemContract, CloudFilesystemContract
/**
* Assert that the given file exists.
*
- * @param string $path
- * @return void
+ * @param string|array $path
+ * @return $this
*/
public function assertExists($path)
{
- PHPUnit::assertTrue(
- $this->exists($path), "Unable to find a file at path [{$path}]."
- );
+ $paths = Arr::wrap($path);
+
+ foreach ($paths as $path) {
+ PHPUnit::assertTrue(
+ $this->exists($path), "Unable to find a file at path [{$path}]."
+ );
+ }
+
+ return $this;
}
/**
* Assert that the given file does not exist.
*
- * @param string $path
- * @return void
+ * @param string|array $path
+ * @return $this
*/
public function assertMissing($path)
{
- PHPUnit::assertFalse(
- $this->exists($path), "Found unexpected file at path [{$path}]."
- );
+ $paths = Arr::wrap($path);
+
+ foreach ($paths as $path) {
+ PHPUnit::assertFalse(
+ $this->exists($path), "Found unexpected file at path [{$path}]."
+ );
+ }
+
+ return $this;
}
/**
@@ -106,19 +125,77 @@ class FilesystemAdapter implements FilesystemContract, CloudFilesystemContract
}
}
+ /**
+ * Create a streamed response for a given file.
+ *
+ * @param string $path
+ * @param string|null $name
+ * @param array|null $headers
+ * @param string|null $disposition
+ * @return \Symfony\Component\HttpFoundation\StreamedResponse
+ */
+ public function response($path, $name = null, array $headers = [], $disposition = 'inline')
+ {
+ $response = new StreamedResponse;
+
+ $filename = $name ?? basename($path);
+
+ $disposition = $response->headers->makeDisposition(
+ $disposition, $filename, $this->fallbackName($filename)
+ );
+
+ $response->headers->replace($headers + [
+ 'Content-Type' => $this->mimeType($path),
+ 'Content-Length' => $this->size($path),
+ 'Content-Disposition' => $disposition,
+ ]);
+
+ $response->setCallback(function () use ($path) {
+ $stream = $this->readStream($path);
+ fpassthru($stream);
+ fclose($stream);
+ });
+
+ return $response;
+ }
+
+ /**
+ * Create a streamed download response for a given file.
+ *
+ * @param string $path
+ * @param string|null $name
+ * @param array|null $headers
+ * @return \Symfony\Component\HttpFoundation\StreamedResponse
+ */
+ public function download($path, $name = null, array $headers = [])
+ {
+ return $this->response($path, $name, $headers, 'attachment');
+ }
+
+ /**
+ * Convert the string to ASCII characters that are equivalent to the given name.
+ *
+ * @param string $name
+ * @return string
+ */
+ protected function fallbackName($name)
+ {
+ return str_replace('%', '', Str::ascii($name));
+ }
+
/**
* Write the contents of a file.
*
* @param string $path
* @param string|resource $contents
- * @param array $options
+ * @param mixed $options
* @return bool
*/
public function put($path, $contents, $options = [])
{
- if (is_string($options)) {
- $options = ['visibility' => $options];
- }
+ $options = is_string($options)
+ ? ['visibility' => $options]
+ : (array) $options;
// If the given contents is actually a file or uploaded file instance than we will
// automatically store the file using a stream. This provides a convenient path
@@ -157,7 +234,7 @@ class FilesystemAdapter implements FilesystemContract, CloudFilesystemContract
*/
public function putFileAs($path, $file, $name, $options = [])
{
- $stream = fopen($file->getRealPath(), 'r+');
+ $stream = fopen($file->getRealPath(), 'r');
// Next, we will format the path of the file and store the file using a stream since
// they provide better performance than alternatives. Once we write the file this
@@ -193,7 +270,7 @@ class FilesystemAdapter implements FilesystemContract, CloudFilesystemContract
*
* @param string $path
* @param string $visibility
- * @return void
+ * @return bool
*/
public function setVisibility($path, $visibility)
{
@@ -206,7 +283,7 @@ class FilesystemAdapter implements FilesystemContract, CloudFilesystemContract
* @param string $path
* @param string $data
* @param string $separator
- * @return int
+ * @return bool
*/
public function prepend($path, $data, $separator = PHP_EOL)
{
@@ -223,7 +300,7 @@ class FilesystemAdapter implements FilesystemContract, CloudFilesystemContract
* @param string $path
* @param string $data
* @param string $separator
- * @return int
+ * @return bool
*/
public function append($path, $data, $separator = PHP_EOL)
{
@@ -321,15 +398,25 @@ class FilesystemAdapter implements FilesystemContract, CloudFilesystemContract
*
* @param string $path
* @return string
+ *
+ * @throws \RuntimeException
*/
public function url($path)
{
$adapter = $this->driver->getAdapter();
+ if ($adapter instanceof CachedAdapter) {
+ $adapter = $adapter->getAdapter();
+ }
+
if (method_exists($adapter, 'getUrl')) {
return $adapter->getUrl($path);
+ } elseif (method_exists($this->driver, 'getUrl')) {
+ return $this->driver->getUrl($path);
} elseif ($adapter instanceof AwsS3Adapter) {
return $this->getAwsUrl($adapter, $path);
+ } elseif ($adapter instanceof RackspaceAdapter) {
+ return $this->getRackspaceUrl($adapter, $path);
} elseif ($adapter instanceof LocalAdapter) {
return $this->getLocalUrl($path);
} else {
@@ -337,6 +424,30 @@ class FilesystemAdapter implements FilesystemContract, CloudFilesystemContract
}
}
+ /**
+ * {@inheritdoc}
+ */
+ public function readStream($path)
+ {
+ try {
+ return $this->driver->readStream($path) ?: null;
+ } catch (FileNotFoundException $e) {
+ throw new ContractFileNotFoundException($e->getMessage(), $e->getCode(), $e);
+ }
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function writeStream($path, $resource, array $options = [])
+ {
+ try {
+ return $this->driver->writeStream($path, $resource, $options);
+ } catch (FileExistsException $e) {
+ throw new ContractFileExistsException($e->getMessage(), $e->getCode(), $e);
+ }
+ }
+
/**
* Get the URL for the file at the given path.
*
@@ -346,11 +457,30 @@ class FilesystemAdapter implements FilesystemContract, CloudFilesystemContract
*/
protected function getAwsUrl($adapter, $path)
{
+ // If an explicit base URL has been set on the disk configuration then we will use
+ // it as the base URL instead of the default path. This allows the developer to
+ // have full control over the base path for this filesystem's generated URLs.
+ if (! is_null($url = $this->driver->getConfig()->get('url'))) {
+ return $this->concatPathToUrl($url, $adapter->getPathPrefix().$path);
+ }
+
return $adapter->getClient()->getObjectUrl(
$adapter->getBucket(), $adapter->getPathPrefix().$path
);
}
+ /**
+ * Get the URL for the file at the given path.
+ *
+ * @param \League\Flysystem\Rackspace\RackspaceAdapter $adapter
+ * @param string $path
+ * @return string
+ */
+ protected function getRackspaceUrl($adapter, $path)
+ {
+ return (string) $adapter->getContainer()->getObject($path)->getPublicUrl();
+ }
+
/**
* Get the URL for the file at the given path.
*
@@ -365,7 +495,7 @@ class FilesystemAdapter implements FilesystemContract, CloudFilesystemContract
// it as the base URL instead of the default path. This allows the developer to
// have full control over the base path for this filesystem's generated URLs.
if ($config->has('url')) {
- return rtrim($config->get('url'), '/').'/'.ltrim($path, '/');
+ return $this->concatPathToUrl($config->get('url'), $path);
}
$path = '/storage/'.$path;
@@ -375,9 +505,9 @@ class FilesystemAdapter implements FilesystemContract, CloudFilesystemContract
// are really supposed to use. We will remove the public from this path here.
if (Str::contains($path, '/storage/public/')) {
return Str::replaceFirst('/public/', '/', $path);
- } else {
- return $path;
}
+
+ return $path;
}
/**
@@ -387,17 +517,39 @@ class FilesystemAdapter implements FilesystemContract, CloudFilesystemContract
* @param \DateTimeInterface $expiration
* @param array $options
* @return string
+ *
+ * @throws \RuntimeException
*/
public function temporaryUrl($path, $expiration, array $options = [])
{
$adapter = $this->driver->getAdapter();
- if (method_exists($adapter, 'getTemporaryUrl')) {
- return $adapter->getTemporaryUrl($path, $expiration, $options);
- } elseif (! $adapter instanceof AwsS3Adapter) {
- throw new RuntimeException('This driver does not support creating temporary URLs.');
+ if ($adapter instanceof CachedAdapter) {
+ $adapter = $adapter->getAdapter();
}
+ if (method_exists($adapter, 'getTemporaryUrl')) {
+ return $adapter->getTemporaryUrl($path, $expiration, $options);
+ } elseif ($adapter instanceof AwsS3Adapter) {
+ return $this->getAwsTemporaryUrl($adapter, $path, $expiration, $options);
+ } elseif ($adapter instanceof RackspaceAdapter) {
+ return $this->getRackspaceTemporaryUrl($adapter, $path, $expiration, $options);
+ } else {
+ throw new RuntimeException('This driver does not support creating temporary URLs.');
+ }
+ }
+
+ /**
+ * Get a temporary URL for the file at the given path.
+ *
+ * @param \League\Flysystem\AwsS3v3\AwsS3Adapter $adapter
+ * @param string $path
+ * @param \DateTimeInterface $expiration
+ * @param array $options
+ * @return string
+ */
+ public function getAwsTemporaryUrl($adapter, $path, $expiration, $options)
+ {
$client = $adapter->getClient();
$command = $client->getCommand('GetObject', array_merge([
@@ -410,6 +562,36 @@ class FilesystemAdapter implements FilesystemContract, CloudFilesystemContract
)->getUri();
}
+ /**
+ * Get a temporary URL for the file at the given path.
+ *
+ * @param \League\Flysystem\Rackspace\RackspaceAdapter $adapter
+ * @param string $path
+ * @param \DateTimeInterface $expiration
+ * @param array $options
+ * @return string
+ */
+ public function getRackspaceTemporaryUrl($adapter, $path, $expiration, $options)
+ {
+ return $adapter->getContainer()->getObject($path)->getTemporaryUrl(
+ Carbon::now()->diffInSeconds($expiration),
+ $options['method'] ?? 'GET',
+ $options['forcePublicUrl'] ?? true
+ );
+ }
+
+ /**
+ * Concatenate a path to a URL.
+ *
+ * @param string $url
+ * @param string $path
+ * @return string
+ */
+ protected function concatPathToUrl($url, $path)
+ {
+ return rtrim($url, '/').'/'.ltrim($path, '/');
+ }
+
/**
* Get an array of all files in a directory.
*
@@ -482,6 +664,20 @@ class FilesystemAdapter implements FilesystemContract, CloudFilesystemContract
return $this->driver->deleteDir($directory);
}
+ /**
+ * Flush the Flysystem cache.
+ *
+ * @return void
+ */
+ public function flushCache()
+ {
+ $adapter = $this->driver->getAdapter();
+
+ if ($adapter instanceof CachedAdapter) {
+ $adapter->getCache()->flush();
+ }
+ }
+
/**
* Get the Flysystem driver.
*
@@ -529,7 +725,7 @@ class FilesystemAdapter implements FilesystemContract, CloudFilesystemContract
return AdapterInterface::VISIBILITY_PRIVATE;
}
- throw new InvalidArgumentException('Unknown visibility: '.$visibility);
+ throw new InvalidArgumentException("Unknown visibility: {$visibility}");
}
/**
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Filesystem/FilesystemManager.php b/pfosten/vendor/laravel/framework/src/Illuminate/Filesystem/FilesystemManager.php
index 9979bfdf..51647019 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Filesystem/FilesystemManager.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Filesystem/FilesystemManager.php
@@ -8,12 +8,15 @@ use OpenCloud\Rackspace;
use Illuminate\Support\Arr;
use InvalidArgumentException;
use League\Flysystem\AdapterInterface;
+use League\Flysystem\Sftp\SftpAdapter;
use League\Flysystem\FilesystemInterface;
+use League\Flysystem\Cached\CachedAdapter;
use League\Flysystem\Filesystem as Flysystem;
use League\Flysystem\Adapter\Ftp as FtpAdapter;
use League\Flysystem\Rackspace\RackspaceAdapter;
use League\Flysystem\Adapter\Local as LocalAdapter;
use League\Flysystem\AwsS3v3\AwsS3Adapter as S3Adapter;
+use League\Flysystem\Cached\Storage\Memory as MemoryStore;
use Illuminate\Contracts\Filesystem\Factory as FactoryContract;
/**
@@ -56,7 +59,7 @@ class FilesystemManager implements FactoryContract
/**
* Get a filesystem instance.
*
- * @param string $name
+ * @param string|null $name
* @return \Illuminate\Contracts\Filesystem\Filesystem
*/
public function drive($name = null)
@@ -67,7 +70,7 @@ class FilesystemManager implements FactoryContract
/**
* Get a filesystem instance.
*
- * @param string $name
+ * @param string|null $name
* @return \Illuminate\Contracts\Filesystem\Filesystem
*/
public function disk($name = null)
@@ -97,7 +100,7 @@ class FilesystemManager implements FactoryContract
*/
protected function get($name)
{
- return isset($this->disks[$name]) ? $this->disks[$name] : $this->resolve($name);
+ return $this->disks[$name] ?? $this->resolve($name);
}
/**
@@ -150,14 +153,14 @@ class FilesystemManager implements FactoryContract
*/
public function createLocalDriver(array $config)
{
- $permissions = isset($config['permissions']) ? $config['permissions'] : [];
+ $permissions = $config['permissions'] ?? [];
- $links = Arr::get($config, 'links') === 'skip'
+ $links = ($config['links'] ?? null) === 'skip'
? LocalAdapter::SKIP_LINKS
: LocalAdapter::DISALLOW_LINKS;
return $this->adapt($this->createFlysystem(new LocalAdapter(
- $config['root'], LOCK_EX, $links, $permissions
+ $config['root'], $config['lock'] ?? LOCK_EX, $links, $permissions
), $config));
}
@@ -169,12 +172,21 @@ class FilesystemManager implements FactoryContract
*/
public function createFtpDriver(array $config)
{
- $ftpConfig = Arr::only($config, [
- 'host', 'username', 'password', 'port', 'root', 'passive', 'ssl', 'timeout',
- ]);
-
return $this->adapt($this->createFlysystem(
- new FtpAdapter($ftpConfig), $config
+ new FtpAdapter($config), $config
+ ));
+ }
+
+ /**
+ * Create an instance of the sftp driver.
+ *
+ * @param array $config
+ * @return \Illuminate\Contracts\Filesystem\Filesystem
+ */
+ public function createSftpDriver(array $config)
+ {
+ return $this->adapt($this->createFlysystem(
+ new SftpAdapter($config), $config
));
}
@@ -188,9 +200,9 @@ class FilesystemManager implements FactoryContract
{
$s3Config = $this->formatS3Config($config);
- $root = isset($s3Config['root']) ? $s3Config['root'] : null;
+ $root = $s3Config['root'] ?? null;
- $options = isset($config['options']) ? $config['options'] : [];
+ $options = $config['options'] ?? [];
return $this->adapt($this->createFlysystem(
new S3Adapter(new S3Client($s3Config), $s3Config['bucket'], $root, $options), $config
@@ -207,8 +219,8 @@ class FilesystemManager implements FactoryContract
{
$config += ['version' => 'latest'];
- if ($config['key'] && $config['secret']) {
- $config['credentials'] = Arr::only($config, ['key', 'secret']);
+ if (! empty($config['key']) && ! empty($config['secret'])) {
+ $config['credentials'] = Arr::only($config, ['key', 'secret', 'token']);
}
return $config;
@@ -224,9 +236,9 @@ class FilesystemManager implements FactoryContract
{
$client = new Rackspace($config['endpoint'], [
'username' => $config['username'], 'apiKey' => $config['key'],
- ]);
+ ], $config['options'] ?? []);
- $root = isset($config['root']) ? $config['root'] : null;
+ $root = $config['root'] ?? null;
return $this->adapt($this->createFlysystem(
new RackspaceAdapter($this->getRackspaceContainer($client, $config), $root), $config
@@ -242,7 +254,7 @@ class FilesystemManager implements FactoryContract
*/
protected function getRackspaceContainer(Rackspace $client, array $config)
{
- $urlType = Arr::get($config, 'url_type');
+ $urlType = $config['url_type'] ?? null;
$store = $client->objectStoreService('cloudFiles', $config['region'], $urlType);
@@ -254,15 +266,42 @@ class FilesystemManager implements FactoryContract
*
* @param \League\Flysystem\AdapterInterface $adapter
* @param array $config
- * @return \League\Flysystem\FlysystemInterface
+ * @return \League\Flysystem\FilesystemInterface
*/
protected function createFlysystem(AdapterInterface $adapter, array $config)
{
+ $cache = Arr::pull($config, 'cache');
+
$config = Arr::only($config, ['visibility', 'disable_asserts', 'url']);
+ if ($cache) {
+ $adapter = new CachedAdapter($adapter, $this->createCacheStore($cache));
+ }
+
return new Flysystem($adapter, count($config) > 0 ? $config : null);
}
+ /**
+ * Create a cache store instance.
+ *
+ * @param mixed $config
+ * @return \League\Flysystem\Cached\CacheInterface
+ *
+ * @throws \InvalidArgumentException
+ */
+ protected function createCacheStore($config)
+ {
+ if ($config === true) {
+ return new MemoryStore;
+ }
+
+ return new Cache(
+ $this->app['cache']->store($config['store']),
+ $config['prefix'] ?? 'flysystem',
+ $config['expire'] ?? null
+ );
+ }
+
/**
* Adapt the filesystem implementation.
*
@@ -279,11 +318,13 @@ class FilesystemManager implements FactoryContract
*
* @param string $name
* @param mixed $disk
- * @return void
+ * @return $this
*/
public function set($name, $disk)
{
$this->disks[$name] = $disk;
+
+ return $this;
}
/**
@@ -317,6 +358,21 @@ class FilesystemManager implements FactoryContract
return $this->app['config']['filesystems.cloud'];
}
+ /**
+ * Unset the given disk instances.
+ *
+ * @param array|string $disk
+ * @return $this
+ */
+ public function forgetDisk($disk)
+ {
+ foreach ((array) $disk as $diskName) {
+ unset($this->disks[$diskName]);
+ }
+
+ return $this;
+ }
+
/**
* Register a custom driver creator Closure.
*
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Filesystem/composer.json b/pfosten/vendor/laravel/framework/src/Illuminate/Filesystem/composer.json
index 2dc0f7a3..2bafd57d 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Filesystem/composer.json
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Filesystem/composer.json
@@ -14,10 +14,10 @@
}
],
"require": {
- "php": ">=5.6.4",
- "illuminate/contracts": "5.4.*",
- "illuminate/support": "5.4.*",
- "symfony/finder": "~3.2"
+ "php": "^7.1.3",
+ "illuminate/contracts": "5.8.*",
+ "illuminate/support": "5.8.*",
+ "symfony/finder": "^4.2"
},
"autoload": {
"psr-4": {
@@ -26,13 +26,15 @@
},
"extra": {
"branch-alias": {
- "dev-master": "5.4-dev"
+ "dev-master": "5.8-dev"
}
},
"suggest": {
- "league/flysystem": "Required to use the Flysystem local and FTP drivers (~1.0).",
- "league/flysystem-aws-s3-v3": "Required to use the Flysystem S3 driver (~1.0).",
- "league/flysystem-rackspace": "Required to use the Flysystem Rackspace driver (~1.0)."
+ "league/flysystem": "Required to use the Flysystem local and FTP drivers (^1.0).",
+ "league/flysystem-aws-s3-v3": "Required to use the Flysystem S3 driver (^1.0).",
+ "league/flysystem-cached-adapter": "Required to use the Flysystem cache (^1.0).",
+ "league/flysystem-rackspace": "Required to use the Flysystem Rackspace driver (^1.0).",
+ "league/flysystem-sftp": "Required to use the Flysystem SFTP driver (^1.0)."
},
"config": {
"sort-packages": true
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/AliasLoader.php b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/AliasLoader.php
index 4d9e6848..63f38913 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/AliasLoader.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/AliasLoader.php
@@ -36,6 +36,7 @@ class AliasLoader
* Create a new AliasLoader instance.
*
* @param array $aliases
+ * @return void
*/
private function __construct($aliases)
{
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Application.php b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Application.php
index bf3f53ed..f7503612 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Application.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Application.php
@@ -7,6 +7,7 @@ use RuntimeException;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
use Illuminate\Http\Request;
+use Illuminate\Support\Collection;
use Illuminate\Container\Container;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Log\LogServiceProvider;
@@ -28,7 +29,7 @@ class Application extends Container implements ApplicationContract, HttpKernelIn
*
* @var string
*/
- const VERSION = '5.4.36';
+ const VERSION = '5.8.36';
/**
* The base path for the Laravel installation.
@@ -54,28 +55,28 @@ class Application extends Container implements ApplicationContract, HttpKernelIn
/**
* The array of booting callbacks.
*
- * @var array
+ * @var callable[]
*/
protected $bootingCallbacks = [];
/**
* The array of booted callbacks.
*
- * @var array
+ * @var callable[]
*/
protected $bootedCallbacks = [];
/**
* The array of terminating callbacks.
*
- * @var array
+ * @var callable[]
*/
protected $terminatingCallbacks = [];
/**
* All of the registered service providers.
*
- * @var array
+ * @var \Illuminate\Support\ServiceProvider[]
*/
protected $serviceProviders = [];
@@ -94,11 +95,11 @@ class Application extends Container implements ApplicationContract, HttpKernelIn
protected $deferredServices = [];
/**
- * A custom callback used to configure Monolog.
+ * The custom application path defined by the developer.
*
- * @var callable|null
+ * @var string
*/
- protected $monologConfigurator;
+ protected $appPath;
/**
* The custom database path defined by the developer.
@@ -148,9 +149,7 @@ class Application extends Container implements ApplicationContract, HttpKernelIn
}
$this->registerBaseBindings();
-
$this->registerBaseServiceProviders();
-
$this->registerCoreContainerAliases();
}
@@ -176,6 +175,11 @@ class Application extends Container implements ApplicationContract, HttpKernelIn
$this->instance('app', $this);
$this->instance(Container::class, $this);
+ $this->singleton(Mix::class);
+
+ $this->instance(PackageManifest::class, new PackageManifest(
+ new Filesystem, $this->basePath(), $this->getCachedPackagesPath()
+ ));
}
/**
@@ -186,16 +190,14 @@ class Application extends Container implements ApplicationContract, HttpKernelIn
protected function registerBaseServiceProviders()
{
$this->register(new EventServiceProvider($this));
-
$this->register(new LogServiceProvider($this));
-
$this->register(new RoutingServiceProvider($this));
}
/**
* Run the given array of bootstrap classes.
*
- * @param array $bootstrappers
+ * @param string[] $bootstrappers
* @return void
*/
public function bootstrapWith(array $bootstrappers)
@@ -203,11 +205,11 @@ class Application extends Container implements ApplicationContract, HttpKernelIn
$this->hasBeenBootstrapped = true;
foreach ($bootstrappers as $bootstrapper) {
- $this['events']->fire('bootstrapping: '.$bootstrapper, [$this]);
+ $this['events']->dispatch('bootstrapping: '.$bootstrapper, [$this]);
$this->make($bootstrapper)->bootstrap($this);
- $this['events']->fire('bootstrapped: '.$bootstrapper, [$this]);
+ $this['events']->dispatch('bootstrapped: '.$bootstrapper, [$this]);
}
}
@@ -228,7 +230,7 @@ class Application extends Container implements ApplicationContract, HttpKernelIn
* Register a callback to run before a bootstrapper.
*
* @param string $bootstrapper
- * @param Closure $callback
+ * @param \Closure $callback
* @return void
*/
public function beforeBootstrapping($bootstrapper, Closure $callback)
@@ -240,7 +242,7 @@ class Application extends Container implements ApplicationContract, HttpKernelIn
* Register a callback to run after a bootstrapper.
*
* @param string $bootstrapper
- * @param Closure $callback
+ * @param \Closure $callback
* @return void
*/
public function afterBootstrapping($bootstrapper, Closure $callback)
@@ -294,18 +296,35 @@ class Application extends Container implements ApplicationContract, HttpKernelIn
/**
* Get the path to the application "app" directory.
*
- * @param string $path Optionally, a path to append to the app path
+ * @param string $path
* @return string
*/
public function path($path = '')
{
- return $this->basePath.DIRECTORY_SEPARATOR.'app'.($path ? DIRECTORY_SEPARATOR.$path : $path);
+ $appPath = $this->appPath ?: $this->basePath.DIRECTORY_SEPARATOR.'app';
+
+ return $appPath.($path ? DIRECTORY_SEPARATOR.$path : $path);
+ }
+
+ /**
+ * Set the application directory.
+ *
+ * @param string $path
+ * @return $this
+ */
+ public function useAppPath($path)
+ {
+ $this->appPath = $path;
+
+ $this->instance('path', $path);
+
+ return $this;
}
/**
* Get the base path of the Laravel installation.
*
- * @param string $path Optionally, a path to append to the base path
+ * @param string $path Optionally, a path to append to the base path
* @return string
*/
public function basePath($path = '')
@@ -316,7 +335,7 @@ class Application extends Container implements ApplicationContract, HttpKernelIn
/**
* Get the path to the bootstrap directory.
*
- * @param string $path Optionally, a path to append to the bootstrap path
+ * @param string $path Optionally, a path to append to the bootstrap path
* @return string
*/
public function bootstrapPath($path = '')
@@ -327,7 +346,7 @@ class Application extends Container implements ApplicationContract, HttpKernelIn
/**
* Get the path to the application configuration files.
*
- * @param string $path Optionally, a path to append to the config path
+ * @param string $path Optionally, a path to append to the config path
* @return string
*/
public function configPath($path = '')
@@ -338,7 +357,7 @@ class Application extends Container implements ApplicationContract, HttpKernelIn
/**
* Get the path to the database directory.
*
- * @param string $path Optionally, a path to append to the database path
+ * @param string $path Optionally, a path to append to the database path
* @return string
*/
public function databasePath($path = '')
@@ -470,26 +489,21 @@ class Application extends Container implements ApplicationContract, HttpKernelIn
*/
public function environmentFilePath()
{
- return $this->environmentPath().'/'.$this->environmentFile();
+ return $this->environmentPath().DIRECTORY_SEPARATOR.$this->environmentFile();
}
/**
* Get or check the current application environment.
*
+ * @param string|array $environments
* @return string|bool
*/
- public function environment()
+ public function environment(...$environments)
{
- if (func_num_args() > 0) {
- $patterns = is_array(func_get_arg(0)) ? func_get_arg(0) : func_get_args();
+ if (count($environments) > 0) {
+ $patterns = is_array($environments[0]) ? $environments[0] : $environments;
- foreach ($patterns as $pattern) {
- if (Str::is($pattern, $this['env'])) {
- return true;
- }
- }
-
- return false;
+ return Str::is($patterns, $this['env']);
}
return $this['env'];
@@ -502,7 +516,17 @@ class Application extends Container implements ApplicationContract, HttpKernelIn
*/
public function isLocal()
{
- return $this['env'] == 'local';
+ return $this['env'] === 'local';
+ }
+
+ /**
+ * Determine if application is in production environment.
+ *
+ * @return bool
+ */
+ public function isProduction()
+ {
+ return $this['env'] === 'production';
}
/**
@@ -513,29 +537,33 @@ class Application extends Container implements ApplicationContract, HttpKernelIn
*/
public function detectEnvironment(Closure $callback)
{
- $args = isset($_SERVER['argv']) ? $_SERVER['argv'] : null;
+ $args = $_SERVER['argv'] ?? null;
- return $this['env'] = (new EnvironmentDetector())->detect($callback, $args);
+ return $this['env'] = (new EnvironmentDetector)->detect($callback, $args);
}
/**
- * Determine if we are running in the console.
+ * Determine if the application is running in the console.
*
* @return bool
*/
public function runningInConsole()
{
- return php_sapi_name() == 'cli' || php_sapi_name() == 'phpdbg';
+ if (isset($_ENV['APP_RUNNING_IN_CONSOLE'])) {
+ return $_ENV['APP_RUNNING_IN_CONSOLE'] === 'true';
+ }
+
+ return php_sapi_name() === 'cli' || php_sapi_name() === 'phpdbg';
}
/**
- * Determine if we are running unit tests.
+ * Determine if the application is running unit tests.
*
* @return bool
*/
public function runningUnitTests()
{
- return $this['env'] == 'testing';
+ return $this['env'] === 'testing';
}
/**
@@ -545,19 +573,25 @@ class Application extends Container implements ApplicationContract, HttpKernelIn
*/
public function registerConfiguredProviders()
{
+ $providers = Collection::make($this->config['app.providers'])
+ ->partition(function ($provider) {
+ return Str::startsWith($provider, 'Illuminate\\');
+ });
+
+ $providers->splice(1, 0, [$this->make(PackageManifest::class)->providers()]);
+
(new ProviderRepository($this, new Filesystem, $this->getCachedServicesPath()))
- ->load($this->config['app.providers']);
+ ->load($providers->collapse()->toArray());
}
/**
* 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 = [], $force = false)
+ public function register($provider, $force = false)
{
if (($registered = $this->getProvider($provider)) && ! $force) {
return $registered;
@@ -570,8 +604,21 @@ class Application extends Container implements ApplicationContract, HttpKernelIn
$provider = $this->resolveProvider($provider);
}
- if (method_exists($provider, 'register')) {
- $provider->register();
+ $provider->register();
+
+ // If there are bindings / singletons set as properties on the provider we
+ // will spin through them and register them with the application, which
+ // serves as a convenience layer while registering a lot of bindings.
+ if (property_exists($provider, 'bindings')) {
+ foreach ($provider->bindings as $key => $value) {
+ $this->bind($key, $value);
+ }
+ }
+
+ if (property_exists($provider, 'singletons')) {
+ foreach ($provider->singletons as $key => $value) {
+ $this->singleton($key, $value);
+ }
}
$this->markAsRegistered($provider);
@@ -579,7 +626,7 @@ class Application extends Container implements ApplicationContract, HttpKernelIn
// If the application has already booted, we will call this boot method on
// the provider class so it has an opportunity to do its boot logic and
// will be ready for any usage by this developer's application logic.
- if ($this->booted) {
+ if ($this->isBooted()) {
$this->bootProvider($provider);
}
@@ -593,10 +640,21 @@ class Application extends Container implements ApplicationContract, HttpKernelIn
* @return \Illuminate\Support\ServiceProvider|null
*/
public function getProvider($provider)
+ {
+ return array_values($this->getProviders($provider))[0] ?? null;
+ }
+
+ /**
+ * Get the registered service provider instances if any exist.
+ *
+ * @param \Illuminate\Support\ServiceProvider|string $provider
+ * @return array
+ */
+ public function getProviders($provider)
{
$name = is_string($provider) ? $provider : get_class($provider);
- return Arr::first($this->serviceProviders, function ($value) use ($name) {
+ return Arr::where($this->serviceProviders, function ($value) use ($name) {
return $value instanceof $name;
});
}
@@ -650,7 +708,7 @@ class Application extends Container implements ApplicationContract, HttpKernelIn
*/
public function loadDeferredProvider($service)
{
- if (! isset($this->deferredServices[$service])) {
+ if (! $this->isDeferredService($service)) {
return;
}
@@ -682,7 +740,7 @@ class Application extends Container implements ApplicationContract, HttpKernelIn
$this->register($instance = new $provider($this));
- if (! $this->booted) {
+ if (! $this->isBooted()) {
$this->booting(function () use ($instance) {
$this->bootProvider($instance);
});
@@ -692,40 +750,21 @@ class Application extends Container implements ApplicationContract, HttpKernelIn
/**
* Resolve the given type from the container.
*
- * (Overriding Container::makeWith)
+ * (Overriding Container::make)
*
* @param string $abstract
* @param array $parameters
* @return mixed
*/
- public function makeWith($abstract, array $parameters)
+ public function make($abstract, array $parameters = [])
{
$abstract = $this->getAlias($abstract);
- if (isset($this->deferredServices[$abstract])) {
+ if ($this->isDeferredService($abstract) && ! isset($this->instances[$abstract])) {
$this->loadDeferredProvider($abstract);
}
- return parent::makeWith($abstract, $parameters);
- }
-
- /**
- * Resolve the given type from the container.
- *
- * (Overriding Container::make)
- *
- * @param string $abstract
- * @return mixed
- */
- public function make($abstract)
- {
- $abstract = $this->getAlias($abstract);
-
- if (isset($this->deferredServices[$abstract])) {
- $this->loadDeferredProvider($abstract);
- }
-
- return parent::make($abstract);
+ return parent::make($abstract, $parameters);
}
/**
@@ -738,7 +777,7 @@ class Application extends Container implements ApplicationContract, HttpKernelIn
*/
public function bound($abstract)
{
- return isset($this->deferredServices[$abstract]) || parent::bound($abstract);
+ return $this->isDeferredService($abstract) || parent::bound($abstract);
}
/**
@@ -758,7 +797,7 @@ class Application extends Container implements ApplicationContract, HttpKernelIn
*/
public function boot()
{
- if ($this->booted) {
+ if ($this->isBooted()) {
return;
}
@@ -792,7 +831,7 @@ class Application extends Container implements ApplicationContract, HttpKernelIn
/**
* Register a new boot listener.
*
- * @param mixed $callback
+ * @param callable $callback
* @return void
*/
public function booting($callback)
@@ -803,7 +842,7 @@ class Application extends Container implements ApplicationContract, HttpKernelIn
/**
* Register a new "booted" listener.
*
- * @param mixed $callback
+ * @param callable $callback
* @return void
*/
public function booted($callback)
@@ -818,7 +857,7 @@ class Application extends Container implements ApplicationContract, HttpKernelIn
/**
* Call the booting callbacks for the application.
*
- * @param array $callbacks
+ * @param callable[] $callbacks
* @return void
*/
protected function fireAppCallbacks(array $callbacks)
@@ -854,7 +893,17 @@ class Application extends Container implements ApplicationContract, HttpKernelIn
*/
public function getCachedServicesPath()
{
- return $this->bootstrapPath().'/cache/services.php';
+ return $_ENV['APP_SERVICES_CACHE'] ?? $this->bootstrapPath().'/cache/services.php';
+ }
+
+ /**
+ * Get the path to the cached packages.php file.
+ *
+ * @return string
+ */
+ public function getCachedPackagesPath()
+ {
+ return $_ENV['APP_PACKAGES_CACHE'] ?? $this->bootstrapPath().'/cache/packages.php';
}
/**
@@ -874,7 +923,7 @@ class Application extends Container implements ApplicationContract, HttpKernelIn
*/
public function getCachedConfigPath()
{
- return $this->bootstrapPath().'/cache/config.php';
+ return $_ENV['APP_CONFIG_CACHE'] ?? $this->bootstrapPath().'/cache/config.php';
}
/**
@@ -894,7 +943,27 @@ class Application extends Container implements ApplicationContract, HttpKernelIn
*/
public function getCachedRoutesPath()
{
- return $this->bootstrapPath().'/cache/routes.php';
+ return $_ENV['APP_ROUTES_CACHE'] ?? $this->bootstrapPath().'/cache/routes.php';
+ }
+
+ /**
+ * Determine if the application events are cached.
+ *
+ * @return bool
+ */
+ public function eventsAreCached()
+ {
+ return $this['files']->exists($this->getCachedEventsPath());
+ }
+
+ /**
+ * Get the path to the events cache file.
+ *
+ * @return string
+ */
+ public function getCachedEventsPath()
+ {
+ return $_ENV['APP_EVENTS_CACHE'] ?? $this->bootstrapPath().'/cache/events.php';
}
/**
@@ -929,10 +998,10 @@ class Application extends Container implements ApplicationContract, HttpKernelIn
/**
* Register a terminating callback with the application.
*
- * @param \Closure $callback
+ * @param callable|string $callback
* @return $this
*/
- public function terminating(Closure $callback)
+ public function terminating($callback)
{
$this->terminatingCallbacks[] = $callback;
@@ -1015,39 +1084,6 @@ class Application extends Container implements ApplicationContract, HttpKernelIn
AliasLoader::setFacadeNamespace($namespace);
}
- /**
- * Define a callback to be used to configure Monolog.
- *
- * @param callable $callback
- * @return $this
- */
- public function configureMonologUsing(callable $callback)
- {
- $this->monologConfigurator = $callback;
-
- return $this;
- }
-
- /**
- * Determine if the application has a custom Monolog configurator.
- *
- * @return bool
- */
- public function hasMonologConfigurator()
- {
- return ! is_null($this->monologConfigurator);
- }
-
- /**
- * Get the custom Monolog configurator for the application.
- *
- * @return callable
- */
- public function getMonologConfigurator()
- {
- return $this->monologConfigurator;
- }
-
/**
* Get the current application locale.
*
@@ -1092,7 +1128,7 @@ class Application extends Container implements ApplicationContract, HttpKernelIn
public function registerCoreContainerAliases()
{
foreach ([
- 'app' => [\Illuminate\Foundation\Application::class, \Illuminate\Contracts\Container\Container::class, \Illuminate\Contracts\Foundation\Application::class],
+ 'app' => [self::class, \Illuminate\Contracts\Container\Container::class, \Illuminate\Contracts\Foundation\Application::class, \Psr\Container\ContainerInterface::class],
'auth' => [\Illuminate\Auth\AuthManager::class, \Illuminate\Contracts\Auth\Factory::class],
'auth.driver' => [\Illuminate\Contracts\Auth\Guard::class],
'blade.compiler' => [\Illuminate\View\Compilers\BladeCompiler::class],
@@ -1108,9 +1144,10 @@ class Application extends Container implements ApplicationContract, HttpKernelIn
'filesystem' => [\Illuminate\Filesystem\FilesystemManager::class, \Illuminate\Contracts\Filesystem\Factory::class],
'filesystem.disk' => [\Illuminate\Contracts\Filesystem\Filesystem::class],
'filesystem.cloud' => [\Illuminate\Contracts\Filesystem\Cloud::class],
- 'hash' => [\Illuminate\Contracts\Hashing\Hasher::class],
+ 'hash' => [\Illuminate\Hashing\HashManager::class],
+ 'hash.driver' => [\Illuminate\Contracts\Hashing\Hasher::class],
'translator' => [\Illuminate\Translation\Translator::class, \Illuminate\Contracts\Translation\Translator::class],
- 'log' => [\Illuminate\Log\Writer::class, \Illuminate\Contracts\Logging\Log::class, \Psr\Log\LoggerInterface::class],
+ 'log' => [\Illuminate\Log\LogManager::class, \Psr\Log\LoggerInterface::class],
'mailer' => [\Illuminate\Mail\Mailer::class, \Illuminate\Contracts\Mail\Mailer::class, \Illuminate\Contracts\Mail\MailQueue::class],
'auth.password' => [\Illuminate\Auth\Passwords\PasswordBrokerManager::class, \Illuminate\Contracts\Auth\PasswordBrokerFactory::class],
'auth.password.broker' => [\Illuminate\Auth\Passwords\PasswordBroker::class, \Illuminate\Contracts\Auth\PasswordBroker::class],
@@ -1142,7 +1179,16 @@ class Application extends Container implements ApplicationContract, HttpKernelIn
{
parent::flush();
+ $this->buildStack = [];
$this->loadedProviders = [];
+ $this->bootedCallbacks = [];
+ $this->bootingCallbacks = [];
+ $this->deferredServices = [];
+ $this->reboundCallbacks = [];
+ $this->serviceProviders = [];
+ $this->resolvingCallbacks = [];
+ $this->afterResolvingCallbacks = [];
+ $this->globalResolvingCallbacks = [];
}
/**
@@ -1158,11 +1204,11 @@ class Application extends Container implements ApplicationContract, HttpKernelIn
return $this->namespace;
}
- $composer = json_decode(file_get_contents(base_path('composer.json')), true);
+ $composer = json_decode(file_get_contents($this->basePath('composer.json')), true);
foreach ((array) data_get($composer, 'autoload.psr-4') as $namespace => $path) {
foreach ((array) $path as $pathChoice) {
- if (realpath(app_path()) == realpath(base_path().'/'.$pathChoice)) {
+ if (realpath($this->path()) === realpath($this->basePath($pathChoice))) {
return $this->namespace = $namespace;
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Auth/Access/AuthorizesRequests.php b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Auth/Access/AuthorizesRequests.php
index 7c2aa1bc..9930d905 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Auth/Access/AuthorizesRequests.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Auth/Access/AuthorizesRequests.php
@@ -2,6 +2,7 @@
namespace Illuminate\Foundation\Auth\Access;
+use Illuminate\Support\Str;
use Illuminate\Contracts\Auth\Access\Gate;
trait AuthorizesRequests
@@ -17,7 +18,7 @@ trait AuthorizesRequests
*/
public function authorize($ability, $arguments = [])
{
- list($ability, $arguments) = $this->parseAbilityAndArguments($ability, $arguments);
+ [$ability, $arguments] = $this->parseAbilityAndArguments($ability, $arguments);
return app(Gate::class)->authorize($ability, $arguments);
}
@@ -34,7 +35,7 @@ trait AuthorizesRequests
*/
public function authorizeForUser($user, $ability, $arguments = [])
{
- list($ability, $arguments) = $this->parseAbilityAndArguments($ability, $arguments);
+ [$ability, $arguments] = $this->parseAbilityAndArguments($ability, $arguments);
return app(Gate::class)->forUser($user)->authorize($ability, $arguments);
}
@@ -67,7 +68,7 @@ trait AuthorizesRequests
{
$map = $this->resourceAbilityMap();
- return isset($map[$ability]) ? $map[$ability] : $ability;
+ return $map[$ability] ?? $ability;
}
/**
@@ -81,7 +82,7 @@ trait AuthorizesRequests
*/
public function authorizeResource($model, $parameter = null, array $options = [], $request = null)
{
- $parameter = $parameter ?: lcfirst(class_basename($model));
+ $parameter = $parameter ?: Str::snake(class_basename($model));
$middleware = [];
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Auth/AuthenticatesUsers.php b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Auth/AuthenticatesUsers.php
index d76e2a45..6ad55f6b 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Auth/AuthenticatesUsers.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Auth/AuthenticatesUsers.php
@@ -4,6 +4,7 @@ namespace Illuminate\Foundation\Auth;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
+use Illuminate\Validation\ValidationException;
trait AuthenticatesUsers
{
@@ -23,7 +24,9 @@ trait AuthenticatesUsers
* Handle a login request to the application.
*
* @param \Illuminate\Http\Request $request
- * @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\Response
+ * @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\Response|\Illuminate\Http\JsonResponse
+ *
+ * @throws \Illuminate\Validation\ValidationException
*/
public function login(Request $request)
{
@@ -32,7 +35,8 @@ trait AuthenticatesUsers
// If the class is using the ThrottlesLogins trait, we can automatically throttle
// the login attempts for this application. We'll key this by the username and
// the IP address of the client making these requests into this application.
- if ($this->hasTooManyLoginAttempts($request)) {
+ if (method_exists($this, 'hasTooManyLoginAttempts') &&
+ $this->hasTooManyLoginAttempts($request)) {
$this->fireLockoutEvent($request);
return $this->sendLockoutResponse($request);
@@ -55,10 +59,12 @@ trait AuthenticatesUsers
*
* @param \Illuminate\Http\Request $request
* @return void
+ *
+ * @throws \Illuminate\Validation\ValidationException
*/
protected function validateLogin(Request $request)
{
- $this->validate($request, [
+ $request->validate([
$this->username() => 'required|string',
'password' => 'required|string',
]);
@@ -73,7 +79,7 @@ trait AuthenticatesUsers
protected function attemptLogin(Request $request)
{
return $this->guard()->attempt(
- $this->credentials($request), $request->has('remember')
+ $this->credentials($request), $request->filled('remember')
);
}
@@ -120,19 +126,15 @@ trait AuthenticatesUsers
* Get the failed login response instance.
*
* @param \Illuminate\Http\Request $request
- * @return \Illuminate\Http\RedirectResponse
+ * @return \Symfony\Component\HttpFoundation\Response
+ *
+ * @throws \Illuminate\Validation\ValidationException
*/
protected function sendFailedLoginResponse(Request $request)
{
- $errors = [$this->username() => trans('auth.failed')];
-
- if ($request->expectsJson()) {
- return response()->json($errors, 422);
- }
-
- return redirect()->back()
- ->withInput($request->only($this->username(), 'remember'))
- ->withErrors($errors);
+ throw ValidationException::withMessages([
+ $this->username() => [trans('auth.failed')],
+ ]);
}
/**
@@ -157,7 +159,18 @@ trait AuthenticatesUsers
$request->session()->invalidate();
- return redirect('/');
+ return $this->loggedOut($request) ?: redirect('/');
+ }
+
+ /**
+ * The user has logged out of the application.
+ *
+ * @param \Illuminate\Http\Request $request
+ * @return mixed
+ */
+ protected function loggedOut(Request $request)
+ {
+ //
}
/**
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Auth/ResetsPasswords.php b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Auth/ResetsPasswords.php
index c6d2cac1..9cb780d1 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Auth/ResetsPasswords.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Auth/ResetsPasswords.php
@@ -5,7 +5,9 @@ namespace Illuminate\Foundation\Auth;
use Illuminate\Support\Str;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
+use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Password;
+use Illuminate\Auth\Events\PasswordReset;
trait ResetsPasswords
{
@@ -31,11 +33,11 @@ trait ResetsPasswords
* Reset the given user's password.
*
* @param \Illuminate\Http\Request $request
- * @return \Illuminate\Http\RedirectResponse
+ * @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\JsonResponse
*/
public function reset(Request $request)
{
- $this->validate($request, $this->rules(), $this->validationErrorMessages());
+ $request->validate($this->rules(), $this->validationErrorMessages());
// Here we will attempt to reset the user's password. If it is successful we
// will update the password on an actual user model and persist it to the
@@ -50,7 +52,7 @@ trait ResetsPasswords
// the application's home authenticated view. If there is an error we can
// redirect them back to where they came from with their error message.
return $response == Password::PASSWORD_RESET
- ? $this->sendResetResponse($response)
+ ? $this->sendResetResponse($request, $response)
: $this->sendResetFailedResponse($request, $response);
}
@@ -64,7 +66,7 @@ trait ResetsPasswords
return [
'token' => 'required',
'email' => 'required|email',
- 'password' => 'required|confirmed|min:6',
+ 'password' => 'required|confirmed|min:8',
];
}
@@ -100,10 +102,13 @@ trait ResetsPasswords
*/
protected function resetPassword($user, $password)
{
- $user->forceFill([
- 'password' => bcrypt($password),
- 'remember_token' => Str::random(60),
- ])->save();
+ $user->password = Hash::make($password);
+
+ $user->setRememberToken(Str::random(60));
+
+ $user->save();
+
+ event(new PasswordReset($user));
$this->guard()->login($user);
}
@@ -111,10 +116,11 @@ trait ResetsPasswords
/**
* Get the response for a successful password reset.
*
+ * @param \Illuminate\Http\Request $request
* @param string $response
- * @return \Illuminate\Http\RedirectResponse
+ * @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\JsonResponse
*/
- protected function sendResetResponse($response)
+ protected function sendResetResponse(Request $request, $response)
{
return redirect($this->redirectPath())
->with('status', trans($response));
@@ -123,9 +129,9 @@ trait ResetsPasswords
/**
* Get the response for a failed password reset.
*
- * @param \Illuminate\Http\Request
+ * @param \Illuminate\Http\Request $request
* @param string $response
- * @return \Illuminate\Http\RedirectResponse
+ * @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\JsonResponse
*/
protected function sendResetFailedResponse(Request $request, $response)
{
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Auth/SendsPasswordResetEmails.php b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Auth/SendsPasswordResetEmails.php
index eb29b56e..070c6482 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Auth/SendsPasswordResetEmails.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Auth/SendsPasswordResetEmails.php
@@ -21,7 +21,7 @@ trait SendsPasswordResetEmails
* Send a reset link to the given user.
*
* @param \Illuminate\Http\Request $request
- * @return \Illuminate\Http\RedirectResponse
+ * @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\JsonResponse
*/
public function sendResetLinkEmail(Request $request)
{
@@ -31,32 +31,44 @@ trait SendsPasswordResetEmails
// to send the link, we will examine the response then see the message we
// need to show to the user. Finally, we'll send out a proper response.
$response = $this->broker()->sendResetLink(
- $request->only('email')
+ $this->credentials($request)
);
return $response == Password::RESET_LINK_SENT
- ? $this->sendResetLinkResponse($response)
+ ? $this->sendResetLinkResponse($request, $response)
: $this->sendResetLinkFailedResponse($request, $response);
}
/**
* Validate the email for the given request.
*
- * @param \Illuminate\Http\Request $request
+ * @param \Illuminate\Http\Request $request
* @return void
*/
protected function validateEmail(Request $request)
{
- $this->validate($request, ['email' => 'required|email']);
+ $request->validate(['email' => 'required|email']);
+ }
+
+ /**
+ * Get the needed authentication credentials from the request.
+ *
+ * @param \Illuminate\Http\Request $request
+ * @return array
+ */
+ protected function credentials(Request $request)
+ {
+ return $request->only('email');
}
/**
* Get the response for a successful password reset link.
*
+ * @param \Illuminate\Http\Request $request
* @param string $response
- * @return \Illuminate\Http\RedirectResponse
+ * @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\JsonResponse
*/
- protected function sendResetLinkResponse($response)
+ protected function sendResetLinkResponse(Request $request, $response)
{
return back()->with('status', trans($response));
}
@@ -64,15 +76,15 @@ trait SendsPasswordResetEmails
/**
* Get the response for a failed password reset link.
*
- * @param \Illuminate\Http\Request
+ * @param \Illuminate\Http\Request $request
* @param string $response
- * @return \Illuminate\Http\RedirectResponse
+ * @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\JsonResponse
*/
protected function sendResetLinkFailedResponse(Request $request, $response)
{
- return back()->withErrors(
- ['email' => trans($response)]
- );
+ return back()
+ ->withInput($request->only('email'))
+ ->withErrors(['email' => trans($response)]);
}
/**
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Auth/ThrottlesLogins.php b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Auth/ThrottlesLogins.php
index a7f0b7f2..6d7e56cf 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Auth/ThrottlesLogins.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Auth/ThrottlesLogins.php
@@ -4,9 +4,11 @@ namespace Illuminate\Foundation\Auth;
use Illuminate\Support\Str;
use Illuminate\Http\Request;
+use Illuminate\Http\Response;
use Illuminate\Cache\RateLimiter;
use Illuminate\Auth\Events\Lockout;
use Illuminate\Support\Facades\Lang;
+use Illuminate\Validation\ValidationException;
trait ThrottlesLogins
{
@@ -19,7 +21,7 @@ trait ThrottlesLogins
protected function hasTooManyLoginAttempts(Request $request)
{
return $this->limiter()->tooManyAttempts(
- $this->throttleKey($request), $this->maxAttempts(), $this->decayMinutes()
+ $this->throttleKey($request), $this->maxAttempts()
);
}
@@ -31,14 +33,18 @@ trait ThrottlesLogins
*/
protected function incrementLoginAttempts(Request $request)
{
- $this->limiter()->hit($this->throttleKey($request));
+ $this->limiter()->hit(
+ $this->throttleKey($request), $this->decayMinutes() * 60
+ );
}
/**
* Redirect the user after determining they are locked out.
*
* @param \Illuminate\Http\Request $request
- * @return \Illuminate\Http\RedirectResponse
+ * @return void
+ *
+ * @throws \Illuminate\Validation\ValidationException
*/
protected function sendLockoutResponse(Request $request)
{
@@ -46,17 +52,9 @@ trait ThrottlesLogins
$this->throttleKey($request)
);
- $message = Lang::get('auth.throttle', ['seconds' => $seconds]);
-
- $errors = [$this->username() => $message];
-
- if ($request->expectsJson()) {
- return response()->json($errors, 423);
- }
-
- return redirect()->back()
- ->withInput($request->only($this->username(), 'remember'))
- ->withErrors($errors);
+ throw ValidationException::withMessages([
+ $this->username() => [Lang::get('auth.throttle', ['seconds' => $seconds])],
+ ])->status(Response::HTTP_TOO_MANY_REQUESTS);
}
/**
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Auth/User.php b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Auth/User.php
index 5c847785..c816436f 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Auth/User.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Auth/User.php
@@ -3,6 +3,7 @@
namespace Illuminate\Foundation\Auth;
use Illuminate\Auth\Authenticatable;
+use Illuminate\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Auth\Passwords\CanResetPassword;
use Illuminate\Foundation\Auth\Access\Authorizable;
@@ -15,5 +16,5 @@ class User extends Model implements
AuthorizableContract,
CanResetPasswordContract
{
- use Authenticatable, Authorizable, CanResetPassword;
+ use Authenticatable, Authorizable, CanResetPassword, MustVerifyEmail;
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php
index b7edb683..ad576347 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php
@@ -12,6 +12,13 @@ use Symfony\Component\Debug\Exception\FatalThrowableError;
class HandleExceptions
{
+ /**
+ * Reserved memory so that errors can be displayed properly on memory exhaustion.
+ *
+ * @var string
+ */
+ public static $reservedMemory;
+
/**
* The application instance.
*
@@ -27,6 +34,8 @@ class HandleExceptions
*/
public function bootstrap(Application $app)
{
+ self::$reservedMemory = str_repeat('x', 10240);
+
$this->app = $app;
error_reporting(-1);
@@ -78,6 +87,8 @@ class HandleExceptions
}
try {
+ self::$reservedMemory = null;
+
$this->getExceptionHandler()->report($e);
} catch (Exception $e) {
//
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/LoadConfiguration.php b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/LoadConfiguration.php
index 6a2dcfc0..8f4653de 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/LoadConfiguration.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/LoadConfiguration.php
@@ -57,6 +57,7 @@ class LoadConfiguration
* @param \Illuminate\Contracts\Foundation\Application $app
* @param \Illuminate\Contracts\Config\Repository $repository
* @return void
+ *
* @throws \Exception
*/
protected function loadConfigurationFiles(Application $app, RepositoryContract $repository)
@@ -90,6 +91,8 @@ class LoadConfiguration
$files[$directory.basename($file->getRealPath(), '.php')] = $file->getRealPath();
}
+ ksort($files, SORT_NATURAL);
+
return $files;
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/LoadEnvironmentVariables.php b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/LoadEnvironmentVariables.php
index 6ec3e802..b39bbf83 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/LoadEnvironmentVariables.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/LoadEnvironmentVariables.php
@@ -3,9 +3,14 @@
namespace Illuminate\Foundation\Bootstrap;
use Dotenv\Dotenv;
-use Dotenv\Exception\InvalidPathException;
+use Dotenv\Environment\DotenvFactory;
+use Dotenv\Exception\InvalidFileException;
+use Dotenv\Environment\Adapter\PutenvAdapter;
use Symfony\Component\Console\Input\ArgvInput;
+use Dotenv\Environment\Adapter\EnvConstAdapter;
use Illuminate\Contracts\Foundation\Application;
+use Dotenv\Environment\Adapter\ServerConstAdapter;
+use Symfony\Component\Console\Output\ConsoleOutput;
class LoadEnvironmentVariables
{
@@ -24,9 +29,9 @@ class LoadEnvironmentVariables
$this->checkForSpecificEnvironmentFile($app);
try {
- (new Dotenv($app->environmentPath(), $app->environmentFile()))->load();
- } catch (InvalidPathException $e) {
- //
+ $this->createDotenv($app)->safeLoad();
+ } catch (InvalidFileException $e) {
+ $this->writeErrorAndDie($e);
}
}
@@ -38,10 +43,12 @@ class LoadEnvironmentVariables
*/
protected function checkForSpecificEnvironmentFile($app)
{
- if (php_sapi_name() == 'cli' && with($input = new ArgvInput)->hasParameterOption('--env')) {
- $this->setEnvironmentFilePath(
+ if ($app->runningInConsole() && ($input = new ArgvInput)->hasParameterOption('--env')) {
+ if ($this->setEnvironmentFilePath(
$app, $app->environmentFile().'.'.$input->getParameterOption('--env')
- );
+ )) {
+ return;
+ }
}
if (! env('APP_ENV')) {
@@ -58,12 +65,47 @@ class LoadEnvironmentVariables
*
* @param \Illuminate\Contracts\Foundation\Application $app
* @param string $file
- * @return void
+ * @return bool
*/
protected function setEnvironmentFilePath($app, $file)
{
if (file_exists($app->environmentPath().'/'.$file)) {
$app->loadEnvironmentFrom($file);
+
+ return true;
}
+
+ return false;
+ }
+
+ /**
+ * Create a Dotenv instance.
+ *
+ * @param \Illuminate\Contracts\Foundation\Application $app
+ * @return \Dotenv\Dotenv
+ */
+ protected function createDotenv($app)
+ {
+ return Dotenv::create(
+ $app->environmentPath(),
+ $app->environmentFile(),
+ new DotenvFactory([new EnvConstAdapter, new ServerConstAdapter, new PutenvAdapter])
+ );
+ }
+
+ /**
+ * Write the error information to the screen and exit.
+ *
+ * @param \Dotenv\Exception\InvalidFileException $e
+ * @return void
+ */
+ protected function writeErrorAndDie(InvalidFileException $e)
+ {
+ $output = (new ConsoleOutput)->getErrorOutput();
+
+ $output->writeln('The environment file is invalid!');
+ $output->writeln($e->getMessage());
+
+ die(1);
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/RegisterFacades.php b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/RegisterFacades.php
index 0c2d5cfc..62a42d07 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/RegisterFacades.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/RegisterFacades.php
@@ -4,6 +4,7 @@ namespace Illuminate\Foundation\Bootstrap;
use Illuminate\Foundation\AliasLoader;
use Illuminate\Support\Facades\Facade;
+use Illuminate\Foundation\PackageManifest;
use Illuminate\Contracts\Foundation\Application;
class RegisterFacades
@@ -20,6 +21,9 @@ class RegisterFacades
Facade::setFacadeApplication($app);
- AliasLoader::getInstance($app->make('config')->get('app.aliases', []))->register();
+ AliasLoader::getInstance(array_merge(
+ $app->make('config')->get('app.aliases', []),
+ $app->make(PackageManifest::class)->aliases()
+ ))->register();
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Bus/Dispatchable.php b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Bus/Dispatchable.php
index d91d8db2..6dd992e5 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Bus/Dispatchable.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Bus/Dispatchable.php
@@ -2,6 +2,8 @@
namespace Illuminate\Foundation\Bus;
+use Illuminate\Contracts\Bus\Dispatcher;
+
trait Dispatchable
{
/**
@@ -13,4 +15,25 @@ trait Dispatchable
{
return new PendingDispatch(new static(...func_get_args()));
}
+
+ /**
+ * Dispatch a command to its appropriate handler in the current process.
+ *
+ * @return mixed
+ */
+ public static function dispatchNow()
+ {
+ return app(Dispatcher::class)->dispatchNow(new static(...func_get_args()));
+ }
+
+ /**
+ * Set the jobs that should run if this job is successful.
+ *
+ * @param array $chain
+ * @return \Illuminate\Foundation\Bus\PendingChain
+ */
+ public static function withChain($chain)
+ {
+ return new PendingChain(static::class, $chain);
+ }
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Bus/DispatchesJobs.php b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Bus/DispatchesJobs.php
index 94a96844..46d6e5b4 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Bus/DispatchesJobs.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Bus/DispatchesJobs.php
@@ -18,7 +18,7 @@ trait DispatchesJobs
}
/**
- * Dispatch a command to its appropriate handler in the current process.
+ * Dispatch a job to its appropriate handler in the current process.
*
* @param mixed $job
* @return mixed
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Bus/PendingDispatch.php b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Bus/PendingDispatch.php
index 7d5053d8..3c3879d4 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Bus/PendingDispatch.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Bus/PendingDispatch.php
@@ -2,8 +2,17 @@
namespace Illuminate\Foundation\Bus;
+use Illuminate\Contracts\Bus\Dispatcher;
+
class PendingDispatch
{
+ /**
+ * The job.
+ *
+ * @var mixed
+ */
+ protected $job;
+
/**
* Create a new pending job dispatch.
*
@@ -41,10 +50,36 @@ class PendingDispatch
return $this;
}
+ /**
+ * Set the desired connection for the chain.
+ *
+ * @param string|null $connection
+ * @return $this
+ */
+ public function allOnConnection($connection)
+ {
+ $this->job->allOnConnection($connection);
+
+ return $this;
+ }
+
+ /**
+ * Set the desired queue for the chain.
+ *
+ * @param string|null $queue
+ * @return $this
+ */
+ public function allOnQueue($queue)
+ {
+ $this->job->allOnQueue($queue);
+
+ return $this;
+ }
+
/**
* Set the desired delay for the job.
*
- * @param \DateTime|int|null $delay
+ * @param \DateTimeInterface|\DateInterval|int|null $delay
* @return $this
*/
public function delay($delay)
@@ -54,6 +89,19 @@ class PendingDispatch
return $this;
}
+ /**
+ * Set the jobs that should run if this job is successful.
+ *
+ * @param array $chain
+ * @return $this
+ */
+ public function chain($chain)
+ {
+ $this->job->chain($chain);
+
+ return $this;
+ }
+
/**
* Handle the object's destruction.
*
@@ -61,6 +109,6 @@ class PendingDispatch
*/
public function __destruct()
{
- dispatch($this->job);
+ app(Dispatcher::class)->dispatch($this->job);
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/ComposerScripts.php b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/ComposerScripts.php
index 9b4c1dde..fcda187f 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/ComposerScripts.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/ComposerScripts.php
@@ -32,6 +32,19 @@ class ComposerScripts
static::clearCompiled();
}
+ /**
+ * Handle the post-autoload-dump Composer event.
+ *
+ * @param \Composer\Script\Event $event
+ * @return void
+ */
+ public static function postAutoloadDump(Event $event)
+ {
+ require_once $event->getComposer()->getConfig()->get('vendor-dir').'/autoload.php';
+
+ static::clearCompiled();
+ }
+
/**
* Clear the cached Laravel bootstrapping files.
*
@@ -44,5 +57,9 @@ class ComposerScripts
if (file_exists($servicesPath = $laravel->getCachedServicesPath())) {
@unlink($servicesPath);
}
+
+ if (file_exists($packagesPath = $laravel->getCachedPackagesPath())) {
+ @unlink($packagesPath);
+ }
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/AppNameCommand.php b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/AppNameCommand.php
index 93dd3253..1c0d359f 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/AppNameCommand.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/AppNameCommand.php
@@ -65,7 +65,7 @@ class AppNameCommand extends Command
*
* @return void
*/
- public function fire()
+ public function handle()
{
$this->currentRoot = trim($this->laravel->getNamespace(), '\\');
@@ -79,7 +79,7 @@ class AppNameCommand extends Command
$this->composer->dumpAutoloads();
- $this->call('clear-compiled');
+ $this->call('optimize:clear');
}
/**
@@ -223,10 +223,17 @@ class AppNameCommand extends Command
*/
protected function setDatabaseFactoryNamespaces()
{
- $this->replaceIn(
- $this->laravel->databasePath().'/factories/ModelFactory.php',
- $this->currentRoot, $this->argument('name')
- );
+ $files = Finder::create()
+ ->in(database_path('factories'))
+ ->contains($this->currentRoot)
+ ->name('*.php');
+
+ foreach ($files as $file) {
+ $this->replaceIn(
+ $file->getRealPath(),
+ $this->currentRoot, $this->argument('name')
+ );
+ }
}
/**
@@ -261,7 +268,7 @@ class AppNameCommand extends Command
*/
protected function getComposerPath()
{
- return $this->laravel->basePath().'/composer.json';
+ return base_path('composer.json');
}
/**
@@ -283,7 +290,7 @@ class AppNameCommand extends Command
protected function getArguments()
{
return [
- ['name', InputArgument::REQUIRED, 'The desired namespace.'],
+ ['name', InputArgument::REQUIRED, 'The desired namespace'],
];
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/ClearCompiledCommand.php b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/ClearCompiledCommand.php
index 8d87b715..399a44dc 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/ClearCompiledCommand.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/ClearCompiledCommand.php
@@ -25,14 +25,16 @@ class ClearCompiledCommand extends Command
*
* @return void
*/
- public function fire()
+ public function handle()
{
- $servicesPath = $this->laravel->getCachedServicesPath();
-
- if (file_exists($servicesPath)) {
+ if (file_exists($servicesPath = $this->laravel->getCachedServicesPath())) {
@unlink($servicesPath);
}
- $this->info('The compiled services file has been removed.');
+ if (file_exists($packagesPath = $this->laravel->getCachedPackagesPath())) {
+ @unlink($packagesPath);
+ }
+
+ $this->info('Compiled services and packages files removed!');
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/ClosureCommand.php b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/ClosureCommand.php
index c2f19636..1e34b86d 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/ClosureCommand.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/ClosureCommand.php
@@ -21,7 +21,7 @@ class ClosureCommand extends Command
* Create a new command instance.
*
* @param string $signature
- * @param Closure $callback
+ * @param \Closure $callback
* @return void
*/
public function __construct($signature, Closure $callback)
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/ConfigCacheCommand.php b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/ConfigCacheCommand.php
index 2d479612..714921c3 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/ConfigCacheCommand.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/ConfigCacheCommand.php
@@ -2,6 +2,8 @@
namespace Illuminate\Foundation\Console;
+use Throwable;
+use LogicException;
use Illuminate\Console\Command;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Contracts\Console\Kernel as ConsoleKernelContract;
@@ -46,17 +48,29 @@ class ConfigCacheCommand extends Command
* Execute the console command.
*
* @return void
+ *
+ * @throws \LogicException
*/
- public function fire()
+ public function handle()
{
$this->call('config:clear');
$config = $this->getFreshConfiguration();
+ $configPath = $this->laravel->getCachedConfigPath();
+
$this->files->put(
- $this->laravel->getCachedConfigPath(), 'files->delete($configPath);
+
+ throw new LogicException('Your configuration files are not serializable.', 0, $e);
+ }
+
$this->info('Configuration cached successfully!');
}
@@ -69,6 +83,8 @@ class ConfigCacheCommand extends Command
{
$app = require $this->laravel->bootstrapPath().'/app.php';
+ $app->useStoragePath($this->laravel->storagePath());
+
$app->make(ConsoleKernelContract::class)->bootstrap();
return $app['config']->all();
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/ConfigClearCommand.php b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/ConfigClearCommand.php
index bb25a8ef..d20e2d85 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/ConfigClearCommand.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/ConfigClearCommand.php
@@ -46,7 +46,7 @@ class ConfigClearCommand extends Command
*
* @return void
*/
- public function fire()
+ public function handle()
{
$this->files->delete($this->laravel->getCachedConfigPath());
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/ConsoleMakeCommand.php b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/ConsoleMakeCommand.php
index a9b164b9..54183e90 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/ConsoleMakeCommand.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/ConsoleMakeCommand.php
@@ -72,7 +72,7 @@ class ConsoleMakeCommand extends GeneratorCommand
protected function getArguments()
{
return [
- ['name', InputArgument::REQUIRED, 'The name of the command.'],
+ ['name', InputArgument::REQUIRED, 'The name of the command'],
];
}
@@ -84,7 +84,7 @@ class ConsoleMakeCommand extends GeneratorCommand
protected function getOptions()
{
return [
- ['command', null, InputOption::VALUE_OPTIONAL, 'The terminal command that should be assigned.', 'command:name'],
+ ['command', null, InputOption::VALUE_OPTIONAL, 'The terminal command that should be assigned', 'command:name'],
];
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/DownCommand.php b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/DownCommand.php
index 358a5841..50f8a6d1 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/DownCommand.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/DownCommand.php
@@ -2,18 +2,22 @@
namespace Illuminate\Foundation\Console;
-use Carbon\Carbon;
+use Exception;
use Illuminate\Console\Command;
+use Illuminate\Support\InteractsWithTime;
class DownCommand extends Command
{
+ use InteractsWithTime;
+
/**
* The console command signature.
*
* @var string
*/
- protected $signature = 'down {--message= : The message for the maintenance mode. }
- {--retry= : The number of seconds after which the request may be retried.}';
+ protected $signature = 'down {--message= : The message for the maintenance mode}
+ {--retry= : The number of seconds after which the request may be retried}
+ {--allow=* : IP or networks allowed to access the application while in maintenance mode}';
/**
* The console command description.
@@ -25,16 +29,23 @@ class DownCommand extends Command
/**
* Execute the console command.
*
- * @return void
+ * @return int
*/
- public function fire()
+ public function handle()
{
- file_put_contents(
- $this->laravel->storagePath().'/framework/down',
- json_encode($this->getDownFilePayload(), JSON_PRETTY_PRINT)
- );
+ try {
+ file_put_contents(storage_path('framework/down'),
+ json_encode($this->getDownFilePayload(),
+ JSON_PRETTY_PRINT));
- $this->comment('Application is now in maintenance mode.');
+ $this->comment('Application is now in maintenance mode.');
+ } catch (Exception $e) {
+ $this->error('Failed to enter maintenance mode.');
+
+ $this->error($e->getMessage());
+
+ return 1;
+ }
}
/**
@@ -45,9 +56,10 @@ class DownCommand extends Command
protected function getDownFilePayload()
{
return [
- 'time' => Carbon::now()->getTimestamp(),
+ 'time' => $this->currentTime(),
'message' => $this->option('message'),
'retry' => $this->getRetryTime(),
+ 'allowed' => $this->option('allow'),
];
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/EnvironmentCommand.php b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/EnvironmentCommand.php
index b227165c..ab3bb320 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/EnvironmentCommand.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/EnvironmentCommand.php
@@ -25,7 +25,7 @@ class EnvironmentCommand extends Command
*
* @return void
*/
- public function fire()
+ public function handle()
{
$this->line('
Current application environment: '.$this->laravel['env'].'');
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/EventGenerateCommand.php b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/EventGenerateCommand.php
index bf4c989e..0c6a4a7b 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/EventGenerateCommand.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/EventGenerateCommand.php
@@ -27,12 +27,14 @@ class EventGenerateCommand extends Command
*
* @return void
*/
- public function fire()
+ public function handle()
{
- $provider = $this->laravel->getProvider(EventServiceProvider::class);
+ $providers = $this->laravel->getProviders(EventServiceProvider::class);
- foreach ($provider->listens() as $event => $listeners) {
- $this->makeEventAndListeners($event, $listeners);
+ foreach ($providers as $provider) {
+ foreach ($provider->listens() as $event => $listeners) {
+ $this->makeEventAndListeners($event, $listeners);
+ }
}
$this->info('Events and listeners generated successfully!');
@@ -68,7 +70,9 @@ class EventGenerateCommand extends Command
foreach ($listeners as $listener) {
$listener = preg_replace('/@.+$/', '', $listener);
- $this->callSilent('make:listener', ['name' => $listener, '--event' => $event]);
+ $this->callSilent('make:listener', array_filter(
+ ['name' => $listener, '--event' => $event]
+ ));
}
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/JobMakeCommand.php b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/JobMakeCommand.php
index af006720..60d942eb 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/JobMakeCommand.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/JobMakeCommand.php
@@ -59,7 +59,7 @@ class JobMakeCommand extends GeneratorCommand
protected function getOptions()
{
return [
- ['sync', null, InputOption::VALUE_NONE, 'Indicates that job should be synchronous.'],
+ ['sync', null, InputOption::VALUE_NONE, 'Indicates that job should be synchronous'],
];
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php
index 7c7a1f45..ea8a1074 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php
@@ -5,12 +5,16 @@ namespace Illuminate\Foundation\Console;
use Closure;
use Exception;
use Throwable;
+use ReflectionClass;
+use Illuminate\Support\Arr;
+use Illuminate\Support\Str;
+use Illuminate\Console\Command;
+use Symfony\Component\Finder\Finder;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Contracts\Events\Dispatcher;
use Illuminate\Console\Application as Artisan;
use Illuminate\Contracts\Debug\ExceptionHandler;
use Illuminate\Contracts\Foundation\Application;
-use Illuminate\Contracts\Cache\Repository as Cache;
use Illuminate\Contracts\Console\Kernel as KernelContract;
use Symfony\Component\Debug\Exception\FatalThrowableError;
@@ -94,18 +98,31 @@ class Kernel implements KernelContract
*/
protected function defineConsoleSchedule()
{
- $this->app->instance(
- Schedule::class, $schedule = new Schedule($this->app[Cache::class])
- );
+ $this->app->singleton(Schedule::class, function ($app) {
+ return (new Schedule($this->scheduleTimezone()))
+ ->useCache($this->scheduleCache());
+ });
+
+ $schedule = $this->app->make(Schedule::class);
$this->schedule($schedule);
}
+ /**
+ * Get the name of the cache store that should manage scheduling mutexes.
+ *
+ * @return string
+ */
+ protected function scheduleCache()
+ {
+ return $_ENV['SCHEDULE_CACHE_DRIVER'] ?? null;
+ }
+
/**
* Run the console application.
*
* @param \Symfony\Component\Console\Input\InputInterface $input
- * @param \Symfony\Component\Console\Output\OutputInterface $output
+ * @param \Symfony\Component\Console\Output\OutputInterface|null $output
* @return int
*/
public function handle($input, $output = null)
@@ -113,12 +130,6 @@ class Kernel implements KernelContract
try {
$this->bootstrap();
- if (! $this->commandsLoaded) {
- $this->commands();
-
- $this->commandsLoaded = true;
- }
-
return $this->getArtisan()->run($input, $output);
} catch (Exception $e) {
$this->reportException($e);
@@ -160,6 +171,18 @@ class Kernel implements KernelContract
//
}
+ /**
+ * Get the timezone that should be used by default for scheduled events.
+ *
+ * @return \DateTimeZone|string|null
+ */
+ protected function scheduleTimezone()
+ {
+ $config = $this->app['config'];
+
+ return $config->get('app.schedule_timezone', $config->get('app.timezone'));
+ }
+
/**
* Register the Closure based commands for the application.
*
@@ -174,7 +197,7 @@ class Kernel implements KernelContract
* Register a Closure based command with the application.
*
* @param string $signature
- * @param Closure $callback
+ * @param \Closure $callback
* @return \Illuminate\Foundation\Console\ClosureCommand
*/
public function command($signature, Closure $callback)
@@ -188,6 +211,42 @@ class Kernel implements KernelContract
return $command;
}
+ /**
+ * Register all of the commands in the given directory.
+ *
+ * @param array|string $paths
+ * @return void
+ */
+ protected function load($paths)
+ {
+ $paths = array_unique(Arr::wrap($paths));
+
+ $paths = array_filter($paths, function ($path) {
+ return is_dir($path);
+ });
+
+ if (empty($paths)) {
+ return;
+ }
+
+ $namespace = $this->app->getNamespace();
+
+ foreach ((new Finder)->in($paths)->files() as $command) {
+ $command = $namespace.str_replace(
+ ['/', '.php'],
+ ['\\', ''],
+ Str::after($command->getPathname(), realpath(app_path()).DIRECTORY_SEPARATOR)
+ );
+
+ if (is_subclass_of($command, Command::class) &&
+ ! (new ReflectionClass($command))->isAbstract()) {
+ Artisan::starting(function ($artisan) use ($command) {
+ $artisan->resolve($command);
+ });
+ }
+ }
+ }
+
/**
* Register the given command with the console application.
*
@@ -204,19 +263,15 @@ class Kernel implements KernelContract
*
* @param string $command
* @param array $parameters
- * @param \Symfony\Component\Console\Output\OutputInterface $outputBuffer
+ * @param \Symfony\Component\Console\Output\OutputInterface|null $outputBuffer
* @return int
+ *
+ * @throws \Symfony\Component\Console\Exception\CommandNotFoundException
*/
public function call($command, array $parameters = [], $outputBuffer = null)
{
$this->bootstrap();
- if (! $this->commandsLoaded) {
- $this->commands();
-
- $this->commandsLoaded = true;
- }
-
return $this->getArtisan()->call($command, $parameters, $outputBuffer);
}
@@ -267,10 +322,13 @@ class Kernel implements KernelContract
$this->app->bootstrapWith($this->bootstrappers());
}
- // If we are calling an arbitrary command from within the application, we'll load
- // all of the available deferred providers which will make all of the commands
- // available to an application. Otherwise the command will not be available.
$this->app->loadDeferredProviders();
+
+ if (! $this->commandsLoaded) {
+ $this->commands();
+
+ $this->commandsLoaded = true;
+ }
}
/**
@@ -321,7 +379,7 @@ class Kernel implements KernelContract
}
/**
- * Report the exception to the exception handler.
+ * Render the given exception.
*
* @param \Symfony\Component\Console\Output\OutputInterface $output
* @param \Exception $e
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/KeyGenerateCommand.php b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/KeyGenerateCommand.php
index b48a8069..99492f07 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/KeyGenerateCommand.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/KeyGenerateCommand.php
@@ -3,6 +3,7 @@
namespace Illuminate\Foundation\Console;
use Illuminate\Console\Command;
+use Illuminate\Encryption\Encrypter;
use Illuminate\Console\ConfirmableTrait;
class KeyGenerateCommand extends Command
@@ -30,7 +31,7 @@ class KeyGenerateCommand extends Command
*
* @return void
*/
- public function fire()
+ public function handle()
{
$key = $this->generateRandomKey();
@@ -47,7 +48,7 @@ class KeyGenerateCommand extends Command
$this->laravel['config']['app.key'] = $key;
- $this->info("Application key [$key] set successfully.");
+ $this->info('Application key set successfully.');
}
/**
@@ -57,9 +58,9 @@ class KeyGenerateCommand extends Command
*/
protected function generateRandomKey()
{
- return 'base64:'.base64_encode(random_bytes(
- $this->laravel['config']['app.cipher'] == 'AES-128-CBC' ? 16 : 32
- ));
+ return 'base64:'.base64_encode(
+ Encrypter::generateKey($this->laravel['config']['app.cipher'])
+ );
}
/**
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/ListenerMakeCommand.php b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/ListenerMakeCommand.php
index 971d1b76..7fed4e67 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/ListenerMakeCommand.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/ListenerMakeCommand.php
@@ -29,20 +29,6 @@ class ListenerMakeCommand extends GeneratorCommand
*/
protected $type = 'Listener';
- /**
- * Execute the console command.
- *
- * @return void
- */
- public function fire()
- {
- if (! $this->option('event')) {
- return $this->error('Missing required option: --event');
- }
-
- parent::fire();
- }
-
/**
* Build the class with the given name.
*
@@ -53,8 +39,11 @@ class ListenerMakeCommand extends GeneratorCommand
{
$event = $this->option('event');
- if (! Str::startsWith($event, $this->laravel->getNamespace()) &&
- ! Str::startsWith($event, 'Illuminate')) {
+ if (! Str::startsWith($event, [
+ $this->laravel->getNamespace(),
+ 'Illuminate',
+ '\\',
+ ])) {
$event = $this->laravel->getNamespace().'Events\\'.$event;
}
@@ -63,7 +52,7 @@ class ListenerMakeCommand extends GeneratorCommand
);
return str_replace(
- 'DummyFullEvent', $event, $stub
+ 'DummyFullEvent', trim($event, '\\'), $stub
);
}
@@ -75,10 +64,14 @@ class ListenerMakeCommand extends GeneratorCommand
protected function getStub()
{
if ($this->option('queued')) {
- return __DIR__.'/stubs/listener-queued.stub';
- } else {
- return __DIR__.'/stubs/listener.stub';
+ return $this->option('event')
+ ? __DIR__.'/stubs/listener-queued.stub'
+ : __DIR__.'/stubs/listener-queued-duck.stub';
}
+
+ return $this->option('event')
+ ? __DIR__.'/stubs/listener.stub'
+ : __DIR__.'/stubs/listener-duck.stub';
}
/**
@@ -111,9 +104,9 @@ class ListenerMakeCommand extends GeneratorCommand
protected function getOptions()
{
return [
- ['event', 'e', InputOption::VALUE_REQUIRED, 'The event class being listened for.'],
+ ['event', 'e', InputOption::VALUE_OPTIONAL, 'The event class being listened for'],
- ['queued', null, InputOption::VALUE_NONE, 'Indicates the event listener should be queued.'],
+ ['queued', null, InputOption::VALUE_NONE, 'Indicates the event listener should be queued'],
];
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/MailMakeCommand.php b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/MailMakeCommand.php
index 103fe639..d401a9ec 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/MailMakeCommand.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/MailMakeCommand.php
@@ -33,9 +33,9 @@ class MailMakeCommand extends GeneratorCommand
*
* @return void
*/
- public function fire()
+ public function handle()
{
- if (parent::fire() === false && ! $this->option('force')) {
+ if (parent::handle() === false && ! $this->option('force')) {
return;
}
@@ -108,9 +108,9 @@ class MailMakeCommand extends GeneratorCommand
protected function getOptions()
{
return [
- ['force', 'f', InputOption::VALUE_NONE, 'Create the class even if the mailable already exists.'],
+ ['force', 'f', InputOption::VALUE_NONE, 'Create the class even if the mailable already exists'],
- ['markdown', 'm', InputOption::VALUE_OPTIONAL, 'Create a new Markdown template for the mailable.'],
+ ['markdown', 'm', InputOption::VALUE_OPTIONAL, 'Create a new Markdown template for the mailable'],
];
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/ModelMakeCommand.php b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/ModelMakeCommand.php
index ab14f593..c0116999 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/ModelMakeCommand.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/ModelMakeCommand.php
@@ -34,10 +34,21 @@ class ModelMakeCommand extends GeneratorCommand
*
* @return void
*/
- public function fire()
+ public function handle()
{
- if (parent::fire() === false && ! $this->option('force')) {
- return;
+ if (parent::handle() === false && ! $this->option('force')) {
+ return false;
+ }
+
+ if ($this->option('all')) {
+ $this->input->setOption('factory', true);
+ $this->input->setOption('migration', true);
+ $this->input->setOption('controller', true);
+ $this->input->setOption('resource', true);
+ }
+
+ if ($this->option('factory')) {
+ $this->createFactory();
}
if ($this->option('migration')) {
@@ -49,6 +60,21 @@ class ModelMakeCommand extends GeneratorCommand
}
}
+ /**
+ * Create a model factory for the model.
+ *
+ * @return void
+ */
+ protected function createFactory()
+ {
+ $factory = Str::studly(class_basename($this->argument('name')));
+
+ $this->call('make:factory', [
+ 'name' => "{$factory}Factory",
+ '--model' => $this->qualifyClass($this->getNameInput()),
+ ]);
+ }
+
/**
* Create a migration file for the model.
*
@@ -56,7 +82,11 @@ class ModelMakeCommand extends GeneratorCommand
*/
protected function createMigration()
{
- $table = Str::plural(Str::snake(class_basename($this->argument('name'))));
+ $table = Str::snake(Str::pluralStudly(class_basename($this->argument('name'))));
+
+ if ($this->option('pivot')) {
+ $table = Str::singular($table);
+ }
$this->call('make:migration', [
'name' => "create_{$table}_table",
@@ -88,18 +118,11 @@ class ModelMakeCommand extends GeneratorCommand
*/
protected function getStub()
{
- return __DIR__.'/stubs/model.stub';
- }
+ if ($this->option('pivot')) {
+ return __DIR__.'/stubs/pivot.model.stub';
+ }
- /**
- * Get the default namespace for the class.
- *
- * @param string $rootNamespace
- * @return string
- */
- protected function getDefaultNamespace($rootNamespace)
- {
- return $rootNamespace;
+ return __DIR__.'/stubs/model.stub';
}
/**
@@ -110,13 +133,19 @@ class ModelMakeCommand extends GeneratorCommand
protected function getOptions()
{
return [
- ['force', 'f', InputOption::VALUE_NONE, 'Create the class even if the model already exists.'],
+ ['all', 'a', InputOption::VALUE_NONE, 'Generate a migration, factory, and resource controller for the model'],
- ['migration', 'm', InputOption::VALUE_NONE, 'Create a new migration file for the model.'],
+ ['controller', 'c', InputOption::VALUE_NONE, 'Create a new controller for the model'],
- ['controller', 'c', InputOption::VALUE_NONE, 'Create a new controller for the model.'],
+ ['factory', 'f', InputOption::VALUE_NONE, 'Create a new factory for the model'],
- ['resource', 'r', InputOption::VALUE_NONE, 'Indicates if the generated controller should be a resource controller.'],
+ ['force', null, InputOption::VALUE_NONE, 'Create the class even if the model already exists'],
+
+ ['migration', 'm', InputOption::VALUE_NONE, 'Create a new migration file for the model'],
+
+ ['pivot', 'p', InputOption::VALUE_NONE, 'Indicates if the generated model should be a custom intermediate table model'],
+
+ ['resource', 'r', InputOption::VALUE_NONE, 'Indicates if the generated controller should be a resource controller'],
];
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/NotificationMakeCommand.php b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/NotificationMakeCommand.php
index fd225bfe..40e9d849 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/NotificationMakeCommand.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/NotificationMakeCommand.php
@@ -33,9 +33,9 @@ class NotificationMakeCommand extends GeneratorCommand
*
* @return void
*/
- public function fire()
+ public function handle()
{
- if (parent::fire() === false && ! $this->option('force')) {
+ if (parent::handle() === false && ! $this->option('force')) {
return;
}
@@ -108,9 +108,9 @@ class NotificationMakeCommand extends GeneratorCommand
protected function getOptions()
{
return [
- ['force', 'f', InputOption::VALUE_NONE, 'Create the class even if the notification already exists.'],
+ ['force', 'f', InputOption::VALUE_NONE, 'Create the class even if the notification already exists'],
- ['markdown', 'm', InputOption::VALUE_OPTIONAL, 'Create a new Markdown template for the notification.'],
+ ['markdown', 'm', InputOption::VALUE_OPTIONAL, 'Create a new Markdown template for the notification'],
];
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/OptimizeCommand.php b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/OptimizeCommand.php
index b64156e1..af5d731e 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/OptimizeCommand.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/OptimizeCommand.php
@@ -3,8 +3,6 @@
namespace Illuminate\Foundation\Console;
use Illuminate\Console\Command;
-use Illuminate\Support\Composer;
-use Symfony\Component\Console\Input\InputOption;
class OptimizeCommand extends Command
{
@@ -20,57 +18,18 @@ class OptimizeCommand extends Command
*
* @var string
*/
- protected $description = 'Optimize the framework for better performance';
-
- /**
- * The composer instance.
- *
- * @var \Illuminate\Support\Composer
- */
- protected $composer;
-
- /**
- * Create a new optimize command instance.
- *
- * @param \Illuminate\Support\Composer $composer
- * @return void
- */
- public function __construct(Composer $composer)
- {
- parent::__construct();
-
- $this->composer = $composer;
- }
+ protected $description = 'Cache the framework bootstrap files';
/**
* Execute the console command.
*
* @return void
*/
- public function fire()
+ public function handle()
{
- $this->info('Generating optimized class loader');
+ $this->call('config:cache');
+ $this->call('route:cache');
- if ($this->option('psr')) {
- $this->composer->dumpAutoloads();
- } else {
- $this->composer->dumpOptimized();
- }
-
- $this->call('clear-compiled');
- }
-
- /**
- * Get the console command options.
- *
- * @return array
- */
- protected function getOptions()
- {
- return [
- ['force', null, InputOption::VALUE_NONE, 'Force the compiled class file to be written (deprecated).'],
-
- ['psr', null, InputOption::VALUE_NONE, 'Do not optimize Composer dump-autoload.'],
- ];
+ $this->info('Files cached successfully!');
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/PolicyMakeCommand.php b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/PolicyMakeCommand.php
index 8e006387..1d4f07ec 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/PolicyMakeCommand.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/PolicyMakeCommand.php
@@ -54,13 +54,15 @@ class PolicyMakeCommand extends GeneratorCommand
*/
protected function replaceUserNamespace($stub)
{
- if (! config('auth.providers.users.model')) {
+ $model = $this->userProviderModel();
+
+ if (! $model) {
return $stub;
}
return str_replace(
$this->rootNamespace().'User',
- config('auth.providers.users.model'),
+ $model,
$stub
);
}
@@ -90,11 +92,19 @@ class PolicyMakeCommand extends GeneratorCommand
$model = class_basename(trim($model, '\\'));
+ $dummyUser = class_basename($this->userProviderModel());
+
+ $dummyModel = Str::camel($model) === 'user' ? 'model' : $model;
+
+ $stub = str_replace('DocDummyModel', Str::snake($dummyModel, ' '), $stub);
+
$stub = str_replace('DummyModel', $model, $stub);
- $stub = str_replace('dummyModel', Str::camel($model), $stub);
+ $stub = str_replace('dummyModel', Str::camel($dummyModel), $stub);
- return str_replace('dummyPluralModel', Str::plural(Str::camel($model)), $stub);
+ $stub = str_replace('DummyUser', $dummyUser, $stub);
+
+ return str_replace('DocDummyPluralModel', Str::snake(Str::pluralStudly($dummyModel), ' '), $stub);
}
/**
@@ -128,7 +138,7 @@ class PolicyMakeCommand extends GeneratorCommand
protected function getOptions()
{
return [
- ['model', 'm', InputOption::VALUE_OPTIONAL, 'The model that the policy applies to.'],
+ ['model', 'm', InputOption::VALUE_OPTIONAL, 'The model that the policy applies to'],
];
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/RouteCacheCommand.php b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/RouteCacheCommand.php
index 890842e1..9d86f16f 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/RouteCacheCommand.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/RouteCacheCommand.php
@@ -48,13 +48,13 @@ class RouteCacheCommand extends Command
*
* @return void
*/
- public function fire()
+ public function handle()
{
$this->call('route:clear');
$routes = $this->getFreshApplicationRoutes();
- if (count($routes) == 0) {
+ if (count($routes) === 0) {
return $this->error("Your application doesn't have any routes.");
}
@@ -85,7 +85,7 @@ class RouteCacheCommand extends Command
/**
* Get a fresh application instance.
*
- * @return \Illuminate\Foundation\Application
+ * @return \Illuminate\Contracts\Foundation\Application
*/
protected function getFreshApplication()
{
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/RouteClearCommand.php b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/RouteClearCommand.php
index a14b280e..03fab1d9 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/RouteClearCommand.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/RouteClearCommand.php
@@ -46,7 +46,7 @@ class RouteClearCommand extends Command
*
* @return void
*/
- public function fire()
+ public function handle()
{
$this->files->delete($this->laravel->getCachedRoutesPath());
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/RouteListCommand.php b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/RouteListCommand.php
index 701cc70b..dd83e982 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/RouteListCommand.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/RouteListCommand.php
@@ -33,13 +33,6 @@ class RouteListCommand extends Command
*/
protected $router;
- /**
- * An array of all the registered routes.
- *
- * @var \Illuminate\Routing\RouteCollection
- */
- protected $routes;
-
/**
* The table headers for the command.
*
@@ -47,6 +40,13 @@ class RouteListCommand extends Command
*/
protected $headers = ['Domain', 'Method', 'URI', 'Name', 'Action', 'Middleware'];
+ /**
+ * The columns to display when using the "compact" flag.
+ *
+ * @var array
+ */
+ protected $compactColumns = ['method', 'uri', 'action'];
+
/**
* Create a new route command instance.
*
@@ -58,7 +58,6 @@ class RouteListCommand extends Command
parent::__construct();
$this->router = $router;
- $this->routes = $router->getRoutes();
}
/**
@@ -66,13 +65,17 @@ class RouteListCommand extends Command
*
* @return void
*/
- public function fire()
+ public function handle()
{
- if (count($this->routes) == 0) {
+ if (empty($this->router->getRoutes())) {
return $this->error("Your application doesn't have any routes.");
}
- $this->displayRoutes($this->getRoutes());
+ if (empty($routes = $this->getRoutes())) {
+ return $this->error("Your application doesn't have any routes matching the given criteria.");
+ }
+
+ $this->displayRoutes($routes);
}
/**
@@ -82,9 +85,9 @@ class RouteListCommand extends Command
*/
protected function getRoutes()
{
- $routes = collect($this->routes)->map(function ($route) {
+ $routes = collect($this->router->getRoutes())->map(function ($route) {
return $this->getRouteInformation($route);
- })->all();
+ })->filter()->all();
if ($sort = $this->option('sort')) {
$routes = $this->sortRoutes($sort, $routes);
@@ -94,7 +97,7 @@ class RouteListCommand extends Command
$routes = array_reverse($routes);
}
- return array_filter($routes);
+ return $this->pluckColumns($routes);
}
/**
@@ -106,11 +109,11 @@ class RouteListCommand extends Command
protected function getRouteInformation(Route $route)
{
return $this->filterRoute([
- 'host' => $route->domain(),
+ 'domain' => $route->domain(),
'method' => implode('|', $route->methods()),
'uri' => $route->uri(),
'name' => $route->getName(),
- 'action' => $route->getActionName(),
+ 'action' => ltrim($route->getActionName(), '\\'),
'middleware' => $this->getMiddleware($route),
]);
}
@@ -122,13 +125,26 @@ class RouteListCommand extends Command
* @param array $routes
* @return array
*/
- protected function sortRoutes($sort, $routes)
+ protected function sortRoutes($sort, array $routes)
{
return Arr::sort($routes, function ($route) use ($sort) {
return $route[$sort];
});
}
+ /**
+ * Remove unnecessary columns from the routes.
+ *
+ * @param array $routes
+ * @return array
+ */
+ protected function pluckColumns(array $routes)
+ {
+ return array_map(function ($route) {
+ return Arr::only($route, $this->getColumns());
+ }, $routes);
+ }
+
/**
* Display the route information on the console.
*
@@ -137,7 +153,13 @@ class RouteListCommand extends Command
*/
protected function displayRoutes(array $routes)
{
- $this->table($this->headers, $routes);
+ if ($this->option('json')) {
+ $this->line(json_encode(array_values($routes)));
+
+ return;
+ }
+
+ $this->table($this->getHeaders(), $routes);
}
/**
@@ -163,13 +185,64 @@ class RouteListCommand extends Command
{
if (($this->option('name') && ! Str::contains($route['name'], $this->option('name'))) ||
$this->option('path') && ! Str::contains($route['uri'], $this->option('path')) ||
- $this->option('method') && ! Str::contains($route['method'], $this->option('method'))) {
+ $this->option('method') && ! Str::contains($route['method'], strtoupper($this->option('method')))) {
return;
}
return $route;
}
+ /**
+ * Get the table headers for the visible columns.
+ *
+ * @return array
+ */
+ protected function getHeaders()
+ {
+ return Arr::only($this->headers, array_keys($this->getColumns()));
+ }
+
+ /**
+ * Get the column names to show (lowercase table headers).
+ *
+ * @return array
+ */
+ protected function getColumns()
+ {
+ $availableColumns = array_map('strtolower', $this->headers);
+
+ if ($this->option('compact')) {
+ return array_intersect($availableColumns, $this->compactColumns);
+ }
+
+ if ($columns = $this->option('columns')) {
+ return array_intersect($availableColumns, $this->parseColumns($columns));
+ }
+
+ return $availableColumns;
+ }
+
+ /**
+ * Parse the column list.
+ *
+ * @param array $columns
+ * @return array
+ */
+ protected function parseColumns(array $columns)
+ {
+ $results = [];
+
+ foreach ($columns as $i => $column) {
+ if (Str::contains($column, ',')) {
+ $results = array_merge($results, explode(',', $column));
+ } else {
+ $results[] = $column;
+ }
+ }
+
+ return $results;
+ }
+
/**
* Get the console command options.
*
@@ -178,15 +251,14 @@ class RouteListCommand extends Command
protected function getOptions()
{
return [
- ['method', null, InputOption::VALUE_OPTIONAL, 'Filter the routes by method.'],
-
- ['name', null, InputOption::VALUE_OPTIONAL, 'Filter the routes by name.'],
-
- ['path', null, InputOption::VALUE_OPTIONAL, 'Filter the routes by path.'],
-
- ['reverse', 'r', InputOption::VALUE_NONE, 'Reverse the ordering of the routes.'],
-
- ['sort', null, InputOption::VALUE_OPTIONAL, 'The column (host, method, uri, name, action, middleware) to sort by.', 'uri'],
+ ['columns', null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, 'Columns to include in the route table'],
+ ['compact', 'c', InputOption::VALUE_NONE, 'Only show method, URI and action columns'],
+ ['json', null, InputOption::VALUE_NONE, 'Output the route list as JSON'],
+ ['method', null, InputOption::VALUE_OPTIONAL, 'Filter the routes by method'],
+ ['name', null, InputOption::VALUE_OPTIONAL, 'Filter the routes by name'],
+ ['path', null, InputOption::VALUE_OPTIONAL, 'Filter the routes by path'],
+ ['reverse', 'r', InputOption::VALUE_NONE, 'Reverse the ordering of the routes'],
+ ['sort', null, InputOption::VALUE_OPTIONAL, 'The column (domain, method, uri, name, action, middleware) to sort by', 'uri'],
];
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/ServeCommand.php b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/ServeCommand.php
index 927fa424..60d9cce9 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/ServeCommand.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/ServeCommand.php
@@ -3,7 +3,7 @@
namespace Illuminate\Foundation\Console;
use Illuminate\Console\Command;
-use Symfony\Component\Process\ProcessUtils;
+use Illuminate\Support\ProcessUtils;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Process\PhpExecutableFinder;
@@ -23,20 +23,35 @@ class ServeCommand extends Command
*/
protected $description = 'Serve the application on the PHP development server';
+ /**
+ * The current port offset.
+ *
+ * @var int
+ */
+ protected $portOffset = 0;
+
/**
* Execute the console command.
*
- * @return void
+ * @return int
*
* @throws \Exception
*/
- public function fire()
+ public function handle()
{
- chdir($this->laravel->publicPath());
+ chdir(public_path());
$this->line("
Laravel development server started: host()}:{$this->port()}>");
- passthru($this->serverCommand());
+ passthru($this->serverCommand(), $status);
+
+ if ($status && $this->canTryAnotherPort()) {
+ $this->portOffset += 1;
+
+ return $this->handle();
+ }
+
+ return $status;
}
/**
@@ -46,11 +61,11 @@ class ServeCommand extends Command
*/
protected function serverCommand()
{
- return sprintf('%s -S %s:%s %s/server.php',
+ return sprintf('%s -S %s:%s %s',
ProcessUtils::escapeArgument((new PhpExecutableFinder)->find(false)),
$this->host(),
$this->port(),
- ProcessUtils::escapeArgument($this->laravel->basePath())
+ ProcessUtils::escapeArgument(base_path('server.php'))
);
}
@@ -71,7 +86,20 @@ class ServeCommand extends Command
*/
protected function port()
{
- return $this->input->getOption('port');
+ $port = $this->input->getOption('port') ?: 8000;
+
+ return $port + $this->portOffset;
+ }
+
+ /**
+ * Check if command has reached its max amount of port tries.
+ *
+ * @return bool
+ */
+ protected function canTryAnotherPort()
+ {
+ return is_null($this->input->getOption('port')) &&
+ ($this->input->getOption('tries') > $this->portOffset);
}
/**
@@ -82,9 +110,11 @@ class ServeCommand extends Command
protected function getOptions()
{
return [
- ['host', null, InputOption::VALUE_OPTIONAL, 'The host address to serve the application on.', '127.0.0.1'],
+ ['host', null, InputOption::VALUE_OPTIONAL, 'The host address to serve the application on', '127.0.0.1'],
- ['port', null, InputOption::VALUE_OPTIONAL, 'The port to serve the application on.', 8000],
+ ['port', null, InputOption::VALUE_OPTIONAL, 'The port to serve the application on', $_ENV['SERVER_PORT'] ?? null],
+
+ ['tries', null, InputOption::VALUE_OPTIONAL, 'The max number of ports to attempt to serve from', 10],
];
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/StorageLinkCommand.php b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/StorageLinkCommand.php
index ac29de9b..11e5c148 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/StorageLinkCommand.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/StorageLinkCommand.php
@@ -25,7 +25,7 @@ class StorageLinkCommand extends Command
*
* @return void
*/
- public function fire()
+ public function handle()
{
if (file_exists(public_path('storage'))) {
return $this->error('The "public/storage" directory already exists.');
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/TestMakeCommand.php b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/TestMakeCommand.php
index 3c633230..ea08d7cf 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/TestMakeCommand.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/TestMakeCommand.php
@@ -2,6 +2,7 @@
namespace Illuminate\Foundation\Console;
+use Illuminate\Support\Str;
use Illuminate\Console\GeneratorCommand;
class TestMakeCommand extends GeneratorCommand
@@ -36,9 +37,9 @@ class TestMakeCommand extends GeneratorCommand
{
if ($this->option('unit')) {
return __DIR__.'/stubs/unit-test.stub';
- } else {
- return __DIR__.'/stubs/test.stub';
}
+
+ return __DIR__.'/stubs/test.stub';
}
/**
@@ -49,9 +50,9 @@ class TestMakeCommand extends GeneratorCommand
*/
protected function getPath($name)
{
- $name = str_replace_first($this->rootNamespace(), '', $name);
+ $name = Str::replaceFirst($this->rootNamespace(), '', $name);
- return $this->laravel->basePath().'/tests'.str_replace('\\', '/', $name).'.php';
+ return base_path('tests').str_replace('\\', '/', $name).'.php';
}
/**
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/UpCommand.php b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/UpCommand.php
index 82d83850..9f659920 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/UpCommand.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/UpCommand.php
@@ -2,6 +2,7 @@
namespace Illuminate\Foundation\Console;
+use Exception;
use Illuminate\Console\Command;
class UpCommand extends Command
@@ -23,12 +24,26 @@ class UpCommand extends Command
/**
* Execute the console command.
*
- * @return void
+ * @return int
*/
- public function fire()
+ public function handle()
{
- @unlink($this->laravel->storagePath().'/framework/down');
+ try {
+ if (! file_exists(storage_path('framework/down'))) {
+ $this->comment('Application is already up.');
- $this->info('Application is now live.');
+ return true;
+ }
+
+ unlink(storage_path('framework/down'));
+
+ $this->info('Application is now live.');
+ } catch (Exception $e) {
+ $this->error('Failed to disable maintenance mode.');
+
+ $this->error($e->getMessage());
+
+ return 1;
+ }
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/VendorPublishCommand.php b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/VendorPublishCommand.php
index 73f1c3a3..5c878cdc 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/VendorPublishCommand.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/VendorPublishCommand.php
@@ -2,6 +2,7 @@
namespace Illuminate\Foundation\Console;
+use Illuminate\Support\Arr;
use Illuminate\Console\Command;
use League\Flysystem\MountManager;
use Illuminate\Filesystem\Filesystem;
@@ -18,14 +19,29 @@ class VendorPublishCommand extends Command
*/
protected $files;
+ /**
+ * The provider to publish.
+ *
+ * @var string
+ */
+ protected $provider = null;
+
+ /**
+ * The tags to publish.
+ *
+ * @var array
+ */
+ protected $tags = [];
+
/**
* The console command signature.
*
* @var string
*/
- protected $signature = 'vendor:publish {--force : Overwrite any existing files.}
- {--provider= : The service provider that has assets you want to publish.}
- {--tag=* : One or many tags that have assets you want to publish.}';
+ protected $signature = 'vendor:publish {--force : Overwrite any existing files}
+ {--all : Publish assets for all service providers without prompt}
+ {--provider= : The service provider that has assets you want to publish}
+ {--tag=* : One or many tags that have assets you want to publish}';
/**
* The console command description.
@@ -52,13 +68,85 @@ class VendorPublishCommand extends Command
*
* @return void
*/
- public function fire()
+ public function handle()
{
- $tags = $this->option('tag') ?: [null];
+ $this->determineWhatShouldBePublished();
- foreach ((array) $tags as $tag) {
+ foreach ($this->tags ?: [null] as $tag) {
$this->publishTag($tag);
}
+
+ $this->info('Publishing complete.');
+ }
+
+ /**
+ * Determine the provider or tag(s) to publish.
+ *
+ * @return void
+ */
+ protected function determineWhatShouldBePublished()
+ {
+ if ($this->option('all')) {
+ return;
+ }
+
+ [$this->provider, $this->tags] = [
+ $this->option('provider'), (array) $this->option('tag'),
+ ];
+
+ if (! $this->provider && ! $this->tags) {
+ $this->promptForProviderOrTag();
+ }
+ }
+
+ /**
+ * Prompt for which provider or tag to publish.
+ *
+ * @return void
+ */
+ protected function promptForProviderOrTag()
+ {
+ $choice = $this->choice(
+ "Which provider or tag's files would you like to publish?",
+ $choices = $this->publishableChoices()
+ );
+
+ if ($choice == $choices[0] || is_null($choice)) {
+ return;
+ }
+
+ $this->parseChoice($choice);
+ }
+
+ /**
+ * The choices available via the prompt.
+ *
+ * @return array
+ */
+ protected function publishableChoices()
+ {
+ return array_merge(
+ ['Publish files from all providers and tags listed below'],
+ preg_filter('/^/', 'Provider: ', Arr::sort(ServiceProvider::publishableProviders())),
+ preg_filter('/^/', 'Tag: ', Arr::sort(ServiceProvider::publishableGroups()))
+ );
+ }
+
+ /**
+ * Parse the answer that was given via the prompt.
+ *
+ * @param string $choice
+ * @return void
+ */
+ protected function parseChoice($choice)
+ {
+ [$type, $value] = explode(': ', strip_tags($choice));
+
+ if ($type === 'Provider') {
+ $this->provider = $value;
+ } elseif ($type === 'Tag') {
+ $this->tags = [$value];
+ }
}
/**
@@ -72,8 +160,6 @@ class VendorPublishCommand extends Command
foreach ($this->pathsToPublish($tag) as $from => $to) {
$this->publishItem($from, $to);
}
-
- $this->info('Publishing complete.');
}
/**
@@ -85,7 +171,7 @@ class VendorPublishCommand extends Command
protected function pathsToPublish($tag)
{
return ServiceProvider::pathsToPublish(
- $this->option('provider'), $tag
+ $this->provider, $tag
);
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/ViewClearCommand.php b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/ViewClearCommand.php
index c7e443e7..251e3937 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/ViewClearCommand.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/ViewClearCommand.php
@@ -46,8 +46,10 @@ class ViewClearCommand extends Command
* Execute the console command.
*
* @return void
+ *
+ * @throws \RuntimeException
*/
- public function fire()
+ public function handle()
{
$path = $this->laravel['config']['view.compiled'];
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/stubs/event.stub b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/stubs/event.stub
index e30cccfd..e1e46c3c 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/stubs/event.stub
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/stubs/event.stub
@@ -27,7 +27,7 @@ class DummyClass
/**
* Get the channels the event should broadcast on.
*
- * @return Channel|array
+ * @return \Illuminate\Broadcasting\Channel|array
*/
public function broadcastOn()
{
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/stubs/policy.plain.stub b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/stubs/policy.plain.stub
index e8221bef..82834fb3 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/stubs/policy.plain.stub
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/stubs/policy.plain.stub
@@ -2,7 +2,7 @@
namespace DummyNamespace;
-use DummyRootNamespaceUser;
+use NamespacedDummyUserModel;
use Illuminate\Auth\Access\HandlesAuthorization;
class DummyClass
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/stubs/policy.stub b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/stubs/policy.stub
index 451089bc..f3b7e59d 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/stubs/policy.stub
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/stubs/policy.stub
@@ -2,57 +2,92 @@
namespace DummyNamespace;
-use DummyRootNamespaceUser;
+use NamespacedDummyUserModel;
use NamespacedDummyModel;
use Illuminate\Auth\Access\HandlesAuthorization;
class DummyClass
{
use HandlesAuthorization;
-
+
/**
- * Determine whether the user can view the dummyModel.
+ * Determine whether the user can view any DocDummyPluralModel.
*
- * @param \DummyRootNamespaceUser $user
- * @param \NamespacedDummyModel $dummyModel
+ * @param \NamespacedDummyUserModel $user
* @return mixed
*/
- public function view(User $user, DummyModel $dummyModel)
+ public function viewAny(DummyUser $user)
{
//
}
/**
- * Determine whether the user can create dummyPluralModel.
+ * Determine whether the user can view the DocDummyModel.
*
- * @param \DummyRootNamespaceUser $user
+ * @param \NamespacedDummyUserModel $user
+ * @param \NamespacedDummyModel $dummyModel
* @return mixed
*/
- public function create(User $user)
+ public function view(DummyUser $user, DummyModel $dummyModel)
{
//
}
/**
- * Determine whether the user can update the dummyModel.
+ * Determine whether the user can create DocDummyPluralModel.
*
- * @param \DummyRootNamespaceUser $user
- * @param \NamespacedDummyModel $dummyModel
+ * @param \NamespacedDummyUserModel $user
* @return mixed
*/
- public function update(User $user, DummyModel $dummyModel)
+ public function create(DummyUser $user)
{
//
}
/**
- * Determine whether the user can delete the dummyModel.
+ * Determine whether the user can update the DocDummyModel.
*
- * @param \DummyRootNamespaceUser $user
+ * @param \NamespacedDummyUserModel $user
* @param \NamespacedDummyModel $dummyModel
* @return mixed
*/
- public function delete(User $user, DummyModel $dummyModel)
+ public function update(DummyUser $user, DummyModel $dummyModel)
+ {
+ //
+ }
+
+ /**
+ * Determine whether the user can delete the DocDummyModel.
+ *
+ * @param \NamespacedDummyUserModel $user
+ * @param \NamespacedDummyModel $dummyModel
+ * @return mixed
+ */
+ public function delete(DummyUser $user, DummyModel $dummyModel)
+ {
+ //
+ }
+
+ /**
+ * Determine whether the user can restore the DocDummyModel.
+ *
+ * @param \NamespacedDummyUserModel $user
+ * @param \NamespacedDummyModel $dummyModel
+ * @return mixed
+ */
+ public function restore(DummyUser $user, DummyModel $dummyModel)
+ {
+ //
+ }
+
+ /**
+ * Determine whether the user can permanently delete the DocDummyModel.
+ *
+ * @param \NamespacedDummyUserModel $user
+ * @param \NamespacedDummyModel $dummyModel
+ * @return mixed
+ */
+ public function forceDelete(DummyUser $user, DummyModel $dummyModel)
{
//
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/stubs/provider.stub b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/stubs/provider.stub
index 4303cf7b..fcd5d124 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/stubs/provider.stub
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/stubs/provider.stub
@@ -7,17 +7,7 @@ use Illuminate\Support\ServiceProvider;
class DummyClass extends ServiceProvider
{
/**
- * Bootstrap the application services.
- *
- * @return void
- */
- public function boot()
- {
- //
- }
-
- /**
- * Register the application services.
+ * Register services.
*
* @return void
*/
@@ -25,4 +15,14 @@ class DummyClass extends ServiceProvider
{
//
}
+
+ /**
+ * Bootstrap services.
+ *
+ * @return void
+ */
+ public function boot()
+ {
+ //
+ }
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/stubs/test.stub b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/stubs/test.stub
index dd804dc9..9de1d020 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/stubs/test.stub
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/stubs/test.stub
@@ -3,19 +3,20 @@
namespace DummyNamespace;
use Tests\TestCase;
-use Illuminate\Foundation\Testing\WithoutMiddleware;
-use Illuminate\Foundation\Testing\DatabaseMigrations;
-use Illuminate\Foundation\Testing\DatabaseTransactions;
+use Illuminate\Foundation\Testing\WithFaker;
+use Illuminate\Foundation\Testing\RefreshDatabase;
class DummyClass extends TestCase
{
/**
- * A basic test example.
+ * A basic feature test example.
*
* @return void
*/
public function testExample()
{
- $this->assertTrue(true);
+ $response = $this->get('/');
+
+ $response->assertStatus(200);
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/stubs/unit-test.stub b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/stubs/unit-test.stub
index 315e7078..00deed88 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/stubs/unit-test.stub
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Console/stubs/unit-test.stub
@@ -3,13 +3,13 @@
namespace DummyNamespace;
use Tests\TestCase;
-use Illuminate\Foundation\Testing\DatabaseMigrations;
-use Illuminate\Foundation\Testing\DatabaseTransactions;
+use Illuminate\Foundation\Testing\WithFaker;
+use Illuminate\Foundation\Testing\RefreshDatabase;
class DummyClass extends TestCase
{
/**
- * A basic test example.
+ * A basic unit test example.
*
* @return void
*/
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/EnvironmentDetector.php b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/EnvironmentDetector.php
index 205f73bc..2ff154c6 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/EnvironmentDetector.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/EnvironmentDetector.php
@@ -3,7 +3,6 @@
namespace Illuminate\Foundation;
use Closure;
-use Illuminate\Support\Arr;
use Illuminate\Support\Str;
class EnvironmentDetector
@@ -48,7 +47,7 @@ class EnvironmentDetector
// and if it was that automatically overrides as the environment. Otherwise, we
// will check the environment as a "web" request like a typical HTTP request.
if (! is_null($value = $this->getEnvironmentArgument($args))) {
- return head(array_slice(explode('=', $value), 1));
+ return $value;
}
return $this->detectWebEnvironment($callback);
@@ -62,8 +61,14 @@ class EnvironmentDetector
*/
protected function getEnvironmentArgument(array $args)
{
- return Arr::first($args, function ($value) {
- return Str::startsWith($value, '--env');
- });
+ foreach ($args as $i => $value) {
+ if ($value === '--env') {
+ return $args[$i + 1] ?? null;
+ }
+
+ if (Str::startsWith($value, '--env')) {
+ return head(array_slice(explode('=', $value), 1));
+ }
+ }
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php
index f737c673..59221deb 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php
@@ -3,22 +3,37 @@
namespace Illuminate\Foundation\Exceptions;
use Exception;
+use Throwable;
+use Whoops\Run as Whoops;
+use Illuminate\Support\Arr;
use Psr\Log\LoggerInterface;
use Illuminate\Http\Response;
+use Illuminate\Routing\Router;
+use Illuminate\Http\JsonResponse;
+use Illuminate\Support\Facades\Auth;
+use Illuminate\Support\Facades\View;
+use Illuminate\Support\ViewErrorBag;
+use Whoops\Handler\HandlerInterface;
use Illuminate\Http\RedirectResponse;
use Illuminate\Auth\AuthenticationException;
use Illuminate\Contracts\Container\Container;
+use Illuminate\Contracts\Support\Responsable;
+use Illuminate\Session\TokenMismatchException;
use Illuminate\Validation\ValidationException;
use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Http\Exceptions\HttpResponseException;
use Symfony\Component\Debug\Exception\FlattenException;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Symfony\Component\HttpKernel\Exception\HttpException;
+use Illuminate\Contracts\Container\BindingResolutionException;
use Symfony\Component\Console\Application as ConsoleApplication;
use Symfony\Component\HttpFoundation\Response as SymfonyResponse;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
+use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
+use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
use Symfony\Component\Debug\ExceptionHandler as SymfonyExceptionHandler;
use Illuminate\Contracts\Debug\ExceptionHandler as ExceptionHandlerContract;
+use Symfony\Component\HttpFoundation\Exception\SuspiciousOperationException;
use Symfony\Component\HttpFoundation\RedirectResponse as SymfonyRedirectResponse;
class Handler implements ExceptionHandlerContract
@@ -31,12 +46,38 @@ class Handler implements ExceptionHandlerContract
protected $container;
/**
- * A list of the exception types that should not be reported.
+ * A list of the exception types that are not reported.
*
* @var array
*/
protected $dontReport = [];
+ /**
+ * A list of the internal exception types that should not be reported.
+ *
+ * @var array
+ */
+ protected $internalDontReport = [
+ AuthenticationException::class,
+ AuthorizationException::class,
+ HttpException::class,
+ HttpResponseException::class,
+ ModelNotFoundException::class,
+ SuspiciousOperationException::class,
+ TokenMismatchException::class,
+ ValidationException::class,
+ ];
+
+ /**
+ * A list of the inputs that are never flashed for validation exceptions.
+ *
+ * @var array
+ */
+ protected $dontFlash = [
+ 'password',
+ 'password_confirmation',
+ ];
+
/**
* Create a new exception handler instance.
*
@@ -52,7 +93,7 @@ class Handler implements ExceptionHandlerContract
* Report or log an exception.
*
* @param \Exception $e
- * @return void
+ * @return mixed
*
* @throws \Exception
*/
@@ -62,13 +103,20 @@ class Handler implements ExceptionHandlerContract
return;
}
+ if (is_callable($reportCallable = [$e, 'report'])) {
+ return $this->container->call($reportCallable);
+ }
+
try {
$logger = $this->container->make(LoggerInterface::class);
} catch (Exception $ex) {
- throw $e; // throw the original exception
+ throw $e;
}
- $logger->error($e);
+ $logger->error(
+ $e->getMessage(),
+ array_merge($this->context(), ['exception' => $e]
+ ));
}
/**
@@ -90,22 +138,45 @@ class Handler implements ExceptionHandlerContract
*/
protected function shouldntReport(Exception $e)
{
- $dontReport = array_merge($this->dontReport, [HttpResponseException::class]);
+ $dontReport = array_merge($this->dontReport, $this->internalDontReport);
- return ! is_null(collect($dontReport)->first(function ($type) use ($e) {
+ return ! is_null(Arr::first($dontReport, function ($type) use ($e) {
return $e instanceof $type;
}));
}
+ /**
+ * Get the default context variables for logging.
+ *
+ * @return array
+ */
+ protected function context()
+ {
+ try {
+ return array_filter([
+ 'userId' => Auth::id(),
+ // 'email' => optional(Auth::user())->email,
+ ]);
+ } catch (Throwable $e) {
+ return [];
+ }
+ }
+
/**
* Render an exception into a response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $e
- * @return \Symfony\Component\HttpFoundation\Response
+ * @return \Illuminate\Http\Response|\Symfony\Component\HttpFoundation\Response
*/
public function render($request, Exception $e)
{
+ if (method_exists($e, 'render') && $response = $e->render($request)) {
+ return Router::toResponse($request, $response);
+ } elseif ($e instanceof Responsable) {
+ return $e->toResponse($request);
+ }
+
$e = $this->prepareException($e);
if ($e instanceof HttpResponseException) {
@@ -116,7 +187,9 @@ class Handler implements ExceptionHandlerContract
return $this->convertValidationExceptionToResponse($e, $request);
}
- return $this->prepareResponse($request, $e);
+ return $request->expectsJson()
+ ? $this->prepareJsonResponse($request, $e)
+ : $this->prepareResponse($request, $e);
}
/**
@@ -130,12 +203,30 @@ class Handler implements ExceptionHandlerContract
if ($e instanceof ModelNotFoundException) {
$e = new NotFoundHttpException($e->getMessage(), $e);
} elseif ($e instanceof AuthorizationException) {
- $e = new HttpException(403, $e->getMessage());
+ $e = new AccessDeniedHttpException($e->getMessage(), $e);
+ } elseif ($e instanceof TokenMismatchException) {
+ $e = new HttpException(419, $e->getMessage(), $e);
+ } elseif ($e instanceof SuspiciousOperationException) {
+ $e = new NotFoundHttpException('Bad hostname provided.', $e);
}
return $e;
}
+ /**
+ * Convert an authentication exception into a response.
+ *
+ * @param \Illuminate\Http\Request $request
+ * @param \Illuminate\Auth\AuthenticationException $exception
+ * @return \Symfony\Component\HttpFoundation\Response
+ */
+ protected function unauthenticated($request, AuthenticationException $exception)
+ {
+ return $request->expectsJson()
+ ? response()->json(['message' => $exception->getMessage()], 401)
+ : redirect()->guest($exception->redirectTo() ?? route('login'));
+ }
+
/**
* Create a response object from the given validation exception.
*
@@ -149,19 +240,42 @@ class Handler implements ExceptionHandlerContract
return $e->response;
}
- $errors = $e->validator->errors()->getMessages();
-
- if ($request->expectsJson()) {
- return response()->json($errors, 422);
- }
-
- return redirect()->back()->withInput(
- $request->input()
- )->withErrors($errors);
+ return $request->expectsJson()
+ ? $this->invalidJson($request, $e)
+ : $this->invalid($request, $e);
}
/**
- * Prepare response containing exception render.
+ * Convert a validation exception into a response.
+ *
+ * @param \Illuminate\Http\Request $request
+ * @param \Illuminate\Validation\ValidationException $exception
+ * @return \Illuminate\Http\Response
+ */
+ protected function invalid($request, ValidationException $exception)
+ {
+ return redirect($exception->redirectTo ?? url()->previous())
+ ->withInput(Arr::except($request->input(), $this->dontFlash))
+ ->withErrors($exception->errors(), $exception->errorBag);
+ }
+
+ /**
+ * Convert a validation exception into a JSON response.
+ *
+ * @param \Illuminate\Http\Request $request
+ * @param \Illuminate\Validation\ValidationException $exception
+ * @return \Illuminate\Http\JsonResponse
+ */
+ protected function invalidJson($request, ValidationException $exception)
+ {
+ return response()->json([
+ 'message' => $exception->getMessage(),
+ 'errors' => $exception->errors(),
+ ], $exception->status);
+ }
+
+ /**
+ * Prepare a response for the given exception.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $e
@@ -169,33 +283,17 @@ class Handler implements ExceptionHandlerContract
*/
protected function prepareResponse($request, Exception $e)
{
- if ($this->isHttpException($e)) {
- return $this->toIlluminateResponse($this->renderHttpException($e), $e);
- } else {
+ if (! $this->isHttpException($e) && config('app.debug')) {
return $this->toIlluminateResponse($this->convertExceptionToResponse($e), $e);
}
- }
- /**
- * Render the given HttpException.
- *
- * @param \Symfony\Component\HttpKernel\Exception\HttpException $e
- * @return \Symfony\Component\HttpFoundation\Response
- */
- protected function renderHttpException(HttpException $e)
- {
- $status = $e->getStatusCode();
-
- view()->replaceNamespace('errors', [
- resource_path('views/errors'),
- __DIR__.'/views',
- ]);
-
- if (view()->exists("errors::{$status}")) {
- return response()->view("errors::{$status}", ['exception' => $e], $status, $e->getHeaders());
- } else {
- return $this->convertExceptionToResponse($e);
+ if (! $this->isHttpException($e)) {
+ $e = new HttpException(500, $e->getMessage());
}
+
+ return $this->toIlluminateResponse(
+ $this->renderHttpException($e), $e
+ );
}
/**
@@ -206,11 +304,107 @@ class Handler implements ExceptionHandlerContract
*/
protected function convertExceptionToResponse(Exception $e)
{
- $e = FlattenException::create($e);
+ return SymfonyResponse::create(
+ $this->renderExceptionContent($e),
+ $this->isHttpException($e) ? $e->getStatusCode() : 500,
+ $this->isHttpException($e) ? $e->getHeaders() : []
+ );
+ }
- $handler = new SymfonyExceptionHandler(config('app.debug', false));
+ /**
+ * Get the response content for the given exception.
+ *
+ * @param \Exception $e
+ * @return string
+ */
+ protected function renderExceptionContent(Exception $e)
+ {
+ try {
+ return config('app.debug') && class_exists(Whoops::class)
+ ? $this->renderExceptionWithWhoops($e)
+ : $this->renderExceptionWithSymfony($e, config('app.debug'));
+ } catch (Exception $e) {
+ return $this->renderExceptionWithSymfony($e, config('app.debug'));
+ }
+ }
- return SymfonyResponse::create($handler->getHtml($e), $e->getStatusCode(), $e->getHeaders());
+ /**
+ * Render an exception to a string using "Whoops".
+ *
+ * @param \Exception $e
+ * @return string
+ */
+ protected function renderExceptionWithWhoops(Exception $e)
+ {
+ return tap(new Whoops, function ($whoops) {
+ $whoops->pushHandler($this->whoopsHandler());
+
+ $whoops->writeToOutput(false);
+
+ $whoops->allowQuit(false);
+ })->handleException($e);
+ }
+
+ /**
+ * Get the Whoops handler for the application.
+ *
+ * @return \Whoops\Handler\Handler
+ */
+ protected function whoopsHandler()
+ {
+ try {
+ return app(HandlerInterface::class);
+ } catch (BindingResolutionException $e) {
+ return (new WhoopsHandler)->forDebug();
+ }
+ }
+
+ /**
+ * Render an exception to a string using Symfony.
+ *
+ * @param \Exception $e
+ * @param bool $debug
+ * @return string
+ */
+ protected function renderExceptionWithSymfony(Exception $e, $debug)
+ {
+ return (new SymfonyExceptionHandler($debug))->getHtml(
+ FlattenException::create($e)
+ );
+ }
+
+ /**
+ * Render the given HttpException.
+ *
+ * @param \Symfony\Component\HttpKernel\Exception\HttpExceptionInterface $e
+ * @return \Symfony\Component\HttpFoundation\Response
+ */
+ protected function renderHttpException(HttpExceptionInterface $e)
+ {
+ $this->registerErrorViewPaths();
+
+ if (view()->exists($view = "errors::{$e->getStatusCode()}")) {
+ return response()->view($view, [
+ 'errors' => new ViewErrorBag,
+ 'exception' => $e,
+ ], $e->getStatusCode(), $e->getHeaders());
+ }
+
+ return $this->convertExceptionToResponse($e);
+ }
+
+ /**
+ * Register the error template hint paths.
+ *
+ * @return void
+ */
+ protected function registerErrorViewPaths()
+ {
+ $paths = collect(config('view.paths'));
+
+ View::replaceNamespace('errors', $paths->map(function ($path) {
+ return "{$path}/errors";
+ })->push(__DIR__.'/views')->all());
}
/**
@@ -223,14 +417,56 @@ class Handler implements ExceptionHandlerContract
protected function toIlluminateResponse($response, Exception $e)
{
if ($response instanceof SymfonyRedirectResponse) {
- $response = new RedirectResponse($response->getTargetUrl(), $response->getStatusCode(), $response->headers->all());
+ $response = new RedirectResponse(
+ $response->getTargetUrl(), $response->getStatusCode(), $response->headers->all()
+ );
} else {
- $response = new Response($response->getContent(), $response->getStatusCode(), $response->headers->all());
+ $response = new Response(
+ $response->getContent(), $response->getStatusCode(), $response->headers->all()
+ );
}
return $response->withException($e);
}
+ /**
+ * Prepare a JSON response for the given exception.
+ *
+ * @param \Illuminate\Http\Request $request
+ * @param \Exception $e
+ * @return \Illuminate\Http\JsonResponse
+ */
+ protected function prepareJsonResponse($request, Exception $e)
+ {
+ return new JsonResponse(
+ $this->convertExceptionToArray($e),
+ $this->isHttpException($e) ? $e->getStatusCode() : 500,
+ $this->isHttpException($e) ? $e->getHeaders() : [],
+ JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES
+ );
+ }
+
+ /**
+ * Convert the given exception to an array.
+ *
+ * @param \Exception $e
+ * @return array
+ */
+ protected function convertExceptionToArray(Exception $e)
+ {
+ return config('app.debug') ? [
+ 'message' => $e->getMessage(),
+ 'exception' => get_class($e),
+ 'file' => $e->getFile(),
+ 'line' => $e->getLine(),
+ 'trace' => collect($e->getTrace())->map(function ($trace) {
+ return Arr::except($trace, ['args']);
+ })->all(),
+ ] : [
+ 'message' => $this->isHttpException($e) ? $e->getMessage() : 'Server Error',
+ ];
+ }
+
/**
* Render an exception to the console.
*
@@ -251,6 +487,6 @@ class Handler implements ExceptionHandlerContract
*/
protected function isHttpException(Exception $e)
{
- return $e instanceof HttpException;
+ return $e instanceof HttpExceptionInterface;
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/views/503.blade.php b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/views/503.blade.php
index 756f745c..acd38100 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/views/503.blade.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/views/503.blade.php
@@ -1,56 +1,5 @@
-
-
-
-
-
-
+@extends('errors::minimal')
- Service Unavailable
-
-
-
-
-
-
-
-
-
-
-
- Das Tippspiel wird gerade gewartet.
-
-
-
-
-
+@section('title', __('Service Unavailable'))
+@section('code', '503')
+@section('message', __($exception->getMessage() ?: 'Service Unavailable'))
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Http/Exceptions/MaintenanceModeException.php b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Http/Exceptions/MaintenanceModeException.php
index 6ee1de62..45c76b22 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Http/Exceptions/MaintenanceModeException.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Http/Exceptions/MaintenanceModeException.php
@@ -3,7 +3,8 @@
namespace Illuminate\Foundation\Http\Exceptions;
use Exception;
-use Carbon\Carbon;
+use Illuminate\Support\Carbon;
+use Illuminate\Support\Facades\Date;
use Symfony\Component\HttpKernel\Exception\ServiceUnavailableHttpException;
class MaintenanceModeException extends ServiceUnavailableHttpException
@@ -11,7 +12,7 @@ class MaintenanceModeException extends ServiceUnavailableHttpException
/**
* When the application was put in maintenance mode.
*
- * @var \Carbon\Carbon
+ * @var \Illuminate\Support\Carbon
*/
public $wentDownAt;
@@ -25,7 +26,7 @@ class MaintenanceModeException extends ServiceUnavailableHttpException
/**
* When the application should next be available.
*
- * @var \Carbon\Carbon
+ * @var \Illuminate\Support\Carbon
*/
public $willBeAvailableAt;
@@ -33,9 +34,9 @@ class MaintenanceModeException extends ServiceUnavailableHttpException
* Create a new exception instance.
*
* @param int $time
- * @param int $retryAfter
- * @param string $message
- * @param \Exception $previous
+ * @param int|null $retryAfter
+ * @param string|null $message
+ * @param \Exception|null $previous
* @param int $code
* @return void
*/
@@ -43,12 +44,12 @@ class MaintenanceModeException extends ServiceUnavailableHttpException
{
parent::__construct($retryAfter, $message, $previous, $code);
- $this->wentDownAt = Carbon::createFromTimestamp($time);
+ $this->wentDownAt = Date::createFromTimestamp($time);
if ($retryAfter) {
$this->retryAfter = $retryAfter;
- $this->willBeAvailableAt = Carbon::createFromTimestamp($time)->addSeconds($this->retryAfter);
+ $this->willBeAvailableAt = Date::instance(Carbon::createFromTimestamp($time)->addRealSeconds($this->retryAfter));
}
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Http/FormRequest.php b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Http/FormRequest.php
index de2ef7d6..a67b2c3c 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Http/FormRequest.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Http/FormRequest.php
@@ -3,7 +3,6 @@
namespace Illuminate\Foundation\Http;
use Illuminate\Http\Request;
-use Illuminate\Http\JsonResponse;
use Illuminate\Routing\Redirector;
use Illuminate\Contracts\Container\Container;
use Illuminate\Contracts\Validation\Validator;
@@ -60,11 +59,11 @@ class FormRequest extends Request implements ValidatesWhenResolved
protected $errorBag = 'default';
/**
- * The input keys that should not be flashed on redirect.
+ * The validator instance.
*
- * @var array
+ * @var \Illuminate\Contracts\Validation\Validator
*/
- protected $dontFlash = ['password', 'password_confirmation'];
+ protected $validator;
/**
* Get the validator instance for the request.
@@ -73,6 +72,10 @@ class FormRequest extends Request implements ValidatesWhenResolved
*/
protected function getValidatorInstance()
{
+ if ($this->validator) {
+ return $this->validator;
+ }
+
$factory = $this->container->make(ValidationFactory::class);
if (method_exists($this, 'validator')) {
@@ -85,7 +88,9 @@ class FormRequest extends Request implements ValidatesWhenResolved
$this->withValidator($validator);
}
- return $validator;
+ $this->setValidator($validator);
+
+ return $this->validator;
}
/**
@@ -122,37 +127,9 @@ class FormRequest extends Request implements ValidatesWhenResolved
*/
protected function failedValidation(Validator $validator)
{
- throw new ValidationException($validator, $this->response(
- $this->formatErrors($validator)
- ));
- }
-
- /**
- * Get the proper failed validation response for the request.
- *
- * @param array $errors
- * @return \Symfony\Component\HttpFoundation\Response
- */
- public function response(array $errors)
- {
- if ($this->expectsJson()) {
- return new JsonResponse($errors, 422);
- }
-
- return $this->redirector->to($this->getRedirectUrl())
- ->withInput($this->except($this->dontFlash))
- ->withErrors($errors, $this->errorBag);
- }
-
- /**
- * Format the errors from the given Validator instance.
- *
- * @param \Illuminate\Contracts\Validation\Validator $validator
- * @return array
- */
- protected function formatErrors(Validator $validator)
- {
- return $validator->getMessageBag()->toArray();
+ throw (new ValidationException($validator))
+ ->errorBag($this->errorBag)
+ ->redirectTo($this->getRedirectUrl());
}
/**
@@ -186,7 +163,7 @@ class FormRequest extends Request implements ValidatesWhenResolved
return $this->container->call([$this, 'authorize']);
}
- return false;
+ return true;
}
/**
@@ -201,6 +178,16 @@ class FormRequest extends Request implements ValidatesWhenResolved
throw new AuthorizationException('This action is unauthorized.');
}
+ /**
+ * Get the validated data from the request.
+ *
+ * @return array
+ */
+ public function validated()
+ {
+ return $this->validator->validated();
+ }
+
/**
* Get custom messages for validator errors.
*
@@ -221,6 +208,19 @@ class FormRequest extends Request implements ValidatesWhenResolved
return [];
}
+ /**
+ * Set the Validator instance.
+ *
+ * @param \Illuminate\Contracts\Validation\Validator $validator
+ * @return $this
+ */
+ public function setValidator(Validator $validator)
+ {
+ $this->validator = $validator;
+
+ return $this;
+ }
+
/**
* Set the Redirector instance.
*
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php
index f3758328..022dd8ee 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php
@@ -66,7 +66,7 @@ class Kernel implements KernelContract
/**
* The priority-sorted list of middleware.
*
- * Forces the listed middleware to always be in the given order.
+ * Forces non-global middleware to always be in the given order.
*
* @var array
*/
@@ -210,7 +210,7 @@ class Kernel implements KernelContract
continue;
}
- list($name, $parameters) = $this->parseMiddleware($middleware);
+ [$name] = $this->parseMiddleware($middleware);
$instance = $this->app->make($name);
@@ -243,7 +243,7 @@ class Kernel implements KernelContract
*/
protected function parseMiddleware($middleware)
{
- list($name, $parameters) = array_pad(explode(':', $middleware, 2), 2, []);
+ [$name, $parameters] = array_pad(explode(':', $middleware, 2), 2, []);
if (is_string($parameters)) {
$parameters = explode(',', $parameters);
@@ -326,6 +326,26 @@ class Kernel implements KernelContract
return $this->app[ExceptionHandler::class]->render($request, $e);
}
+ /**
+ * Get the application's route middleware groups.
+ *
+ * @return array
+ */
+ public function getMiddlewareGroups()
+ {
+ return $this->middlewareGroups;
+ }
+
+ /**
+ * Get the application's route middleware.
+ *
+ * @return array
+ */
+ public function getRouteMiddleware()
+ {
+ return $this->routeMiddleware;
+ }
+
/**
* Get the Laravel application instance.
*
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php
index 6de75096..037e5a47 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php
@@ -3,6 +3,7 @@
namespace Illuminate\Foundation\Http\Middleware;
use Closure;
+use Symfony\Component\HttpFoundation\IpUtils;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Foundation\Http\Exceptions\MaintenanceModeException;
@@ -15,6 +16,13 @@ class CheckForMaintenanceMode
*/
protected $app;
+ /**
+ * The URIs that should be accessible while maintenance mode is enabled.
+ *
+ * @var array
+ */
+ protected $except = [];
+
/**
* Create a new middleware instance.
*
@@ -40,9 +48,38 @@ class CheckForMaintenanceMode
if ($this->app->isDownForMaintenance()) {
$data = json_decode(file_get_contents($this->app->storagePath().'/framework/down'), true);
+ if (isset($data['allowed']) && IpUtils::checkIp($request->ip(), (array) $data['allowed'])) {
+ return $next($request);
+ }
+
+ if ($this->inExceptArray($request)) {
+ return $next($request);
+ }
+
throw new MaintenanceModeException($data['time'], $data['retry'], $data['message']);
}
return $next($request);
}
+
+ /**
+ * Determine if the request has a URI that should be accessible in maintenance mode.
+ *
+ * @param \Illuminate\Http\Request $request
+ * @return bool
+ */
+ protected function inExceptArray($request)
+ {
+ foreach ($this->except as $except) {
+ if ($except !== '/') {
+ $except = trim($except, '/');
+ }
+
+ if ($request->fullUrlIs($except) || $request->is($except)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php
index 0d3c6c13..a61a1bd7 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php
@@ -7,13 +7,6 @@ use Symfony\Component\HttpFoundation\ParameterBag;
class TransformsRequest
{
- /**
- * The additional attributes passed to the middleware.
- *
- * @var array
- */
- protected $attributes = [];
-
/**
* Handle an incoming request.
*
@@ -21,10 +14,8 @@ class TransformsRequest
* @param \Closure $next
* @return mixed
*/
- public function handle($request, Closure $next, ...$attributes)
+ public function handle($request, Closure $next)
{
- $this->attributes = $attributes;
-
$this->clean($request);
return $next($request);
@@ -42,7 +33,7 @@ class TransformsRequest
if ($request->isJson()) {
$this->cleanParameterBag($request->json());
- } else {
+ } elseif ($request->request !== $request->query) {
$this->cleanParameterBag($request->request);
}
}
@@ -62,12 +53,13 @@ class TransformsRequest
* Clean the data in the given array.
*
* @param array $data
+ * @param string $keyPrefix
* @return array
*/
- protected function cleanArray(array $data)
+ protected function cleanArray(array $data, $keyPrefix = '')
{
- return collect($data)->map(function ($value, $key) {
- return $this->cleanValue($key, $value);
+ return collect($data)->map(function ($value, $key) use ($keyPrefix) {
+ return $this->cleanValue($keyPrefix.$key, $value);
})->all();
}
@@ -81,7 +73,7 @@ class TransformsRequest
protected function cleanValue($key, $value)
{
if (is_array($value)) {
- return $this->cleanArray($value);
+ return $this->cleanArray($value, $key.'.');
}
return $this->transform($key, $value);
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php
index d952b0c0..adc5f5a3 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php
@@ -39,16 +39,17 @@ class ValidatePostSize
}
$metric = strtoupper(substr($postMaxSize, -1));
+ $postMaxSize = (int) $postMaxSize;
switch ($metric) {
case 'K':
- return (int) $postMaxSize * 1024;
+ return $postMaxSize * 1024;
case 'M':
- return (int) $postMaxSize * 1048576;
+ return $postMaxSize * 1048576;
case 'G':
- return (int) $postMaxSize * 1073741824;
+ return $postMaxSize * 1073741824;
default:
- return (int) $postMaxSize;
+ return $postMaxSize;
}
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php
index 9424f73a..beb7946e 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php
@@ -3,18 +3,21 @@
namespace Illuminate\Foundation\Http\Middleware;
use Closure;
-use Carbon\Carbon;
-use Illuminate\Foundation\Application;
+use Illuminate\Support\InteractsWithTime;
use Symfony\Component\HttpFoundation\Cookie;
use Illuminate\Contracts\Encryption\Encrypter;
use Illuminate\Session\TokenMismatchException;
+use Illuminate\Contracts\Foundation\Application;
+use Illuminate\Cookie\Middleware\EncryptCookies;
class VerifyCsrfToken
{
+ use InteractsWithTime;
+
/**
* The application instance.
*
- * @var \Illuminate\Foundation\Application
+ * @var \Illuminate\Contracts\Foundation\Application
*/
protected $app;
@@ -32,10 +35,17 @@ class VerifyCsrfToken
*/
protected $except = [];
+ /**
+ * Indicates whether the XSRF-TOKEN cookie should be set on the response.
+ *
+ * @var bool
+ */
+ protected $addHttpCookie = true;
+
/**
* Create a new middleware instance.
*
- * @param \Illuminate\Foundation\Application $app
+ * @param \Illuminate\Contracts\Foundation\Application $app
* @param \Illuminate\Contracts\Encryption\Encrypter $encrypter
* @return void
*/
@@ -62,10 +72,14 @@ class VerifyCsrfToken
$this->inExceptArray($request) ||
$this->tokensMatch($request)
) {
- return $this->addCookieToResponse($request, $next($request));
+ return tap($next($request), function ($response) use ($request) {
+ if ($this->shouldAddXsrfTokenCookie()) {
+ $this->addCookieToResponse($request, $response);
+ }
+ });
}
- throw new TokenMismatchException;
+ throw new TokenMismatchException('CSRF token mismatch.');
}
/**
@@ -102,7 +116,7 @@ class VerifyCsrfToken
$except = trim($except, '/');
}
- if ($request->is($except)) {
+ if ($request->fullUrlIs($except) || $request->is($except)) {
return true;
}
}
@@ -136,12 +150,22 @@ class VerifyCsrfToken
$token = $request->input('_token') ?: $request->header('X-CSRF-TOKEN');
if (! $token && $header = $request->header('X-XSRF-TOKEN')) {
- $token = $this->encrypter->decrypt($header);
+ $token = $this->encrypter->decrypt($header, static::serialized());
}
return $token;
}
+ /**
+ * Determine if the cookie should be added to the response.
+ *
+ * @return bool
+ */
+ public function shouldAddXsrfTokenCookie()
+ {
+ return $this->addHttpCookie;
+ }
+
/**
* Add the CSRF token to the response cookies.
*
@@ -155,11 +179,21 @@ class VerifyCsrfToken
$response->headers->setCookie(
new Cookie(
- 'XSRF-TOKEN', $request->session()->token(), Carbon::now()->getTimestamp() + 60 * $config['lifetime'],
- $config['path'], $config['domain'], $config['secure'], false
+ 'XSRF-TOKEN', $request->session()->token(), $this->availableAt(60 * $config['lifetime']),
+ $config['path'], $config['domain'], $config['secure'], false, false, $config['same_site'] ?? null
)
);
return $response;
}
+
+ /**
+ * Determine if the cookie contents should be serialized.
+ *
+ * @return bool
+ */
+ public static function serialized()
+ {
+ return EncryptCookies::serialized('XSRF-TOKEN');
+ }
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Inspiring.php b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Inspiring.php
index 5216088a..61258cb4 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Inspiring.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Inspiring.php
@@ -13,6 +13,8 @@ class Inspiring
*
* May McGinnis always control the board. #LaraconUS2015
*
+ * RIP Charlie - Feb 6, 2018
+ *
* @return string
*/
public static function quote()
@@ -29,6 +31,8 @@ class Inspiring
'It is quality rather than quantity that matters. - Lucius Annaeus Seneca',
'Genius is one percent inspiration and ninety-nine percent perspiration. - Thomas Edison',
'Computer science is no more about computers than astronomy is about telescopes. - Edsger Dijkstra',
+ 'It always seems impossible until it is done. - Nelson Mandela',
+ 'Act only according to that maxim whereby you can, at the same time, will that it should become a universal law. - Immanuel Kant',
])->random();
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php
index e29bb3c3..903908f3 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php
@@ -186,11 +186,11 @@ class ProviderRepository
*/
public function writeManifest($manifest)
{
- if (! is_writable(dirname($this->manifestPath))) {
- throw new Exception('The bootstrap/cache directory must be present and writable.');
+ if (! is_writable($dirname = dirname($this->manifestPath))) {
+ throw new Exception("The {$dirname} directory must be present and writable.");
}
- $this->files->put(
+ $this->files->replace(
$this->manifestPath, ' 'command.config.clear',
'Down' => 'command.down',
'Environment' => 'command.environment',
+ 'EventCache' => 'command.event.cache',
+ 'EventClear' => 'command.event.clear',
+ 'EventList' => 'command.event.list',
'KeyGenerate' => 'command.key.generate',
'Migrate' => 'command.migrate',
+ 'MigrateFresh' => 'command.migrate.fresh',
'MigrateInstall' => 'command.migrate.install',
'MigrateRefresh' => 'command.migrate.refresh',
'MigrateReset' => 'command.migrate.reset',
'MigrateRollback' => 'command.migrate.rollback',
'MigrateStatus' => 'command.migrate.status',
'Optimize' => 'command.optimize',
+ 'OptimizeClear' => 'command.optimize.clear',
+ 'PackageDiscover' => 'command.package.discover',
+ 'Preset' => 'command.preset',
'QueueFailed' => 'command.queue.failed',
'QueueFlush' => 'command.queue.flush',
'QueueForget' => 'command.queue.forget',
@@ -107,6 +122,7 @@ class ArtisanServiceProvider extends ServiceProvider
'ScheduleRun' => ScheduleRunCommand::class,
'StorageLink' => 'command.storage.link',
'Up' => 'command.up',
+ 'ViewCache' => 'command.view.cache',
'ViewClear' => 'command.view.clear',
];
@@ -119,10 +135,13 @@ class ArtisanServiceProvider extends ServiceProvider
'AppName' => 'command.app.name',
'AuthMake' => 'command.auth.make',
'CacheTable' => 'command.cache.table',
+ 'ChannelMake' => 'command.channel.make',
'ConsoleMake' => 'command.console.make',
'ControllerMake' => 'command.controller.make',
'EventGenerate' => 'command.event.generate',
'EventMake' => 'command.event.make',
+ 'ExceptionMake' => 'command.exception.make',
+ 'FactoryMake' => 'command.factory.make',
'JobMake' => 'command.job.make',
'ListenerMake' => 'command.listener.make',
'MailMake' => 'command.mail.make',
@@ -131,11 +150,14 @@ class ArtisanServiceProvider extends ServiceProvider
'ModelMake' => 'command.model.make',
'NotificationMake' => 'command.notification.make',
'NotificationTable' => 'command.notification.table',
+ 'ObserverMake' => 'command.observer.make',
'PolicyMake' => 'command.policy.make',
'ProviderMake' => 'command.provider.make',
'QueueFailedTable' => 'command.queue.failed-table',
'QueueTable' => 'command.queue.table',
'RequestMake' => 'command.request.make',
+ 'ResourceMake' => 'command.resource.make',
+ 'RuleMake' => 'command.rule.make',
'SeederMake' => 'command.seeder.make',
'SessionTable' => 'command.session.table',
'Serve' => 'command.serve',
@@ -189,7 +211,7 @@ class ArtisanServiceProvider extends ServiceProvider
*/
protected function registerAuthMakeCommand()
{
- $this->app->singleton('command.auth.make', function ($app) {
+ $this->app->singleton('command.auth.make', function () {
return new AuthMakeCommand;
});
}
@@ -202,7 +224,7 @@ class ArtisanServiceProvider extends ServiceProvider
protected function registerCacheClearCommand()
{
$this->app->singleton('command.cache.clear', function ($app) {
- return new CacheClearCommand($app['cache']);
+ return new CacheClearCommand($app['cache'], $app['files']);
});
}
@@ -230,6 +252,18 @@ class ArtisanServiceProvider extends ServiceProvider
});
}
+ /**
+ * Register the command.
+ *
+ * @return void
+ */
+ protected function registerChannelMakeCommand()
+ {
+ $this->app->singleton('command.channel.make', function ($app) {
+ return new ChannelMakeCommand($app['files']);
+ });
+ }
+
/**
* Register the command.
*
@@ -326,6 +360,30 @@ class ArtisanServiceProvider extends ServiceProvider
});
}
+ /**
+ * Register the command.
+ *
+ * @return void
+ */
+ protected function registerExceptionMakeCommand()
+ {
+ $this->app->singleton('command.exception.make', function ($app) {
+ return new ExceptionMakeCommand($app['files']);
+ });
+ }
+
+ /**
+ * Register the command.
+ *
+ * @return void
+ */
+ protected function registerFactoryMakeCommand()
+ {
+ $this->app->singleton('command.factory.make', function ($app) {
+ return new FactoryMakeCommand($app['files']);
+ });
+ }
+
/**
* Register the command.
*
@@ -350,6 +408,42 @@ class ArtisanServiceProvider extends ServiceProvider
});
}
+ /**
+ * Register the command.
+ *
+ * @return void
+ */
+ protected function registerEventCacheCommand()
+ {
+ $this->app->singleton('command.event.cache', function () {
+ return new EventCacheCommand;
+ });
+ }
+
+ /**
+ * Register the command.
+ *
+ * @return void
+ */
+ protected function registerEventClearCommand()
+ {
+ $this->app->singleton('command.event.clear', function ($app) {
+ return new EventClearCommand($app['files']);
+ });
+ }
+
+ /**
+ * Register the command.
+ *
+ * @return void
+ */
+ protected function registerEventListCommand()
+ {
+ $this->app->singleton('command.event.list', function () {
+ return new EventListCommand();
+ });
+ }
+
/**
* Register the command.
*
@@ -422,6 +516,18 @@ class ArtisanServiceProvider extends ServiceProvider
});
}
+ /**
+ * Register the command.
+ *
+ * @return void
+ */
+ protected function registerMigrateFreshCommand()
+ {
+ $this->app->singleton('command.migrate.fresh', function () {
+ return new MigrateFreshCommand;
+ });
+ }
+
/**
* Register the command.
*
@@ -525,6 +631,18 @@ class ArtisanServiceProvider extends ServiceProvider
});
}
+ /**
+ * Register the command.
+ *
+ * @return void
+ */
+ protected function registerNotificationTableCommand()
+ {
+ $this->app->singleton('command.notification.table', function ($app) {
+ return new NotificationTableCommand($app['files'], $app['composer']);
+ });
+ }
+
/**
* Register the command.
*
@@ -532,8 +650,68 @@ class ArtisanServiceProvider extends ServiceProvider
*/
protected function registerOptimizeCommand()
{
- $this->app->singleton('command.optimize', function ($app) {
- return new OptimizeCommand($app['composer']);
+ $this->app->singleton('command.optimize', function () {
+ return new OptimizeCommand;
+ });
+ }
+
+ /**
+ * Register the command.
+ *
+ * @return void
+ */
+ protected function registerObserverMakeCommand()
+ {
+ $this->app->singleton('command.observer.make', function ($app) {
+ return new ObserverMakeCommand($app['files']);
+ });
+ }
+
+ /**
+ * Register the command.
+ *
+ * @return void
+ */
+ protected function registerOptimizeClearCommand()
+ {
+ $this->app->singleton('command.optimize.clear', function () {
+ return new OptimizeClearCommand;
+ });
+ }
+
+ /**
+ * Register the command.
+ *
+ * @return void
+ */
+ protected function registerPackageDiscoverCommand()
+ {
+ $this->app->singleton('command.package.discover', function () {
+ return new PackageDiscoverCommand;
+ });
+ }
+
+ /**
+ * Register the command.
+ *
+ * @return void
+ */
+ protected function registerPolicyMakeCommand()
+ {
+ $this->app->singleton('command.policy.make', function ($app) {
+ return new PolicyMakeCommand($app['files']);
+ });
+ }
+
+ /**
+ * Register the command.
+ *
+ * @return void
+ */
+ protected function registerPresetCommand()
+ {
+ $this->app->singleton('command.preset', function () {
+ return new PresetCommand;
});
}
@@ -669,6 +847,30 @@ class ArtisanServiceProvider extends ServiceProvider
});
}
+ /**
+ * Register the command.
+ *
+ * @return void
+ */
+ protected function registerResourceMakeCommand()
+ {
+ $this->app->singleton('command.resource.make', function ($app) {
+ return new ResourceMakeCommand($app['files']);
+ });
+ }
+
+ /**
+ * Register the command.
+ *
+ * @return void
+ */
+ protected function registerRuleMakeCommand()
+ {
+ $this->app->singleton('command.rule.make', function ($app) {
+ return new RuleMakeCommand($app['files']);
+ });
+ }
+
/**
* Register the command.
*
@@ -821,6 +1023,18 @@ class ArtisanServiceProvider extends ServiceProvider
});
}
+ /**
+ * Register the command.
+ *
+ * @return void
+ */
+ protected function registerViewCacheCommand()
+ {
+ $this->app->singleton('command.view.cache', function () {
+ return new ViewCacheCommand;
+ });
+ }
+
/**
* Register the command.
*
@@ -833,30 +1047,6 @@ class ArtisanServiceProvider extends ServiceProvider
});
}
- /**
- * Register the command.
- *
- * @return void
- */
- protected function registerPolicyMakeCommand()
- {
- $this->app->singleton('command.policy.make', function ($app) {
- return new PolicyMakeCommand($app['files']);
- });
- }
-
- /**
- * Register the command.
- *
- * @return void
- */
- protected function registerNotificationTableCommand()
- {
- $this->app->singleton('command.notification.table', function ($app) {
- return new NotificationTableCommand($app['files'], $app['composer']);
- });
- }
-
/**
* Get the services provided by the provider.
*
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Providers/ComposerServiceProvider.php b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Providers/ComposerServiceProvider.php
index 295ca960..6b05c256 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Providers/ComposerServiceProvider.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Providers/ComposerServiceProvider.php
@@ -4,16 +4,10 @@ namespace Illuminate\Foundation\Providers;
use Illuminate\Support\Composer;
use Illuminate\Support\ServiceProvider;
+use Illuminate\Contracts\Support\DeferrableProvider;
-class ComposerServiceProvider extends ServiceProvider
+class ComposerServiceProvider extends ServiceProvider implements DeferrableProvider
{
- /**
- * Indicates if loading of the provider is deferred.
- *
- * @var bool
- */
- protected $defer = true;
-
/**
* Register the service provider.
*
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Providers/ConsoleSupportServiceProvider.php b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Providers/ConsoleSupportServiceProvider.php
index 8e92d28c..f3608381 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Providers/ConsoleSupportServiceProvider.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Providers/ConsoleSupportServiceProvider.php
@@ -4,16 +4,10 @@ namespace Illuminate\Foundation\Providers;
use Illuminate\Support\AggregateServiceProvider;
use Illuminate\Database\MigrationServiceProvider;
+use Illuminate\Contracts\Support\DeferrableProvider;
-class ConsoleSupportServiceProvider extends AggregateServiceProvider
+class ConsoleSupportServiceProvider extends AggregateServiceProvider implements DeferrableProvider
{
- /**
- * Indicates if loading of the provider is deferred.
- *
- * @var bool
- */
- protected $defer = true;
-
/**
* The provider class names.
*
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Providers/FormRequestServiceProvider.php b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Providers/FormRequestServiceProvider.php
index 9e413f10..7028d333 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Providers/FormRequestServiceProvider.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Providers/FormRequestServiceProvider.php
@@ -5,7 +5,6 @@ namespace Illuminate\Foundation\Providers;
use Illuminate\Routing\Redirector;
use Illuminate\Support\ServiceProvider;
use Illuminate\Foundation\Http\FormRequest;
-use Symfony\Component\HttpFoundation\Request;
use Illuminate\Contracts\Validation\ValidatesWhenResolved;
class FormRequestServiceProvider extends ServiceProvider
@@ -28,42 +27,13 @@ class FormRequestServiceProvider extends ServiceProvider
public function boot()
{
$this->app->afterResolving(ValidatesWhenResolved::class, function ($resolved) {
- $resolved->validate();
+ $resolved->validateResolved();
});
$this->app->resolving(FormRequest::class, function ($request, $app) {
- $this->initializeRequest($request, $app['request']);
+ $request = FormRequest::createFrom($app['request'], $request);
$request->setContainer($app)->setRedirector($app->make(Redirector::class));
});
}
-
- /**
- * Initialize the form request with data from the given request.
- *
- * @param \Illuminate\Foundation\Http\FormRequest $form
- * @param \Symfony\Component\HttpFoundation\Request $current
- * @return void
- */
- protected function initializeRequest(FormRequest $form, Request $current)
- {
- $files = $current->files->all();
-
- $files = is_array($files) ? array_filter($files) : $files;
-
- $form->initialize(
- $current->query->all(), $current->request->all(), $current->attributes->all(),
- $current->cookies->all(), $files, $current->server->all(), $current->getContent()
- );
-
- $form->setJson($current->json());
-
- if ($session = $current->getSession()) {
- $form->setLaravelSession($session);
- }
-
- $form->setUserResolver($current->getUserResolver());
-
- $form->setRouteResolver($current->getRouteResolver());
- }
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Providers/FoundationServiceProvider.php b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Providers/FoundationServiceProvider.php
index f1f48373..fc008854 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Providers/FoundationServiceProvider.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Providers/FoundationServiceProvider.php
@@ -2,6 +2,8 @@
namespace Illuminate\Foundation\Providers;
+use Illuminate\Http\Request;
+use Illuminate\Support\Facades\URL;
use Illuminate\Support\AggregateServiceProvider;
class FoundationServiceProvider extends AggregateServiceProvider
@@ -14,4 +16,53 @@ class FoundationServiceProvider extends AggregateServiceProvider
protected $providers = [
FormRequestServiceProvider::class,
];
+
+ /**
+ * Boot the service provider.
+ */
+ public function boot()
+ {
+ if ($this->app->runningInConsole()) {
+ $this->publishes([
+ __DIR__.'/../Exceptions/views' => $this->app->resourcePath('views/errors/'),
+ ], 'laravel-errors');
+ }
+ }
+
+ /**
+ * Register the service provider.
+ *
+ * @return void
+ */
+ public function register()
+ {
+ parent::register();
+
+ $this->registerRequestValidation();
+ $this->registerRequestSignatureValidation();
+ }
+
+ /**
+ * Register the "validate" macro on the request.
+ *
+ * @return void
+ */
+ public function registerRequestValidation()
+ {
+ Request::macro('validate', function (array $rules, ...$params) {
+ return validator()->validate($this->all(), $rules, ...$params);
+ });
+ }
+
+ /**
+ * Register the "hasValidSignature" macro on the request.
+ *
+ * @return void
+ */
+ public function registerRequestSignatureValidation()
+ {
+ Request::macro('hasValidSignature', function ($absolute = true) {
+ return URL::hasValidSignature($this, $absolute);
+ });
+ }
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Support/Providers/AuthServiceProvider.php b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Support/Providers/AuthServiceProvider.php
index 880370a9..ac32319c 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Support/Providers/AuthServiceProvider.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Support/Providers/AuthServiceProvider.php
@@ -27,10 +27,12 @@ class AuthServiceProvider extends ServiceProvider
}
/**
- * {@inheritdoc}
+ * Get the policies defined on the provider.
+ *
+ * @return array
*/
- public function register()
+ public function policies()
{
- //
+ return $this->policies;
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Support/Providers/EventServiceProvider.php b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Support/Providers/EventServiceProvider.php
index 307f2cef..f38eb045 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Support/Providers/EventServiceProvider.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Support/Providers/EventServiceProvider.php
@@ -4,6 +4,7 @@ namespace Illuminate\Foundation\Support\Providers;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\ServiceProvider;
+use Illuminate\Foundation\Events\DiscoverEvents;
class EventServiceProvider extends ServiceProvider
{
@@ -28,8 +29,10 @@ class EventServiceProvider extends ServiceProvider
*/
public function boot()
{
- foreach ($this->listens() as $event => $listeners) {
- foreach ($listeners as $listener) {
+ $events = $this->getEvents();
+
+ foreach ($events as $event => $listeners) {
+ foreach (array_unique($listeners) as $listener) {
Event::listen($event, $listener);
}
}
@@ -39,14 +42,6 @@ class EventServiceProvider extends ServiceProvider
}
}
- /**
- * {@inheritdoc}
- */
- public function register()
- {
- //
- }
-
/**
* Get the events and handlers.
*
@@ -56,4 +51,76 @@ class EventServiceProvider extends ServiceProvider
{
return $this->listen;
}
+
+ /**
+ * Get the discovered events and listeners for the application.
+ *
+ * @return array
+ */
+ public function getEvents()
+ {
+ if ($this->app->eventsAreCached()) {
+ $cache = require $this->app->getCachedEventsPath();
+
+ return $cache[get_class($this)] ?? [];
+ } else {
+ return array_merge_recursive(
+ $this->discoveredEvents(),
+ $this->listens()
+ );
+ }
+ }
+
+ /**
+ * Get the discovered events for the application.
+ *
+ * @return array
+ */
+ protected function discoveredEvents()
+ {
+ return $this->shouldDiscoverEvents()
+ ? $this->discoverEvents()
+ : [];
+ }
+
+ /**
+ * Determine if events and listeners should be automatically discovered.
+ *
+ * @return bool
+ */
+ public function shouldDiscoverEvents()
+ {
+ return false;
+ }
+
+ /**
+ * Discover the events and listeners for the application.
+ *
+ * @return array
+ */
+ public function discoverEvents()
+ {
+ return collect($this->discoverEventsWithin())
+ ->reject(function ($directory) {
+ return ! is_dir($directory);
+ })
+ ->reduce(function ($discovered, $directory) {
+ return array_merge_recursive(
+ $discovered,
+ DiscoverEvents::within($directory, base_path())
+ );
+ }, []);
+ }
+
+ /**
+ * Get the listener directories that should be used to discover events.
+ *
+ * @return array
+ */
+ protected function discoverEventsWithin()
+ {
+ return [
+ $this->app->path('Listeners'),
+ ];
+ }
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Support/Providers/RouteServiceProvider.php b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Support/Providers/RouteServiceProvider.php
index c753447b..c86ad8c6 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Support/Providers/RouteServiceProvider.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Support/Providers/RouteServiceProvider.php
@@ -4,6 +4,7 @@ namespace Illuminate\Foundation\Support\Providers;
use Illuminate\Routing\Router;
use Illuminate\Support\ServiceProvider;
+use Illuminate\Support\Traits\ForwardsCalls;
use Illuminate\Contracts\Routing\UrlGenerator;
/**
@@ -11,6 +12,8 @@ use Illuminate\Contracts\Routing\UrlGenerator;
*/
class RouteServiceProvider extends ServiceProvider
{
+ use ForwardsCalls;
+
/**
* The controller namespace for the application.
*
@@ -27,7 +30,7 @@ class RouteServiceProvider extends ServiceProvider
{
$this->setRootControllerNamespace();
- if ($this->app->routesAreCached()) {
+ if ($this->routesAreCached()) {
$this->loadCachedRoutes();
} else {
$this->loadRoutes();
@@ -51,6 +54,16 @@ class RouteServiceProvider extends ServiceProvider
}
}
+ /**
+ * Determine if the application routes are cached.
+ *
+ * @return bool
+ */
+ protected function routesAreCached()
+ {
+ return $this->app->routesAreCached();
+ }
+
/**
* Load the cached routes for the application.
*
@@ -75,16 +88,6 @@ class RouteServiceProvider extends ServiceProvider
}
}
- /**
- * Register the service provider.
- *
- * @return void
- */
- public function register()
- {
- //
- }
-
/**
* Pass dynamic methods onto the router instance.
*
@@ -94,8 +97,8 @@ class RouteServiceProvider extends ServiceProvider
*/
public function __call($method, $parameters)
{
- return call_user_func_array(
- [$this->app->make(Router::class), $method], $parameters
+ return $this->forwardCallTo(
+ $this->app->make(Router::class), $method, $parameters
);
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithAuthentication.php b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithAuthentication.php
index 6c5c7a1c..404a8bfb 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithAuthentication.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithAuthentication.php
@@ -15,9 +15,7 @@ trait InteractsWithAuthentication
*/
public function actingAs(UserContract $user, $driver = null)
{
- $this->be($user, $driver);
-
- return $this;
+ return $this->be($user, $driver);
}
/**
@@ -25,13 +23,19 @@ trait InteractsWithAuthentication
*
* @param \Illuminate\Contracts\Auth\Authenticatable $user
* @param string|null $driver
- * @return void
+ * @return $this
*/
public function be(UserContract $user, $driver = null)
{
+ if (isset($user->wasRecentlyCreated) && $user->wasRecentlyCreated) {
+ $user->wasRecentlyCreated = false;
+ }
+
$this->app['auth']->guard($driver)->setUser($user);
$this->app['auth']->shouldUse($driver);
+
+ return $this;
}
/**
@@ -40,7 +44,7 @@ trait InteractsWithAuthentication
* @param string|null $guard
* @return $this
*/
- public function seeIsAuthenticated($guard = null)
+ public function assertAuthenticated($guard = null)
{
$this->assertTrue($this->isAuthenticated($guard), 'The user is not authenticated');
@@ -53,7 +57,7 @@ trait InteractsWithAuthentication
* @param string|null $guard
* @return $this
*/
- public function dontSeeIsAuthenticated($guard = null)
+ public function assertGuest($guard = null)
{
$this->assertFalse($this->isAuthenticated($guard), 'The user is authenticated');
@@ -74,14 +78,16 @@ trait InteractsWithAuthentication
/**
* Assert that the user is authenticated as the given user.
*
- * @param $user
+ * @param \Illuminate\Contracts\Auth\Authenticatable $user
* @param string|null $guard
* @return $this
*/
- public function seeIsAuthenticatedAs($user, $guard = null)
+ public function assertAuthenticatedAs($user, $guard = null)
{
$expected = $this->app->make('auth')->guard($guard)->user();
+ $this->assertNotNull($expected, 'The current user is not authenticated.');
+
$this->assertInstanceOf(
get_class($expected), $user,
'The currently authenticated user is not who was expected'
@@ -102,7 +108,7 @@ trait InteractsWithAuthentication
* @param string|null $guard
* @return $this
*/
- public function seeCredentials(array $credentials, $guard = null)
+ public function assertCredentials(array $credentials, $guard = null)
{
$this->assertTrue(
$this->hasCredentials($credentials, $guard), 'The given credentials are invalid.'
@@ -118,7 +124,7 @@ trait InteractsWithAuthentication
* @param string|null $guard
* @return $this
*/
- public function dontSeeCredentials(array $credentials, $guard = null)
+ public function assertInvalidCredentials(array $credentials, $guard = null)
{
$this->assertFalse(
$this->hasCredentials($credentials, $guard), 'The given credentials are valid.'
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithConsole.php b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithConsole.php
index ba078b31..5e962e80 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithConsole.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithConsole.php
@@ -2,19 +2,71 @@
namespace Illuminate\Foundation\Testing\Concerns;
+use Illuminate\Support\Arr;
+use Illuminate\Console\OutputStyle;
use Illuminate\Contracts\Console\Kernel;
+use Illuminate\Foundation\Testing\PendingCommand;
trait InteractsWithConsole
{
+ /**
+ * Indicates if the console output should be mocked.
+ *
+ * @var bool
+ */
+ public $mockConsoleOutput = true;
+
+ /**
+ * All of the expected output lines.
+ *
+ * @var array
+ */
+ public $expectedOutput = [];
+
+ /**
+ * All of the expected questions.
+ *
+ * @var array
+ */
+ public $expectedQuestions = [];
+
/**
* Call artisan command and return code.
*
* @param string $command
* @param array $parameters
- * @return int
+ * @return \Illuminate\Foundation\Testing\PendingCommand|int
*/
public function artisan($command, $parameters = [])
{
- return $this->app[Kernel::class]->call($command, $parameters);
+ if (! $this->mockConsoleOutput) {
+ return $this->app[Kernel::class]->call($command, $parameters);
+ }
+
+ $this->beforeApplicationDestroyed(function () {
+ if (count($this->expectedQuestions)) {
+ $this->fail('Question "'.Arr::first($this->expectedQuestions)[0].'" was not asked.');
+ }
+
+ if (count($this->expectedOutput)) {
+ $this->fail('Output "'.Arr::first($this->expectedOutput).'" was not printed.');
+ }
+ });
+
+ return new PendingCommand($this, $this->app, $command, $parameters);
+ }
+
+ /**
+ * Disable mocking the console output.
+ *
+ * @return $this
+ */
+ protected function withoutMockingConsoleOutput()
+ {
+ $this->mockConsoleOutput = false;
+
+ $this->app->offsetUnset(OutputStyle::class);
+
+ return $this;
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithContainer.php b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithContainer.php
index 5a0ad1e0..90776019 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithContainer.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithContainer.php
@@ -2,6 +2,9 @@
namespace Illuminate\Foundation\Testing\Concerns;
+use Closure;
+use Mockery;
+
trait InteractsWithContainer
{
/**
@@ -29,4 +32,28 @@ trait InteractsWithContainer
return $instance;
}
+
+ /**
+ * Mock an instance of an object in the container.
+ *
+ * @param string $abstract
+ * @param \Closure|null $mock
+ * @return object
+ */
+ protected function mock($abstract, Closure $mock = null)
+ {
+ return $this->instance($abstract, Mockery::mock(...array_filter(func_get_args())));
+ }
+
+ /**
+ * Spy an instance of an object in the container.
+ *
+ * @param string $abstract
+ * @param \Closure|null $mock
+ * @return object
+ */
+ protected function spy($abstract, Closure $mock = null)
+ {
+ return $this->instance($abstract, Mockery::spy(...array_filter(func_get_args())));
+ }
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithDatabase.php b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithDatabase.php
index a2e60e79..17914ba2 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithDatabase.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithDatabase.php
@@ -2,8 +2,10 @@
namespace Illuminate\Foundation\Testing\Concerns;
-use PHPUnit_Framework_Constraint_Not as ReverseConstraint;
+use Illuminate\Support\Arr;
+use Illuminate\Database\Eloquent\Model;
use Illuminate\Foundation\Testing\Constraints\HasInDatabase;
+use PHPUnit\Framework\Constraint\LogicalNot as ReverseConstraint;
use Illuminate\Foundation\Testing\Constraints\SoftDeletedInDatabase;
trait InteractsWithDatabase
@@ -13,7 +15,7 @@ trait InteractsWithDatabase
*
* @param string $table
* @param array $data
- * @param string $connection
+ * @param string|null $connection
* @return $this
*/
protected function assertDatabaseHas($table, array $data, $connection = null)
@@ -30,7 +32,7 @@ trait InteractsWithDatabase
*
* @param string $table
* @param array $data
- * @param string $connection
+ * @param string|null $connection
* @return $this
*/
protected function assertDatabaseMissing($table, array $data, $connection = null)
@@ -47,13 +49,17 @@ trait InteractsWithDatabase
/**
* Assert the given record has been deleted.
*
- * @param string $table
+ * @param string|\Illuminate\Database\Eloquent\Model $table
* @param array $data
- * @param string $connection
+ * @param string|null $connection
* @return $this
*/
- protected function assertSoftDeleted($table, array $data, $connection = null)
+ protected function assertSoftDeleted($table, array $data = [], $connection = null)
{
+ if ($table instanceof Model) {
+ return $this->assertSoftDeleted($table->getTable(), [$table->getKeyName() => $table->getKey()], $table->getConnectionName());
+ }
+
$this->assertThat(
$table, new SoftDeletedInDatabase($this->getConnection($connection), $data)
);
@@ -79,12 +85,14 @@ trait InteractsWithDatabase
/**
* Seed a given database connection.
*
- * @param string $class
+ * @param array|string $class
* @return $this
*/
public function seed($class = 'DatabaseSeeder')
{
- $this->artisan('db:seed', ['--class' => $class]);
+ foreach (Arr::wrap($class) as $class) {
+ $this->artisan('db:seed', ['--class' => $class, '--no-interaction' => true]);
+ }
return $this;
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php
index 3c9058e8..29e752aa 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php
@@ -11,6 +11,13 @@ use Symfony\Component\HttpFoundation\File\UploadedFile as SymfonyUploadedFile;
trait MakesHttpRequests
{
+ /**
+ * Additional headers for the request.
+ *
+ * @var array
+ */
+ protected $defaultHeaders = [];
+
/**
* Additional server variables for the request.
*
@@ -18,6 +25,52 @@ trait MakesHttpRequests
*/
protected $serverVariables = [];
+ /**
+ * Indicates whether redirects should be followed.
+ *
+ * @var bool
+ */
+ protected $followRedirects = false;
+
+ /**
+ * Define additional headers to be sent with the request.
+ *
+ * @param array $headers
+ * @return $this
+ */
+ public function withHeaders(array $headers)
+ {
+ $this->defaultHeaders = array_merge($this->defaultHeaders, $headers);
+
+ return $this;
+ }
+
+ /**
+ * Add a header to be sent with the request.
+ *
+ * @param string $name
+ * @param string $value
+ * @return $this
+ */
+ public function withHeader(string $name, string $value)
+ {
+ $this->defaultHeaders[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Flush all the configured headers.
+ *
+ * @return $this
+ */
+ public function flushHeaders()
+ {
+ $this->defaultHeaders = [];
+
+ return $this;
+ }
+
/**
* Define a set of server variables to be sent with the requests.
*
@@ -34,15 +87,75 @@ trait MakesHttpRequests
/**
* Disable middleware for the test.
*
+ * @param string|array|null $middleware
* @return $this
*/
- public function withoutMiddleware()
+ public function withoutMiddleware($middleware = null)
{
- $this->app->instance('middleware.disable', true);
+ if (is_null($middleware)) {
+ $this->app->instance('middleware.disable', true);
+
+ return $this;
+ }
+
+ foreach ((array) $middleware as $abstract) {
+ $this->app->instance($abstract, new class {
+ public function handle($request, $next)
+ {
+ return $next($request);
+ }
+ });
+ }
return $this;
}
+ /**
+ * Enable the given middleware for the test.
+ *
+ * @param string|array|null $middleware
+ * @return $this
+ */
+ public function withMiddleware($middleware = null)
+ {
+ if (is_null($middleware)) {
+ unset($this->app['middleware.disable']);
+
+ return $this;
+ }
+
+ foreach ((array) $middleware as $abstract) {
+ unset($this->app[$abstract]);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Automatically follow any redirects returned from the response.
+ *
+ * @return $this
+ */
+ public function followingRedirects()
+ {
+ $this->followRedirects = true;
+
+ return $this;
+ }
+
+ /**
+ * Set the referer header and previous URL session value in order to simulate a previous request.
+ *
+ * @param string $url
+ * @return $this
+ */
+ public function from(string $url)
+ {
+ $this->app['session']->setPreviousUrl($url);
+
+ return $this->withHeader('referer', $url);
+ }
+
/**
* Visit the given URI with a GET request.
*
@@ -181,6 +294,34 @@ trait MakesHttpRequests
return $this->json('DELETE', $uri, $data, $headers);
}
+ /**
+ * Visit the given URI with a OPTION request.
+ *
+ * @param string $uri
+ * @param array $data
+ * @param array $headers
+ * @return \Illuminate\Foundation\Testing\TestResponse
+ */
+ public function option($uri, array $data = [], array $headers = [])
+ {
+ $server = $this->transformHeadersToServerVars($headers);
+
+ return $this->call('OPTION', $uri, $data, [], [], $server);
+ }
+
+ /**
+ * Visit the given URI with a OPTION request, expecting a JSON response.
+ *
+ * @param string $uri
+ * @param array $data
+ * @param array $headers
+ * @return \Illuminate\Foundation\Testing\TestResponse
+ */
+ public function optionJson($uri, array $data = [], array $headers = [])
+ {
+ return $this->json('OPTION', $uri, $data, $headers);
+ }
+
/**
* Call the given URI with a JSON request.
*
@@ -216,7 +357,7 @@ trait MakesHttpRequests
* @param array $cookies
* @param array $files
* @param array $server
- * @param string $content
+ * @param string|null $content
* @return \Illuminate\Foundation\Testing\TestResponse
*/
public function call($method, $uri, $parameters = [], $cookies = [], $files = [], $server = [], $content = null)
@@ -234,6 +375,10 @@ trait MakesHttpRequests
$request = Request::createFromBase($symfonyRequest)
);
+ if ($this->followRedirects) {
+ $response = $this->followRedirects($response);
+ }
+
$kernel->terminate($request, $response);
return $this->createTestResponse($response);
@@ -266,7 +411,7 @@ trait MakesHttpRequests
*/
protected function transformHeadersToServerVars(array $headers)
{
- return collect($headers)->mapWithKeys(function ($value, $name) {
+ return collect(array_merge($this->defaultHeaders, $headers))->mapWithKeys(function ($value, $name) {
$name = strtr(strtoupper($name), '-', '_');
return [$this->formatServerHeaderKey($name) => $value];
@@ -281,7 +426,7 @@ trait MakesHttpRequests
*/
protected function formatServerHeaderKey($name)
{
- if (! Str::startsWith($name, 'HTTP_') && $name != 'CONTENT_TYPE') {
+ if (! Str::startsWith($name, 'HTTP_') && $name !== 'CONTENT_TYPE' && $name !== 'REMOTE_ADDR') {
return 'HTTP_'.$name;
}
@@ -315,6 +460,23 @@ trait MakesHttpRequests
return $files;
}
+ /**
+ * Follow a redirect chain until a non-redirect is received.
+ *
+ * @param \Illuminate\Http\Response $response
+ * @return \Illuminate\Http\Response|\Illuminate\Foundation\Testing\TestResponse
+ */
+ protected function followRedirects($response)
+ {
+ while ($response->isRedirect()) {
+ $response = $this->get($response->headers->get('Location'));
+ }
+
+ $this->followRedirects = false;
+
+ return $response;
+ }
+
/**
* Create the test response instance from the given response.
*
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/MocksApplicationServices.php b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/MocksApplicationServices.php
index 04bb2aed..0dd37f7f 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/MocksApplicationServices.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/MocksApplicationServices.php
@@ -96,9 +96,9 @@ trait MocksApplicationServices
*/
protected function withoutEvents()
{
- $mock = Mockery::mock(EventsDispatcherContract::class);
+ $mock = Mockery::mock(EventsDispatcherContract::class)->shouldIgnoreMissing();
- $mock->shouldReceive('fire', 'dispatch')->andReturnUsing(function ($called) {
+ $mock->shouldReceive('dispatch', 'until')->andReturnUsing(function ($called) {
$this->firedEvents[] = $called;
});
@@ -175,7 +175,7 @@ trait MocksApplicationServices
*/
protected function withoutJobs()
{
- $mock = Mockery::mock(BusDispatcherContract::class);
+ $mock = Mockery::mock(BusDispatcherContract::class)->shouldIgnoreMissing();
$mock->shouldReceive('dispatch', 'dispatchNow')->andReturnUsing(function ($dispatched) {
$this->dispatchedJobs[] = $dispatched;
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Constraints/HasInDatabase.php b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Constraints/HasInDatabase.php
index b3265b4e..b88f3422 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Constraints/HasInDatabase.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Constraints/HasInDatabase.php
@@ -2,10 +2,10 @@
namespace Illuminate\Foundation\Testing\Constraints;
-use PHPUnit_Framework_Constraint;
use Illuminate\Database\Connection;
+use PHPUnit\Framework\Constraint\Constraint;
-class HasInDatabase extends PHPUnit_Framework_Constraint
+class HasInDatabase extends Constraint
{
/**
* Number of records that will be shown in the console in case of failure.
@@ -48,7 +48,7 @@ class HasInDatabase extends PHPUnit_Framework_Constraint
* @param string $table
* @return bool
*/
- public function matches($table)
+ public function matches($table): bool
{
return $this->database->table($table)->where($this->data)->count() > 0;
}
@@ -59,7 +59,7 @@ class HasInDatabase extends PHPUnit_Framework_Constraint
* @param string $table
* @return string
*/
- public function failureDescription($table)
+ public function failureDescription($table): string
{
return sprintf(
"a row in the table [%s] matches the attributes %s.\n\n%s",
@@ -96,7 +96,7 @@ class HasInDatabase extends PHPUnit_Framework_Constraint
* @param int $options
* @return string
*/
- public function toString($options = 0)
+ public function toString($options = 0): string
{
return json_encode($this->data, $options);
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Constraints/SoftDeletedInDatabase.php b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Constraints/SoftDeletedInDatabase.php
index 8d74d4f6..abab48cc 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Constraints/SoftDeletedInDatabase.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Constraints/SoftDeletedInDatabase.php
@@ -2,10 +2,10 @@
namespace Illuminate\Foundation\Testing\Constraints;
-use PHPUnit_Framework_Constraint;
use Illuminate\Database\Connection;
+use PHPUnit\Framework\Constraint\Constraint;
-class SoftDeletedInDatabase extends PHPUnit_Framework_Constraint
+class SoftDeletedInDatabase extends Constraint
{
/**
* Number of records that will be shown in the console in case of failure.
@@ -48,7 +48,7 @@ class SoftDeletedInDatabase extends PHPUnit_Framework_Constraint
* @param string $table
* @return bool
*/
- public function matches($table)
+ public function matches($table): bool
{
return $this->database->table($table)
->where($this->data)->whereNotNull('deleted_at')->count() > 0;
@@ -60,7 +60,7 @@ class SoftDeletedInDatabase extends PHPUnit_Framework_Constraint
* @param string $table
* @return string
*/
- public function failureDescription($table)
+ public function failureDescription($table): string
{
return sprintf(
"any soft deleted row in the table [%s] matches the attributes %s.\n\n%s",
@@ -96,7 +96,7 @@ class SoftDeletedInDatabase extends PHPUnit_Framework_Constraint
*
* @return string
*/
- public function toString()
+ public function toString(): string
{
return json_encode($this->data);
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Testing/DatabaseMigrations.php b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Testing/DatabaseMigrations.php
index a6e527f1..889a4532 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Testing/DatabaseMigrations.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Testing/DatabaseMigrations.php
@@ -13,12 +13,14 @@ trait DatabaseMigrations
*/
public function runDatabaseMigrations()
{
- $this->artisan('migrate');
+ $this->artisan('migrate:fresh');
$this->app[Kernel::class]->setArtisan(null);
$this->beforeApplicationDestroyed(function () {
$this->artisan('migrate:rollback');
+
+ RefreshDatabaseState::$migrated = false;
});
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Testing/HttpException.php b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Testing/HttpException.php
deleted file mode 100644
index 67d2b2f2..00000000
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Testing/HttpException.php
+++ /dev/null
@@ -1,10 +0,0 @@
-app) {
$this->refreshApplication();
@@ -98,6 +110,10 @@ abstract class TestCase extends BaseTestCase
{
$uses = array_flip(class_uses_recursive(static::class));
+ if (isset($uses[RefreshDatabase::class])) {
+ $this->refreshDatabase();
+ }
+
if (isset($uses[DatabaseMigrations::class])) {
$this->runDatabaseMigrations();
}
@@ -114,6 +130,10 @@ abstract class TestCase extends BaseTestCase
$this->disableEventsForAllTests();
}
+ if (isset($uses[WithFaker::class])) {
+ $this->setUpFaker();
+ }
+
return $uses;
}
@@ -122,12 +142,10 @@ abstract class TestCase extends BaseTestCase
*
* @return void
*/
- protected function tearDown()
+ protected function tearDown(): void
{
if ($this->app) {
- foreach ($this->beforeApplicationDestroyedCallbacks as $callback) {
- call_user_func($callback);
- }
+ $this->callBeforeApplicationDestroyedCallbacks();
$this->app->flush();
@@ -140,14 +158,40 @@ abstract class TestCase extends BaseTestCase
$this->serverVariables = [];
}
+ if (property_exists($this, 'defaultHeaders')) {
+ $this->defaultHeaders = [];
+ }
+
if (class_exists('Mockery')) {
- Mockery::close();
+ if ($container = Mockery::getContainer()) {
+ $this->addToAssertionCount($container->mockery_getExpectationCount());
+ }
+
+ try {
+ Mockery::close();
+ } catch (InvalidCountException $e) {
+ if (! Str::contains($e->getMethodName(), ['doWrite', 'askQuestion'])) {
+ throw $e;
+ }
+ }
+ }
+
+ if (class_exists(Carbon::class)) {
+ Carbon::setTestNow();
+ }
+
+ if (class_exists(CarbonImmutable::class)) {
+ CarbonImmutable::setTestNow();
}
$this->afterApplicationCreatedCallbacks = [];
$this->beforeApplicationDestroyedCallbacks = [];
Artisan::forgetBootstrappers();
+
+ if ($this->callbackException) {
+ throw $this->callbackException;
+ }
}
/**
@@ -175,4 +219,22 @@ abstract class TestCase extends BaseTestCase
{
$this->beforeApplicationDestroyedCallbacks[] = $callback;
}
+
+ /**
+ * Execute the application's pre-destruction callbacks.
+ *
+ * @return void
+ */
+ protected function callBeforeApplicationDestroyedCallbacks()
+ {
+ foreach ($this->beforeApplicationDestroyedCallbacks as $callback) {
+ try {
+ call_user_func($callback);
+ } catch (\Throwable $e) {
+ if (! $this->callbackException) {
+ $this->callbackException = $e;
+ }
+ }
+ }
+ }
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestResponse.php b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestResponse.php
index becbfae4..8a6a947a 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestResponse.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestResponse.php
@@ -5,17 +5,21 @@ namespace Illuminate\Foundation\Testing;
use Closure;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
+use Illuminate\Support\Carbon;
use Illuminate\Contracts\View\View;
+use Illuminate\Database\Eloquent\Model;
+use Illuminate\Support\Traits\Tappable;
use Illuminate\Support\Traits\Macroable;
-use PHPUnit\Framework\Assert as PHPUnit;
-use Symfony\Component\HttpFoundation\Cookie;
+use Illuminate\Foundation\Testing\Assert as PHPUnit;
+use Symfony\Component\HttpFoundation\StreamedResponse;
+use Illuminate\Foundation\Testing\Constraints\SeeInOrder;
/**
* @mixin \Illuminate\Http\Response
*/
class TestResponse
{
- use Macroable {
+ use Tappable, Macroable {
__call as macroCall;
}
@@ -26,6 +30,13 @@ class TestResponse
*/
public $baseResponse;
+ /**
+ * The streamed content of the response.
+ *
+ * @var string
+ */
+ protected $streamedContent;
+
/**
* Create a new test response instance.
*
@@ -63,6 +74,68 @@ class TestResponse
return $this;
}
+ /**
+ * Assert that the response has a 200 status code.
+ *
+ * @return $this
+ */
+ public function assertOk()
+ {
+ PHPUnit::assertTrue(
+ $this->isOk(),
+ 'Response status code ['.$this->getStatusCode().'] does not match expected 200 status code.'
+ );
+
+ return $this;
+ }
+
+ /**
+ * Assert that the response has a not found status code.
+ *
+ * @return $this
+ */
+ public function assertNotFound()
+ {
+ PHPUnit::assertTrue(
+ $this->isNotFound(),
+ 'Response status code ['.$this->getStatusCode().'] is not a not found status code.'
+ );
+
+ return $this;
+ }
+
+ /**
+ * Assert that the response has a forbidden status code.
+ *
+ * @return $this
+ */
+ public function assertForbidden()
+ {
+ PHPUnit::assertTrue(
+ $this->isForbidden(),
+ 'Response status code ['.$this->getStatusCode().'] is not a forbidden status code.'
+ );
+
+ return $this;
+ }
+
+ /**
+ * Assert that the response has an unauthorized status code.
+ *
+ * @return $this
+ */
+ public function assertUnauthorized()
+ {
+ $actual = $this->getStatusCode();
+
+ PHPUnit::assertTrue(
+ 401 === $actual,
+ 'Response status code ['.$actual.'] is not an unauthorized status code.'
+ );
+
+ return $this;
+ }
+
/**
* Assert that the response has the given status code.
*
@@ -84,7 +157,7 @@ class TestResponse
/**
* Assert whether the response is redirecting to a given URI.
*
- * @param string $uri
+ * @param string|null $uri
* @return $this
*/
public function assertRedirect($uri = null)
@@ -94,7 +167,7 @@ class TestResponse
);
if (! is_null($uri)) {
- PHPUnit::assertEquals(app('url')->to($uri), $this->headers->get('Location'));
+ $this->assertLocation($uri);
}
return $this;
@@ -125,6 +198,36 @@ class TestResponse
return $this;
}
+ /**
+ * Asserts that the response does not contains the given header.
+ *
+ * @param string $headerName
+ * @return $this
+ */
+ public function assertHeaderMissing($headerName)
+ {
+ PHPUnit::assertFalse(
+ $this->headers->has($headerName), "Unexpected header [{$headerName}] is present on response."
+ );
+
+ return $this;
+ }
+
+ /**
+ * Assert that the current location header matches the given URI.
+ *
+ * @param string $uri
+ * @return $this
+ */
+ public function assertLocation($uri)
+ {
+ PHPUnit::assertEquals(
+ app('url')->to($uri), app('url')->to($this->headers->get('Location'))
+ );
+
+ return $this;
+ }
+
/**
* Asserts that the response contains the given cookie and equals the optional value.
*
@@ -145,9 +248,10 @@ class TestResponse
* @param string $cookieName
* @param mixed $value
* @param bool $encrypted
+ * @param bool $unserialize
* @return $this
*/
- public function assertCookie($cookieName, $value = null, $encrypted = true)
+ public function assertCookie($cookieName, $value = null, $encrypted = true, $unserialize = false)
{
PHPUnit::assertNotNull(
$cookie = $this->getCookie($cookieName),
@@ -161,7 +265,7 @@ class TestResponse
$cookieValue = $cookie->getValue();
$actual = $encrypted
- ? app('encrypter')->decrypt($cookieValue) : $cookieValue;
+ ? app('encrypter')->decrypt($cookieValue, $unserialize) : $cookieValue;
PHPUnit::assertEquals(
$value, $actual,
@@ -171,6 +275,68 @@ class TestResponse
return $this;
}
+ /**
+ * Asserts that the response contains the given cookie and is expired.
+ *
+ * @param string $cookieName
+ * @return $this
+ */
+ public function assertCookieExpired($cookieName)
+ {
+ PHPUnit::assertNotNull(
+ $cookie = $this->getCookie($cookieName),
+ "Cookie [{$cookieName}] not present on response."
+ );
+
+ $expiresAt = Carbon::createFromTimestamp($cookie->getExpiresTime());
+
+ PHPUnit::assertTrue(
+ $expiresAt->lessThan(Carbon::now()),
+ "Cookie [{$cookieName}] is not expired, it expires at [{$expiresAt}]."
+ );
+
+ return $this;
+ }
+
+ /**
+ * Asserts that the response contains the given cookie and is not expired.
+ *
+ * @param string $cookieName
+ * @return $this
+ */
+ public function assertCookieNotExpired($cookieName)
+ {
+ PHPUnit::assertNotNull(
+ $cookie = $this->getCookie($cookieName),
+ "Cookie [{$cookieName}] not present on response."
+ );
+
+ $expiresAt = Carbon::createFromTimestamp($cookie->getExpiresTime());
+
+ PHPUnit::assertTrue(
+ $expiresAt->greaterThan(Carbon::now()),
+ "Cookie [{$cookieName}] is expired, it expired at [{$expiresAt}]."
+ );
+
+ return $this;
+ }
+
+ /**
+ * Asserts that the response does not contains the given cookie.
+ *
+ * @param string $cookieName
+ * @return $this
+ */
+ public function assertCookieMissing($cookieName)
+ {
+ PHPUnit::assertNull(
+ $this->getCookie($cookieName),
+ "Cookie [{$cookieName}] is present on response."
+ );
+
+ return $this;
+ }
+
/**
* Get the given cookie from the response.
*
@@ -194,7 +360,20 @@ class TestResponse
*/
public function assertSee($value)
{
- PHPUnit::assertContains($value, $this->getContent());
+ PHPUnit::assertStringContainsString((string) $value, $this->getContent());
+
+ return $this;
+ }
+
+ /**
+ * Assert that the given strings are contained in order within the response.
+ *
+ * @param array $values
+ * @return $this
+ */
+ public function assertSeeInOrder(array $values)
+ {
+ PHPUnit::assertThat($values, new SeeInOrder($this->getContent()));
return $this;
}
@@ -207,7 +386,20 @@ class TestResponse
*/
public function assertSeeText($value)
{
- PHPUnit::assertContains($value, strip_tags($this->getContent()));
+ PHPUnit::assertStringContainsString((string) $value, strip_tags($this->getContent()));
+
+ return $this;
+ }
+
+ /**
+ * Assert that the given strings are contained in order within the response text.
+ *
+ * @param array $values
+ * @return $this
+ */
+ public function assertSeeTextInOrder(array $values)
+ {
+ PHPUnit::assertThat($values, new SeeInOrder(strip_tags($this->getContent())));
return $this;
}
@@ -220,7 +412,7 @@ class TestResponse
*/
public function assertDontSee($value)
{
- PHPUnit::assertNotContains($value, $this->getContent());
+ PHPUnit::assertStringNotContainsString((string) $value, $this->getContent());
return $this;
}
@@ -233,7 +425,7 @@ class TestResponse
*/
public function assertDontSeeText($value)
{
- PHPUnit::assertNotContains($value, strip_tags($this->getContent()));
+ PHPUnit::assertStringNotContainsString((string) $value, strip_tags($this->getContent()));
return $this;
}
@@ -242,12 +434,13 @@ class TestResponse
* Assert that the response is a superset of the given JSON.
*
* @param array $data
+ * @param bool $strict
* @return $this
*/
- public function assertJson(array $data)
+ public function assertJson(array $data, $strict = false)
{
PHPUnit::assertArraySubset(
- $data, $this->decodeResponseJson(), false, $this->assertJsonMessage($data)
+ $data, $this->decodeResponseJson(), $strict, $this->assertJsonMessage($data)
);
return $this;
@@ -301,12 +494,12 @@ class TestResponse
));
foreach (Arr::sortRecursive($data) as $key => $value) {
- $expected = substr(json_encode([$key => $value]), 1, -1);
+ $expected = $this->jsonSearchStrings($key, $value);
PHPUnit::assertTrue(
Str::contains($actual, $expected),
'Unable to find JSON fragment: '.PHP_EOL.PHP_EOL.
- "[{$expected}]".PHP_EOL.PHP_EOL.
+ '['.json_encode([$key => $value]).']'.PHP_EOL.PHP_EOL.
'within'.PHP_EOL.PHP_EOL.
"[{$actual}]."
);
@@ -319,21 +512,26 @@ class TestResponse
* Assert that the response does not contain the given JSON fragment.
*
* @param array $data
+ * @param bool $exact
* @return $this
*/
- public function assertJsonMissing(array $data)
+ public function assertJsonMissing(array $data, $exact = false)
{
+ if ($exact) {
+ return $this->assertJsonMissingExact($data);
+ }
+
$actual = json_encode(Arr::sortRecursive(
(array) $this->decodeResponseJson()
));
foreach (Arr::sortRecursive($data) as $key => $value) {
- $expected = substr(json_encode([$key => $value]), 1, -1);
+ $unexpected = $this->jsonSearchStrings($key, $value);
PHPUnit::assertFalse(
- Str::contains($actual, $expected),
+ Str::contains($actual, $unexpected),
'Found unexpected JSON fragment: '.PHP_EOL.PHP_EOL.
- "[{$expected}]".PHP_EOL.PHP_EOL.
+ '['.json_encode([$key => $value]).']'.PHP_EOL.PHP_EOL.
'within'.PHP_EOL.PHP_EOL.
"[{$actual}]."
);
@@ -342,6 +540,52 @@ class TestResponse
return $this;
}
+ /**
+ * Assert that the response does not contain the exact JSON fragment.
+ *
+ * @param array $data
+ * @return $this
+ */
+ public function assertJsonMissingExact(array $data)
+ {
+ $actual = json_encode(Arr::sortRecursive(
+ (array) $this->decodeResponseJson()
+ ));
+
+ foreach (Arr::sortRecursive($data) as $key => $value) {
+ $unexpected = $this->jsonSearchStrings($key, $value);
+
+ if (! Str::contains($actual, $unexpected)) {
+ return $this;
+ }
+ }
+
+ PHPUnit::fail(
+ 'Found unexpected JSON fragment: '.PHP_EOL.PHP_EOL.
+ '['.json_encode($data).']'.PHP_EOL.PHP_EOL.
+ 'within'.PHP_EOL.PHP_EOL.
+ "[{$actual}]."
+ );
+ }
+
+ /**
+ * Get the strings we need to search for when examining the JSON.
+ *
+ * @param string $key
+ * @param string $value
+ * @return array
+ */
+ protected function jsonSearchStrings($key, $value)
+ {
+ $needle = substr(json_encode([$key => $value]), 1, -1);
+
+ return [
+ $needle.']',
+ $needle.'}',
+ $needle.',',
+ ];
+ }
+
/**
* Assert that the response has a given JSON structure.
*
@@ -352,7 +596,7 @@ class TestResponse
public function assertJsonStructure(array $structure = null, $responseData = null)
{
if (is_null($structure)) {
- return $this->assertJson($this->json());
+ return $this->assertExactJson($this->json());
}
if (is_null($responseData)) {
@@ -361,7 +605,7 @@ class TestResponse
foreach ($structure as $key => $value) {
if (is_array($value) && $key === '*') {
- PHPUnit::assertInternalType('array', $responseData);
+ PHPUnit::assertIsArray($responseData);
foreach ($responseData as $responseDataItem) {
$this->assertJsonStructure($structure['*'], $responseDataItem);
@@ -378,12 +622,128 @@ class TestResponse
return $this;
}
+ /**
+ * Assert that the response JSON has the expected count of items at the given key.
+ *
+ * @param int $count
+ * @param string|null $key
+ * @return $this
+ */
+ public function assertJsonCount(int $count, $key = null)
+ {
+ if ($key) {
+ PHPUnit::assertCount(
+ $count, data_get($this->json(), $key),
+ "Failed to assert that the response count matched the expected {$count}"
+ );
+
+ return $this;
+ }
+
+ PHPUnit::assertCount($count,
+ $this->json(),
+ "Failed to assert that the response count matched the expected {$count}"
+ );
+
+ return $this;
+ }
+
+ /**
+ * Assert that the response has the given JSON validation errors.
+ *
+ * @param string|array $errors
+ * @return $this
+ */
+ public function assertJsonValidationErrors($errors)
+ {
+ $errors = Arr::wrap($errors);
+
+ PHPUnit::assertNotEmpty($errors, 'No validation errors were provided.');
+
+ $jsonErrors = $this->json()['errors'] ?? [];
+
+ $errorMessage = $jsonErrors
+ ? 'Response has the following JSON validation errors:'.
+ PHP_EOL.PHP_EOL.json_encode($jsonErrors, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE).PHP_EOL
+ : 'Response does not have JSON validation errors.';
+
+ foreach ($errors as $key => $value) {
+ PHPUnit::assertArrayHasKey(
+ (is_int($key)) ? $value : $key,
+ $jsonErrors,
+ "Failed to find a validation error in the response for key: '{$value}'".PHP_EOL.PHP_EOL.$errorMessage
+ );
+
+ if (! is_int($key)) {
+ $hasError = false;
+
+ foreach (Arr::wrap($jsonErrors[$key]) as $jsonErrorMessage) {
+ if (Str::contains($jsonErrorMessage, $value)) {
+ $hasError = true;
+
+ break;
+ }
+ }
+
+ if (! $hasError) {
+ PHPUnit::fail(
+ "Failed to find a validation error in the response for key and message: '$key' => '$value'".PHP_EOL.PHP_EOL.$errorMessage
+ );
+ }
+ }
+ }
+
+ return $this;
+ }
+
+ /**
+ * Assert that the response has no JSON validation errors for the given keys.
+ *
+ * @param string|array|null $keys
+ * @return $this
+ */
+ public function assertJsonMissingValidationErrors($keys = null)
+ {
+ if ($this->getContent() === '') {
+ PHPUnit::assertTrue(true);
+
+ return $this;
+ }
+
+ $json = $this->json();
+
+ if (! array_key_exists('errors', $json)) {
+ PHPUnit::assertArrayNotHasKey('errors', $json);
+
+ return $this;
+ }
+
+ $errors = $json['errors'];
+
+ if (is_null($keys) && count($errors) > 0) {
+ PHPUnit::fail(
+ 'Response has unexpected validation errors: '.PHP_EOL.PHP_EOL.
+ json_encode($errors, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)
+ );
+ }
+
+ foreach (Arr::wrap($keys) as $key) {
+ PHPUnit::assertFalse(
+ isset($errors[$key]),
+ "Found unexpected validation error for key: '{$key}'"
+ );
+ }
+
+ return $this;
+ }
+
/**
* Validate and return the decoded response JSON.
*
- * @return array
+ * @param string|null $key
+ * @return mixed
*/
- public function decodeResponseJson()
+ public function decodeResponseJson($key = null)
{
$decodedResponse = json_decode($this->getContent(), true);
@@ -395,17 +755,18 @@ class TestResponse
}
}
- return $decodedResponse;
+ return data_get($decodedResponse, $key);
}
/**
* Validate and return the decoded response JSON.
*
- * @return array
+ * @param string|null $key
+ * @return mixed
*/
- public function json()
+ public function json($key = null)
{
- return $this->decodeResponseJson();
+ return $this->decodeResponseJson($key);
}
/**
@@ -418,7 +779,7 @@ class TestResponse
{
$this->ensureResponseHasView();
- PHPUnit::assertEquals($value, $this->original->getName());
+ PHPUnit::assertEquals($value, $this->original->name());
return $this;
}
@@ -439,11 +800,13 @@ class TestResponse
$this->ensureResponseHasView();
if (is_null($value)) {
- PHPUnit::assertArrayHasKey($key, $this->original->getData());
+ PHPUnit::assertArrayHasKey($key, $this->original->gatherData());
} elseif ($value instanceof Closure) {
- PHPUnit::assertTrue($value($this->original->$key));
+ PHPUnit::assertTrue($value($this->original->gatherData()[$key]));
+ } elseif ($value instanceof Model) {
+ PHPUnit::assertTrue($value->is($this->original->gatherData()[$key]));
} else {
- PHPUnit::assertEquals($value, $this->original->$key);
+ PHPUnit::assertEquals($value, $this->original->gatherData()[$key]);
}
return $this;
@@ -468,6 +831,19 @@ class TestResponse
return $this;
}
+ /**
+ * Get a piece of data from the original view.
+ *
+ * @param string $key
+ * @return mixed
+ */
+ public function viewData($key)
+ {
+ $this->ensureResponseHasView();
+
+ return $this->original->gatherData()[$key];
+ }
+
/**
* Assert that the response view is missing a piece of bound data.
*
@@ -478,7 +854,7 @@ class TestResponse
{
$this->ensureResponseHasView();
- PHPUnit::assertArrayNotHasKey($key, $this->original->getData());
+ PHPUnit::assertArrayNotHasKey($key, $this->original->gatherData());
return $this;
}
@@ -515,8 +891,10 @@ class TestResponse
$this->session()->has($key),
"Session is missing expected key [{$key}]."
);
+ } elseif ($value instanceof Closure) {
+ PHPUnit::assertTrue($value($this->session()->get($key)));
} else {
- PHPUnit::assertEquals($value, app('session.store')->get($key));
+ PHPUnit::assertEquals($value, $this->session()->get($key));
}
return $this;
@@ -541,20 +919,56 @@ class TestResponse
return $this;
}
+ /**
+ * Assert that the session has a given value in the flashed input array.
+ *
+ * @param string|array $key
+ * @param mixed $value
+ * @return $this
+ */
+ public function assertSessionHasInput($key, $value = null)
+ {
+ if (is_array($key)) {
+ foreach ($key as $k => $v) {
+ if (is_int($k)) {
+ $this->assertSessionHasInput($v);
+ } else {
+ $this->assertSessionHasInput($k, $v);
+ }
+ }
+
+ return $this;
+ }
+
+ if (is_null($value)) {
+ PHPUnit::assertTrue(
+ $this->session()->getOldInput($key),
+ "Session is missing expected key [{$key}]."
+ );
+ } elseif ($value instanceof Closure) {
+ PHPUnit::assertTrue($value($this->session()->getOldInput($key)));
+ } else {
+ PHPUnit::assertEquals($value, $this->session()->getOldInput($key));
+ }
+
+ return $this;
+ }
+
/**
* Assert that the session has the given errors.
*
* @param string|array $keys
* @param mixed $format
+ * @param string $errorBag
* @return $this
*/
- public function assertSessionHasErrors($keys = [], $format = null)
+ public function assertSessionHasErrors($keys = [], $format = null, $errorBag = 'default')
{
$this->assertSessionHas('errors');
$keys = (array) $keys;
- $errors = app('session.store')->get('errors');
+ $errors = $this->session()->get('errors')->getBag($errorBag);
foreach ($keys as $key => $value) {
if (is_int($key)) {
@@ -567,6 +981,74 @@ class TestResponse
return $this;
}
+ /**
+ * Assert that the session is missing the given errors.
+ *
+ * @param string|array $keys
+ * @param string|null $format
+ * @param string $errorBag
+ * @return $this
+ */
+ public function assertSessionDoesntHaveErrors($keys = [], $format = null, $errorBag = 'default')
+ {
+ $keys = (array) $keys;
+
+ if (empty($keys)) {
+ return $this->assertSessionHasNoErrors();
+ }
+
+ if (is_null($this->session()->get('errors'))) {
+ PHPUnit::assertTrue(true);
+
+ return $this;
+ }
+
+ $errors = $this->session()->get('errors')->getBag($errorBag);
+
+ foreach ($keys as $key => $value) {
+ if (is_int($key)) {
+ PHPUnit::assertFalse($errors->has($value), "Session has unexpected error: $value");
+ } else {
+ PHPUnit::assertNotContains($value, $errors->get($key, $format));
+ }
+ }
+
+ return $this;
+ }
+
+ /**
+ * Assert that the session has no errors.
+ *
+ * @return $this
+ */
+ public function assertSessionHasNoErrors()
+ {
+ $hasErrors = $this->session()->has('errors');
+
+ $errors = $hasErrors ? $this->session()->get('errors')->all() : [];
+
+ PHPUnit::assertFalse(
+ $hasErrors,
+ 'Session has unexpected errors: '.PHP_EOL.PHP_EOL.
+ json_encode($errors, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)
+ );
+
+ return $this;
+ }
+
+ /**
+ * Assert that the session has the given errors.
+ *
+ * @param string $errorBag
+ * @param string|array $keys
+ * @param mixed $format
+ * @return $this
+ */
+ public function assertSessionHasErrorsIn($errorBag, $keys = [], $format = null)
+ {
+ return $this->assertSessionHasErrors($keys, $format, $errorBag);
+ }
+
/**
* Assert that the session does not have a given key.
*
@@ -602,7 +1084,7 @@ class TestResponse
/**
* Dump the content from the response.
*
- * @return void
+ * @return $this
*/
public function dump()
{
@@ -614,7 +1096,43 @@ class TestResponse
$content = $json;
}
- dd($content);
+ dump($content);
+
+ return $this;
+ }
+
+ /**
+ * Dump the headers from the response.
+ *
+ * @return $this
+ */
+ public function dumpHeaders()
+ {
+ dump($this->headers->all());
+
+ return $this;
+ }
+
+ /**
+ * Get the streamed content from the response.
+ *
+ * @return string
+ */
+ public function streamedContent()
+ {
+ if (! is_null($this->streamedContent)) {
+ return $this->streamedContent;
+ }
+
+ if (! $this->baseResponse instanceof StreamedResponse) {
+ PHPUnit::fail('The response is not a streamed response.');
+ }
+
+ ob_start();
+
+ $this->sendContent();
+
+ return $this->streamedContent = ob_get_clean();
}
/**
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Validation/ValidatesRequests.php b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Validation/ValidatesRequests.php
index c1873b4c..89ab3d12 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Validation/ValidatesRequests.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/Validation/ValidatesRequests.php
@@ -3,39 +3,29 @@
namespace Illuminate\Foundation\Validation;
use Illuminate\Http\Request;
-use Illuminate\Http\JsonResponse;
-use Illuminate\Routing\UrlGenerator;
use Illuminate\Contracts\Validation\Factory;
-use Illuminate\Contracts\Validation\Validator;
use Illuminate\Validation\ValidationException;
trait ValidatesRequests
{
- /**
- * The default error bag.
- *
- * @var string
- */
- protected $validatesRequestErrorBag;
-
/**
* Run the validation routine against the given validator.
*
* @param \Illuminate\Contracts\Validation\Validator|array $validator
* @param \Illuminate\Http\Request|null $request
- * @return void
+ * @return array
+ *
+ * @throws \Illuminate\Validation\ValidationException
*/
public function validateWith($validator, Request $request = null)
{
- $request = $request ?: app('request');
+ $request = $request ?: request();
if (is_array($validator)) {
$validator = $this->getValidationFactory()->make($request->all(), $validator);
}
- if ($validator->fails()) {
- $this->throwValidationException($request, $validator);
- }
+ return $validator->validate();
}
/**
@@ -45,115 +35,40 @@ trait ValidatesRequests
* @param array $rules
* @param array $messages
* @param array $customAttributes
- * @return void
- */
- public function validate(Request $request, array $rules, array $messages = [], array $customAttributes = [])
- {
- $validator = $this->getValidationFactory()->make($request->all(), $rules, $messages, $customAttributes);
-
- if ($validator->fails()) {
- $this->throwValidationException($request, $validator);
- }
- }
-
- /**
- * Validate the given request with the given rules.
- *
- * @param string $errorBag
- * @param \Illuminate\Http\Request $request
- * @param array $rules
- * @param array $messages
- * @param array $customAttributes
- * @return void
- *
- * @throws \Illuminate\Validation\ValidationException
- */
- public function validateWithBag($errorBag, Request $request, array $rules, array $messages = [], array $customAttributes = [])
- {
- $this->withErrorBag($errorBag, function () use ($request, $rules, $messages, $customAttributes) {
- $this->validate($request, $rules, $messages, $customAttributes);
- });
- }
-
- /**
- * Execute a Closure within with a given error bag set as the default bag.
- *
- * @param string $errorBag
- * @param callable $callback
- * @return void
- */
- protected function withErrorBag($errorBag, callable $callback)
- {
- $this->validatesRequestErrorBag = $errorBag;
-
- call_user_func($callback);
-
- $this->validatesRequestErrorBag = null;
- }
-
- /**
- * Throw the failed validation exception.
- *
- * @param \Illuminate\Http\Request $request
- * @param \Illuminate\Contracts\Validation\Validator $validator
- * @return void
- *
- * @throws \Illuminate\Validation\ValidationException
- */
- protected function throwValidationException(Request $request, $validator)
- {
- throw new ValidationException($validator, $this->buildFailedValidationResponse(
- $request, $this->formatValidationErrors($validator)
- ));
- }
-
- /**
- * Create the response for when a request fails validation.
- *
- * @param \Illuminate\Http\Request $request
- * @param array $errors
- * @return \Symfony\Component\HttpFoundation\Response
- */
- protected function buildFailedValidationResponse(Request $request, array $errors)
- {
- if ($request->expectsJson()) {
- return new JsonResponse($errors, 422);
- }
-
- return redirect()->to($this->getRedirectUrl())
- ->withInput($request->input())
- ->withErrors($errors, $this->errorBag());
- }
-
- /**
- * Format the validation errors to be returned.
- *
- * @param \Illuminate\Contracts\Validation\Validator $validator
* @return array
+ *
+ * @throws \Illuminate\Validation\ValidationException
*/
- protected function formatValidationErrors(Validator $validator)
+ public function validate(Request $request, array $rules,
+ array $messages = [], array $customAttributes = [])
{
- return $validator->errors()->getMessages();
+ return $this->getValidationFactory()->make(
+ $request->all(), $rules, $messages, $customAttributes
+ )->validate();
}
/**
- * Get the key to be used for the view error bag.
+ * Validate the given request with the given rules.
*
- * @return string
+ * @param string $errorBag
+ * @param \Illuminate\Http\Request $request
+ * @param array $rules
+ * @param array $messages
+ * @param array $customAttributes
+ * @return array
+ *
+ * @throws \Illuminate\Validation\ValidationException
*/
- protected function errorBag()
+ public function validateWithBag($errorBag, Request $request, array $rules,
+ array $messages = [], array $customAttributes = [])
{
- return $this->validatesRequestErrorBag ?: 'default';
- }
+ try {
+ return $this->validate($request, $rules, $messages, $customAttributes);
+ } catch (ValidationException $e) {
+ $e->errorBag = $errorBag;
- /**
- * Get the URL we should redirect to.
- *
- * @return string
- */
- protected function getRedirectUrl()
- {
- return app(UrlGenerator::class)->previous();
+ throw $e;
+ }
}
/**
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php
index 5313ffb6..b5edd0ad 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php
@@ -1,14 +1,24 @@
toResponse(request()));
+ }
+
app()->abort($code, $message, $headers);
}
}
@@ -77,8 +93,8 @@ if (! function_exists('action')) {
/**
* Generate the URL to a controller action.
*
- * @param string $name
- * @param array $parameters
+ * @param string|array $name
+ * @param mixed $parameters
* @param bool $absolute
* @return string
*/
@@ -92,9 +108,9 @@ if (! function_exists('app')) {
/**
* Get the available container instance.
*
- * @param string $abstract
+ * @param string|null $abstract
* @param array $parameters
- * @return mixed|\Illuminate\Foundation\Application
+ * @return mixed|\Illuminate\Contracts\Foundation\Application
*/
function app($abstract = null, array $parameters = [])
{
@@ -102,9 +118,7 @@ if (! function_exists('app')) {
return Container::getInstance();
}
- return empty($parameters)
- ? Container::getInstance()->make($abstract)
- : Container::getInstance()->makeWith($abstract, $parameters);
+ return Container::getInstance()->make($abstract, $parameters);
}
}
@@ -126,7 +140,7 @@ if (! function_exists('asset')) {
* Generate an asset path for the application.
*
* @param string $path
- * @param bool $secure
+ * @param bool|null $secure
* @return string
*/
function asset($path, $secure = null)
@@ -146,9 +160,9 @@ if (! function_exists('auth')) {
{
if (is_null($guard)) {
return app(AuthFactory::class);
- } else {
- return app(AuthFactory::class)->guard($guard);
}
+
+ return app(AuthFactory::class)->guard($guard);
}
}
@@ -182,15 +196,15 @@ if (! function_exists('base_path')) {
if (! function_exists('bcrypt')) {
/**
- * Hash the given value.
+ * Hash the given value against the bcrypt algorithm.
*
* @param string $value
- * @param array $options
+ * @param array $options
* @return string
*/
function bcrypt($value, $options = [])
{
- return app('hash')->make($value, $options);
+ return app('hash')->driver('bcrypt')->make($value, $options);
}
}
@@ -199,7 +213,7 @@ if (! function_exists('broadcast')) {
* Begin broadcasting an event.
*
* @param mixed|null $event
- * @return \Illuminate\Broadcasting\PendingBroadcast|void
+ * @return \Illuminate\Broadcasting\PendingBroadcast
*/
function broadcast($event = null)
{
@@ -214,7 +228,7 @@ if (! function_exists('cache')) {
* If an array is passed, we'll assume you want to put to the cache.
*
* @param dynamic key|key,default|data,expiration|null
- * @return mixed
+ * @return mixed|\Illuminate\Cache\CacheManager
*
* @throws \Exception
*/
@@ -227,7 +241,7 @@ if (! function_exists('cache')) {
}
if (is_string($arguments[0])) {
- return app('cache')->get($arguments[0], isset($arguments[1]) ? $arguments[1] : null);
+ return app('cache')->get(...$arguments);
}
if (! is_array($arguments[0])) {
@@ -252,9 +266,9 @@ if (! function_exists('config')) {
*
* If an array is passed as the key, we will assume you want to set an array of values.
*
- * @param array|string $key
+ * @param array|string|null $key
* @param mixed $default
- * @return mixed
+ * @return mixed|\Illuminate\Config\Repository
*/
function config($key = null, $default = null)
{
@@ -287,16 +301,18 @@ if (! function_exists('cookie')) {
/**
* 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
+ * @param string|null $name
+ * @param string|null $value
+ * @param int $minutes
+ * @param string|null $path
+ * @param string|null $domain
+ * @param bool $secure
+ * @param bool $httpOnly
+ * @param bool $raw
+ * @param string|null $sameSite
+ * @return \Illuminate\Cookie\CookieJar|\Symfony\Component\HttpFoundation\Cookie
*/
- function cookie($name = null, $value = null, $minutes = 0, $path = null, $domain = null, $secure = false, $httpOnly = true)
+ function cookie($name = null, $value = null, $minutes = 0, $path = null, $domain = null, $secure = false, $httpOnly = true, $raw = false, $sameSite = null)
{
$cookie = app(CookieFactory::class);
@@ -304,7 +320,7 @@ if (! function_exists('cookie')) {
return $cookie;
}
- return $cookie->make($name, $value, $minutes, $path, $domain, $secure, $httpOnly);
+ return $cookie->make($name, $value, $minutes, $path, $domain, $secure, $httpOnly, $raw, $sameSite);
}
}
@@ -358,11 +374,12 @@ if (! function_exists('decrypt')) {
* Decrypt the given value.
*
* @param string $value
- * @return string
+ * @param bool $unserialize
+ * @return mixed
*/
- function decrypt($value)
+ function decrypt($value, $unserialize = true)
{
- return app('encrypter')->decrypt($value);
+ return app('encrypter')->decrypt($value, $unserialize);
}
}
@@ -371,11 +388,29 @@ if (! function_exists('dispatch')) {
* Dispatch a job to its appropriate handler.
*
* @param mixed $job
- * @return mixed
+ * @return \Illuminate\Foundation\Bus\PendingDispatch
*/
function dispatch($job)
{
- return app(Dispatcher::class)->dispatch($job);
+ if ($job instanceof Closure) {
+ $job = new CallQueuedClosure(new SerializableClosure($job));
+ }
+
+ return new PendingDispatch($job);
+ }
+}
+
+if (! function_exists('dispatch_now')) {
+ /**
+ * Dispatch a command to its appropriate handler in the current process.
+ *
+ * @param mixed $job
+ * @param mixed $handler
+ * @return mixed
+ */
+ function dispatch_now($job, $handler = null)
+ {
+ return app(Dispatcher::class)->dispatchNow($job, $handler);
}
}
@@ -424,11 +459,12 @@ if (! function_exists('encrypt')) {
* Encrypt the given value.
*
* @param mixed $value
+ * @param bool $serialize
* @return string
*/
- function encrypt($value)
+ function encrypt($value, $serialize = true)
{
- return app('encrypter')->encrypt($value);
+ return app('encrypter')->encrypt($value, $serialize);
}
}
@@ -461,12 +497,12 @@ if (! function_exists('factory')) {
$arguments = func_get_args();
if (isset($arguments[1]) && is_string($arguments[1])) {
- return $factory->of($arguments[0], $arguments[1])->times(isset($arguments[2]) ? $arguments[2] : null);
+ return $factory->of($arguments[0], $arguments[1])->times($arguments[2] ?? null);
} elseif (isset($arguments[1])) {
return $factory->of($arguments[0])->times($arguments[1]);
- } else {
- return $factory->of($arguments[0]);
}
+
+ return $factory->of($arguments[0]);
}
}
@@ -480,7 +516,7 @@ if (! function_exists('info')) {
*/
function info($message, $context = [])
{
- return app('log')->info($message, $context);
+ app('log')->info($message, $context);
}
}
@@ -488,9 +524,9 @@ if (! function_exists('logger')) {
/**
* Log a debug message to the logs.
*
- * @param string $message
+ * @param string|null $message
* @param array $context
- * @return \Illuminate\Contracts\Logging\Log|null
+ * @return \Illuminate\Log\LogManager|null
*/
function logger($message = null, array $context = [])
{
@@ -502,6 +538,19 @@ if (! function_exists('logger')) {
}
}
+if (! function_exists('logs')) {
+ /**
+ * Get a log driver instance.
+ *
+ * @param string|null $driver
+ * @return \Illuminate\Log\LogManager|\Psr\Log\LoggerInterface
+ */
+ function logs($driver = null)
+ {
+ return $driver ? app('log')->driver($driver) : app('log');
+ }
+}
+
if (! function_exists('method_field')) {
/**
* Generate a form field to spoof the HTTP verb used by forms.
@@ -521,46 +570,26 @@ if (! function_exists('mix')) {
*
* @param string $path
* @param string $manifestDirectory
- * @return \Illuminate\Support\HtmlString
+ * @return \Illuminate\Support\HtmlString|string
*
* @throws \Exception
*/
function mix($path, $manifestDirectory = '')
{
- static $manifests = [];
+ return app(Mix::class)(...func_get_args());
+ }
+}
- if (! starts_with($path, '/')) {
- $path = "/{$path}";
- }
-
- if ($manifestDirectory && ! starts_with($manifestDirectory, '/')) {
- $manifestDirectory = "/{$manifestDirectory}";
- }
-
- if (file_exists(public_path($manifestDirectory.'/hot'))) {
- return new HtmlString("//localhost:8080{$path}");
- }
-
- $manifestPath = public_path($manifestDirectory.'/mix-manifest.json');
-
- if (! isset($manifests[$manifestPath])) {
- if (! file_exists($manifestPath)) {
- throw new Exception('The Mix manifest does not exist.');
- }
-
- $manifests[$manifestPath] = json_decode(file_get_contents($manifestPath), true);
- }
-
- $manifest = $manifests[$manifestPath];
-
- if (! isset($manifest[$path])) {
- throw new Exception(
- "Unable to locate Mix file: {$path}. Please check your ".
- 'webpack.mix.js output paths and try again.'
- );
- }
-
- return new HtmlString($manifestDirectory.$manifest[$path]);
+if (! function_exists('now')) {
+ /**
+ * Create a new Carbon instance for the current time.
+ *
+ * @param \DateTimeZone|string|null $tz
+ * @return \Illuminate\Support\Carbon
+ */
+ function now($tz = null)
+ {
+ return Date::now($tz);
}
}
@@ -568,7 +597,7 @@ if (! function_exists('old')) {
/**
* Retrieve an old input item.
*
- * @param string $key
+ * @param string|null $key
* @param mixed $default
* @return mixed
*/
@@ -613,7 +642,7 @@ if (! function_exists('redirect')) {
* @param string|null $to
* @param int $status
* @param array $headers
- * @param bool $secure
+ * @param bool|null $secure
* @return \Illuminate\Routing\Redirector|\Illuminate\Http\RedirectResponse
*/
function redirect($to = null, $status = 302, $headers = [], $secure = null)
@@ -626,11 +655,29 @@ if (! function_exists('redirect')) {
}
}
+if (! function_exists('report')) {
+ /**
+ * Report an exception.
+ *
+ * @param \Throwable $exception
+ * @return void
+ */
+ function report($exception)
+ {
+ if ($exception instanceof Throwable &&
+ ! $exception instanceof Exception) {
+ $exception = new FatalThrowableError($exception);
+ }
+
+ app(ExceptionHandler::class)->report($exception);
+ }
+}
+
if (! function_exists('request')) {
/**
* Get an instance of the current request or an input item from the request.
*
- * @param array|string $key
+ * @param array|string|null $key
* @param mixed $default
* @return \Illuminate\Http\Request|string|array
*/
@@ -644,7 +691,32 @@ if (! function_exists('request')) {
return app('request')->only($key);
}
- return data_get(app('request')->all(), $key, $default);
+ $value = app('request')->__get($key);
+
+ return is_null($value) ? value($default) : $value;
+ }
+}
+
+if (! function_exists('rescue')) {
+ /**
+ * Catch a potential exception and return a default value.
+ *
+ * @param callable $callback
+ * @param mixed $rescue
+ * @param bool $report
+ * @return mixed
+ */
+ function rescue(callable $callback, $rescue = null, $report = true)
+ {
+ try {
+ return $callback();
+ } catch (Throwable $e) {
+ if ($report) {
+ report($e);
+ }
+
+ return value($rescue);
+ }
}
}
@@ -653,11 +725,12 @@ if (! function_exists('resolve')) {
* Resolve a service from the container.
*
* @param string $name
+ * @param array $parameters
* @return mixed
*/
- function resolve($name)
+ function resolve($name, array $parameters = [])
{
- return app($name);
+ return app($name, $parameters);
}
}
@@ -678,10 +751,10 @@ if (! function_exists('response')) {
/**
* Return a new response from the application.
*
- * @param string $content
+ * @param \Illuminate\View\View|string|array|null $content
* @param int $status
* @param array $headers
- * @return \Symfony\Component\HttpFoundation\Response|\Illuminate\Contracts\Routing\ResponseFactory
+ * @return \Illuminate\Http\Response|\Illuminate\Contracts\Routing\ResponseFactory
*/
function response($content = '', $status = 200, array $headers = [])
{
@@ -699,9 +772,9 @@ if (! function_exists('route')) {
/**
* Generate the URL to a named route.
*
- * @param string $name
- * @param array $parameters
- * @param bool $absolute
+ * @param array|string $name
+ * @param mixed $parameters
+ * @param bool $absolute
* @return string
*/
function route($name, $parameters = [], $absolute = true)
@@ -743,9 +816,9 @@ if (! function_exists('session')) {
*
* If an array is passed as the key, we will assume you want to set an array of values.
*
- * @param array|string $key
+ * @param array|string|null $key
* @param mixed $default
- * @return mixed
+ * @return mixed|\Illuminate\Session\Store|\Illuminate\Session\SessionManager
*/
function session($key = null, $default = null)
{
@@ -774,13 +847,26 @@ if (! function_exists('storage_path')) {
}
}
+if (! function_exists('today')) {
+ /**
+ * Create a new Carbon instance for the current date.
+ *
+ * @param \DateTimeZone|string|null $tz
+ * @return \Illuminate\Support\Carbon
+ */
+ function today($tz = null)
+ {
+ return Date::today($tz);
+ }
+}
+
if (! function_exists('trans')) {
/**
* Translate the given message.
*
- * @param string $key
+ * @param string|null $key
* @param array $replace
- * @param string $locale
+ * @param string|null $locale
* @return \Illuminate\Contracts\Translation\Translator|string|array|null
*/
function trans($key = null, $replace = [], $locale = null)
@@ -800,7 +886,7 @@ if (! function_exists('trans_choice')) {
* @param string $key
* @param int|array|\Countable $number
* @param array $replace
- * @param string $locale
+ * @param string|null $locale
* @return string
*/
function trans_choice($key, $number, array $replace = [], $locale = null)
@@ -815,10 +901,10 @@ if (! function_exists('__')) {
*
* @param string $key
* @param array $replace
- * @param string $locale
- * @return \Illuminate\Contracts\Translation\Translator|string
+ * @param string|null $locale
+ * @return string|array|null
*/
- function __($key = null, $replace = [], $locale = null)
+ function __($key, $replace = [], $locale = null)
{
return app('translator')->getFromJson($key, $replace, $locale);
}
@@ -830,7 +916,7 @@ if (! function_exists('url')) {
*
* @param string $path
* @param mixed $parameters
- * @param bool $secure
+ * @param bool|null $secure
* @return \Illuminate\Contracts\Routing\UrlGenerator|string
*/
function url($path = null, $parameters = [], $secure = null)
@@ -851,7 +937,7 @@ if (! function_exists('validator')) {
* @param array $rules
* @param array $messages
* @param array $customAttributes
- * @return \Illuminate\Contracts\Validation\Validator
+ * @return \Illuminate\Contracts\Validation\Validator|\Illuminate\Contracts\Validation\Factory
*/
function validator(array $data = [], array $rules = [], array $messages = [], array $customAttributes = [])
{
@@ -869,8 +955,8 @@ if (! function_exists('view')) {
/**
* Get the evaluated view contents for the given view.
*
- * @param string $view
- * @param array $data
+ * @param string|null $view
+ * @param \Illuminate\Contracts\Support\Arrayable|array $data
* @param array $mergeData
* @return \Illuminate\View\View|\Illuminate\Contracts\View\Factory
*/
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Hashing/BcryptHasher.php b/pfosten/vendor/laravel/framework/src/Illuminate/Hashing/BcryptHasher.php
index 0a403b88..c853915c 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Hashing/BcryptHasher.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Hashing/BcryptHasher.php
@@ -5,15 +5,34 @@ namespace Illuminate\Hashing;
use RuntimeException;
use Illuminate\Contracts\Hashing\Hasher as HasherContract;
-class BcryptHasher implements HasherContract
+class BcryptHasher extends AbstractHasher implements HasherContract
{
/**
- * Default crypt cost factor.
+ * The default cost factor.
*
* @var int
*/
protected $rounds = 10;
+ /**
+ * Indicates whether to perform an algorithm check.
+ *
+ * @var bool
+ */
+ protected $verifyAlgorithm = false;
+
+ /**
+ * Create a new hasher instance.
+ *
+ * @param array $options
+ * @return void
+ */
+ public function __construct(array $options = [])
+ {
+ $this->rounds = $options['rounds'] ?? $this->rounds;
+ $this->verifyAlgorithm = $options['verify'] ?? $this->verifyAlgorithm;
+ }
+
/**
* Hash the given value.
*
@@ -41,16 +60,18 @@ class BcryptHasher implements HasherContract
*
* @param string $value
* @param string $hashedValue
- * @param array $options
+ * @param array $options
* @return bool
+ *
+ * @throws \RuntimeException
*/
public function check($value, $hashedValue, array $options = [])
{
- if (strlen($hashedValue) === 0) {
- return false;
+ if ($this->verifyAlgorithm && $this->info($hashedValue)['algoName'] !== 'bcrypt') {
+ throw new RuntimeException('This password does not use the Bcrypt algorithm.');
}
- return password_verify($value, $hashedValue);
+ return parent::check($value, $hashedValue, $options);
}
/**
@@ -88,6 +109,6 @@ class BcryptHasher implements HasherContract
*/
protected function cost(array $options = [])
{
- return isset($options['rounds']) ? $options['rounds'] : $this->rounds;
+ return $options['rounds'] ?? $this->rounds;
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Hashing/HashServiceProvider.php b/pfosten/vendor/laravel/framework/src/Illuminate/Hashing/HashServiceProvider.php
index 85581f40..123b25fa 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Hashing/HashServiceProvider.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Hashing/HashServiceProvider.php
@@ -3,16 +3,10 @@
namespace Illuminate\Hashing;
use Illuminate\Support\ServiceProvider;
+use Illuminate\Contracts\Support\DeferrableProvider;
-class HashServiceProvider extends ServiceProvider
+class HashServiceProvider extends ServiceProvider implements DeferrableProvider
{
- /**
- * Indicates if loading of the provider is deferred.
- *
- * @var bool
- */
- protected $defer = true;
-
/**
* Register the service provider.
*
@@ -20,8 +14,12 @@ class HashServiceProvider extends ServiceProvider
*/
public function register()
{
- $this->app->singleton('hash', function () {
- return new BcryptHasher;
+ $this->app->singleton('hash', function ($app) {
+ return new HashManager($app);
+ });
+
+ $this->app->singleton('hash.driver', function ($app) {
+ return $app['hash']->driver();
});
}
@@ -32,6 +30,6 @@ class HashServiceProvider extends ServiceProvider
*/
public function provides()
{
- return ['hash'];
+ return ['hash', 'hash.driver'];
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Hashing/composer.json b/pfosten/vendor/laravel/framework/src/Illuminate/Hashing/composer.json
index 24680835..4da36baa 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Hashing/composer.json
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Hashing/composer.json
@@ -14,9 +14,9 @@
}
],
"require": {
- "php": ">=5.6.4",
- "illuminate/contracts": "5.4.*",
- "illuminate/support": "5.4.*"
+ "php": "^7.1.3",
+ "illuminate/contracts": "5.8.*",
+ "illuminate/support": "5.8.*"
},
"autoload": {
"psr-4": {
@@ -25,7 +25,7 @@
},
"extra": {
"branch-alias": {
- "dev-master": "5.4-dev"
+ "dev-master": "5.8-dev"
}
},
"config": {
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Http/Concerns/InteractsWithContentTypes.php b/pfosten/vendor/laravel/framework/src/Illuminate/Http/Concerns/InteractsWithContentTypes.php
index 492c131b..be760a26 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Http/Concerns/InteractsWithContentTypes.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Http/Concerns/InteractsWithContentTypes.php
@@ -41,11 +41,11 @@ trait InteractsWithContentTypes
*/
public function expectsJson()
{
- return ($this->ajax() && ! $this->pjax()) || $this->wantsJson();
+ return ($this->ajax() && ! $this->pjax() && $this->acceptsAnyContentType()) || $this->wantsJson();
}
/**
- * Determine if the current request is asking for JSON in return.
+ * Determine if the current request is asking for JSON.
*
* @return bool
*/
@@ -118,6 +118,20 @@ trait InteractsWithContentTypes
}
}
+ /**
+ * Determine if the current request accepts any content type.
+ *
+ * @return bool
+ */
+ public function acceptsAnyContentType()
+ {
+ $acceptable = $this->getAcceptableContentTypes();
+
+ return count($acceptable) === 0 || (
+ isset($acceptable[0]) && ($acceptable[0] === '*/*' || $acceptable[0] === '*')
+ );
+ }
+
/**
* Determines whether a request accepts JSON.
*
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Http/Concerns/InteractsWithFlashData.php b/pfosten/vendor/laravel/framework/src/Illuminate/Http/Concerns/InteractsWithFlashData.php
index c6b84f2e..25e11a95 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Http/Concerns/InteractsWithFlashData.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Http/Concerns/InteractsWithFlashData.php
@@ -7,13 +7,13 @@ trait InteractsWithFlashData
/**
* Retrieve an old input item.
*
- * @param string $key
+ * @param string|null $key
* @param string|array|null $default
* @return string|array
*/
public function old($key = null, $default = null)
{
- return $this->session()->getOldInput($key, $default);
+ return $this->hasSession() ? $this->session()->getOldInput($key, $default) : $default;
}
/**
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Http/Concerns/InteractsWithInput.php b/pfosten/vendor/laravel/framework/src/Illuminate/Http/Concerns/InteractsWithInput.php
index e00b1323..3b876267 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Http/Concerns/InteractsWithInput.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Http/Concerns/InteractsWithInput.php
@@ -2,6 +2,7 @@
namespace Illuminate\Http\Concerns;
+use stdClass;
use SplFileInfo;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
@@ -12,9 +13,9 @@ trait InteractsWithInput
/**
* Retrieve a server variable from the request.
*
- * @param string $key
+ * @param string|null $key
* @param string|array|null $default
- * @return string|array
+ * @return string|array|null
*/
public function server($key = null, $default = null)
{
@@ -35,9 +36,9 @@ trait InteractsWithInput
/**
* Retrieve a header from the request.
*
- * @param string $key
+ * @param string|null $key
* @param string|array|null $default
- * @return string|array
+ * @return string|array|null
*/
public function header($key = null, $default = null)
{
@@ -65,6 +66,17 @@ trait InteractsWithInput
* @return bool
*/
public function exists($key)
+ {
+ return $this->has($key);
+ }
+
+ /**
+ * Determine if the request contains a given input item key.
+ *
+ * @param string|array $key
+ * @return bool
+ */
+ public function has($key)
{
$keys = is_array($key) ? $key : func_get_args();
@@ -79,13 +91,34 @@ trait InteractsWithInput
return true;
}
+ /**
+ * Determine if the request contains any of the given inputs.
+ *
+ * @param string|array $keys
+ * @return bool
+ */
+ public function hasAny($keys)
+ {
+ $keys = is_array($keys) ? $keys : func_get_args();
+
+ $input = $this->all();
+
+ foreach ($keys as $key) {
+ if (Arr::has($input, $key)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
/**
* Determine if the request contains a non-empty value for an input item.
*
* @param string|array $key
* @return bool
*/
- public function has($key)
+ public function filled($key)
{
$keys = is_array($key) ? $key : func_get_args();
@@ -98,6 +131,25 @@ trait InteractsWithInput
return true;
}
+ /**
+ * Determine if the request contains a non-empty value for any of the given inputs.
+ *
+ * @param string|array $keys
+ * @return bool
+ */
+ public function anyFilled($keys)
+ {
+ $keys = is_array($keys) ? $keys : func_get_args();
+
+ foreach ($keys as $key) {
+ if ($this->filled($key)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
/**
* Determine if the given input key is an empty string for "has".
*
@@ -112,21 +164,44 @@ trait InteractsWithInput
}
/**
- * Get all of the input and files for the request.
+ * Get the keys for all of the input and files.
*
* @return array
*/
- public function all()
+ public function keys()
{
- return array_replace_recursive($this->input(), $this->allFiles());
+ return array_merge(array_keys($this->input()), $this->files->keys());
+ }
+
+ /**
+ * Get all of the input and files for the request.
+ *
+ * @param array|mixed|null $keys
+ * @return array
+ */
+ public function all($keys = null)
+ {
+ $input = array_replace_recursive($this->input(), $this->allFiles());
+
+ if (! $keys) {
+ return $input;
+ }
+
+ $results = [];
+
+ foreach (is_array($keys) ? $keys : func_get_args() as $key) {
+ Arr::set($results, $key, Arr::get($input, $key));
+ }
+
+ return $results;
}
/**
* Retrieve an input item from the request.
*
- * @param string $key
+ * @param string|null $key
* @param string|array|null $default
- * @return string|array
+ * @return string|array|null
*/
public function input($key = null, $default = null)
{
@@ -143,14 +218,18 @@ trait InteractsWithInput
*/
public function only($keys)
{
- $keys = is_array($keys) ? $keys : func_get_args();
-
$results = [];
$input = $this->all();
- foreach ($keys as $key) {
- Arr::set($results, $key, data_get($input, $key));
+ $placeholder = new stdClass;
+
+ foreach (is_array($keys) ? $keys : func_get_args() as $key) {
+ $value = data_get($input, $key, $placeholder);
+
+ if ($value !== $placeholder) {
+ Arr::set($results, $key, $value);
+ }
}
return $results;
@@ -173,29 +252,30 @@ trait InteractsWithInput
return $results;
}
- /**
- * Intersect an array of items with the input data.
- *
- * @param array|mixed $keys
- * @return array
- */
- public function intersect($keys)
- {
- return array_filter($this->only(is_array($keys) ? $keys : func_get_args()));
- }
-
/**
* Retrieve a query string item from the request.
*
- * @param string $key
+ * @param string|null $key
* @param string|array|null $default
- * @return string|array
+ * @return string|array|null
*/
public function query($key = null, $default = null)
{
return $this->retrieveItem('query', $key, $default);
}
+ /**
+ * Retrieve a request payload item from the request.
+ *
+ * @param string|null $key
+ * @param string|array|null $default
+ * @return string|array|null
+ */
+ public function post($key = null, $default = null)
+ {
+ return $this->retrieveItem('request', $key, $default);
+ }
+
/**
* Determine if a cookie is set on the request.
*
@@ -210,9 +290,9 @@ trait InteractsWithInput
/**
* Retrieve a cookie from the request.
*
- * @param string $key
+ * @param string|null $key
* @param string|array|null $default
- * @return string|array
+ * @return string|array|null
*/
public function cookie($key = null, $default = null)
{
@@ -228,9 +308,7 @@ trait InteractsWithInput
{
$files = $this->files->all();
- return $this->convertedFiles
- ? $this->convertedFiles
- : $this->convertedFiles = $this->convertUploadedFiles($files);
+ return $this->convertedFiles = $this->convertedFiles ?? $this->convertUploadedFiles($files);
}
/**
@@ -281,15 +359,15 @@ trait InteractsWithInput
*/
protected function isValidFile($file)
{
- return $file instanceof SplFileInfo && $file->getPath() != '';
+ return $file instanceof SplFileInfo && $file->getPath() !== '';
}
/**
* Retrieve a file from the request.
*
- * @param string $key
+ * @param string|null $key
* @param mixed $default
- * @return \Illuminate\Http\UploadedFile|array|null
+ * @return \Illuminate\Http\UploadedFile|\Illuminate\Http\UploadedFile[]|array|null
*/
public function file($key = null, $default = null)
{
@@ -302,7 +380,7 @@ trait InteractsWithInput
* @param string $source
* @param string $key
* @param string|array|null $default
- * @return string|array
+ * @return string|array|null
*/
protected function retrieveItem($source, $key, $default)
{
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Http/Exceptions/PostTooLargeException.php b/pfosten/vendor/laravel/framework/src/Illuminate/Http/Exceptions/PostTooLargeException.php
index 30421da4..640b8ec7 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Http/Exceptions/PostTooLargeException.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Http/Exceptions/PostTooLargeException.php
@@ -3,8 +3,21 @@
namespace Illuminate\Http\Exceptions;
use Exception;
+use Symfony\Component\HttpKernel\Exception\HttpException;
-class PostTooLargeException extends Exception
+class PostTooLargeException extends HttpException
{
- //
+ /**
+ * PostTooLargeException constructor.
+ *
+ * @param string|null $message
+ * @param \Exception|null $previous
+ * @param array $headers
+ * @param int $code
+ * @return void
+ */
+ public function __construct($message = null, Exception $previous = null, array $headers = [], $code = 0)
+ {
+ parent::__construct(413, $message, $previous, $headers, $code);
+ }
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Http/FileHelpers.php b/pfosten/vendor/laravel/framework/src/Illuminate/Http/FileHelpers.php
index 8da45181..36ed55be 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Http/FileHelpers.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Http/FileHelpers.php
@@ -33,20 +33,10 @@ trait FileHelpers
return $this->guessExtension();
}
- /**
- * Get the file's extension supplied by the client.
- *
- * @return string
- */
- public function clientExtension()
- {
- return $this->guessClientExtension();
- }
-
/**
* Get a filename for the file.
*
- * @param string $path
+ * @param string|null $path
* @return string
*/
public function hashName($path = null)
@@ -57,6 +47,10 @@ trait FileHelpers
$hash = $this->hashName ?: $this->hashName = Str::random(40);
- return $path.$hash.'.'.$this->guessExtension();
+ if ($extension = $this->guessExtension()) {
+ $extension = '.'.$extension;
+ }
+
+ return $path.$hash.$extension;
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Http/JsonResponse.php b/pfosten/vendor/laravel/framework/src/Illuminate/Http/JsonResponse.php
index 65bbecb1..9baf417b 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Http/JsonResponse.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Http/JsonResponse.php
@@ -4,13 +4,16 @@ namespace Illuminate\Http;
use JsonSerializable;
use InvalidArgumentException;
+use Illuminate\Support\Traits\Macroable;
use Illuminate\Contracts\Support\Jsonable;
use Illuminate\Contracts\Support\Arrayable;
use Symfony\Component\HttpFoundation\JsonResponse as BaseJsonResponse;
class JsonResponse extends BaseJsonResponse
{
- use ResponseTrait;
+ use ResponseTrait, Macroable {
+ Macroable::__call as macroCall;
+ }
/**
* Constructor.
@@ -19,6 +22,7 @@ class JsonResponse extends BaseJsonResponse
* @param int $status
* @param array $headers
* @param int $options
+ * @return void
*/
public function __construct($data = null, $status = 200, $headers = [], $options = 0)
{
@@ -57,12 +61,12 @@ class JsonResponse extends BaseJsonResponse
{
$this->original = $data;
- if ($data instanceof Arrayable) {
- $this->data = json_encode($data->toArray(), $this->encodingOptions);
- } elseif ($data instanceof Jsonable) {
+ if ($data instanceof Jsonable) {
$this->data = $data->toJson($this->encodingOptions);
} elseif ($data instanceof JsonSerializable) {
$this->data = json_encode($data->jsonSerialize(), $this->encodingOptions);
+ } elseif ($data instanceof Arrayable) {
+ $this->data = json_encode($data->toArray(), $this->encodingOptions);
} else {
$this->data = json_encode($data, $this->encodingOptions);
}
@@ -82,9 +86,16 @@ class JsonResponse extends BaseJsonResponse
*/
protected function hasValidJson($jsonError)
{
- return $jsonError === JSON_ERROR_NONE ||
- ($jsonError === JSON_ERROR_UNSUPPORTED_TYPE &&
- $this->hasEncodingOption(JSON_PARTIAL_OUTPUT_ON_ERROR));
+ if ($jsonError === JSON_ERROR_NONE) {
+ return true;
+ }
+
+ return $this->hasEncodingOption(JSON_PARTIAL_OUTPUT_ON_ERROR) &&
+ in_array($jsonError, [
+ JSON_ERROR_RECURSION,
+ JSON_ERROR_INF_OR_NAN,
+ JSON_ERROR_UNSUPPORTED_TYPE,
+ ]);
}
/**
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Http/RedirectResponse.php b/pfosten/vendor/laravel/framework/src/Illuminate/Http/RedirectResponse.php
index 0a462ffd..1a7ec144 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Http/RedirectResponse.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Http/RedirectResponse.php
@@ -2,11 +2,11 @@
namespace Illuminate\Http;
-use BadMethodCallException;
use Illuminate\Support\Str;
use Illuminate\Support\MessageBag;
use Illuminate\Support\ViewErrorBag;
use Illuminate\Support\Traits\Macroable;
+use Illuminate\Support\Traits\ForwardsCalls;
use Illuminate\Session\Store as SessionStore;
use Illuminate\Contracts\Support\MessageProvider;
use Symfony\Component\HttpFoundation\File\UploadedFile as SymfonyUploadedFile;
@@ -14,7 +14,7 @@ use Symfony\Component\HttpFoundation\RedirectResponse as BaseRedirectResponse;
class RedirectResponse extends BaseRedirectResponse
{
- use ResponseTrait, Macroable {
+ use ForwardsCalls, ResponseTrait, Macroable {
Macroable::__call as macroCall;
}
@@ -26,7 +26,7 @@ class RedirectResponse extends BaseRedirectResponse
protected $request;
/**
- * The session store implementation.
+ * The session store instance.
*
* @var \Illuminate\Session\Store
*/
@@ -37,7 +37,7 @@ class RedirectResponse extends BaseRedirectResponse
*
* @param string|array $key
* @param mixed $value
- * @return \Illuminate\Http\RedirectResponse
+ * @return $this
*/
public function with($key, $value = null)
{
@@ -68,7 +68,7 @@ class RedirectResponse extends BaseRedirectResponse
/**
* Flash an array of input to the session.
*
- * @param array $input
+ * @param array|null $input
* @return $this
*/
public function withInput(array $input = null)
@@ -114,7 +114,7 @@ class RedirectResponse extends BaseRedirectResponse
/**
* Flash an array of input to the session.
*
- * @return \Illuminate\Http\RedirectResponse
+ * @return $this
*/
public function exceptInput()
{
@@ -192,7 +192,7 @@ class RedirectResponse extends BaseRedirectResponse
}
/**
- * Get the session store implementation.
+ * Get the session store instance.
*
* @return \Illuminate\Session\Store|null
*/
@@ -202,7 +202,7 @@ class RedirectResponse extends BaseRedirectResponse
}
/**
- * Set the session store implementation.
+ * Set the session store instance.
*
* @param \Illuminate\Session\Store $session
* @return void
@@ -217,7 +217,7 @@ class RedirectResponse extends BaseRedirectResponse
*
* @param string $method
* @param array $parameters
- * @return $this
+ * @return mixed
*
* @throws \BadMethodCallException
*/
@@ -231,8 +231,6 @@ class RedirectResponse extends BaseRedirectResponse
return $this->with(Str::snake(substr($method, 4)), $parameters[0]);
}
- throw new BadMethodCallException(
- "Method [$method] does not exist on Redirect."
- );
+ static::throwBadMethodCallException($method);
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Http/Request.php b/pfosten/vendor/laravel/framework/src/Illuminate/Http/Request.php
index 799c7fcc..7c289341 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Http/Request.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Http/Request.php
@@ -22,7 +22,7 @@ class Request extends SymfonyRequest implements Arrayable, ArrayAccess
/**
* The decoded JSON content for the request.
*
- * @var string
+ * @var \Symfony\Component\HttpFoundation\ParameterBag|null
*/
protected $json;
@@ -108,7 +108,7 @@ class Request extends SymfonyRequest implements Arrayable, ArrayAccess
{
$query = $this->getQueryString();
- $question = $this->getBaseUrl().$this->getPathInfo() == '/' ? '/?' : '?';
+ $question = $this->getBaseUrl().$this->getPathInfo() === '/' ? '/?' : '?';
return $query ? $this->url().$question.$query : $this->url();
}
@@ -121,11 +121,11 @@ class Request extends SymfonyRequest implements Arrayable, ArrayAccess
*/
public function fullUrlWithQuery(array $query)
{
- $question = $this->getBaseUrl().$this->getPathInfo() == '/' ? '/?' : '?';
+ $question = $this->getBaseUrl().$this->getPathInfo() === '/' ? '/?' : '?';
return count($this->query()) > 0
- ? $this->url().$question.http_build_query(array_merge($this->query(), $query))
- : $this->fullUrl().$question.http_build_query($query);
+ ? $this->url().$question.Arr::query(array_merge($this->query(), $query))
+ : $this->fullUrl().$question.Arr::query($query);
}
/**
@@ -141,7 +141,7 @@ class Request extends SymfonyRequest implements Arrayable, ArrayAccess
}
/**
- * Get the current encoded path info for the request.
+ * Get the current decoded path info for the request.
*
* @return string
*/
@@ -171,20 +171,23 @@ class Request extends SymfonyRequest implements Arrayable, ArrayAccess
{
$segments = explode('/', $this->decodedPath());
- return array_values(array_filter($segments, function ($v) {
- return $v != '';
+ return array_values(array_filter($segments, function ($value) {
+ return $value !== '';
}));
}
/**
* Determine if the current request URI matches a pattern.
*
+ * @param mixed ...$patterns
* @return bool
*/
- public function is()
+ public function is(...$patterns)
{
- foreach (func_get_args() as $pattern) {
- if (Str::is($pattern, $this->decodedPath())) {
+ $path = $this->decodedPath();
+
+ foreach ($patterns as $pattern) {
+ if (Str::is($pattern, $path)) {
return true;
}
}
@@ -193,26 +196,27 @@ class Request extends SymfonyRequest implements Arrayable, ArrayAccess
}
/**
- * Check if the route name matches the given string.
+ * Determine if the route name matches a given pattern.
*
- * @param string $name
+ * @param mixed ...$patterns
* @return bool
*/
- public function routeIs($name)
+ public function routeIs(...$patterns)
{
- return $this->route() && $this->route()->named($name);
+ return $this->route() && $this->route()->named(...$patterns);
}
/**
* Determine if the current request URL and query string matches a pattern.
*
+ * @param mixed ...$patterns
* @return bool
*/
- public function fullUrlIs()
+ public function fullUrlIs(...$patterns)
{
$url = $this->fullUrl();
- foreach (func_get_args() as $pattern) {
+ foreach ($patterns as $pattern) {
if (Str::is($pattern, $url)) {
return true;
}
@@ -241,6 +245,17 @@ class Request extends SymfonyRequest implements Arrayable, ArrayAccess
return $this->headers->get('X-PJAX') == true;
}
+ /**
+ * Determine if the request is the result of an prefetch call.
+ *
+ * @return bool
+ */
+ public function prefetch()
+ {
+ return strcasecmp($this->server->get('HTTP_X_MOZ'), 'prefetch') === 0 ||
+ strcasecmp($this->headers->get('Purpose'), 'prefetch') === 0;
+ }
+
/**
* Determine if the request is over HTTPS.
*
@@ -254,7 +269,7 @@ class Request extends SymfonyRequest implements Arrayable, ArrayAccess
/**
* Get the client IP address.
*
- * @return string
+ * @return string|null
*/
public function ip()
{
@@ -285,30 +300,48 @@ class Request extends SymfonyRequest implements Arrayable, ArrayAccess
* Merge new input into the current request's input array.
*
* @param array $input
- * @return void
+ * @return $this
*/
public function merge(array $input)
{
$this->getInputSource()->add($input);
+
+ return $this;
}
/**
* Replace the input for the current request.
*
* @param array $input
- * @return void
+ * @return $this
*/
public function replace(array $input)
{
$this->getInputSource()->replace($input);
+
+ return $this;
+ }
+
+ /**
+ * This method belongs to Symfony HttpFoundation and is not usually needed when using Laravel.
+ *
+ * Instead, you may use the "input" method.
+ *
+ * @param string $key
+ * @param mixed $default
+ * @return mixed
+ */
+ public function get($key, $default = null)
+ {
+ return parent::get($key, $default);
}
/**
* Get the JSON payload for the request.
*
- * @param string $key
+ * @param string|null $key
* @param mixed $default
- * @return mixed
+ * @return \Symfony\Component\HttpFoundation\ParameterBag|mixed
*/
public function json($key = null, $default = null)
{
@@ -334,14 +367,54 @@ class Request extends SymfonyRequest implements Arrayable, ArrayAccess
return $this->json();
}
- return $this->getRealMethod() == 'GET' ? $this->query : $this->request;
+ return in_array($this->getRealMethod(), ['GET', 'HEAD']) ? $this->query : $this->request;
+ }
+
+ /**
+ * Create a new request instance from the given Laravel request.
+ *
+ * @param \Illuminate\Http\Request $from
+ * @param \Illuminate\Http\Request|null $to
+ * @return static
+ */
+ public static function createFrom(self $from, $to = null)
+ {
+ $request = $to ?: new static;
+
+ $files = $from->files->all();
+
+ $files = is_array($files) ? array_filter($files) : $files;
+
+ $request->initialize(
+ $from->query->all(),
+ $from->request->all(),
+ $from->attributes->all(),
+ $from->cookies->all(),
+ $files,
+ $from->server->all(),
+ $from->getContent()
+ );
+
+ $request->headers->replace($from->headers->all());
+
+ $request->setJson($from->json());
+
+ if ($session = $from->getSession()) {
+ $request->setLaravelSession($session);
+ }
+
+ $request->setUserResolver($from->getUserResolver());
+
+ $request->setRouteResolver($from->getRouteResolver());
+
+ return $request;
}
/**
* Create an Illuminate request from a Symfony instance.
*
* @param \Symfony\Component\HttpFoundation\Request $request
- * @return \Illuminate\Http\Request
+ * @return static
*/
public static function createFromBase(SymfonyRequest $request)
{
@@ -349,18 +422,18 @@ class Request extends SymfonyRequest implements Arrayable, ArrayAccess
return $request;
}
- $content = $request->content;
-
- $request = (new static)->duplicate(
+ $newRequest = (new static)->duplicate(
$request->query->all(), $request->request->all(), $request->attributes->all(),
$request->cookies->all(), $request->files->all(), $request->server->all()
);
- $request->content = $content;
+ $newRequest->headers->replace($request->headers->all());
- $request->request = $request->getInputSource();
+ $newRequest->content = $request->content;
- return $request;
+ $newRequest->request = $newRequest->getInputSource();
+
+ return $newRequest;
}
/**
@@ -409,7 +482,17 @@ class Request extends SymfonyRequest implements Arrayable, ArrayAccess
throw new RuntimeException('Session store not set on request.');
}
- return $this->getSession();
+ return $this->session;
+ }
+
+ /**
+ * Get the session associated with the request.
+ *
+ * @return \Illuminate\Session\Store|null
+ */
+ public function getSession()
+ {
+ return $this->session;
}
/**
@@ -438,10 +521,10 @@ class Request extends SymfonyRequest implements Arrayable, ArrayAccess
* Get the route handling the request.
*
* @param string|null $param
- *
+ * @param mixed $default
* @return \Illuminate\Routing\Route|object|string
*/
- public function route($param = null)
+ public function route($param = null, $default = null)
{
$route = call_user_func($this->getRouteResolver());
@@ -449,7 +532,7 @@ class Request extends SymfonyRequest implements Arrayable, ArrayAccess
return $route;
}
- return $route->parameter($param);
+ return $route->parameter($param, $default);
}
/**
@@ -466,14 +549,15 @@ class Request extends SymfonyRequest implements Arrayable, ArrayAccess
}
return sha1(implode('|', array_merge(
- $route->methods(), [$route->domain(), $route->uri(), $this->ip()]
+ $route->methods(),
+ [$route->getDomain(), $route->uri(), $this->ip()]
)));
}
/**
* Set the JSON payload for the request.
*
- * @param array $json
+ * @param \Symfony\Component\HttpFoundation\ParameterBag $json
* @return $this
*/
public function setJson($json)
@@ -551,7 +635,10 @@ class Request extends SymfonyRequest implements Arrayable, ArrayAccess
*/
public function offsetExists($offset)
{
- return array_key_exists($offset, $this->all());
+ return Arr::has(
+ $this->all() + $this->route()->parameters(),
+ $offset
+ );
}
/**
@@ -562,7 +649,7 @@ class Request extends SymfonyRequest implements Arrayable, ArrayAccess
*/
public function offsetGet($offset)
{
- return data_get($this->all(), $offset);
+ return $this->__get($offset);
}
/**
@@ -607,10 +694,8 @@ class Request extends SymfonyRequest implements Arrayable, ArrayAccess
*/
public function __get($key)
{
- if ($this->offsetExists($key)) {
- return $this->offsetGet($key);
- }
-
- return $this->route($key);
+ return Arr::get($this->all(), $key, function () use ($key) {
+ return $this->route($key);
+ });
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Http/Response.php b/pfosten/vendor/laravel/framework/src/Illuminate/Http/Response.php
index f3bf3fc1..d962dca1 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Http/Response.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Http/Response.php
@@ -4,13 +4,17 @@ namespace Illuminate\Http;
use ArrayObject;
use JsonSerializable;
+use Illuminate\Support\Traits\Macroable;
use Illuminate\Contracts\Support\Jsonable;
+use Illuminate\Contracts\Support\Arrayable;
use Illuminate\Contracts\Support\Renderable;
use Symfony\Component\HttpFoundation\Response as BaseResponse;
class Response extends BaseResponse
{
- use ResponseTrait;
+ use ResponseTrait, Macroable {
+ Macroable::__call as macroCall;
+ }
/**
* Set the content on the response.
@@ -38,7 +42,9 @@ class Response extends BaseResponse
$content = $content->render();
}
- return parent::setContent($content);
+ parent::setContent($content);
+
+ return $this;
}
/**
@@ -49,7 +55,8 @@ class Response extends BaseResponse
*/
protected function shouldBeJson($content)
{
- return $content instanceof Jsonable ||
+ return $content instanceof Arrayable ||
+ $content instanceof Jsonable ||
$content instanceof ArrayObject ||
$content instanceof JsonSerializable ||
is_array($content);
@@ -65,6 +72,8 @@ class Response extends BaseResponse
{
if ($content instanceof Jsonable) {
return $content->toJson();
+ } elseif ($content instanceof Arrayable) {
+ return json_encode($content->toArray());
}
return json_encode($content);
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Http/ResponseTrait.php b/pfosten/vendor/laravel/framework/src/Illuminate/Http/ResponseTrait.php
index c7a4f80e..21cd4c51 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Http/ResponseTrait.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Http/ResponseTrait.php
@@ -3,6 +3,7 @@
namespace Illuminate\Http;
use Exception;
+use Symfony\Component\HttpFoundation\HeaderBag;
use Illuminate\Http\Exceptions\HttpResponseException;
trait ResponseTrait
@@ -48,7 +49,9 @@ trait ResponseTrait
*/
public function getOriginalContent()
{
- return $this->original;
+ $original = $this->original;
+
+ return $original instanceof self ? $original->{__FUNCTION__}() : $original;
}
/**
@@ -69,11 +72,15 @@ trait ResponseTrait
/**
* Add an array of headers to the response.
*
- * @param array $headers
+ * @param \Symfony\Component\HttpFoundation\HeaderBag|array $headers
* @return $this
*/
- public function withHeaders(array $headers)
+ public function withHeaders($headers)
{
+ if ($headers instanceof HeaderBag) {
+ $headers = $headers->all();
+ }
+
foreach ($headers as $key => $value) {
$this->headers->set($key, $value);
}
@@ -109,6 +116,16 @@ trait ResponseTrait
return $this;
}
+ /**
+ * Get the callback of the response.
+ *
+ * @return string|null
+ */
+ public function getCallback()
+ {
+ return $this->callback ?? null;
+ }
+
/**
* Set the exception to attach to the response.
*
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Http/Testing/File.php b/pfosten/vendor/laravel/framework/src/Illuminate/Http/Testing/File.php
index 01c118f1..4b1140c7 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Http/Testing/File.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Http/Testing/File.php
@@ -41,7 +41,7 @@ class File extends UploadedFile
parent::__construct(
$this->tempFilePath(), $name, $this->getMimeType(),
- filesize($this->tempFilePath()), $error = null, $test = true
+ null, true
);
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Http/Testing/FileFactory.php b/pfosten/vendor/laravel/framework/src/Illuminate/Http/Testing/FileFactory.php
index 0a677d7d..c79617eb 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Http/Testing/FileFactory.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Http/Testing/FileFactory.php
@@ -2,6 +2,8 @@
namespace Illuminate\Http\Testing;
+use Illuminate\Support\Str;
+
class FileFactory
{
/**
@@ -28,7 +30,9 @@ class FileFactory
*/
public function image($name, $width = 10, $height = 10)
{
- return new File($name, $this->generateImage($width, $height));
+ return new File($name, $this->generateImage(
+ $width, $height, Str::endsWith(Str::lower($name), ['.jpg', '.jpeg']) ? 'jpeg' : 'png'
+ ));
}
/**
@@ -36,14 +40,24 @@ class FileFactory
*
* @param int $width
* @param int $height
+ * @param string $type
* @return resource
*/
- protected function generateImage($width, $height)
+ protected function generateImage($width, $height, $type)
{
- return tap(tmpfile(), function ($temp) use ($width, $height) {
+ return tap(tmpfile(), function ($temp) use ($width, $height, $type) {
ob_start();
- imagepng(imagecreatetruecolor($width, $height));
+ $image = imagecreatetruecolor($width, $height);
+
+ switch ($type) {
+ case 'jpeg':
+ imagejpeg($image);
+ break;
+ case 'png':
+ imagepng($image);
+ break;
+ }
fwrite($temp, ob_get_clean());
});
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Http/Testing/MimeType.php b/pfosten/vendor/laravel/framework/src/Illuminate/Http/Testing/MimeType.php
index 470614ad..af1fc602 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Http/Testing/MimeType.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Http/Testing/MimeType.php
@@ -747,6 +747,7 @@ class MimeType
'mp4' => 'video/mp4',
'mpeg' => 'video/mpeg',
'ogv' => 'video/ogg',
+ 'mov' => 'video/quicktime',
'qt' => 'video/quicktime',
'uvh' => 'video/vnd.dece.hd',
'uvm' => 'video/vnd.dece.mobile',
@@ -788,6 +789,39 @@ class MimeType
{
$extension = pathinfo($filename, PATHINFO_EXTENSION);
- return collect(self::$mimes)->get($extension, 'application/octet-stream');
+ return self::getMimeTypeFromExtension($extension);
+ }
+
+ /**
+ * Get the MIME type for a given extension or return all mimes.
+ *
+ * @param string|null $extension
+ * @return string|array
+ */
+ public static function get($extension = null)
+ {
+ return $extension ? self::getMimeTypeFromExtension($extension) : self::$mimes;
+ }
+
+ /**
+ * Search for the extension of a given MIME type.
+ *
+ * @param string $mimeType
+ * @return string|null
+ */
+ public static function search($mimeType)
+ {
+ return array_search($mimeType, self::$mimes) ?: null;
+ }
+
+ /**
+ * Get the MIME type for a given extension.
+ *
+ * @param string $extension
+ * @return string
+ */
+ protected static function getMimeTypeFromExtension($extension)
+ {
+ return self::$mimes[$extension] ?? 'application/octet-stream';
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Http/UploadedFile.php b/pfosten/vendor/laravel/framework/src/Illuminate/Http/UploadedFile.php
index 8ed7e7f9..7962209b 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Http/UploadedFile.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Http/UploadedFile.php
@@ -5,6 +5,7 @@ namespace Illuminate\Http;
use Illuminate\Support\Arr;
use Illuminate\Container\Container;
use Illuminate\Support\Traits\Macroable;
+use Illuminate\Contracts\Filesystem\FileNotFoundException;
use Illuminate\Contracts\Filesystem\Factory as FilesystemFactory;
use Symfony\Component\HttpFoundation\File\UploadedFile as SymfonyUploadedFile;
@@ -86,6 +87,32 @@ class UploadedFile extends SymfonyUploadedFile
);
}
+ /**
+ * Get the contents of the uploaded file.
+ *
+ * @return bool|string
+ *
+ * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
+ */
+ public function get()
+ {
+ if (! $this->isValid()) {
+ throw new FileNotFoundException("File does not exist at path {$this->getPathname()}");
+ }
+
+ return file_get_contents($this->getPathname());
+ }
+
+ /**
+ * Get the file's extension supplied by the client.
+ *
+ * @return string
+ */
+ public function clientExtension()
+ {
+ return $this->guessClientExtension();
+ }
+
/**
* Create a new file instance from a base instance.
*
@@ -99,7 +126,6 @@ class UploadedFile extends SymfonyUploadedFile
$file->getPathname(),
$file->getClientOriginalName(),
$file->getClientMimeType(),
- $file->getClientSize(),
$file->getError(),
$test
);
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Http/composer.json b/pfosten/vendor/laravel/framework/src/Illuminate/Http/composer.json
index 14bf748c..eb9ba210 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Http/composer.json
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Http/composer.json
@@ -14,20 +14,24 @@
}
],
"require": {
- "php": ">=5.6.4",
- "illuminate/session": "5.4.*",
- "illuminate/support": "5.4.*",
- "symfony/http-foundation": "~3.2",
- "symfony/http-kernel": "~3.2"
+ "php": "^7.1.3",
+ "ext-json": "*",
+ "illuminate/session": "5.8.*",
+ "illuminate/support": "5.8.*",
+ "symfony/http-foundation": "^4.2",
+ "symfony/http-kernel": "^4.2"
},
"autoload": {
"psr-4": {
"Illuminate\\Http\\": ""
}
},
+ "suggest": {
+ "ext-gd": "Required to use Illuminate\\Http\\Testing\\FileFactory::image()."
+ },
"extra": {
"branch-alias": {
- "dev-master": "5.4-dev"
+ "dev-master": "5.8-dev"
}
},
"config": {
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Log/LogServiceProvider.php b/pfosten/vendor/laravel/framework/src/Illuminate/Log/LogServiceProvider.php
index a927dbf9..cd073921 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Log/LogServiceProvider.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Log/LogServiceProvider.php
@@ -2,7 +2,6 @@
namespace Illuminate\Log;
-use Monolog\Logger as Monolog;
use Illuminate\Support\ServiceProvider;
class LogServiceProvider extends ServiceProvider
@@ -15,140 +14,7 @@ class LogServiceProvider extends ServiceProvider
public function register()
{
$this->app->singleton('log', function () {
- return $this->createLogger();
+ return new LogManager($this->app);
});
}
-
- /**
- * Create the logger.
- *
- * @return \Illuminate\Log\Writer
- */
- public function createLogger()
- {
- $log = new Writer(
- new Monolog($this->channel()), $this->app['events']
- );
-
- if ($this->app->hasMonologConfigurator()) {
- call_user_func($this->app->getMonologConfigurator(), $log->getMonolog());
- } else {
- $this->configureHandler($log);
- }
-
- return $log;
- }
-
- /**
- * Get the name of the log "channel".
- *
- * @return string
- */
- protected function channel()
- {
- return $this->app->bound('env') ? $this->app->environment() : 'production';
- }
-
- /**
- * Configure the Monolog handlers for the application.
- *
- * @param \Illuminate\Log\Writer $log
- * @return void
- */
- protected function configureHandler(Writer $log)
- {
- $this->{'configure'.ucfirst($this->handler()).'Handler'}($log);
- }
-
- /**
- * Configure the Monolog handlers for the application.
- *
- * @param \Illuminate\Log\Writer $log
- * @return void
- */
- protected function configureSingleHandler(Writer $log)
- {
- $log->useFiles(
- $this->app->storagePath().'/logs/laravel.log',
- $this->logLevel()
- );
- }
-
- /**
- * Configure the Monolog handlers for the application.
- *
- * @param \Illuminate\Log\Writer $log
- * @return void
- */
- protected function configureDailyHandler(Writer $log)
- {
- $log->useDailyFiles(
- $this->app->storagePath().'/logs/laravel.log', $this->maxFiles(),
- $this->logLevel()
- );
- }
-
- /**
- * Configure the Monolog handlers for the application.
- *
- * @param \Illuminate\Log\Writer $log
- * @return void
- */
- protected function configureSyslogHandler(Writer $log)
- {
- $log->useSyslog('laravel', $this->logLevel());
- }
-
- /**
- * Configure the Monolog handlers for the application.
- *
- * @param \Illuminate\Log\Writer $log
- * @return void
- */
- protected function configureErrorlogHandler(Writer $log)
- {
- $log->useErrorLog($this->logLevel());
- }
-
- /**
- * Get the default log handler.
- *
- * @return string
- */
- protected function handler()
- {
- if ($this->app->bound('config')) {
- return $this->app->make('config')->get('app.log', 'single');
- }
-
- return 'single';
- }
-
- /**
- * Get the log level for the application.
- *
- * @return string
- */
- protected function logLevel()
- {
- if ($this->app->bound('config')) {
- return $this->app->make('config')->get('app.log_level', 'debug');
- }
-
- return 'debug';
- }
-
- /**
- * Get the maximum number of log files for the application.
- *
- * @return int
- */
- protected function maxFiles()
- {
- if ($this->app->bound('config')) {
- return $this->app->make('config')->get('app.log_max_files', 5);
- }
-
- return 0;
- }
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Log/Writer.php b/pfosten/vendor/laravel/framework/src/Illuminate/Log/Writer.php
deleted file mode 100755
index 94b3e2d6..00000000
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Log/Writer.php
+++ /dev/null
@@ -1,377 +0,0 @@
- MonologLogger::DEBUG,
- 'info' => MonologLogger::INFO,
- 'notice' => MonologLogger::NOTICE,
- 'warning' => MonologLogger::WARNING,
- 'error' => MonologLogger::ERROR,
- 'critical' => MonologLogger::CRITICAL,
- 'alert' => MonologLogger::ALERT,
- 'emergency' => MonologLogger::EMERGENCY,
- ];
-
- /**
- * Create a new log writer instance.
- *
- * @param \Monolog\Logger $monolog
- * @param \Illuminate\Contracts\Events\Dispatcher $dispatcher
- * @return void
- */
- public function __construct(MonologLogger $monolog, Dispatcher $dispatcher = null)
- {
- $this->monolog = $monolog;
-
- if (isset($dispatcher)) {
- $this->dispatcher = $dispatcher;
- }
- }
-
- /**
- * Log an emergency message to the logs.
- *
- * @param string $message
- * @param array $context
- * @return void
- */
- public function emergency($message, array $context = [])
- {
- $this->writeLog(__FUNCTION__, $message, $context);
- }
-
- /**
- * Log an alert message to the logs.
- *
- * @param string $message
- * @param array $context
- * @return void
- */
- public function alert($message, array $context = [])
- {
- $this->writeLog(__FUNCTION__, $message, $context);
- }
-
- /**
- * Log a critical message to the logs.
- *
- * @param string $message
- * @param array $context
- * @return void
- */
- public function critical($message, array $context = [])
- {
- $this->writeLog(__FUNCTION__, $message, $context);
- }
-
- /**
- * Log an error message to the logs.
- *
- * @param string $message
- * @param array $context
- * @return void
- */
- public function error($message, array $context = [])
- {
- $this->writeLog(__FUNCTION__, $message, $context);
- }
-
- /**
- * Log a warning message to the logs.
- *
- * @param string $message
- * @param array $context
- * @return void
- */
- public function warning($message, array $context = [])
- {
- $this->writeLog(__FUNCTION__, $message, $context);
- }
-
- /**
- * Log a notice to the logs.
- *
- * @param string $message
- * @param array $context
- * @return void
- */
- public function notice($message, array $context = [])
- {
- $this->writeLog(__FUNCTION__, $message, $context);
- }
-
- /**
- * Log an informational message to the logs.
- *
- * @param string $message
- * @param array $context
- * @return void
- */
- public function info($message, array $context = [])
- {
- $this->writeLog(__FUNCTION__, $message, $context);
- }
-
- /**
- * Log a debug message to the logs.
- *
- * @param string $message
- * @param array $context
- * @return void
- */
- public function debug($message, array $context = [])
- {
- $this->writeLog(__FUNCTION__, $message, $context);
- }
-
- /**
- * Log a message to the logs.
- *
- * @param string $level
- * @param string $message
- * @param array $context
- * @return void
- */
- public function log($level, $message, array $context = [])
- {
- $this->writeLog($level, $message, $context);
- }
-
- /**
- * Dynamically pass log calls into the writer.
- *
- * @param string $level
- * @param string $message
- * @param array $context
- * @return void
- */
- public function write($level, $message, array $context = [])
- {
- $this->writeLog($level, $message, $context);
- }
-
- /**
- * Write a message to Monolog.
- *
- * @param string $level
- * @param string $message
- * @param array $context
- * @return void
- */
- protected function writeLog($level, $message, $context)
- {
- $this->fireLogEvent($level, $message = $this->formatMessage($message), $context);
-
- $this->monolog->{$level}($message, $context);
- }
-
- /**
- * Register a file log handler.
- *
- * @param string $path
- * @param string $level
- * @return void
- */
- public function useFiles($path, $level = 'debug')
- {
- $this->monolog->pushHandler($handler = new StreamHandler($path, $this->parseLevel($level)));
-
- $handler->setFormatter($this->getDefaultFormatter());
- }
-
- /**
- * 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')
- {
- $this->monolog->pushHandler(
- $handler = new RotatingFileHandler($path, $days, $this->parseLevel($level))
- );
-
- $handler->setFormatter($this->getDefaultFormatter());
- }
-
- /**
- * Register a Syslog handler.
- *
- * @param string $name
- * @param string $level
- * @param mixed $facility
- * @return \Psr\Log\LoggerInterface
- */
- public function useSyslog($name = 'laravel', $level = 'debug', $facility = LOG_USER)
- {
- return $this->monolog->pushHandler(new SyslogHandler($name, $facility, $level));
- }
-
- /**
- * Register an error_log handler.
- *
- * @param string $level
- * @param int $messageType
- * @return void
- */
- public function useErrorLog($level = 'debug', $messageType = ErrorLogHandler::OPERATING_SYSTEM)
- {
- $this->monolog->pushHandler(
- $handler = new ErrorLogHandler($messageType, $this->parseLevel($level))
- );
-
- $handler->setFormatter($this->getDefaultFormatter());
- }
-
- /**
- * Register a new callback handler for when a log event is triggered.
- *
- * @param \Closure $callback
- * @return void
- *
- * @throws \RuntimeException
- */
- public function listen(Closure $callback)
- {
- if (! isset($this->dispatcher)) {
- throw new RuntimeException('Events dispatcher has not been set.');
- }
-
- $this->dispatcher->listen(MessageLogged::class, $callback);
- }
-
- /**
- * Fires a log event.
- *
- * @param string $level
- * @param string $message
- * @param array $context
- * @return void
- */
- protected function fireLogEvent($level, $message, array $context = [])
- {
- // If the event dispatcher is set, we will pass along the parameters to the
- // log listeners. These are useful for building profilers or other tools
- // that aggregate all of the log messages for a given "request" cycle.
- if (isset($this->dispatcher)) {
- $this->dispatcher->dispatch(new MessageLogged($level, $message, $context));
- }
- }
-
- /**
- * Format the parameters for the logger.
- *
- * @param mixed $message
- * @return mixed
- */
- protected function formatMessage($message)
- {
- if (is_array($message)) {
- return var_export($message, true);
- } elseif ($message instanceof Jsonable) {
- return $message->toJson();
- } elseif ($message instanceof Arrayable) {
- return var_export($message->toArray(), true);
- }
-
- return $message;
- }
-
- /**
- * Parse the string level into a Monolog constant.
- *
- * @param string $level
- * @return int
- *
- * @throws \InvalidArgumentException
- */
- protected function parseLevel($level)
- {
- if (isset($this->levels[$level])) {
- return $this->levels[$level];
- }
-
- throw new InvalidArgumentException('Invalid log level.');
- }
-
- /**
- * Get the underlying Monolog instance.
- *
- * @return \Monolog\Logger
- */
- public function getMonolog()
- {
- return $this->monolog;
- }
-
- /**
- * Get a default Monolog formatter instance.
- *
- * @return \Monolog\Formatter\LineFormatter
- */
- protected function getDefaultFormatter()
- {
- return new LineFormatter(null, null, true, true);
- }
-
- /**
- * Get the event dispatcher instance.
- *
- * @return \Illuminate\Contracts\Events\Dispatcher
- */
- public function getEventDispatcher()
- {
- return $this->dispatcher;
- }
-
- /**
- * Set the event dispatcher instance.
- *
- * @param \Illuminate\Contracts\Events\Dispatcher $dispatcher
- * @return void
- */
- public function setEventDispatcher(Dispatcher $dispatcher)
- {
- $this->dispatcher = $dispatcher;
- }
-}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Log/composer.json b/pfosten/vendor/laravel/framework/src/Illuminate/Log/composer.json
index cfcad97e..578cf5d9 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Log/composer.json
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Log/composer.json
@@ -14,10 +14,10 @@
}
],
"require": {
- "php": ">=5.6.4",
- "illuminate/contracts": "5.4.*",
- "illuminate/support": "5.4.*",
- "monolog/monolog": "~1.11"
+ "php": "^7.1.3",
+ "illuminate/contracts": "5.8.*",
+ "illuminate/support": "5.8.*",
+ "monolog/monolog": "^1.12"
},
"autoload": {
"psr-4": {
@@ -26,7 +26,7 @@
},
"extra": {
"branch-alias": {
- "dev-master": "5.4-dev"
+ "dev-master": "5.8-dev"
}
},
"config": {
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Mail/Events/MessageSending.php b/pfosten/vendor/laravel/framework/src/Illuminate/Mail/Events/MessageSending.php
index 17bc2573..cff45213 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Mail/Events/MessageSending.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Mail/Events/MessageSending.php
@@ -11,14 +11,23 @@ class MessageSending
*/
public $message;
+ /**
+ * The message data.
+ *
+ * @var array
+ */
+ public $data;
+
/**
* Create a new event instance.
*
- * @param \Swift_Message $message
+ * @param \Swift_Message $message
+ * @param array $data
* @return void
*/
- public function __construct($message)
+ public function __construct($message, $data = [])
{
+ $this->data = $data;
$this->message = $message;
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Mail/Events/MessageSent.php b/pfosten/vendor/laravel/framework/src/Illuminate/Mail/Events/MessageSent.php
index 8af4a0e9..9dee09c2 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Mail/Events/MessageSent.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Mail/Events/MessageSent.php
@@ -11,14 +11,23 @@ class MessageSent
*/
public $message;
+ /**
+ * The message data.
+ *
+ * @var array
+ */
+ public $data;
+
/**
* Create a new event instance.
*
* @param \Swift_Message $message
+ * @param array $data
* @return void
*/
- public function __construct($message)
+ public function __construct($message, $data = [])
{
+ $this->data = $data;
$this->message = $message;
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Mail/MailServiceProvider.php b/pfosten/vendor/laravel/framework/src/Illuminate/Mail/MailServiceProvider.php
index e185c379..0f9e0feb 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Mail/MailServiceProvider.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Mail/MailServiceProvider.php
@@ -5,17 +5,12 @@ namespace Illuminate\Mail;
use Swift_Mailer;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
+use Swift_DependencyContainer;
use Illuminate\Support\ServiceProvider;
+use Illuminate\Contracts\Support\DeferrableProvider;
-class MailServiceProvider extends ServiceProvider
+class MailServiceProvider extends ServiceProvider implements DeferrableProvider
{
- /**
- * Indicates if loading of the provider is deferred.
- *
- * @var bool
- */
- protected $defer = true;
-
/**
* Register the service provider.
*
@@ -24,9 +19,7 @@ class MailServiceProvider extends ServiceProvider
public function register()
{
$this->registerSwiftMailer();
-
$this->registerIlluminateMailer();
-
$this->registerMarkdownRenderer();
}
@@ -37,18 +30,20 @@ class MailServiceProvider extends ServiceProvider
*/
protected function registerIlluminateMailer()
{
- $this->app->singleton('mailer', function ($app) {
- $config = $app->make('config')->get('mail');
+ $this->app->singleton('mailer', function () {
+ $config = $this->app->make('config')->get('mail');
// Once we have create the mailer instance, we will set a container instance
// on the mailer. This allows us to resolve mailer classes via containers
// for maximum testability on said classes instead of passing Closures.
$mailer = new Mailer(
- $app['view'], $app['swift.mailer'], $app['events']
+ $this->app['view'],
+ $this->app['swift.mailer'],
+ $this->app['events']
);
- if ($app->bound('queue')) {
- $mailer->setQueue($app['queue']);
+ if ($this->app->bound('queue')) {
+ $mailer->setQueue($this->app['queue']);
}
// Next we will set all of the global addresses on this mailer, which allows
@@ -91,8 +86,14 @@ class MailServiceProvider extends ServiceProvider
// Once we have the transporter registered, we will register the actual Swift
// mailer instance, passing in the transport instances, which allows us to
// override this transporter instances during app start-up if necessary.
- $this->app->singleton('swift.mailer', function ($app) {
- return new Swift_Mailer($app['swift.transport']->driver());
+ $this->app->singleton('swift.mailer', function () {
+ if ($domain = $this->app->make('config')->get('mail.domain')) {
+ Swift_DependencyContainer::getInstance()
+ ->register('mime.idgenerator.idright')
+ ->asValue($domain);
+ }
+
+ return new Swift_Mailer($this->app['swift.transport']->driver());
});
}
@@ -103,8 +104,8 @@ class MailServiceProvider extends ServiceProvider
*/
protected function registerSwiftTransport()
{
- $this->app->singleton('swift.transport', function ($app) {
- return new TransportManager($app);
+ $this->app->singleton('swift.transport', function () {
+ return new TransportManager($this->app);
});
}
@@ -121,10 +122,10 @@ class MailServiceProvider extends ServiceProvider
], 'laravel-mail');
}
- $this->app->singleton(Markdown::class, function ($app) {
- $config = $app->make('config');
+ $this->app->singleton(Markdown::class, function () {
+ $config = $this->app->make('config');
- return new Markdown($app->make('view'), [
+ return new Markdown($this->app->make('view'), [
'theme' => $config->get('mail.markdown.theme', 'default'),
'paths' => $config->get('mail.markdown.paths', []),
]);
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Mail/Mailable.php b/pfosten/vendor/laravel/framework/src/Illuminate/Mail/Mailable.php
index 01e27606..e5bebd5b 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Mail/Mailable.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Mail/Mailable.php
@@ -4,16 +4,29 @@ namespace Illuminate\Mail;
use ReflectionClass;
use ReflectionProperty;
-use BadMethodCallException;
use Illuminate\Support\Str;
use Illuminate\Support\Collection;
+use Illuminate\Support\HtmlString;
use Illuminate\Container\Container;
+use Illuminate\Support\Traits\Localizable;
+use Illuminate\Contracts\Support\Renderable;
+use Illuminate\Support\Traits\ForwardsCalls;
use Illuminate\Contracts\Queue\Factory as Queue;
use Illuminate\Contracts\Mail\Mailer as MailerContract;
use Illuminate\Contracts\Mail\Mailable as MailableContract;
+use Illuminate\Contracts\Filesystem\Factory as FilesystemFactory;
-class Mailable implements MailableContract
+class Mailable implements MailableContract, Renderable
{
+ use ForwardsCalls, Localizable;
+
+ /**
+ * The locale of the message.
+ *
+ * @var string
+ */
+ public $locale;
+
/**
* The person the message is from.
*
@@ -63,6 +76,13 @@ class Mailable implements MailableContract
*/
protected $markdown;
+ /**
+ * The HTML to use for the message.
+ *
+ * @var string
+ */
+ protected $html;
+
/**
* The view to use for the message.
*
@@ -98,6 +118,13 @@ class Mailable implements MailableContract
*/
public $rawAttachments = [];
+ /**
+ * The attachments from a storage disk.
+ *
+ * @var array
+ */
+ public $diskAttachments = [];
+
/**
* The callbacks for the message.
*
@@ -105,6 +132,13 @@ class Mailable implements MailableContract
*/
public $callbacks = [];
+ /**
+ * The callback that should be invoked while building the view data.
+ *
+ * @var callable
+ */
+ public static $viewDataCallback;
+
/**
* Send the message using the given mailer.
*
@@ -113,14 +147,16 @@ class Mailable implements MailableContract
*/
public function send(MailerContract $mailer)
{
- Container::getInstance()->call([$this, 'build']);
+ return $this->withLocale($this->locale, function () use ($mailer) {
+ Container::getInstance()->call([$this, 'build']);
- $mailer->send($this->buildView(), $this->buildViewData(), function ($message) {
- $this->buildFrom($message)
- ->buildRecipients($message)
- ->buildSubject($message)
- ->buildAttachments($message)
- ->runCallbacks($message);
+ return $mailer->send($this->buildView(), $this->buildViewData(), function ($message) {
+ $this->buildFrom($message)
+ ->buildRecipients($message)
+ ->buildSubject($message)
+ ->runCallbacks($message)
+ ->buildAttachments($message);
+ });
});
}
@@ -132,7 +168,7 @@ class Mailable implements MailableContract
*/
public function queue(Queue $queue)
{
- if (property_exists($this, 'delay')) {
+ if (isset($this->delay)) {
return $this->later($this->delay, $queue);
}
@@ -148,8 +184,8 @@ class Mailable implements MailableContract
/**
* Deliver the queued message after the given delay.
*
- * @param \DateTime|int $delay
- * @param Queue $queue
+ * @param \DateTimeInterface|\DateInterval|int $delay
+ * @param \Illuminate\Contracts\Queue\Factory $queue
* @return mixed
*/
public function later($delay, Queue $queue)
@@ -163,13 +199,40 @@ class Mailable implements MailableContract
);
}
+ /**
+ * Render the mailable into a view.
+ *
+ * @return \Illuminate\View\View
+ *
+ * @throws \ReflectionException
+ */
+ public function render()
+ {
+ return $this->withLocale($this->locale, function () {
+ Container::getInstance()->call([$this, 'build']);
+
+ return Container::getInstance()->make('mailer')->render(
+ $this->buildView(), $this->buildViewData()
+ );
+ });
+ }
+
/**
* Build the view for the message.
*
* @return array|string
+ *
+ * @throws \ReflectionException
*/
protected function buildView()
{
+ if (isset($this->html)) {
+ return array_filter([
+ 'html' => new HtmlString($this->html),
+ 'text' => $this->textView ?? null,
+ ]);
+ }
+
if (isset($this->markdown)) {
return $this->buildMarkdownView();
}
@@ -187,11 +250,17 @@ class Mailable implements MailableContract
* Build the Markdown view for the message.
*
* @return array
+ *
+ * @throws \ReflectionException
*/
protected function buildMarkdownView()
{
$markdown = Container::getInstance()->make(Markdown::class);
+ if (isset($this->theme)) {
+ $markdown->theme($this->theme);
+ }
+
$data = $this->buildViewData();
return [
@@ -204,13 +273,19 @@ class Mailable implements MailableContract
* Build the view data for the message.
*
* @return array
+ *
+ * @throws \ReflectionException
*/
public function buildViewData()
{
$data = $this->viewData;
+ if (static::$viewDataCallback) {
+ $data = array_merge($data, call_user_func(static::$viewDataCallback, $this));
+ }
+
foreach ((new ReflectionClass($this))->getProperties(ReflectionProperty::IS_PUBLIC) as $property) {
- if ($property->getDeclaringClass()->getName() != self::class) {
+ if ($property->getDeclaringClass()->getName() !== self::class) {
$data[$property->getName()] = $property->getValue($this);
}
}
@@ -227,9 +302,8 @@ class Mailable implements MailableContract
*/
protected function buildMarkdownText($markdown, $data)
{
- return isset($this->textView)
- ? $this->textView
- : $markdown->renderText($this->markdown, $data);
+ return $this->textView
+ ?? $markdown->renderText($this->markdown, $data);
}
/**
@@ -299,9 +373,32 @@ class Mailable implements MailableContract
);
}
+ $this->buildDiskAttachments($message);
+
return $this;
}
+ /**
+ * Add all of the disk attachments to the message.
+ *
+ * @param \Illuminate\Mail\Message $message
+ * @return void
+ */
+ protected function buildDiskAttachments($message)
+ {
+ foreach ($this->diskAttachments as $attachment) {
+ $storage = Container::getInstance()->make(
+ FilesystemFactory::class
+ )->disk($attachment['disk']);
+
+ $message->attachData(
+ $storage->get($attachment['path']),
+ $attachment['name'] ?? basename($attachment['path']),
+ array_merge(['mime' => $storage->mimeType($attachment['path'])], $attachment['options'])
+ );
+ }
+ }
+
/**
* Run the callbacks for the message.
*
@@ -317,6 +414,19 @@ class Mailable implements MailableContract
return $this;
}
+ /**
+ * Set the locale of the message.
+ *
+ * @param string $locale
+ * @return $this
+ */
+ public function locale($locale)
+ {
+ $this->locale = $locale;
+
+ return $this;
+ }
+
/**
* Set the priority of this message.
*
@@ -442,6 +552,18 @@ class Mailable implements MailableContract
return $this->setAddress($address, $name, 'replyTo');
}
+ /**
+ * Determine if the given replyTo is set on the mailable.
+ *
+ * @param object|array|string $address
+ * @param string|null $name
+ * @return bool
+ */
+ public function hasReplyTo($address, $name = null)
+ {
+ return $this->hasRecipient($address, $name, 'replyTo');
+ }
+
/**
* Set the recipients of the message.
*
@@ -458,7 +580,7 @@ class Mailable implements MailableContract
$recipient = $this->normalizeRecipient($recipient);
$this->{$property}[] = [
- 'name' => isset($recipient->name) ? $recipient->name : null,
+ 'name' => $recipient->name ?? null,
'address' => $recipient->email,
];
}
@@ -514,16 +636,16 @@ class Mailable implements MailableContract
);
$expected = [
- 'name' => isset($expected->name) ? $expected->name : null,
+ 'name' => $expected->name ?? null,
'address' => $expected->email,
];
return collect($this->{$property})->contains(function ($actual) use ($expected) {
if (! isset($expected['name'])) {
return $actual['address'] == $expected['address'];
- } else {
- return $actual == $expected;
}
+
+ return $actual == $expected;
});
}
@@ -570,6 +692,19 @@ class Mailable implements MailableContract
return $this;
}
+ /**
+ * Set the rendered HTML content for the message.
+ *
+ * @param string $html
+ * @return $this
+ */
+ public function html($html)
+ {
+ $this->html = $html;
+
+ return $this;
+ }
+
/**
* Set the plain text view for the message.
*
@@ -617,6 +752,40 @@ class Mailable implements MailableContract
return $this;
}
+ /**
+ * Attach a file to the message from storage.
+ *
+ * @param string $path
+ * @param string|null $name
+ * @param array $options
+ * @return $this
+ */
+ public function attachFromStorage($path, $name = null, array $options = [])
+ {
+ return $this->attachFromStorageDisk(null, $path, $name, $options);
+ }
+
+ /**
+ * Attach a file to the message from storage.
+ *
+ * @param string $disk
+ * @param string $path
+ * @param string|null $name
+ * @param array $options
+ * @return $this
+ */
+ public function attachFromStorageDisk($disk, $path, $name = null, array $options = [])
+ {
+ $this->diskAttachments[] = [
+ 'disk' => $disk,
+ 'path' => $path,
+ 'name' => $name ?? basename($path),
+ 'options' => $options,
+ ];
+
+ return $this;
+ }
+
/**
* Attach in-memory data as an attachment.
*
@@ -645,6 +814,17 @@ class Mailable implements MailableContract
return $this;
}
+ /**
+ * Register a callback to be called while building the view data.
+ *
+ * @param callable $callback
+ * @return void
+ */
+ public static function buildViewDataUsing(callable $callback)
+ {
+ static::$viewDataCallback = $callback;
+ }
+
/**
* Dynamically bind parameters to the message.
*
@@ -657,9 +837,9 @@ class Mailable implements MailableContract
public function __call($method, $parameters)
{
if (Str::startsWith($method, 'with')) {
- return $this->with(Str::snake(substr($method, 4)), $parameters[0]);
+ return $this->with(Str::camel(substr($method, 4)), $parameters[0]);
}
- throw new BadMethodCallException("Method [$method] does not exist on mailable.");
+ static::throwBadMethodCallException($method);
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Mail/Mailer.php b/pfosten/vendor/laravel/framework/src/Illuminate/Mail/Mailer.php
index f29f875b..a088d3f8 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Mail/Mailer.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Mail/Mailer.php
@@ -3,8 +3,8 @@
namespace Illuminate\Mail;
use Swift_Mailer;
-use Illuminate\Support\Arr;
use InvalidArgumentException;
+use Illuminate\Support\HtmlString;
use Illuminate\Contracts\View\Factory;
use Illuminate\Support\Traits\Macroable;
use Illuminate\Contracts\Support\Htmlable;
@@ -62,9 +62,9 @@ class Mailer implements MailerContract, MailQueueContract
protected $to;
/**
- * The queue implementation.
+ * The queue factory implementation.
*
- * @var \Illuminate\Contracts\Queue\Queue
+ * @var \Illuminate\Contracts\Queue\Factory
*/
protected $queue;
@@ -137,6 +137,17 @@ class Mailer implements MailerContract, MailQueueContract
return (new PendingMail($this))->to($users);
}
+ /**
+ * Begin the process of mailing a mailable class instance.
+ *
+ * @param mixed $users
+ * @return \Illuminate\Mail\PendingMail
+ */
+ public function cc($users)
+ {
+ return (new PendingMail($this))->cc($users);
+ }
+
/**
* Begin the process of mailing a mailable class instance.
*
@@ -149,7 +160,19 @@ class Mailer implements MailerContract, MailQueueContract
}
/**
- * Send a new message when only a raw text part.
+ * Send a new message with only an HTML part.
+ *
+ * @param string $html
+ * @param mixed $callback
+ * @return void
+ */
+ public function html($html, $callback)
+ {
+ return $this->send(['html' => new HtmlString($html)], [], $callback);
+ }
+
+ /**
+ * Send a new message with only a raw text part.
*
* @param string $text
* @param mixed $callback
@@ -161,7 +184,7 @@ class Mailer implements MailerContract, MailQueueContract
}
/**
- * Send a new message when only a plain part.
+ * Send a new message with only a plain part.
*
* @param string $view
* @param array $data
@@ -174,11 +197,30 @@ class Mailer implements MailerContract, MailQueueContract
}
/**
- * Send a new message using a view.
+ * Render the given message as a view.
*
* @param string|array $view
* @param array $data
- * @param \Closure|string $callback
+ * @return string
+ */
+ public function render($view, array $data = [])
+ {
+ // First we need to parse the view, which could either be a string or an array
+ // containing both an HTML and plain text versions of the view which should
+ // be used when sending an e-mail. We will extract both of them out here.
+ [$view, $plain, $raw] = $this->parseView($view);
+
+ $data['message'] = $this->createMessage();
+
+ return $this->renderView($view ?: $plain, $data);
+ }
+
+ /**
+ * Send a new message using a view.
+ *
+ * @param string|array|\Illuminate\Contracts\Mail\Mailable $view
+ * @param array $data
+ * @param \Closure|string|null $callback
* @return void
*/
public function send($view, array $data = [], $callback = null)
@@ -190,46 +232,47 @@ class Mailer implements MailerContract, MailQueueContract
// First we need to parse the view, which could either be a string or an array
// containing both an HTML and plain text versions of the view which should
// be used when sending an e-mail. We will extract both of them out here.
- list($view, $plain, $raw) = $this->parseView($view);
+ [$view, $plain, $raw] = $this->parseView($view);
$data['message'] = $message = $this->createMessage();
// Once we have retrieved the view content for the e-mail we will set the body
// of this message using the HTML type, which will provide a simple wrapper
// to creating view based emails that are able to receive arrays of data.
- $this->addContent($message, $view, $plain, $raw, $data);
-
call_user_func($callback, $message);
+ $this->addContent($message, $view, $plain, $raw, $data);
+
// If a global "to" address has been set, we will set that address on the mail
// message. This is primarily useful during local development in which each
// message should be delivered into a single mail address for inspection.
if (isset($this->to['address'])) {
- $this->setGlobalTo($message);
+ $this->setGlobalToAndRemoveCcAndBcc($message);
}
- // Next we will determine if the message should be send. We give the developer
+ // Next we will determine if the message should be sent. We give the developer
// one final chance to stop this message and then we will send it to all of
// its recipients. We will then fire the sent event for the sent message.
$swiftMessage = $message->getSwiftMessage();
- if ($this->shouldSendMessage($swiftMessage)) {
+ if ($this->shouldSendMessage($swiftMessage, $data)) {
$this->sendSwiftMessage($swiftMessage);
- $this->dispatchSentEvent($message);
+ $this->dispatchSentEvent($message, $data);
}
}
/**
* Send the given mailable.
*
- * @param MailableContract $mailable
+ * @param \Illuminate\Contracts\Mail\Mailable $mailable
* @return mixed
*/
protected function sendMailable(MailableContract $mailable)
{
return $mailable instanceof ShouldQueue
- ? $mailable->queue($this->queue) : $mailable->send($this);
+ ? $mailable->queue($this->queue)
+ : $mailable->send($this);
}
/**
@@ -248,7 +291,7 @@ class Mailer implements MailerContract, MailQueueContract
// If the given view is an array with numeric keys, we will just assume that
// both a "pretty" and "plain" view were provided, so we will return this
- // array as is, since must should contain both views with numeric keys.
+ // array as is, since it should contain both views with numerical keys.
if (is_array($view) && isset($view[0])) {
return [$view[0], $view[1], null];
}
@@ -258,9 +301,9 @@ class Mailer implements MailerContract, MailQueueContract
// named keys instead, allowing the developers to use one or the other.
if (is_array($view)) {
return [
- Arr::get($view, 'html'),
- Arr::get($view, 'text'),
- Arr::get($view, 'raw'),
+ $view['html'] ?? null,
+ $view['text'] ?? null,
+ $view['raw'] ?? null,
];
}
@@ -316,28 +359,32 @@ class Mailer implements MailerContract, MailQueueContract
* @param \Illuminate\Mail\Message $message
* @return void
*/
- protected function setGlobalTo($message)
+ protected function setGlobalToAndRemoveCcAndBcc($message)
{
$message->to($this->to['address'], $this->to['name'], true);
- $message->cc($this->to['address'], $this->to['name'], true);
- $message->bcc($this->to['address'], $this->to['name'], true);
+ $message->cc(null, null, true);
+ $message->bcc(null, null, true);
}
/**
* Queue a new e-mail message for sending.
*
- * @param string|array $view
- * @param array $data
- * @param \Closure|string $callback
+ * @param \Illuminate\Contracts\Mail\Mailable $view
* @param string|null $queue
* @return mixed
+ *
+ * @throws \InvalidArgumentException
*/
- public function queue($view, array $data = [], $callback = null, $queue = null)
+ public function queue($view, $queue = null)
{
if (! $view instanceof MailableContract) {
throw new InvalidArgumentException('Only mailables may be queued.');
}
+ if (is_string($queue)) {
+ $view->onQueue($queue);
+ }
+
return $view->queue($this->queue);
}
@@ -345,14 +392,12 @@ class Mailer implements MailerContract, MailQueueContract
* Queue a new e-mail message for sending on the given queue.
*
* @param string $queue
- * @param string|array $view
- * @param array $data
- * @param \Closure|string $callback
+ * @param \Illuminate\Contracts\Mail\Mailable $view
* @return mixed
*/
- public function onQueue($queue, $view, array $data, $callback)
+ public function onQueue($queue, $view)
{
- return $this->queue($view, $data, $callback, $queue);
+ return $this->queue($view, $queue);
}
/**
@@ -361,48 +406,44 @@ class Mailer implements MailerContract, MailQueueContract
* This method didn't match rest of framework's "onQueue" phrasing. Added "onQueue".
*
* @param string $queue
- * @param string|array $view
- * @param array $data
- * @param \Closure|string $callback
+ * @param \Illuminate\Contracts\Mail\Mailable $view
* @return mixed
*/
- public function queueOn($queue, $view, array $data, $callback)
+ public function queueOn($queue, $view)
{
- return $this->onQueue($queue, $view, $data, $callback);
+ return $this->onQueue($queue, $view);
}
/**
* 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 \DateTimeInterface|\DateInterval|int $delay
+ * @param \Illuminate\Contracts\Mail\Mailable $view
* @param string|null $queue
* @return mixed
+ *
+ * @throws \InvalidArgumentException
*/
- public function later($delay, $view, array $data = [], $callback = null, $queue = null)
+ public function later($delay, $view, $queue = null)
{
if (! $view instanceof MailableContract) {
throw new InvalidArgumentException('Only mailables may be queued.');
}
- return $view->later($delay, $this->queue);
+ return $view->later($delay, is_null($queue) ? $this->queue : $queue);
}
/**
* Queue a new e-mail message for sending after (n) seconds on the given queue.
*
* @param string $queue
- * @param int $delay
- * @param string|array $view
- * @param array $data
- * @param \Closure|string $callback
+ * @param \DateTimeInterface|\DateInterval|int $delay
+ * @param \Illuminate\Contracts\Mail\Mailable $view
* @return mixed
*/
- public function laterOn($queue, $delay, $view, array $data, $callback)
+ public function laterOn($queue, $delay, $view)
{
- return $this->later($delay, $view, $data, $callback, $queue);
+ return $this->later($delay, $view, $queue);
}
/**
@@ -415,15 +456,15 @@ class Mailer implements MailerContract, MailQueueContract
$message = new Message($this->swift->createMessage('message'));
// If a global from address has been specified we will set it on every message
- // instances so the developer does not have to repeat themselves every time
- // they create a new message. We will just go ahead and push the address.
+ // instance so the developer does not have to repeat themselves every time
+ // they create a new message. We'll just go ahead and push this address.
if (! empty($this->from['address'])) {
$message->from($this->from['address'], $this->from['name']);
}
// When a global reply address was specified we will set this on every message
- // instances so the developer does not have to repeat themselves every time
- // they create a new message. We will just go ahead and push the address.
+ // instance so the developer does not have to repeat themselves every time
+ // they create a new message. We will just go ahead and push this address.
if (! empty($this->replyTo['address'])) {
$message->replyTo($this->replyTo['address'], $this->replyTo['name']);
}
@@ -435,7 +476,7 @@ class Mailer implements MailerContract, MailQueueContract
* Send a Swift Message instance.
*
* @param \Swift_Message $message
- * @return void
+ * @return int|null
*/
protected function sendSwiftMessage($message)
{
@@ -450,16 +491,17 @@ class Mailer implements MailerContract, MailQueueContract
* Determines if the message can be sent.
*
* @param \Swift_Message $message
+ * @param array $data
* @return bool
*/
- protected function shouldSendMessage($message)
+ protected function shouldSendMessage($message, $data = [])
{
if (! $this->events) {
return true;
}
return $this->events->until(
- new Events\MessageSending($message)
+ new Events\MessageSending($message, $data)
) !== false;
}
@@ -467,13 +509,14 @@ class Mailer implements MailerContract, MailQueueContract
* Dispatch the message sent event.
*
* @param \Illuminate\Mail\Message $message
+ * @param array $data
* @return void
*/
- protected function dispatchSentEvent($message)
+ protected function dispatchSentEvent($message, $data = [])
{
if ($this->events) {
$this->events->dispatch(
- new Events\MessageSent($message->getSwiftMessage())
+ new Events\MessageSent($message->getSwiftMessage(), $data)
);
}
}
@@ -491,13 +534,13 @@ class Mailer implements MailerContract, MailQueueContract
}
/**
- * Get the view factory instance.
+ * Get the array of failed recipients.
*
- * @return \Illuminate\Contracts\View\Factory
+ * @return array
*/
- public function getViewFactory()
+ public function failures()
{
- return $this->views;
+ return $this->failedRecipients;
}
/**
@@ -511,13 +554,13 @@ class Mailer implements MailerContract, MailQueueContract
}
/**
- * Get the array of failed recipients.
+ * Get the view factory instance.
*
- * @return array
+ * @return \Illuminate\Contracts\View\Factory
*/
- public function failures()
+ public function getViewFactory()
{
- return $this->failedRecipients;
+ return $this->views;
}
/**
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Mail/Markdown.php b/pfosten/vendor/laravel/framework/src/Illuminate/Mail/Markdown.php
index b1b8e0e3..d25c5993 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Mail/Markdown.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Mail/Markdown.php
@@ -3,7 +3,6 @@
namespace Illuminate\Mail;
use Parsedown;
-use Illuminate\Support\Arr;
use Illuminate\Support\HtmlString;
use Illuminate\Contracts\View\Factory as ViewFactory;
use TijsVerkoyen\CssToInlineStyles\CssToInlineStyles;
@@ -13,7 +12,7 @@ class Markdown
/**
* The view factory implementation.
*
- * @var \Illuminate\View\Factory
+ * @var \Illuminate\Contracts\View\Factory
*/
protected $view;
@@ -41,8 +40,8 @@ class Markdown
public function __construct(ViewFactory $view, array $options = [])
{
$this->view = $view;
- $this->theme = Arr::get($options, 'theme', 'default');
- $this->loadComponentsFrom(Arr::get($options, 'paths', []));
+ $this->theme = $options['theme'] ?? 'default';
+ $this->loadComponentsFrom($options['paths'] ?? []);
}
/**
@@ -61,13 +60,13 @@ class Markdown
'mail', $this->htmlComponentPaths()
)->make($view, $data)->render();
- return new HtmlString(with($inliner ?: new CssToInlineStyles)->convert(
+ return new HtmlString(($inliner ?: new CssToInlineStyles)->convert(
$contents, $this->view->make('mail::themes.'.$this->theme)->render()
));
}
/**
- * Render the Markdown template into HTML.
+ * Render the Markdown template into text.
*
* @param string $view
* @param array $data
@@ -78,7 +77,7 @@ class Markdown
$this->view->flushFinderCache();
$contents = $this->view->replaceNamespace(
- 'mail', $this->markdownComponentPaths()
+ 'mail', $this->textComponentPaths()
)->make($view, $data)->render();
return new HtmlString(
@@ -90,7 +89,7 @@ class Markdown
* Parse the given Markdown text into HTML.
*
* @param string $text
- * @return string
+ * @return \Illuminate\Support\HtmlString
*/
public static function parse($text)
{
@@ -112,14 +111,14 @@ class Markdown
}
/**
- * Get the Markdown component paths.
+ * Get the text component paths.
*
* @return array
*/
- public function markdownComponentPaths()
+ public function textComponentPaths()
{
return array_map(function ($path) {
- return $path.'/markdown';
+ return $path.'/text';
}, $this->componentPaths());
}
@@ -145,4 +144,17 @@ class Markdown
{
$this->componentPaths = $paths;
}
+
+ /**
+ * Set the default theme to be used.
+ *
+ * @param string $theme
+ * @return $this
+ */
+ public function theme($theme)
+ {
+ $this->theme = $theme;
+
+ return $this;
+ }
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Mail/Message.php b/pfosten/vendor/laravel/framework/src/Illuminate/Mail/Message.php
index a91c1817..94c9dce2 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Mail/Message.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Mail/Message.php
@@ -4,12 +4,15 @@ namespace Illuminate\Mail;
use Swift_Image;
use Swift_Attachment;
+use Illuminate\Support\Traits\ForwardsCalls;
/**
* @mixin \Swift_Message
*/
class Message
{
+ use ForwardsCalls;
+
/**
* The Swift Message instance.
*
@@ -208,7 +211,7 @@ class Message
* Create a Swift Attachment instance.
*
* @param string $file
- * @return \Swift_Attachment
+ * @return \Swift_Mime_Attachment
*/
protected function createAttachmentFromPath($file)
{
@@ -239,7 +242,7 @@ class Message
*/
protected function createAttachmentFromData($data, $name)
{
- return Swift_Attachment::newInstance($data, $name);
+ return new Swift_Attachment($data, $name);
}
/**
@@ -269,7 +272,7 @@ class Message
*/
public function embedData($data, $name, $contentType = null)
{
- $image = Swift_Image::newInstance($data, $name, $contentType);
+ $image = new Swift_Image($data, $name, $contentType);
return $this->swift->embed($image);
}
@@ -321,8 +324,6 @@ class Message
*/
public function __call($method, $parameters)
{
- $callable = [$this->swift, $method];
-
- return call_user_func_array($callable, $parameters);
+ return $this->forwardCallTo($this->swift, $method, $parameters);
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Mail/PendingMail.php b/pfosten/vendor/laravel/framework/src/Illuminate/Mail/PendingMail.php
index 716c8253..017ccb97 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Mail/PendingMail.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Mail/PendingMail.php
@@ -3,16 +3,26 @@
namespace Illuminate\Mail;
use Illuminate\Contracts\Queue\ShouldQueue;
+use Illuminate\Contracts\Mail\Mailer as MailerContract;
+use Illuminate\Contracts\Translation\HasLocalePreference;
+use Illuminate\Contracts\Mail\Mailable as MailableContract;
class PendingMail
{
/**
* The mailer instance.
*
- * @var array
+ * @var \Illuminate\Contracts\Mail\Mailer
*/
protected $mailer;
+ /**
+ * The locale of the message.
+ *
+ * @var string
+ */
+ protected $locale;
+
/**
* The "to" recipients of the message.
*
@@ -37,14 +47,27 @@ class PendingMail
/**
* Create a new mailable mailer instance.
*
- * @param Mailer $mailer
+ * @param \Illuminate\Contracts\Mail\Mailer $mailer
* @return void
*/
- public function __construct(Mailer $mailer)
+ public function __construct(MailerContract $mailer)
{
$this->mailer = $mailer;
}
+ /**
+ * Set the locale of the message.
+ *
+ * @param string $locale
+ * @return $this
+ */
+ public function locale($locale)
+ {
+ $this->locale = $locale;
+
+ return $this;
+ }
+
/**
* Set the recipients of the message.
*
@@ -55,6 +78,10 @@ class PendingMail
{
$this->to = $users;
+ if (! $this->locale && $users instanceof HasLocalePreference) {
+ $this->locale($users->preferredLocale());
+ }
+
return $this;
}
@@ -87,10 +114,11 @@ class PendingMail
/**
* Send a new mailable message instance.
*
- * @param Mailable $mailable
+ * @param \Illuminate\Contracts\Mail\Mailable $mailable
+ *
* @return mixed
*/
- public function send(Mailable $mailable)
+ public function send(MailableContract $mailable)
{
if ($mailable instanceof ShouldQueue) {
return $this->queue($mailable);
@@ -102,10 +130,10 @@ class PendingMail
/**
* Send a mailable message immediately.
*
- * @param Mailable $mailable
+ * @param \Illuminate\Contracts\Mail\Mailable $mailable;
* @return mixed
*/
- public function sendNow(Mailable $mailable)
+ public function sendNow(MailableContract $mailable)
{
return $this->mailer->send($this->fill($mailable));
}
@@ -113,10 +141,10 @@ class PendingMail
/**
* Push the given mailable onto the queue.
*
- * @param Mailable $mailable
+ * @param \Illuminate\Contracts\Mail\Mailable $mailable;
* @return mixed
*/
- public function queue(Mailable $mailable)
+ public function queue(MailableContract $mailable)
{
$mailable = $this->fill($mailable);
@@ -130,11 +158,11 @@ class PendingMail
/**
* Deliver the queued message after the given delay.
*
- * @param \DateTime|int $delay
- * @param Mailable $mailable
+ * @param \DateTimeInterface|\DateInterval|int $delay
+ * @param \Illuminate\Contracts\Mail\Mailable $mailable;
* @return mixed
*/
- public function later($delay, Mailable $mailable)
+ public function later($delay, MailableContract $mailable)
{
return $this->mailer->later($delay, $this->fill($mailable));
}
@@ -142,13 +170,14 @@ class PendingMail
/**
* Populate the mailable with the addresses.
*
- * @param Mailable $mailable
- * @return Mailable
+ * @param \Illuminate\Contracts\Mail\Mailable $mailable;
+ * @return \Illuminate\Mail\Mailable
*/
- protected function fill(Mailable $mailable)
+ protected function fill(MailableContract $mailable)
{
return $mailable->to($this->to)
->cc($this->cc)
- ->bcc($this->bcc);
+ ->bcc($this->bcc)
+ ->locale($this->locale);
}
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Mail/SendQueuedMailable.php b/pfosten/vendor/laravel/framework/src/Illuminate/Mail/SendQueuedMailable.php
index bab05760..8ab68f46 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Mail/SendQueuedMailable.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Mail/SendQueuedMailable.php
@@ -10,7 +10,7 @@ class SendQueuedMailable
/**
* The mailable message instance.
*
- * @var Mailable
+ * @var \Illuminate\Contracts\Mail\Mailable
*/
public $mailable;
@@ -61,4 +61,41 @@ class SendQueuedMailable
{
return get_class($this->mailable);
}
+
+ /**
+ * Call the failed method on the mailable instance.
+ *
+ * @param \Exception $e
+ * @return void
+ */
+ public function failed($e)
+ {
+ if (method_exists($this->mailable, 'failed')) {
+ $this->mailable->failed($e);
+ }
+ }
+
+ /**
+ * Get the retry delay for the mailable object.
+ *
+ * @return mixed
+ */
+ public function retryAfter()
+ {
+ if (! method_exists($this->mailable, 'retryAfter') && ! isset($this->mailable->retryAfter)) {
+ return;
+ }
+
+ return $this->mailable->retryAfter ?? $this->mailable->retryAfter();
+ }
+
+ /**
+ * Prepare the instance for cloning.
+ *
+ * @return void
+ */
+ public function __clone()
+ {
+ $this->mailable = clone $this->mailable;
+ }
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Mail/Transport/ArrayTransport.php b/pfosten/vendor/laravel/framework/src/Illuminate/Mail/Transport/ArrayTransport.php
index 6213b5b2..766af833 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Mail/Transport/ArrayTransport.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Mail/Transport/ArrayTransport.php
@@ -2,7 +2,7 @@
namespace Illuminate\Mail\Transport;
-use Swift_Mime_Message;
+use Swift_Mime_SimpleMessage;
use Illuminate\Support\Collection;
class ArrayTransport extends Transport
@@ -27,7 +27,7 @@ class ArrayTransport extends Transport
/**
* {@inheritdoc}
*/
- public function send(Swift_Mime_Message $message, &$failedRecipients = null)
+ public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = null)
{
$this->beforeSendPerformed($message);
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Mail/Transport/LogTransport.php b/pfosten/vendor/laravel/framework/src/Illuminate/Mail/Transport/LogTransport.php
index 26c2c220..fb796d57 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Mail/Transport/LogTransport.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Mail/Transport/LogTransport.php
@@ -2,9 +2,9 @@
namespace Illuminate\Mail\Transport;
-use Swift_Mime_Message;
-use Swift_Mime_MimeEntity;
use Psr\Log\LoggerInterface;
+use Swift_Mime_SimpleMessage;
+use Swift_Mime_SimpleMimeEntity;
class LogTransport extends Transport
{
@@ -29,7 +29,7 @@ class LogTransport extends Transport
/**
* {@inheritdoc}
*/
- public function send(Swift_Mime_Message $message, &$failedRecipients = null)
+ public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = null)
{
$this->beforeSendPerformed($message);
@@ -43,10 +43,10 @@ class LogTransport extends Transport
/**
* Get a loggable string out of a Swiftmailer entity.
*
- * @param \Swift_Mime_MimeEntity $entity
+ * @param \Swift_Mime_SimpleMimeEntity $entity
* @return string
*/
- protected function getMimeEntityString(Swift_Mime_MimeEntity $entity)
+ protected function getMimeEntityString(Swift_Mime_SimpleMimeEntity $entity)
{
$string = (string) $entity->getHeaders().PHP_EOL.$entity->getBody();
@@ -56,4 +56,14 @@ class LogTransport extends Transport
return $string;
}
+
+ /**
+ * Get the logger for the LogTransport instance.
+ *
+ * @return \Psr\Log\LoggerInterface
+ */
+ public function logger()
+ {
+ return $this->logger;
+ }
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Mail/Transport/MailgunTransport.php b/pfosten/vendor/laravel/framework/src/Illuminate/Mail/Transport/MailgunTransport.php
index 3b486808..5026cbb5 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Mail/Transport/MailgunTransport.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Mail/Transport/MailgunTransport.php
@@ -2,7 +2,7 @@
namespace Illuminate\Mail\Transport;
-use Swift_Mime_Message;
+use Swift_Mime_SimpleMessage;
use GuzzleHttp\ClientInterface;
class MailgunTransport extends Transport
@@ -22,18 +22,18 @@ class MailgunTransport extends Transport
protected $key;
/**
- * The Mailgun domain.
+ * The Mailgun email domain.
*
* @var string
*/
protected $domain;
/**
- * THe Mailgun API end-point.
+ * The Mailgun API endpoint.
*
* @var string
*/
- protected $url;
+ protected $endpoint;
/**
* Create a new Mailgun transport instance.
@@ -41,19 +41,22 @@ class MailgunTransport extends Transport
* @param \GuzzleHttp\ClientInterface $client
* @param string $key
* @param string $domain
+ * @param string|null $endpoint
* @return void
*/
- public function __construct(ClientInterface $client, $key, $domain)
+ public function __construct(ClientInterface $client, $key, $domain, $endpoint = null)
{
$this->key = $key;
$this->client = $client;
+ $this->endpoint = $endpoint ?? 'api.mailgun.net';
+
$this->setDomain($domain);
}
/**
* {@inheritdoc}
*/
- public function send(Swift_Mime_Message $message, &$failedRecipients = null)
+ public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = null)
{
$this->beforeSendPerformed($message);
@@ -61,7 +64,15 @@ class MailgunTransport extends Transport
$message->setBcc([]);
- $this->client->post($this->url, $this->payload($message, $to));
+ $response = $this->client->request(
+ 'POST',
+ "https://{$this->endpoint}/v3/{$this->domain}/messages.mime",
+ $this->payload($message, $to)
+ );
+
+ $message->getHeaders()->addTextHeader(
+ 'X-Mailgun-Message-ID', $this->getMessageId($response)
+ );
$this->sendPerformed($message);
@@ -71,11 +82,11 @@ class MailgunTransport extends Transport
/**
* Get the HTTP payload for sending the Mailgun message.
*
- * @param \Swift_Mime_Message $message
+ * @param \Swift_Mime_SimpleMessage $message
* @param string $to
* @return array
*/
- protected function payload(Swift_Mime_Message $message, $to)
+ protected function payload(Swift_Mime_SimpleMessage $message, $to)
{
return [
'auth' => [
@@ -99,10 +110,10 @@ class MailgunTransport extends Transport
/**
* Get the "to" payload field for the API request.
*
- * @param \Swift_Mime_Message $message
+ * @param \Swift_Mime_SimpleMessage $message
* @return string
*/
- protected function getTo(Swift_Mime_Message $message)
+ protected function getTo(Swift_Mime_SimpleMessage $message)
{
return collect($this->allContacts($message))->map(function ($display, $address) {
return $display ? $display." <{$address}>" : $address;
@@ -112,16 +123,29 @@ class MailgunTransport extends Transport
/**
* Get all of the contacts for the message.
*
- * @param \Swift_Mime_Message $message
+ * @param \Swift_Mime_SimpleMessage $message
* @return array
*/
- protected function allContacts(Swift_Mime_Message $message)
+ protected function allContacts(Swift_Mime_SimpleMessage $message)
{
return array_merge(
(array) $message->getTo(), (array) $message->getCc(), (array) $message->getBcc()
);
}
+ /**
+ * Get the message ID from the response.
+ *
+ * @param \Psr\Http\Message\ResponseInterface $response
+ * @return string
+ */
+ protected function getMessageId($response)
+ {
+ return object_get(
+ json_decode($response->getBody()->getContents()), 'id'
+ );
+ }
+
/**
* Get the API key being used by the transport.
*
@@ -157,12 +181,31 @@ class MailgunTransport extends Transport
* Set the domain being used by the transport.
*
* @param string $domain
- * @return void
+ * @return string
*/
public function setDomain($domain)
{
- $this->url = 'https://api.mailgun.net/v3/'.$domain.'/messages.mime';
-
return $this->domain = $domain;
}
+
+ /**
+ * Get the API endpoint being used by the transport.
+ *
+ * @return string
+ */
+ public function getEndpoint()
+ {
+ return $this->endpoint;
+ }
+
+ /**
+ * Set the API endpoint being used by the transport.
+ *
+ * @param string $endpoint
+ * @return string
+ */
+ public function setEndpoint($endpoint)
+ {
+ return $this->endpoint = $endpoint;
+ }
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Mail/Transport/MandrillTransport.php b/pfosten/vendor/laravel/framework/src/Illuminate/Mail/Transport/MandrillTransport.php
index c8fdfa36..e8e6ae16 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Mail/Transport/MandrillTransport.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Mail/Transport/MandrillTransport.php
@@ -2,7 +2,7 @@
namespace Illuminate\Mail\Transport;
-use Swift_Mime_Message;
+use Swift_Mime_SimpleMessage;
use GuzzleHttp\ClientInterface;
class MandrillTransport extends Transport
@@ -37,11 +37,11 @@ class MandrillTransport extends Transport
/**
* {@inheritdoc}
*/
- public function send(Swift_Mime_Message $message, &$failedRecipients = null)
+ public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = null)
{
$this->beforeSendPerformed($message);
- $this->client->post('https://mandrillapp.com/api/1.0/messages/send-raw.json', [
+ $this->client->request('POST', 'https://mandrillapp.com/api/1.0/messages/send-raw.json', [
'form_params' => [
'key' => $this->key,
'to' => $this->getTo($message),
@@ -60,10 +60,10 @@ class MandrillTransport extends Transport
*
* Note that Mandrill still respects CC, BCC headers in raw message itself.
*
- * @param \Swift_Mime_Message $message
+ * @param \Swift_Mime_SimpleMessage $message
* @return array
*/
- protected function getTo(Swift_Mime_Message $message)
+ protected function getTo(Swift_Mime_SimpleMessage $message)
{
$to = [];
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Mail/Transport/SesTransport.php b/pfosten/vendor/laravel/framework/src/Illuminate/Mail/Transport/SesTransport.php
index a790423a..0dc8584a 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Mail/Transport/SesTransport.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Mail/Transport/SesTransport.php
@@ -3,7 +3,7 @@
namespace Illuminate\Mail\Transport;
use Aws\Ses\SesClient;
-use Swift_Mime_Message;
+use Swift_Mime_SimpleMessage;
class SesTransport extends Transport
{
@@ -14,35 +14,79 @@ class SesTransport extends Transport
*/
protected $ses;
+ /**
+ * The Amazon SES transmission options.
+ *
+ * @var array
+ */
+ protected $options = [];
+
/**
* Create a new SES transport instance.
*
* @param \Aws\Ses\SesClient $ses
+ * @param array $options
* @return void
*/
- public function __construct(SesClient $ses)
+ public function __construct(SesClient $ses, $options = [])
{
$this->ses = $ses;
+ $this->options = $options;
}
/**
* {@inheritdoc}
*/
- public function send(Swift_Mime_Message $message, &$failedRecipients = null)
+ public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = null)
{
$this->beforeSendPerformed($message);
- $headers = $message->getHeaders();
+ $result = $this->ses->sendRawEmail(
+ array_merge(
+ $this->options, [
+ 'Source' => key($message->getSender() ?: $message->getFrom()),
+ 'RawMessage' => [
+ 'Data' => $message->toString(),
+ ],
+ ]
+ )
+ );
- $headers->addTextHeader('X-SES-Message-ID', $this->ses->sendRawEmail([
- 'Source' => key($message->getSender() ?: $message->getFrom()),
- 'RawMessage' => [
- 'Data' => $message->toString(),
- ],
- ])->get('MessageId'));
+ $message->getHeaders()->addTextHeader('X-SES-Message-ID', $result->get('MessageId'));
$this->sendPerformed($message);
return $this->numberOfRecipients($message);
}
+
+ /**
+ * Get the Amazon SES client for the SesTransport instance.
+ *
+ * @return \Aws\Ses\SesClient
+ */
+ public function ses()
+ {
+ return $this->ses;
+ }
+
+ /**
+ * Get the transmission options being used by the transport.
+ *
+ * @return array
+ */
+ public function getOptions()
+ {
+ return $this->options;
+ }
+
+ /**
+ * Set the transmission options being used by the transport.
+ *
+ * @param array $options
+ * @return array
+ */
+ public function setOptions(array $options)
+ {
+ return $this->options = $options;
+ }
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Mail/Transport/SparkPostTransport.php b/pfosten/vendor/laravel/framework/src/Illuminate/Mail/Transport/SparkPostTransport.php
index 0a59bf48..a2358f1d 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Mail/Transport/SparkPostTransport.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Mail/Transport/SparkPostTransport.php
@@ -2,7 +2,7 @@
namespace Illuminate\Mail\Transport;
-use Swift_Mime_Message;
+use Swift_Mime_SimpleMessage;
use GuzzleHttp\ClientInterface;
class SparkPostTransport extends Transport
@@ -22,7 +22,7 @@ class SparkPostTransport extends Transport
protected $key;
/**
- * Transmission options.
+ * The SparkPost transmission options.
*
* @var array
*/
@@ -46,7 +46,7 @@ class SparkPostTransport extends Transport
/**
* {@inheritdoc}
*/
- public function send(Swift_Mime_Message $message, &$failedRecipients = null)
+ public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = null)
{
$this->beforeSendPerformed($message);
@@ -54,7 +54,7 @@ class SparkPostTransport extends Transport
$message->setBcc([]);
- $response = $this->client->post('https://api.sparkpost.com/api/v1/transmissions', [
+ $response = $this->client->request('POST', $this->getEndpoint(), [
'headers' => [
'Authorization' => $this->key,
],
@@ -80,10 +80,10 @@ class SparkPostTransport extends Transport
*
* Note that SparkPost still respects CC, BCC headers in raw message itself.
*
- * @param \Swift_Mime_Message $message
+ * @param \Swift_Mime_SimpleMessage $message
* @return array
*/
- protected function getRecipients(Swift_Mime_Message $message)
+ protected function getRecipients(Swift_Mime_SimpleMessage $message)
{
$recipients = [];
@@ -105,7 +105,7 @@ class SparkPostTransport extends Transport
/**
* Get the transmission ID from the response.
*
- * @param \GuzzleHttp\Psr7\Response $response
+ * @param \GuzzleHttp\Psr7\Response $response
* @return string
*/
protected function getTransmissionId($response)
@@ -137,10 +137,20 @@ class SparkPostTransport extends Transport
}
/**
- * Get the transmission options being used by the transport.
+ * Get the SparkPost API endpoint.
*
* @return string
*/
+ public function getEndpoint()
+ {
+ return $this->getOptions()['endpoint'] ?? 'https://api.sparkpost.com/api/v1/transmissions';
+ }
+
+ /**
+ * Get the transmission options being used by the transport.
+ *
+ * @return array
+ */
public function getOptions()
{
return $this->options;
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Mail/Transport/Transport.php b/pfosten/vendor/laravel/framework/src/Illuminate/Mail/Transport/Transport.php
index 76e5d527..bc257499 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Mail/Transport/Transport.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Mail/Transport/Transport.php
@@ -3,8 +3,8 @@
namespace Illuminate\Mail\Transport;
use Swift_Transport;
-use Swift_Mime_Message;
use Swift_Events_SendEvent;
+use Swift_Mime_SimpleMessage;
use Swift_Events_EventListener;
abstract class Transport implements Swift_Transport
@@ -40,6 +40,14 @@ abstract class Transport implements Swift_Transport
return true;
}
+ /**
+ * {@inheritdoc}
+ */
+ public function ping()
+ {
+ return true;
+ }
+
/**
* Register a plug-in with the transport.
*
@@ -54,10 +62,10 @@ abstract class Transport implements Swift_Transport
/**
* Iterate through registered plugins and execute plugins' methods.
*
- * @param \Swift_Mime_Message $message
+ * @param \Swift_Mime_SimpleMessage $message
* @return void
*/
- protected function beforeSendPerformed(Swift_Mime_Message $message)
+ protected function beforeSendPerformed(Swift_Mime_SimpleMessage $message)
{
$event = new Swift_Events_SendEvent($this, $message);
@@ -71,10 +79,10 @@ abstract class Transport implements Swift_Transport
/**
* Iterate through registered plugins and execute plugins' methods.
*
- * @param \Swift_Mime_Message $message
+ * @param \Swift_Mime_SimpleMessage $message
* @return void
*/
- protected function sendPerformed(Swift_Mime_Message $message)
+ protected function sendPerformed(Swift_Mime_SimpleMessage $message)
{
$event = new Swift_Events_SendEvent($this, $message);
@@ -88,10 +96,10 @@ abstract class Transport implements Swift_Transport
/**
* Get the number of recipients.
*
- * @param \Swift_Mime_Message $message
+ * @param \Swift_Mime_SimpleMessage $message
* @return int
*/
- protected function numberOfRecipients(Swift_Mime_Message $message)
+ protected function numberOfRecipients(Swift_Mime_SimpleMessage $message)
{
return count(array_merge(
(array) $message->getTo(), (array) $message->getCc(), (array) $message->getBcc()
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Mail/TransportManager.php b/pfosten/vendor/laravel/framework/src/Illuminate/Mail/TransportManager.php
index b61c945a..206727c0 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Mail/TransportManager.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Mail/TransportManager.php
@@ -5,12 +5,13 @@ namespace Illuminate\Mail;
use Aws\Ses\SesClient;
use Illuminate\Support\Arr;
use Psr\Log\LoggerInterface;
+use Illuminate\Log\LogManager;
use Illuminate\Support\Manager;
use GuzzleHttp\Client as HttpClient;
-use Swift_MailTransport as MailTransport;
use Swift_SmtpTransport as SmtpTransport;
use Illuminate\Mail\Transport\LogTransport;
use Illuminate\Mail\Transport\SesTransport;
+use Postmark\Transport as PostmarkTransport;
use Illuminate\Mail\Transport\ArrayTransport;
use Illuminate\Mail\Transport\MailgunTransport;
use Illuminate\Mail\Transport\MandrillTransport;
@@ -31,9 +32,7 @@ class TransportManager extends Manager
// The Swift SMTP transport instance will allow us to use any SMTP backend
// for delivering mail such as Sendgrid, Amazon SES, or a custom server
// a developer has available. We will just pass this configured host.
- $transport = SmtpTransport::newInstance(
- $config['host'], $config['port']
- );
+ $transport = new SmtpTransport($config['host'], $config['port']);
if (isset($config['encryption'])) {
$transport->setEncryption($config['encryption']);
@@ -48,13 +47,30 @@ class TransportManager extends Manager
$transport->setPassword($config['password']);
}
- // Next we will set any stream context options specified for the transport
- // and then return it. The option is not required any may not be inside
- // the configuration array at all so we'll verify that before adding.
+ return $this->configureSmtpDriver($transport, $config);
+ }
+
+ /**
+ * Configure the additional SMTP driver options.
+ *
+ * @param \Swift_SmtpTransport $transport
+ * @param array $config
+ * @return \Swift_SmtpTransport
+ */
+ protected function configureSmtpDriver($transport, $config)
+ {
if (isset($config['stream'])) {
$transport->setStreamOptions($config['stream']);
}
+ if (isset($config['source_ip'])) {
+ $transport->setSourceIp($config['source_ip']);
+ }
+
+ if (isset($config['local_domain'])) {
+ $transport->setLocalDomain($config['local_domain']);
+ }
+
return $transport;
}
@@ -65,15 +81,13 @@ class TransportManager extends Manager
*/
protected function createSendmailDriver()
{
- return SendmailTransport::newInstance(
- $this->app['config']['mail']['sendmail']
- );
+ return new SendmailTransport($this->app['config']['mail']['sendmail']);
}
/**
* Create an instance of the Amazon SES Swift Transport driver.
*
- * @return \Swift_SendmailTransport
+ * @return \Illuminate\Mail\Transport\SesTransport
*/
protected function createSesDriver()
{
@@ -81,9 +95,10 @@ class TransportManager extends Manager
'version' => 'latest', 'service' => 'email',
]);
- return new SesTransport(new SesClient(
- $this->addSesCredentials($config)
- ));
+ return new SesTransport(
+ new SesClient($this->addSesCredentials($config)),
+ $config['options'] ?? []
+ );
}
/**
@@ -94,8 +109,8 @@ class TransportManager extends Manager
*/
protected function addSesCredentials(array $config)
{
- if ($config['key'] && $config['secret']) {
- $config['credentials'] = Arr::only($config, ['key', 'secret']);
+ if (! empty($config['key']) && ! empty($config['secret'])) {
+ $config['credentials'] = Arr::only($config, ['key', 'secret', 'token']);
}
return $config;
@@ -104,11 +119,11 @@ class TransportManager extends Manager
/**
* Create an instance of the Mail Swift Transport driver.
*
- * @return \Swift_MailTransport
+ * @return \Swift_SendmailTransport
*/
protected function createMailDriver()
{
- return MailTransport::newInstance();
+ return new SendmailTransport;
}
/**
@@ -122,7 +137,9 @@ class TransportManager extends Manager
return new MailgunTransport(
$this->guzzle($config),
- $config['secret'], $config['domain']
+ $config['secret'],
+ $config['domain'],
+ $config['endpoint'] ?? null
);
}
@@ -150,7 +167,19 @@ class TransportManager extends Manager
$config = $this->app['config']->get('services.sparkpost', []);
return new SparkPostTransport(
- $this->guzzle($config), $config['secret'], Arr::get($config, 'options', [])
+ $this->guzzle($config), $config['secret'], $config['options'] ?? []
+ );
+ }
+
+ /**
+ * Create an instance of the Postmark Swift Transport driver.
+ *
+ * @return \Swift_Transport
+ */
+ protected function createPostmarkDriver()
+ {
+ return new PostmarkTransport(
+ $this->app['config']->get('services.postmark.token')
);
}
@@ -161,7 +190,13 @@ class TransportManager extends Manager
*/
protected function createLogDriver()
{
- return new LogTransport($this->app->make(LoggerInterface::class));
+ $logger = $this->app->make(LoggerInterface::class);
+
+ if ($logger instanceof LogManager) {
+ $logger = $logger->channel($this->app['config']['mail.log_channel']);
+ }
+
+ return new LogTransport($logger);
}
/**
@@ -183,7 +218,7 @@ class TransportManager extends Manager
protected function guzzle($config)
{
return new HttpClient(Arr::add(
- Arr::get($config, 'guzzle', []), 'connect_timeout', 60
+ $config['guzzle'] ?? [], 'connect_timeout', 60
));
}
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Mail/composer.json b/pfosten/vendor/laravel/framework/src/Illuminate/Mail/composer.json
index 80a9f662..c04704a1 100755
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Mail/composer.json
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Mail/composer.json
@@ -14,14 +14,15 @@
}
],
"require": {
- "php": ">=5.6.4",
- "erusev/parsedown": "~1.6",
- "illuminate/container": "5.4.*",
- "illuminate/contracts": "5.4.*",
- "illuminate/support": "5.4.*",
- "psr/log": "~1.0",
- "swiftmailer/swiftmailer": "~5.4",
- "tijsverkoyen/css-to-inline-styles": "~2.2"
+ "php": "^7.1.3",
+ "ext-json": "*",
+ "erusev/parsedown": "^1.7",
+ "illuminate/container": "5.8.*",
+ "illuminate/contracts": "5.8.*",
+ "illuminate/support": "5.8.*",
+ "psr/log": "^1.0",
+ "swiftmailer/swiftmailer": "^6.0",
+ "tijsverkoyen/css-to-inline-styles": "^2.2.1"
},
"autoload": {
"psr-4": {
@@ -30,12 +31,13 @@
},
"extra": {
"branch-alias": {
- "dev-master": "5.4-dev"
+ "dev-master": "5.8-dev"
}
},
"suggest": {
- "aws/aws-sdk-php": "Required to use the SES mail driver (~3.0).",
- "guzzlehttp/guzzle": "Required to use the Mailgun and Mandrill mail drivers (~6.0)."
+ "aws/aws-sdk-php": "Required to use the SES mail driver (^3.0).",
+ "guzzlehttp/guzzle": "Required to use the Mailgun and Mandrill mail drivers (^6.0).",
+ "wildbit/swiftmailer-postmark": "Required to use Postmark mail driver (^3.0)."
},
"config": {
"sort-packages": true
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Mail/resources/views/html/button.blade.php b/pfosten/vendor/laravel/framework/src/Illuminate/Mail/resources/views/html/button.blade.php
index c7aae1b8..512c1d8c 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Mail/resources/views/html/button.blade.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Mail/resources/views/html/button.blade.php
@@ -1,13 +1,13 @@
-
+
-
+
-
+
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Mail/resources/views/html/footer.blade.php b/pfosten/vendor/laravel/framework/src/Illuminate/Mail/resources/views/html/footer.blade.php
index c3f9360a..33f7dad7 100644
--- a/pfosten/vendor/laravel/framework/src/Illuminate/Mail/resources/views/html/footer.blade.php
+++ b/pfosten/vendor/laravel/framework/src/Illuminate/Mail/resources/views/html/footer.blade.php
@@ -1,6 +1,6 @@
|
- | | |