language stringclasses 1
value | owner stringlengths 2 15 | repo stringlengths 2 21 | sha stringlengths 45 45 | message stringlengths 7 36.3k | path stringlengths 1 199 | patch stringlengths 15 102k | is_multipart bool 2
classes |
|---|---|---|---|---|---|---|---|
Other | laravel | framework | 29923153f049bd1006953a74388511eda729318d.json | Fix possible errors on DocBlocks (#15239)
Generating documentation using Sami, it reported some errors.
I'm not sure if the tags in the comments are wrong or we should just
ignore the error output of Sami.
Anyway this is not a big issue at all, just a minor detail. | src/Illuminate/Contracts/Cookie/QueueingFactory.php | @@ -7,7 +7,6 @@ interface QueueingFactory extends Factory
/**
* Queue a cookie to send with the next response.
*
- * @param mixed
* @return void
*/
public function queue(); | true |
Other | laravel | framework | 29923153f049bd1006953a74388511eda729318d.json | Fix possible errors on DocBlocks (#15239)
Generating documentation using Sami, it reported some errors.
I'm not sure if the tags in the comments are wrong or we should just
ignore the error output of Sami.
Anyway this is not a big issue at all, just a minor detail. | src/Illuminate/Contracts/Foundation/Application.php | @@ -23,7 +23,6 @@ public function basePath();
/**
* Get or check the current application environment.
*
- * @param mixed
* @return string
*/
public function environment(); | true |
Other | laravel | framework | 29923153f049bd1006953a74388511eda729318d.json | Fix possible errors on DocBlocks (#15239)
Generating documentation using Sami, it reported some errors.
I'm not sure if the tags in the comments are wrong or we should just
ignore the error output of Sami.
Anyway this is not a big issue at all, just a minor detail. | src/Illuminate/Cookie/CookieJar.php | @@ -112,7 +112,6 @@ public function queued($key, $default = null)
/**
* Queue a cookie to send with the next response.
*
- * @param mixed
* @return void
*/
public function queue() | true |
Other | laravel | framework | 29923153f049bd1006953a74388511eda729318d.json | Fix possible errors on DocBlocks (#15239)
Generating documentation using Sami, it reported some errors.
I'm not sure if the tags in the comments are wrong or we should just
ignore the error output of Sami.
Anyway this is not a big issue at all, just a minor detail. | src/Illuminate/Database/Eloquent/Builder.php | @@ -388,7 +388,7 @@ public function chunk($count, callable $callback)
*
* @param int $count
* @param callable $callback
- * @param string $alias
+ * @param string $column
* @return bool
*/
public function chunkById($count, callable $callback, $column = 'id') | true |
Other | laravel | framework | 29923153f049bd1006953a74388511eda729318d.json | Fix possible errors on DocBlocks (#15239)
Generating documentation using Sami, it reported some errors.
I'm not sure if the tags in the comments are wrong or we should just
ignore the error output of Sami.
Anyway this is not a big issue at all, just a minor detail. | src/Illuminate/Foundation/Application.php | @@ -465,7 +465,6 @@ public function environmentFilePath()
/**
* Get or check the current application environment.
*
- * @param mixed
* @return string|bool
*/
public function environment() | true |
Other | laravel | framework | 29923153f049bd1006953a74388511eda729318d.json | Fix possible errors on DocBlocks (#15239)
Generating documentation using Sami, it reported some errors.
I'm not sure if the tags in the comments are wrong or we should just
ignore the error output of Sami.
Anyway this is not a big issue at all, just a minor detail. | src/Illuminate/Http/RedirectResponse.php | @@ -101,7 +101,6 @@ protected function removeFilesFromInput(array $input)
/**
* Flash an array of input to the session.
*
- * @param mixed string
* @return $this
*/
public function onlyInput()
@@ -112,7 +111,6 @@ public function onlyInput()
/**
* Flash an array of input to the session.
*
- * @param mixed string
* @return \Illuminate\Http\RedirectResponse
*/
public function exceptInput() | true |
Other | laravel | framework | 29923153f049bd1006953a74388511eda729318d.json | Fix possible errors on DocBlocks (#15239)
Generating documentation using Sami, it reported some errors.
I'm not sure if the tags in the comments are wrong or we should just
ignore the error output of Sami.
Anyway this is not a big issue at all, just a minor detail. | src/Illuminate/Http/Request.php | @@ -177,7 +177,6 @@ public function segments()
/**
* Determine if the current request URI matches a pattern.
*
- * @param mixed string
* @return bool
*/
public function is()
@@ -194,7 +193,6 @@ public function is()
/**
* Determine if the current request URL and query string matches a pattern.
*
- * @param mixed string
* @return bool
*/
public function fullUrlIs() | true |
Other | laravel | framework | 29923153f049bd1006953a74388511eda729318d.json | Fix possible errors on DocBlocks (#15239)
Generating documentation using Sami, it reported some errors.
I'm not sure if the tags in the comments are wrong or we should just
ignore the error output of Sami.
Anyway this is not a big issue at all, just a minor detail. | src/Illuminate/Queue/Worker.php | @@ -189,7 +189,7 @@ protected function getNextJob($connection, $queue)
/**
* Process a given job from the queue.
*
- * @param string $connection
+ * @param string $connectionName
* @param \Illuminate\Contracts\Queue\Job $job
* @param \Illuminate\Queue\WorkerOptions $options
* @return void | true |
Other | laravel | framework | 29923153f049bd1006953a74388511eda729318d.json | Fix possible errors on DocBlocks (#15239)
Generating documentation using Sami, it reported some errors.
I'm not sure if the tags in the comments are wrong or we should just
ignore the error output of Sami.
Anyway this is not a big issue at all, just a minor detail. | src/Illuminate/Routing/Router.php | @@ -1121,7 +1121,6 @@ public function currentRouteName()
/**
* Alias for the "currentRouteNamed" method.
*
- * @param mixed string
* @return bool
*/
public function is()
@@ -1165,7 +1164,6 @@ public function currentRouteAction()
/**
* Alias for the "currentRouteUses" method.
*
- * @param mixed string
* @return bool
*/
public function uses() | true |
Other | laravel | framework | 29923153f049bd1006953a74388511eda729318d.json | Fix possible errors on DocBlocks (#15239)
Generating documentation using Sami, it reported some errors.
I'm not sure if the tags in the comments are wrong or we should just
ignore the error output of Sami.
Anyway this is not a big issue at all, just a minor detail. | src/Illuminate/Support/Facades/Facade.php | @@ -62,7 +62,6 @@ public static function spy()
/**
* Initiate a mock expectation on the facade.
*
- * @param mixed
* @return \Mockery\Expectation
*/
public static function shouldReceive() | true |
Other | laravel | framework | 4495d0cfb8632e3c59d0a80a8da03595b4dfb3ab.json | Fix return type of Model update() (#15243) | src/Illuminate/Database/Eloquent/Model.php | @@ -1401,7 +1401,7 @@ protected function incrementOrDecrementAttributeValue($column, $amount, $method)
*
* @param array $attributes
* @param array $options
- * @return bool|int
+ * @return bool
*/
public function update(array $attributes = [], array $options = [])
{ | false |
Other | laravel | framework | 1315f897bc4cd18a69c449cd64b01d6f9c46d815.json | Fix some docblocks. (#15187) | src/Illuminate/Http/JsonResponse.php | @@ -32,8 +32,6 @@ public function __construct($data = null, $status = 200, $headers = [], $options
*
* @param string|null $callback
* @return $this
- *
- * @throws \InvalidArgumentException
*/
public function withCallback($callback = null)
{ | true |
Other | laravel | framework | 1315f897bc4cd18a69c449cd64b01d6f9c46d815.json | Fix some docblocks. (#15187) | src/Illuminate/Notifications/Messages/NexmoMessage.php | @@ -21,7 +21,7 @@ class NexmoMessage
/**
* Create a new message instance.
*
- * @param string $message
+ * @param string $content
* @return void
*/
public function __construct($content = '')
@@ -45,7 +45,7 @@ public function content($content)
/**
* Set the phone number the message should be sent from.
*
- * @param string $number
+ * @param string $from
* @return $this
*/
public function from($from) | true |
Other | laravel | framework | 2b7cc0e010303a2d0f0336952da90651a046a009.json | fix broken crap | src/Illuminate/Broadcasting/Broadcasters/PusherBroadcaster.php | @@ -5,7 +5,6 @@
use Pusher;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
-use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpKernel\Exception\HttpException;
class PusherBroadcaster extends Broadcaster
@@ -57,14 +56,11 @@ public function auth($request)
public function validAuthenticationResponse($request, $result)
{
if (Str::startsWith($request->channel_name, 'private')) {
- return new JsonResponse(
- $this->pusher->socket_auth($request->channel_name, $request->socket_id)
- );
+ return $this->pusher->socket_auth($request->channel_name, $request->socket_id);
} else {
- return new JsonResponse(
- $this->pusher->presence_auth(
- $request->channel_name, $request->socket_id, $request->user()->id, $result
- ));
+ return $this->pusher->presence_auth(
+ $request->channel_name, $request->socket_id, $request->user()->id, $result
+ );
}
}
| true |
Other | laravel | framework | 2b7cc0e010303a2d0f0336952da90651a046a009.json | fix broken crap | src/Illuminate/Broadcasting/Broadcasters/RedisBroadcaster.php | @@ -4,7 +4,6 @@
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
-use Symfony\Component\HttpFoundation\JsonResponse;
use Illuminate\Contracts\Redis\Database as RedisDatabase;
use Symfony\Component\HttpKernel\Exception\HttpException;
@@ -65,10 +64,10 @@ public function auth($request)
public function validAuthenticationResponse($request, $result)
{
if (is_bool($result)) {
- return new JsonResponse($result);
+ return json_encode($result);
}
- return new JsonResponse(['channel_data' => [
+ return json_encode(['channel_data' => [
'user_id' => $request->user()->getKey(),
'user_info' => $result,
]]); | true |
Other | laravel | framework | 5b258fac3068261c20d40f924928a3a499f89384.json | fix style ci | src/Illuminate/Broadcasting/Broadcasters/PusherBroadcaster.php | @@ -37,7 +37,7 @@ public function __construct(Pusher $pusher)
public function auth($request)
{
if (Str::startsWith($request->channel_name, ['private-', 'presence-']) &&
- !$request->user()
+ ! $request->user()
) {
throw new HttpException(403);
}
@@ -63,8 +63,7 @@ public function validAuthenticationResponse($request, $result)
return new JsonResponse(
$this->pusher->presence_auth(
$request->channel_name, $request->socket_id, $request->user()->id, $result
- )
- , 200, [], true);
+ ), 200, [], true);
}
}
| false |
Other | laravel | framework | e9d5846d5f6a767285bc071c178ee0f5ff4ee2c5.json | Hide empty paginators. (#15125) | src/Illuminate/Pagination/resources/views/bootstrap-4.blade.php | @@ -1,34 +1,36 @@
-<ul class="pagination">
- <!-- Previous Page Link -->
- @if ($paginator->onFirstPage())
- <li class="page-item disabled"><span class="page-link">«</span></li>
- @else
- <li class="page-item"><a class="page-link" href="{{ $paginator->previousPageUrl() }}" rel="prev">«</a></li>
- @endif
-
- <!-- Pagination Elements -->
- @foreach ($elements as $element)
- <!-- "Three Dots" Separator -->
- @if (is_string($element))
- <li class="page-item disabled"><span class="page-link">{{ $element }}</span></li>
+@if ($paginator->count() > 1)
+ <ul class="pagination">
+ <!-- Previous Page Link -->
+ @if ($paginator->onFirstPage())
+ <li class="page-item disabled"><span class="page-link">«</span></li>
+ @else
+ <li class="page-item"><a class="page-link" href="{{ $paginator->previousPageUrl() }}" rel="prev">«</a></li>
@endif
- <!-- Array Of Links -->
- @if (is_array($element))
- @foreach ($element as $page => $url)
- @if ($page == $paginator->currentPage())
- <li class="page-item active"><span class="page-link">{{ $page }}</span></li>
- @else
- <li class="page-item"><a class="page-link" href="{{ $url }}">{{ $page }}</a></li>
- @endif
- @endforeach
- @endif
- @endforeach
+ <!-- Pagination Elements -->
+ @foreach ($elements as $element)
+ <!-- "Three Dots" Separator -->
+ @if (is_string($element))
+ <li class="page-item disabled"><span class="page-link">{{ $element }}</span></li>
+ @endif
- <!-- Next Page Link -->
- @if ($paginator->hasMorePages())
- <li class="page-item"><a class="page-link" href="{{ $paginator->nextPageUrl() }}" rel="next">»</a></li>
- @else
- <li class="page-item disabled"><span class="page-link">»</span></li>
- @endif
-</ul>
+ <!-- Array Of Links -->
+ @if (is_array($element))
+ @foreach ($element as $page => $url)
+ @if ($page == $paginator->currentPage())
+ <li class="page-item active"><span class="page-link">{{ $page }}</span></li>
+ @else
+ <li class="page-item"><a class="page-link" href="{{ $url }}">{{ $page }}</a></li>
+ @endif
+ @endforeach
+ @endif
+ @endforeach
+
+ <!-- Next Page Link -->
+ @if ($paginator->hasMorePages())
+ <li class="page-item"><a class="page-link" href="{{ $paginator->nextPageUrl() }}" rel="next">»</a></li>
+ @else
+ <li class="page-item disabled"><span class="page-link">»</span></li>
+ @endif
+ </ul>
+@endif | true |
Other | laravel | framework | e9d5846d5f6a767285bc071c178ee0f5ff4ee2c5.json | Hide empty paginators. (#15125) | src/Illuminate/Pagination/resources/views/default.blade.php | @@ -1,34 +1,36 @@
-<ul class="pagination">
- <!-- Previous Page Link -->
- @if ($paginator->onFirstPage())
- <li class="disabled"><span>«</span></li>
- @else
- <li><a href="{{ $paginator->previousPageUrl() }}" rel="prev">«</a></li>
- @endif
-
- <!-- Pagination Elements -->
- @foreach ($elements as $element)
- <!-- "Three Dots" Separator -->
- @if (is_string($element))
- <li class="disabled"><span>{{ $element }}</span></li>
+@if ($paginator->count() > 1)
+ <ul class="pagination">
+ <!-- Previous Page Link -->
+ @if ($paginator->onFirstPage())
+ <li class="disabled"><span>«</span></li>
+ @else
+ <li><a href="{{ $paginator->previousPageUrl() }}" rel="prev">«</a></li>
@endif
- <!-- Array Of Links -->
- @if (is_array($element))
- @foreach ($element as $page => $url)
- @if ($page == $paginator->currentPage())
- <li class="active"><span>{{ $page }}</span></li>
- @else
- <li><a href="{{ $url }}">{{ $page }}</a></li>
- @endif
- @endforeach
- @endif
- @endforeach
+ <!-- Pagination Elements -->
+ @foreach ($elements as $element)
+ <!-- "Three Dots" Separator -->
+ @if (is_string($element))
+ <li class="disabled"><span>{{ $element }}</span></li>
+ @endif
- <!-- Next Page Link -->
- @if ($paginator->hasMorePages())
- <li><a href="{{ $paginator->nextPageUrl() }}" rel="next">»</a></li>
- @else
- <li class="disabled"><span>»</span></li>
- @endif
-</ul>
+ <!-- Array Of Links -->
+ @if (is_array($element))
+ @foreach ($element as $page => $url)
+ @if ($page == $paginator->currentPage())
+ <li class="active"><span>{{ $page }}</span></li>
+ @else
+ <li><a href="{{ $url }}">{{ $page }}</a></li>
+ @endif
+ @endforeach
+ @endif
+ @endforeach
+
+ <!-- Next Page Link -->
+ @if ($paginator->hasMorePages())
+ <li><a href="{{ $paginator->nextPageUrl() }}" rel="next">»</a></li>
+ @else
+ <li class="disabled"><span>»</span></li>
+ @endif
+ </ul>
+@endif | true |
Other | laravel | framework | e9d5846d5f6a767285bc071c178ee0f5ff4ee2c5.json | Hide empty paginators. (#15125) | src/Illuminate/Pagination/resources/views/simple-bootstrap-4.blade.php | @@ -1,15 +1,17 @@
-<ul class="pagination">
- <!-- Previous Page Link -->
- @if ($paginator->onFirstPage())
- <li class="page-item disabled"><span class="page-link">«</span></li>
- @else
- <li class="page-item"><a class="page-link" href="{{ $paginator->previousPageUrl() }}" rel="prev">«</a></li>
- @endif
+@if ($paginator->count() > 1)
+ <ul class="pagination">
+ <!-- Previous Page Link -->
+ @if ($paginator->onFirstPage())
+ <li class="page-item disabled"><span class="page-link">«</span></li>
+ @else
+ <li class="page-item"><a class="page-link" href="{{ $paginator->previousPageUrl() }}" rel="prev">«</a></li>
+ @endif
- <!-- Next Page Link -->
- @if ($paginator->hasMorePages())
- <li class="page-item"><a class="page-link" href="{{ $paginator->nextPageUrl() }}" rel="next">»</a></li>
- @else
- <li class="page-item disabled"><span class="page-link">»</span></li>
- @endif
-</ul>
+ <!-- Next Page Link -->
+ @if ($paginator->hasMorePages())
+ <li class="page-item"><a class="page-link" href="{{ $paginator->nextPageUrl() }}" rel="next">»</a></li>
+ @else
+ <li class="page-item disabled"><span class="page-link">»</span></li>
+ @endif
+ </ul>
+@endif | true |
Other | laravel | framework | e9d5846d5f6a767285bc071c178ee0f5ff4ee2c5.json | Hide empty paginators. (#15125) | src/Illuminate/Pagination/resources/views/simple-default.blade.php | @@ -1,15 +1,17 @@
-<ul class="pagination">
- <!-- Previous Page Link -->
- @if ($paginator->onFirstPage())
- <li class="disabled"><span>«</span></li>
- @else
- <li><a href="{{ $paginator->previousPageUrl() }}" rel="prev">«</a></li>
- @endif
+@if ($paginator->count() > 1)
+ <ul class="pagination">
+ <!-- Previous Page Link -->
+ @if ($paginator->onFirstPage())
+ <li class="disabled"><span>«</span></li>
+ @else
+ <li><a href="{{ $paginator->previousPageUrl() }}" rel="prev">«</a></li>
+ @endif
- <!-- Next Page Link -->
- @if ($paginator->hasMorePages())
- <li><a href="{{ $paginator->nextPageUrl() }}" rel="next">»</a></li>
- @else
- <li class="disabled"><span>»</span></li>
- @endif
-</ul>
+ <!-- Next Page Link -->
+ @if ($paginator->hasMorePages())
+ <li><a href="{{ $paginator->nextPageUrl() }}" rel="next">»</a></li>
+ @else
+ <li class="disabled"><span>»</span></li>
+ @endif
+ </ul>
+@endif | true |
Other | laravel | framework | ef627f83c3174f28f6c67e012efeac2e00ef89d8.json | Remove duplicate CSRF Token (#15171) | src/Illuminate/Auth/Console/stubs/make/views/auth/passwords/reset.stub | @@ -11,8 +11,6 @@
<form class="form-horizontal" role="form" method="POST" action="{{ url('/password/reset') }}">
{{ csrf_field() }}
- <input type="hidden" name="token" value="{{ $token }}">
-
<div class="form-group{{ $errors->has('email') ? ' has-error' : '' }}">
<label for="email" class="col-md-4 control-label">E-Mail Address</label>
| false |
Other | laravel | framework | b35d4c7bce7d88c10dfecfdde87589fa952a0d93.json | Remove unneeded variable | src/Illuminate/Database/Eloquent/Model.php | @@ -1539,8 +1539,7 @@ protected function performUpdate(Builder $query)
$dirty = $this->getDirty();
if (count($dirty) > 0) {
- $numRows = $this->setKeysForSaveQuery($query)->update($dirty);
-
+ $this->setKeysForSaveQuery($query)->update($dirty);
$this->fireModelEvent('updated', false);
}
| false |
Other | laravel | framework | 7299d016862c5163570c9c7aa86a95fc26234521.json | Use same condition (#15127) | src/Illuminate/Notifications/resources/views/email.blade.php | @@ -84,7 +84,7 @@
<td style="{{ $fontFamily }} {{ $style['email-body_cell'] }}">
<!-- Greeting -->
<h1 style="{{ $style['header-1'] }}">
- @if (! is_null($greeting))
+ @if (! empty($greeting))
{{ $greeting }}
@else
@if ($level == 'error') | false |
Other | laravel | framework | 6c915b8ba5505d819c949a4b8fac8009d902876d.json | Fix doc block (#15136) | src/Illuminate/Routing/Router.php | @@ -1119,7 +1119,7 @@ public function currentRouteName()
}
/**
- * Alias for the "currentRouteName" method.
+ * Alias for the "currentRouteNamed" method.
*
* @param mixed string
* @return bool | false |
Other | laravel | framework | 0066b5da6f009275348ab71904da2376c6c47281.json | add methods to contract | src/Illuminate/Contracts/Notifications/Factory.php | @@ -11,4 +11,22 @@ interface Factory
* @return mixed
*/
public function channel($name = null);
+
+ /**
+ * Send the given notification to the given notifiable entities.
+ *
+ * @param \Illuminate\Support\Collection|array|mixed $notifiables
+ * @param mixed $notification
+ * @return void
+ */
+ public function send($notifiables, $notification);
+
+ /**
+ * Send the given notification immediately.
+ *
+ * @param \Illuminate\Support\Collection|array|mixed $notifiables
+ * @param mixed $notification
+ * @return void
+ */
+ public function sendNow($notifiables, $notification);
} | false |
Other | laravel | framework | 4046a8165a259f4608179fcee4f977b138e68b4e.json | remove long comment | src/Illuminate/Database/Eloquent/Builder.php | @@ -389,7 +389,7 @@ public function chunk($count, callable $callback)
* @param int $count
* @param callable $callback
* @param string $column
- * @param string $alias Alias of the ID column if there are multiple columns with the same name. The alias must be defined in a select statement.
+ * @param string $alias
* @return bool
*/
public function chunkById($count, callable $callback, $column = null, $alias = null) | false |
Other | laravel | framework | a208d72f60f829a598bed6a94c89beee9d35b358.json | bind resource path | src/Illuminate/Foundation/Application.php | @@ -277,12 +277,12 @@ protected function bindPathsInContainer()
{
$this->instance('path', $this->path());
$this->instance('path.base', $this->basePath());
- $this->instance('path.resources', $this->resourcesPath());
$this->instance('path.lang', $this->langPath());
$this->instance('path.config', $this->configPath());
$this->instance('path.public', $this->publicPath());
$this->instance('path.storage', $this->storagePath());
$this->instance('path.database', $this->databasePath());
+ $this->instance('path.resources', $this->resourcePath());
$this->instance('path.bootstrap', $this->bootstrapPath());
}
@@ -351,24 +351,14 @@ public function useDatabasePath($path)
return $this;
}
- /**
- * Get the path to the resources folder.
- *
- * @return string
- */
- public function resourcesPath()
- {
- return $this->basePath.DIRECTORY_SEPARATOR.'resources';
- }
-
/**
* Get the path to the language files.
*
* @return string
*/
public function langPath()
{
- return $this->resourcesPath().DIRECTORY_SEPARATOR.'lang';
+ return $this->resourcePath().DIRECTORY_SEPARATOR.'lang';
}
/**
@@ -406,6 +396,16 @@ public function useStoragePath($path)
return $this;
}
+ /**
+ * Get the path to the resources directory.
+ *
+ * @return string
+ */
+ public function resourcePath()
+ {
+ return $this->basePath.DIRECTORY_SEPARATOR.'resources';
+ }
+
/**
* Get the path to the environment file directory.
* | false |
Other | laravel | framework | f3730e6872ed95d14b89f6e1801cce0aa209f210.json | Adjust password reset notification (#15092) | src/Illuminate/Auth/Notifications/ResetPassword.php | @@ -44,10 +44,7 @@ public function via($notifiable)
public function toMail()
{
return (new MailMessage)
- ->line([
- 'You are receiving this email because we received a password reset request for your account.',
- 'Click the button below to reset your password:',
- ])
+ ->line('You are receiving this email because we received a password reset request for your account.')
->action('Reset Password', url('password/reset', $this->token))
->line('If you did not request a password reset, no further action is required.');
} | false |
Other | laravel | framework | 5c515a8adce4ab2fea0a8b105191f9ccc49cdb66.json | Add extra space | src/Illuminate/Notifications/resources/views/email-plain.blade.php | @@ -1,5 +1,5 @@
<?php
-if( $greeting !== null ) {
+if ( $greeting !== null ) {
echo e($greeting);
} else {
echo $level == 'error' ? 'Whoops!' : 'Hello!'; | false |
Other | laravel | framework | 8da2c77e926b49423a30b7ccf9003d1afe0d4316.json | Replace tabs with spaces | src/Illuminate/Notifications/resources/views/email-plain.blade.php | @@ -1,8 +1,8 @@
<?php
if( $greeting !== null ) {
- echo e($greeting);
+ echo e($greeting);
} else {
- echo $level == 'error' ? 'Whoops!' : 'Hello!';
+ echo $level == 'error' ? 'Whoops!' : 'Hello!';
}
?> | false |
Other | laravel | framework | 0e193eaa648ae7c7e60eca806551fe9f8627d231.json | Remove nested ternary | src/Illuminate/Notifications/resources/views/email-plain.blade.php | @@ -1,4 +1,11 @@
-{{ ( $greeting !== null ) ? $greeting : ($level == 'error' ? 'Whoops!' : 'Hello!') }}
+<?php
+if( $greeting !== null ) {
+ echo e($greeting);
+} else {
+ echo $level == 'error' ? 'Whoops!' : 'Hello!';
+}
+
+?>
<?php
| false |
Other | laravel | framework | a4090a3ad5af8d87625e013d129c68bd82acaff5.json | Revert new line that casuses styleci failing | src/Illuminate/Notifications/Messages/SimpleMessage.php | @@ -22,7 +22,6 @@ class SimpleMessage
/**
* Greeting at the beginning of the notification.
- *
* If null, a greeting depending on the level will be displayed.
*
* @var string|null | false |
Other | laravel | framework | cef70172b02f20b38281b3360069a951df2baedc.json | Add greeting option to SimpleMessage notification
By default 'Hello!' or 'Whoops!' is displayed as greeting.
You can override this with the `greeting()` method:
```
public function toMail($notifiable)
{
return (new MailMessage)
->greeting("Hi {$notifiable->name},")
->line('The introduction to the notification.')
->action('Notification Action', 'https://laravel.com')
->line('Thank you for using our application!');
}
``` | src/Illuminate/Notifications/Messages/SimpleMessage.php | @@ -20,6 +20,14 @@ class SimpleMessage
*/
public $subject;
+ /**
+ * Greeting at the beginning of the notification.
+ * If null, a greeting depending on the level will be displayed.
+ *
+ * @var string|null
+ */
+ public $greeting = null;
+
/**
* The "intro" lines of the notification.
*
@@ -98,6 +106,19 @@ public function subject($subject)
return $this;
}
+ /**
+ * Set the greeting of the notification.
+ *
+ * @param string $greeting
+ * @return $this
+ */
+ public function greeting($greeting)
+ {
+ $this->greeting = $greeting;
+
+ return $this;
+ }
+
/**
* Add a line of text to the notification.
*
@@ -168,6 +189,7 @@ public function toArray()
return [
'level' => $this->level,
'subject' => $this->subject,
+ 'greeting' => $this->greeting,
'introLines' => $this->introLines,
'outroLines' => $this->outroLines,
'actionText' => $this->actionText, | true |
Other | laravel | framework | cef70172b02f20b38281b3360069a951df2baedc.json | Add greeting option to SimpleMessage notification
By default 'Hello!' or 'Whoops!' is displayed as greeting.
You can override this with the `greeting()` method:
```
public function toMail($notifiable)
{
return (new MailMessage)
->greeting("Hi {$notifiable->name},")
->line('The introduction to the notification.')
->action('Notification Action', 'https://laravel.com')
->line('Thank you for using our application!');
}
``` | src/Illuminate/Notifications/resources/views/email-plain.blade.php | @@ -1,4 +1,4 @@
-{{ $level == 'error' ? 'Whoops!' : 'Hello!' }}
+{{ ( $greeting !== null ) ? $greeting : ($level == 'error' ? 'Whoops!' : 'Hello!') }}
<?php
| true |
Other | laravel | framework | cef70172b02f20b38281b3360069a951df2baedc.json | Add greeting option to SimpleMessage notification
By default 'Hello!' or 'Whoops!' is displayed as greeting.
You can override this with the `greeting()` method:
```
public function toMail($notifiable)
{
return (new MailMessage)
->greeting("Hi {$notifiable->name},")
->line('The introduction to the notification.')
->action('Notification Action', 'https://laravel.com')
->line('Thank you for using our application!');
}
``` | src/Illuminate/Notifications/resources/views/email.blade.php | @@ -84,10 +84,14 @@
<td style="{{ $fontFamily }} {{ $style['email-body_cell'] }}">
<!-- Greeting -->
<h1 style="{{ $style['header-1'] }}">
- @if ($level == 'error')
- Whoops!
+ @if ($greeting !== null)
+ {{ $greeting }}
@else
- Hello!
+ @if ($level == 'error')
+ Whoops!
+ @else
+ Hello!
+ @endif
@endif
</h1>
| true |
Other | laravel | framework | a7870118c1d15813b47479cc7c7b01e36ee1f667.json | Fix serialization mistake | src/Illuminate/Notifications/ChannelManager.php | @@ -59,17 +59,18 @@ public function sendNow($notifiables, $notification)
$original = clone $notification;
foreach ($notifiables as $notifiable) {
- $notification = clone $original;
-
- $notification->id = (string) Uuid::uuid4();
-
+ $notificationId = (string) Uuid::uuid4();
$channels = $notification->via($notifiable);
if (empty($channels)) {
continue;
}
foreach ($channels as $channel) {
+ $notification = clone $original;
+
+ $notification->id = $notificationId;
+
if (! $this->shouldSendNotification($notifiable, $notification, $channel)) {
continue;
} | false |
Other | laravel | framework | e6063d7df79aa6bbc3829dcc0b3907fe8b49201c.json | Support custom `to` address on `MailMessage` | src/Illuminate/Notifications/Channels/MailChannel.php | @@ -42,7 +42,7 @@ public function send($notifiable, Notification $notification)
$message = $notification->toMail($notifiable);
$this->mailer->send($message->view, $message->data(), function ($m) use ($notifiable, $notification, $message) {
- $recipients = $notifiable->routeNotificationFor('mail');
+ $recipients = empty($message->to) ? $notifiable->routeNotificationFor('mail') : $message->to;
if (! empty($message->from)) {
$m->from($message->from[0], isset($message->from[1]) ? $message->from[1] : null); | true |
Other | laravel | framework | e6063d7df79aa6bbc3829dcc0b3907fe8b49201c.json | Support custom `to` address on `MailMessage` | src/Illuminate/Notifications/Messages/MailMessage.php | @@ -28,6 +28,13 @@ class MailMessage extends SimpleMessage
*/
public $from = [];
+ /**
+ * The recipient information for the message.
+ *
+ * @var array
+ */
+ public $to = [];
+
/**
* The attachments for the message.
*
@@ -71,6 +78,19 @@ public function from($address, $name = null)
return $this;
}
+ /**
+ * Set the recipient address for the mail message.
+ *
+ * @param string|array $address
+ * @return $this
+ */
+ public function to($address)
+ {
+ $this->to = $address;
+
+ return $this;
+ }
+
/**
* Attach a file to the message.
* | true |
Other | laravel | framework | e6063d7df79aa6bbc3829dcc0b3907fe8b49201c.json | Support custom `to` address on `MailMessage` | tests/Notifications/NotificationMailChannelTest.php | @@ -181,6 +181,35 @@ public function testMessageWithFromAddressAndNoName()
$channel->send($notifiable, $notification);
}
+
+ public function testMessageWithToAddress()
+ {
+ $notification = new NotificationMailChannelTestNotificationWithToAddress;
+ $notifiable = new NotificationMailChannelTestNotifiable;
+
+ $message = $notification->toMail($notifiable);
+ $data = $message->toArray();
+
+ $channel = new Illuminate\Notifications\Channels\MailChannel(
+ $mailer = Mockery::mock(Illuminate\Contracts\Mail\Mailer::class)
+ );
+
+ $views = ['notifications::email', 'notifications::email-plain'];
+
+ $mailer->shouldReceive('send')->with($views, $data, Mockery::on(function ($closure) {
+ $mock = Mockery::mock('Illuminate\Mailer\Message');
+
+ $mock->shouldReceive('subject')->once();
+
+ $mock->shouldReceive('to')->once()->with('jeffrey@laracasts.com');
+
+ $closure($mock);
+
+ return true;
+ }));
+
+ $channel->send($notifiable, $notification);
+ }
}
class NotificationMailChannelTestNotifiable
@@ -234,3 +263,12 @@ public function toMail($notifiable)
->from('test@mail.com');
}
}
+
+class NotificationMailChannelTestNotificationWithToAddress extends Notification
+{
+ public function toMail($notifiable)
+ {
+ return (new MailMessage)
+ ->to('jeffrey@laracasts.com');
+ }
+} | true |
Other | laravel | framework | abd85c916df0cc0a6dc55de943a39db8b7eb4e0d.json | fix route list and kernel | src/Illuminate/Foundation/Console/RouteListCommand.php | @@ -181,9 +181,13 @@ protected function getControllerMiddlewareFromInstance($controller, $method)
$results = [];
- foreach ($controller->getMiddleware() as $name => $options) {
- if (! $method || ! $this->methodExcludedByOptions($method, $options)) {
- $results[] = Arr::get($middleware, $name, $name);
+ foreach ($controller->getMiddleware() as $data) {
+ if (! is_string($data['middleware'])) {
+ continue;
+ }
+
+ if (! $method || ! $this->methodExcludedByOptions($method, $data['options'])) {
+ $results[] = Arr::get($middleware, $data['middleware'], $data['middleware']);
}
}
| true |
Other | laravel | framework | abd85c916df0cc0a6dc55de943a39db8b7eb4e0d.json | fix route list and kernel | src/Illuminate/Foundation/Http/Kernel.php | @@ -164,6 +164,10 @@ public function terminate($request, $response)
);
foreach ($middlewares as $middleware) {
+ if (! is_string($middleware)) {
+ continue;
+ }
+
list($name, $parameters) = $this->parseMiddleware($middleware);
$instance = $this->app->make($name); | true |
Other | laravel | framework | abd85c916df0cc0a6dc55de943a39db8b7eb4e0d.json | fix route list and kernel | src/Illuminate/Routing/Controller.php | @@ -17,15 +17,15 @@ abstract class Controller
/**
* Register middleware on the controller.
*
- * @param array|string|\Closure $middlewares
+ * @param array|string|\Closure $middleware
* @param array $options
* @return \Illuminate\Routing\ControllerMiddlewareOptions
*/
- public function middleware($middlewares, array $options = [])
+ public function middleware($middleware, array $options = [])
{
- foreach ((array) $middlewares as $middleware) {
+ foreach ((array) $middleware as $m) {
$this->middleware[] = [
- 'middleware' => $middleware,
+ 'middleware' => $m,
'options' => &$options,
];
} | true |
Other | laravel | framework | abd85c916df0cc0a6dc55de943a39db8b7eb4e0d.json | fix route list and kernel | src/Illuminate/Routing/Router.php | @@ -676,11 +676,13 @@ public function resolveMiddlewareClassName($name)
return $name;
} elseif (isset($map[$name]) && $map[$name] instanceof Closure) {
return $map[$name];
+
// If the middleware is the name of a middleware group, we will return the array
// of middlewares that belong to the group. This allows developers to group a
// set of middleware under single keys that can be conveniently referenced.
} elseif (isset($this->middlewareGroups[$name])) {
return $this->parseMiddlewareGroup($name);
+
// Finally, when the middleware is simply a string mapped to a class name the
// middleware name will get parsed into the full class name and parameters
// which may be run using the Pipeline which accepts this string format. | true |
Other | laravel | framework | fcef04958f22fdf8009486ae6b883572f21cf37a.json | Allow direct closure middleware | src/Illuminate/Routing/Router.php | @@ -669,16 +669,18 @@ public function resolveMiddlewareClassName($name)
{
$map = $this->middleware;
- // If the middleware is the name of a middleware group, we will return the array
- // of middlewares that belong to the group. This allows developers to group a
- // set of middleware under single keys that can be conveniently referenced.
- if (isset($this->middlewareGroups[$name])) {
- return $this->parseMiddlewareGroup($name);
// When the middleware is simply a Closure, we will return this Closure instance
// directly so that Closures can be registered as middleware inline, which is
// convenient on occasions when the developers are experimenting with them.
+ if ($name instanceof Closure) {
+ return $name;
} elseif (isset($map[$name]) && $map[$name] instanceof Closure) {
return $map[$name];
+ // If the middleware is the name of a middleware group, we will return the array
+ // of middlewares that belong to the group. This allows developers to group a
+ // set of middleware under single keys that can be conveniently referenced.
+ } elseif (isset($this->middlewareGroups[$name])) {
+ return $this->parseMiddlewareGroup($name);
// Finally, when the middleware is simply a string mapped to a class name the
// middleware name will get parsed into the full class name and parameters
// which may be run using the Pipeline which accepts this string format. | true |
Other | laravel | framework | fcef04958f22fdf8009486ae6b883572f21cf37a.json | Allow direct closure middleware | tests/Routing/RoutingRouteTest.php | @@ -146,6 +146,18 @@ public function testBasicDispatchingOfRoutes()
}
public function testClosureMiddleware()
+ {
+ $router = $this->getRouter();
+ $middleware = function ($request, $next) {
+ return 'caught';
+ };
+ $router->get('foo/bar', ['middleware' => $middleware, function () {
+ return 'hello';
+ }]);
+ $this->assertEquals('caught', $router->dispatch(Request::create('foo/bar', 'GET'))->getContent());
+ }
+
+ public function testDefinedClosureMiddleware()
{
$router = $this->getRouter();
$router->get('foo/bar', ['middleware' => 'foo', function () { | true |
Other | laravel | framework | ae450475b44d145f5b72fe884d26e250607b37a4.json | replace redis to contracts interface (#15041) | src/Illuminate/Cache/RedisStore.php | @@ -3,7 +3,7 @@
namespace Illuminate\Cache;
use Illuminate\Contracts\Cache\Store;
-use Illuminate\Redis\Database as Redis;
+use Illuminate\Contracts\Redis\Database as Redis;
class RedisStore extends TaggableStore implements Store
{ | false |
Other | laravel | framework | 5a96ac2a1acb642d7ec9e4e0ab33000772c6718e.json | fix failing test (#15015) | tests/Support/SupportArrTest.php | @@ -215,8 +215,6 @@ public function testHas()
{
$array = ['products.desk' => ['price' => 100]];
$this->assertTrue(Arr::has($array, 'products.desk'));
- $this->assertTrue(Arr::has($array, ['products.desk']));
- $this->assertFalse(Arr::has($array, ['products.desk', 'missing']));
$array = ['products' => ['desk' => ['price' => 100]]];
$this->assertTrue(Arr::has($array, 'products.desk')); | false |
Other | laravel | framework | 65927fc67b27ddf861ffebdbadc7f87ea48cf934.json | Update BladeCompiler.php (#14986) | src/Illuminate/View/Compilers/BladeCompiler.php | @@ -930,7 +930,7 @@ protected function compileEndpush($expression)
* @param string $expression
* @return string
*/
- protected function stripParentheses($expression)
+ public function stripParentheses($expression)
{
if (Str::startsWith($expression, '(')) {
$expression = substr($expression, 1, -1); | false |
Other | laravel | framework | 33f7e420604645831741412b52c8412139f4a3ef.json | Update AuthorizesRequests.php (#14939)
Edited the comment to clarify the authorize method is for the current user. | src/Illuminate/Foundation/Auth/Access/AuthorizesRequests.php | @@ -7,7 +7,7 @@
trait AuthorizesRequests
{
/**
- * Authorize a given action against a set of arguments.
+ * Authorize a given action against a set of arguments for the current user.
*
* @param mixed $ability
* @param mixed|array $arguments | false |
Other | laravel | framework | 01408ab085348f1f7c09df50c9c67b3c27c3d236.json | Remove unnecessary "else" conditions (#14944) | src/Illuminate/Auth/AuthManager.php | @@ -88,15 +88,15 @@ protected function resolve($name)
if (isset($this->customCreators[$config['driver']])) {
return $this->callCustomCreator($name, $config);
- } else {
- $driverMethod = 'create'.ucfirst($config['driver']).'Driver';
-
- if (method_exists($this, $driverMethod)) {
- return $this->{$driverMethod}($name, $config);
- } else {
- throw new InvalidArgumentException("Auth guard driver [{$name}] is not defined.");
- }
}
+
+ $driverMethod = 'create'.ucfirst($config['driver']).'Driver';
+
+ if (method_exists($this, $driverMethod)) {
+ return $this->{$driverMethod}($name, $config);
+ }
+
+ throw new InvalidArgumentException("Auth guard driver [{$name}] is not defined.");
}
/** | false |
Other | laravel | framework | ddbe239f92be1a344142914d397c75eff604a275.json | Allow failures for PHP 7.1 | .travis.yml | @@ -30,3 +30,8 @@ install:
- if [[ $setup = 'lowest' ]]; then travis_retry composer update --prefer-source --no-interaction --prefer-lowest --prefer-stable; fi
script: vendor/bin/phpunit
+
+matrix:
+ allow_failures:
+ - php: 7.1
+ fast_finish: true | false |
Other | laravel | framework | 99cf673faea7ed8c18f534596685492b4fb615e0.json | add file class | src/Illuminate/Filesystem/FilesystemAdapter.php | @@ -3,6 +3,7 @@
namespace Illuminate\Filesystem;
use RuntimeException;
+use Illuminate\Http\File;
use Illuminate\Support\Str;
use InvalidArgumentException;
use Illuminate\Http\UploadedFile;
@@ -74,7 +75,7 @@ public function get($path)
*/
public function put($path, $contents, $visibility = null)
{
- if ($contents instanceof UploadedFile) {
+ if ($contents instanceof File || $contents instanceof UploadedFile) {
return $this->putFile($path, $contents, $visibility);
}
@@ -108,14 +109,14 @@ public function putFile($path, $file, $visibility = null)
* Store the uploaded file on the disk with a given name.
*
* @param string $path
- * @param \Illuminate\Http\UploadedFile $file
+ * @param \Illuminate\Http\File|\Illuminate\Http\UploadedFile $file
* @param string $name
* @param string $visibility
* @return string|false
*/
public function putFileAs($path, $file, $name, $visibility = null)
{
- $stream = fopen($file->path(), 'r+');
+ $stream = fopen($file->getRealPath(), 'r+');
$result = $this->put($path = trim($path.'/'.$name, '/'), $stream, $visibility);
| true |
Other | laravel | framework | 99cf673faea7ed8c18f534596685492b4fb615e0.json | add file class | src/Illuminate/Http/File.php | @@ -0,0 +1,10 @@
+<?php
+
+namespace Illuminate\Http;
+
+use Symfony\Component\HttpFoundation\File\File as SymfonyFile;
+
+class File extends SymfonyFile
+{
+ use HashesFileNames;
+} | true |
Other | laravel | framework | 99cf673faea7ed8c18f534596685492b4fb615e0.json | add file class | src/Illuminate/Http/HashesFileNames.php | @@ -0,0 +1,21 @@
+<?php
+
+namespace Illuminate\Http;
+
+trait HashesFileNames
+{
+ /**
+ * Get a filename for the file that is the MD5 hash of the contents.
+ *
+ * @param string $path
+ * @return string
+ */
+ public function hashName($path = null)
+ {
+ if ($path) {
+ $path = rtrim($path, '/').'/';
+ }
+
+ return $path.md5_file($this->getRealPath()).'.'.$this->guessExtension();
+ }
+} | true |
Other | laravel | framework | 99cf673faea7ed8c18f534596685492b4fb615e0.json | add file class | src/Illuminate/Http/UploadedFile.php | @@ -9,7 +9,7 @@
class UploadedFile extends SymfonyUploadedFile
{
- use Macroable;
+ use HashesFileNames, Macroable;
/**
* Get the fully qualified path to the file.
@@ -41,21 +41,6 @@ public function clientExtension()
return $this->guessClientExtension();
}
- /**
- * Get a filename for the file that is the MD5 hash of the contents.
- *
- * @param string $path
- * @return string
- */
- public function hashName($path = null)
- {
- if ($path) {
- $path = rtrim($path, '/').'/';
- }
-
- return $path.md5_file($this->path()).'.'.$this->extension();
- }
-
/**
* Store the uploaded file on a filesystem disk.
* | true |
Other | laravel | framework | 71040ec51e58d96f521ab5d5ccf600ea3c4305be.json | Make getTokenForRequest public (#14927)
When calling Auth::guard('api')->user() and receiving null it is not possible to differentiate between guest access and an invalid token. In the case of an invalid token it would be preferable to ask the user to login again and receive a new token rather than assume they are a guest. By making the getTokenForRequest method public that is now possible. | src/Illuminate/Auth/TokenGuard.php | @@ -78,7 +78,7 @@ public function user()
*
* @return string
*/
- protected function getTokenForRequest()
+ public function getTokenForRequest()
{
$token = $this->request->input($this->inputKey);
| false |
Other | laravel | framework | 64b2015f3156ad67fbd4b006efc3b629ec41b989.json | revert recent changes to key generate. | src/Illuminate/Foundation/Console/KeyGenerateCommand.php | @@ -51,11 +51,11 @@ public function fire()
*/
protected function setKeyInEnvironmentFile($key)
{
- $originalEnvContent = file_get_contents($this->laravel->environmentFilePath());
-
- $newEnvContent = preg_replace('/APP_KEY="?[^\'"\s]+"?/', "APP_KEY=\"$key\"", $originalEnvContent);
-
- file_put_contents($this->laravel->environmentFilePath(), $newEnvContent);
+ file_put_contents($this->laravel->environmentFilePath(), str_replace(
+ 'APP_KEY='.$this->laravel['config']['app.key'],
+ 'APP_KEY='.$key,
+ file_get_contents($this->laravel->environmentFilePath())
+ ));
}
/** | false |
Other | laravel | framework | 9d0487bd04b8799cb7da3898b1277d6ac32969dc.json | Remove empty class content. | tests/Bus/BusDispatcherTest.php | @@ -113,7 +113,6 @@ class BusDispatcherTestSpecificQueueAndDelayCommand implements Illuminate\Contra
class StandAloneCommand
{
-
}
class StandAloneHandler | false |
Other | laravel | framework | 73944943476aef81a7c98b9d0615d551cf8226ba.json | Return command from test stub. | tests/Bus/BusDispatcherTest.php | @@ -74,7 +74,7 @@ public function testDispatcherCanDispatchStandAloneHandler()
$response = $dispatcher->dispatch(new StandAloneCommand);
- $this->assertEquals('stone-alone-handler', $response);
+ $this->assertInstanceOf(StandAloneCommand::class, $response);
}
}
@@ -118,8 +118,8 @@ class StandAloneCommand
class StandAloneHandler
{
- public function handle()
+ public function handle(StandAloneCommand $command)
{
- return 'stone-alone-handler';
+ return $command;
}
} | false |
Other | laravel | framework | 6e77be515a1830ebcae9dce5a504e2b74a089dad.json | bind only true ints as ints | src/Illuminate/Database/Connection.php | @@ -407,7 +407,7 @@ public function bindValues($statement, $bindings)
foreach ($bindings as $key => $value) {
$statement->bindValue(
is_string($key) ? $key : $key + 1, $value,
- filter_var($value, FILTER_VALIDATE_INT) !== false ? PDO::PARAM_INT : PDO::PARAM_STR
+ is_int($value) ? PDO::PARAM_INT : PDO::PARAM_STR
);
}
} | false |
Other | laravel | framework | deeada07e03dc5a48b6d8c0cc7f493d58599d002.json | Create NotificationFailed event (#14874) | src/Illuminate/Notifications/Events/NotificationFailed.php | @@ -0,0 +1,51 @@
+<?php
+
+namespace Illuminate\Notifications\Events;
+
+class NotificationFailed
+{
+ /**
+ * The notifiable entity who received the notification.
+ *
+ * @var mixed
+ */
+ public $notifiable;
+
+ /**
+ * The notification instance.
+ *
+ * @var \Illuminate\Notifications\Notification
+ */
+ public $notification;
+
+ /**
+ * The channel name.
+ *
+ * @var string
+ */
+ public $channel;
+
+ /**
+ * The data needed to process this failure.
+ *
+ * @var array
+ */
+ public $data = [];
+
+ /**
+ * Create a new event instance.
+ *
+ * @param mixed $notifiable
+ * @param \Illuminate\Notifications\Notification $notification
+ * @param string $channel
+ * @param array $data
+ * @return void
+ */
+ public function __construct($notifiable, $notification, $channel, $data = [])
+ {
+ $this->channel = $channel;
+ $this->notifiable = $notifiable;
+ $this->notification = $notification;
+ $this->data = $data;
+ }
+} | false |
Other | laravel | framework | afd9c98dc66661b570e26b65b94d60f061a290db.json | allow the disable_asserts config value (#14864) | src/Illuminate/Filesystem/FilesystemManager.php | @@ -239,7 +239,7 @@ protected function getRackspaceContainer(Rackspace $client, array $config)
*/
protected function createFlysystem(AdapterInterface $adapter, array $config)
{
- $config = Arr::only($config, ['visibility']);
+ $config = Arr::only($config, ['visibility', 'disable_asserts']);
return new Flysystem($adapter, count($config) > 0 ? $config : null);
} | false |
Other | laravel | framework | a4247f0c6c0c9c866109bb76ca255f5cf7503f06.json | fix queued mailables | src/Illuminate/Mail/MailableMailer.php | @@ -93,7 +93,7 @@ public function bcc($users)
public function send(Mailable $mailable)
{
if ($mailable instanceof ShouldQueue) {
- return $this->queue($this->fill($mailable));
+ return $this->queue($mailable);
}
return $this->mailer->send($this->fill($mailable));
@@ -110,19 +110,6 @@ public function sendNow(Mailable $mailable)
return $this->mailer->send($this->fill($mailable));
}
- /**
- * Populate the mailable with the addresses.
- *
- * @param Mailable $mailable
- * @return Mailable
- */
- protected function fill(Mailable $mailable)
- {
- return $mailable->to($this->to)
- ->cc($this->cc)
- ->bcc($this->bcc);
- }
-
/**
* Push the given mailable onto the queue.
*
@@ -131,10 +118,25 @@ protected function fill(Mailable $mailable)
*/
public function queue(Mailable $mailable)
{
+ $mailable = $this->fill($mailable);
+
if (isset($mailable->delay)) {
return $this->mailer->later($mailable->delay, $mailable);
}
return $this->mailer->queue($mailable);
}
+
+ /**
+ * Populate the mailable with the addresses.
+ *
+ * @param Mailable $mailable
+ * @return Mailable
+ */
+ protected function fill(Mailable $mailable)
+ {
+ return $mailable->to($this->to)
+ ->cc($this->cc)
+ ->bcc($this->bcc);
+ }
} | false |
Other | laravel | framework | ab9686ae58f1e89bae4e31fcb70bacc0ab546eb6.json | allow returning array when routing mail | src/Illuminate/Notifications/Channels/MailChannel.php | @@ -42,7 +42,13 @@ public function send($notifiable, Notification $notification)
$message = $notification->toMail($notifiable);
$this->mailer->send($message->view, $message->toArray(), function ($m) use ($notifiable, $notification, $message) {
- $m->to($notifiable->routeNotificationFor('mail'));
+ $recipients = $notifiable->routeNotificationFor('mail');
+
+ if (is_array($recipients)) {
+ $m->bcc($recipients);
+ } else {
+ $m->to($recipients);
+ }
$m->subject($message->subject ?: Str::title(
Str::snake(class_basename($notification), ' ') | false |
Other | laravel | framework | ba60590aa0e62a1c0ee271c0008d73d127cc4feb.json | ignore missing methods | src/Illuminate/Support/Facades/Facade.php | @@ -90,6 +90,8 @@ protected static function createFreshMockInstance($name)
$mock->shouldAllowMockingProtectedMethods();
+ $mock->shouldIgnoreMissing();
+
if (isset(static::$app)) {
static::$app->instance($name, $mock);
} | false |
Other | laravel | framework | 180656fba314b28976ba06b44b1d9f03eea3d1dc.json | Add the great macroable to Lang (#14844) | src/Illuminate/Translation/Translator.php | @@ -5,12 +5,15 @@
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
use Illuminate\Support\Collection;
+use Illuminate\Support\Traits\Macroable;
use Illuminate\Support\NamespacedItemResolver;
use Symfony\Component\Translation\MessageSelector;
use Symfony\Component\Translation\TranslatorInterface;
class Translator extends NamespacedItemResolver implements TranslatorInterface
{
+ use Macroable;
+
/**
* The loader implementation.
* | false |
Other | laravel | framework | cd0939d35b68db2e0661efac53a7ca3b932430a8.json | fix method order | src/Illuminate/Notifications/Events/NotificationSent.php | @@ -35,8 +35,8 @@ class NotificationSent
*/
public function __construct($notifiable, $notification, $channel)
{
+ $this->channel = $channel;
$this->notifiable = $notifiable;
$this->notification = $notification;
- $this->channel = $channel;
}
} | false |
Other | laravel | framework | bbc1ba6c6d1f5f9f925e67071427b2aae21731db.json | change method order | src/Illuminate/Database/Eloquent/SoftDeletingScope.php | @@ -9,7 +9,7 @@ class SoftDeletingScope implements Scope
*
* @var array
*/
- protected $extensions = ['ForceDelete', 'Restore', 'WithTrashed', 'OnlyTrashed', 'WithoutTrashed'];
+ protected $extensions = ['ForceDelete', 'Restore', 'WithTrashed', 'WithoutTrashed', 'OnlyTrashed'];
/**
* Apply the scope to a given Eloquent query builder.
@@ -101,17 +101,17 @@ protected function addWithTrashed(Builder $builder)
}
/**
- * Add the only-trashed extension to the builder.
+ * Add the without-trashed extension to the builder.
*
* @param \Illuminate\Database\Eloquent\Builder $builder
* @return void
*/
- protected function addOnlyTrashed(Builder $builder)
+ protected function addWithoutTrashed(Builder $builder)
{
- $builder->macro('onlyTrashed', function (Builder $builder) {
+ $builder->macro('withoutTrashed', function (Builder $builder) {
$model = $builder->getModel();
- $builder->withoutGlobalScope($this)->whereNotNull(
+ $builder->withoutGlobalScope($this)->whereNull(
$model->getQualifiedDeletedAtColumn()
);
@@ -120,17 +120,17 @@ protected function addOnlyTrashed(Builder $builder)
}
/**
- * Add the without-trashed extension to the builder.
+ * Add the only-trashed extension to the builder.
*
* @param \Illuminate\Database\Eloquent\Builder $builder
* @return void
*/
- protected function addWithoutTrashed(Builder $builder)
+ protected function addOnlyTrashed(Builder $builder)
{
- $builder->macro('withoutTrashed', function (Builder $builder) {
+ $builder->macro('onlyTrashed', function (Builder $builder) {
$model = $builder->getModel();
- $builder->withoutGlobalScope($this)->whereNull(
+ $builder->withoutGlobalScope($this)->whereNotNull(
$model->getQualifiedDeletedAtColumn()
);
| false |
Other | laravel | framework | 33aee31523b9fc280aced35a5eb5f6b627263b45.json | add sync without detaching method | src/Illuminate/Database/Eloquent/Relations/BelongsToMany.php | @@ -795,6 +795,17 @@ public function createMany(array $records, array $joinings = [])
return $instances;
}
+ /**
+ * Sync the intermediate tables with a list of IDs without detaching.
+ *
+ * @param \Illuminate\Database\Eloquent\Collection|array $ids
+ * @return array
+ */
+ public function syncWithoutDetaching($ids)
+ {
+ return $this->sync($ids, false);
+ }
+
/**
* Sync the intermediate tables with a list of IDs or collection of models.
* | false |
Other | laravel | framework | 3c57cf0a0f1962f9da9de8454d11b033226c1c39.json | Remove nitpick (#14821) | .gitattributes | @@ -5,7 +5,6 @@
.editorconfig export-ignore
.gitattributes export-ignore
.gitignore export-ignore
-.nitpick.json export-ignore
.php_cs export-ignore
.travis.yml export-ignore
phpunit.xml.dist export-ignore | true |
Other | laravel | framework | 3c57cf0a0f1962f9da9de8454d11b033226c1c39.json | Remove nitpick (#14821) | .nitpick.json | @@ -1,5 +0,0 @@
-{
- "ignore": [
- "tests/*"
- ]
-} | true |
Other | laravel | framework | f67a06a7a918e94fbd3c9d6f93e66f2ebd58f790.json | Update author email
Update the author email address to taylor@laravel.com instead of gmail. | composer.json | @@ -11,7 +11,7 @@
"authors": [
{
"name": "Taylor Otwell",
- "email": "taylorotwell@gmail.com"
+ "email": "taylor@laravel.com"
}
],
"require": { | false |
Other | laravel | framework | 58736c8d416dc95901f94a24b143d21089df374d.json | Fix export-ignore for phpunit.xml
Export phpunit.xml.dist instead of phpunit.xml. | .gitattributes | @@ -8,6 +8,6 @@
.nitpick.json export-ignore
.php_cs export-ignore
.travis.yml export-ignore
-phpunit.xml export-ignore
+phpunit.xml.dist export-ignore
CHANGELOG.md export-ignore
CONTRIBUTING.md export-ignore | false |
Other | laravel | framework | d0bc401b7384ae4b63adcfdaddbd415c4394e3d3.json | fix queue listen | src/Illuminate/Queue/Listener.php | @@ -74,7 +74,7 @@ protected function buildWorkerCommand()
$artisan = defined('ARTISAN_BINARY') ? ProcessUtils::escapeArgument(ARTISAN_BINARY) : 'artisan';
- $command = 'queue:work %s --queue=%s --delay=%s --memory=%s --sleep=%s --tries=%s';
+ $command = 'queue:work %s --once --queue=%s --delay=%s --memory=%s --sleep=%s --tries=%s';
return "{$binary} {$artisan} {$command}";
} | true |
Other | laravel | framework | d0bc401b7384ae4b63adcfdaddbd415c4394e3d3.json | fix queue listen | tests/Queue/QueueListenerTest.php | @@ -39,6 +39,6 @@ public function testMakeProcessCorrectlyFormatsCommandLine()
$this->assertInstanceOf('Symfony\Component\Process\Process', $process);
$this->assertEquals(__DIR__, $process->getWorkingDirectory());
$this->assertEquals(3, $process->getTimeout());
- $this->assertEquals($escape.PHP_BINARY.$escape." artisan queue:work {$escape}connection{$escape} --queue={$escape}queue{$escape} --delay=1 --memory=2 --sleep=3 --tries=0", $process->getCommandLine());
+ $this->assertEquals($escape.PHP_BINARY.$escape." artisan queue:work {$escape}connection{$escape} --once --queue={$escape}queue{$escape} --delay=1 --memory=2 --sleep=3 --tries=0", $process->getCommandLine());
}
} | true |
Other | laravel | framework | 3771406f049e0bb766152b56af1384e0ec6be574.json | Bind numeric string with PDO::PARAM_STR (#14786) | src/Illuminate/Database/Connection.php | @@ -407,7 +407,7 @@ public function bindValues($statement, $bindings)
foreach ($bindings as $key => $value) {
$statement->bindValue(
is_string($key) ? $key : $key + 1, $value,
- filter_var($value, FILTER_VALIDATE_FLOAT) !== false ? PDO::PARAM_INT : PDO::PARAM_STR
+ ! is_string($value) && is_numeric($value) ? PDO::PARAM_INT : PDO::PARAM_STR
);
}
} | false |
Other | laravel | framework | 0dbd340ebb1a909c00c26d09a81fce93c2cfbffd.json | remove unused imports | src/Illuminate/Mail/Mailer.php | @@ -6,8 +6,6 @@
use Swift_Mailer;
use Swift_Message;
use Illuminate\Support\Arr;
-use Illuminate\Support\Str;
-use SuperClosure\Serializer;
use InvalidArgumentException;
use Illuminate\Contracts\View\Factory;
use Illuminate\Contracts\Events\Dispatcher; | false |
Other | laravel | framework | a3a80b44f059fd14627916a762694cd74579937f.json | Fix typo for function_exists (#14766) | src/Illuminate/Queue/Console/WorkCommand.php | @@ -107,7 +107,7 @@ protected function gatherWorkerOptions()
{
$timeout = $this->option('timeout', 60);
- if ($timeout && ! function_exist('pcntl_fork')) {
+ if ($timeout && ! function_exists('pcntl_fork')) {
throw new RuntimeException('The pcntl extension is required in order to specify job timeouts.');
}
| false |
Other | laravel | framework | b7f7a3f5e21733f48c58d2fbcb6512a3a83a453f.json | Make Mailable@with more flexible (#14764) | src/Illuminate/Mail/Mailable.php | @@ -411,12 +411,17 @@ public function text($textView, array $data = [])
/**
* Set the view data for the message.
*
- * @param array $data
+ * @param string|array $key
+ * @param mixed $value
* @return $this
*/
- public function with(array $data)
+ public function with($key, $value = null)
{
- $this->viewData = $data;
+ if (is_array($key)) {
+ $this->viewData = array_merge($this->viewData, $key);
+ } else {
+ $this->viewData[$key] = $value;
+ }
return $this;
} | false |
Other | laravel | framework | 9edd86235328fa805b9ad23eb7f6a61d04562b2e.json | Add missing import at RedisBroadcaster | src/Illuminate/Broadcasting/Broadcasters/RedisBroadcaster.php | @@ -3,6 +3,7 @@
namespace Illuminate\Broadcasting\Broadcasters;
use Illuminate\Support\Arr;
+use Illuminate\Support\Str;
use Illuminate\Contracts\Redis\Database as RedisDatabase;
use Symfony\Component\HttpKernel\Exception\HttpException;
| false |
Other | laravel | framework | 3d74b25c9f5c9c340d9d7a776ad878ce333bca5c.json | fix Action reference (#14746) | src/Illuminate/Notifications/Messages/SimpleMessage.php | @@ -2,6 +2,8 @@
namespace Illuminate\Notifications\Messages;
+use Illuminate\Notifications\Action;
+
class SimpleMessage
{
/** | false |
Other | laravel | framework | f6715f4f7514c2bba44c9f80dc452fef078f19de.json | Allow usage of the worker without pcntl | src/Illuminate/Queue/Console/WorkCommand.php | @@ -3,6 +3,7 @@
namespace Illuminate\Queue\Console;
use Carbon\Carbon;
+use RuntimeException;
use Illuminate\Queue\Worker;
use Illuminate\Console\Command;
use Illuminate\Queue\WorkerOptions;
@@ -104,9 +105,15 @@ protected function runWorker($connection, $queue)
*/
protected function gatherWorkerOptions()
{
+ $timeout = $this->option('timeout', 60);
+
+ if ($timeout && ! function_exist('pcntl_fork')) {
+ throw new RuntimeException('Timeouts not supported without the pcntl_fork extension.');
+ }
+
return new WorkerOptions(
$this->option('delay'), $this->option('memory'),
- $this->option('timeout', 60), $this->option('sleep'),
+ $timeout, $this->option('sleep'),
$this->option('tries')
);
} | true |
Other | laravel | framework | f6715f4f7514c2bba44c9f80dc452fef078f19de.json | Allow usage of the worker without pcntl | src/Illuminate/Queue/Worker.php | @@ -103,7 +103,9 @@ protected function daemonShouldRun()
*/
protected function runNextJobForDaemon($connectionName, $queue, WorkerOptions $options)
{
- if ($processId = pcntl_fork()) {
+ if (! $options->timeout) {
+ $this->runNextJob($connectionName, $queue, $options);
+ } elseif ($processId = pcntl_fork()) {
$this->waitForChildProcess($processId, $options->timeout);
} else {
$this->runNextJob($connectionName, $queue, $options); | true |
Other | laravel | framework | bf6b364c6568893e888d1064a6fccef3e6f91ec2.json | send notification type | src/Illuminate/Notifications/Events/BroadcastNotificationCreated.php | @@ -64,7 +64,10 @@ public function broadcastOn()
*/
public function broadcastWith()
{
- return array_merge($this->data, ['id' => $this->notification->id]);
+ return array_merge($this->data, [
+ 'id' => $this->notification->id,
+ 'type' => get_class($this->notification),
+ ]);
}
/** | false |
Other | laravel | framework | f493e7a0878c9145b9dda1c8854732c80d84eacc.json | Remove undefined parameters from docblocks | src/Illuminate/Contracts/Bus/Dispatcher.php | @@ -8,7 +8,6 @@ interface Dispatcher
* Dispatch a command to its appropriate handler.
*
* @param mixed $command
- * @param \Closure|null $afterResolving
* @return mixed
*/
public function dispatch($command);
@@ -17,7 +16,6 @@ public function dispatch($command);
* Dispatch a command to its appropriate handler in the current process.
*
* @param mixed $command
- * @param \Closure|null $afterResolving
* @return mixed
*/
public function dispatchNow($command); | false |
Other | laravel | framework | 1e4f5b8af243fb95230b39f49a6cf5341d975df9.json | Return new exception | src/Illuminate/Database/Eloquent/RelationNotFoundException.php | @@ -17,6 +17,6 @@ public static function make($model, $relation)
{
$class = get_class($model);
- throw new static("Call to undefined relationship [{$relation}] on model [{$class}].");
+ return new static("Call to undefined relationship [{$relation}] on model [{$class}].");
}
} | false |
Other | laravel | framework | e417a9480220f6cb958747bd922a94b4736698a0.json | Apply patch from StyleCI | tests/Validation/ValidationValidatorTest.php | @@ -249,7 +249,7 @@ public function testDisplayableValuesAreReplaced()
$trans->addResource('array', ['validation.in' => ':attribute must be included in :values.'], 'en', 'messages');
$customValues = [
'type' => [
- '5' => 'Short',
+ '5' => 'Short',
'300' => 'Long',
],
];
@@ -264,7 +264,7 @@ public function testDisplayableValuesAreReplaced()
$trans->addResource('array', ['validation.in' => ':attribute must be included in :values.'], 'en', 'messages');
$customValues = [
'type' => [
- '5' => 'Short',
+ '5' => 'Short',
'300' => 'Long',
],
];
@@ -2938,27 +2938,27 @@ public function testInvalidMethod()
[
['name' => 'John'],
['name' => null],
- ['name' => '']
+ ['name' => ''],
],
[
'*.name' => 'required',
]);
$this->assertEquals($v->invalid(), [
1 => ['name' => null],
- 2 => ['name' => '']
+ 2 => ['name' => ''],
]);
$v = new Validator($trans,
[
- 'name' => ''
+ 'name' => '',
],
[
'name' => 'required',
]);
$this->assertEquals($v->invalid(), [
- 'name' => ''
+ 'name' => '',
]);
}
@@ -2971,32 +2971,32 @@ public function testValidMethod()
['name' => 'John'],
['name' => null],
['name' => ''],
- ['name' => 'Doe']
+ ['name' => 'Doe'],
],
[
'*.name' => 'required',
]);
$this->assertEquals($v->valid(), [
0 => ['name' => 'John'],
- 3 => ['name' => 'Doe']
+ 3 => ['name' => 'Doe'],
]);
$v = new Validator($trans,
[
'name' => 'Carlos',
'age' => 'unknown',
- 'gender' => 'male'
+ 'gender' => 'male',
],
[
'name' => 'required',
'gernder' => 'in:male,female',
- 'age' => 'required|int'
+ 'age' => 'required|int',
]);
$this->assertEquals($v->valid(), [
'name' => 'Carlos',
- 'gender' => 'male'
+ 'gender' => 'male',
]);
}
| false |
Other | laravel | framework | 45d6abfe9926aca8610fd65518974a0ceab33716.json | fix bugs in code | src/Illuminate/Database/Eloquent/Model.php | @@ -2150,9 +2150,7 @@ public function makeHidden($attributes)
{
$this->visible = array_diff($this->visible, (array) $attributes);
- if (! empty($this->hidden)) {
- $this->addHidden($attributes);
- }
+ $this->hidden = array_unique(array_merge($this->hidden, $attributes));
return $this;
}
@@ -2612,10 +2610,14 @@ protected function getArrayableRelations()
protected function getArrayableItems(array $values)
{
if (count($this->getVisible()) > 0) {
- return array_intersect_key($values, array_flip($this->getVisible()));
+ $values = array_intersect_key($values, array_flip($this->getVisible()));
+ }
+
+ if (count($this->getHidden()) > 0) {
+ $values = array_diff_key($values, array_flip($this->getHidden()));
}
- return array_diff_key($values, array_flip($this->getHidden()));
+ return $values;
}
/** | true |
Other | laravel | framework | 45d6abfe9926aca8610fd65518974a0ceab33716.json | fix bugs in code | tests/Database/DatabaseEloquentModelTest.php | @@ -698,17 +698,6 @@ public function testVisible()
$this->assertArrayNotHasKey('age', $array);
}
- public function testHiddenAreIgnoringWhenVisibleExists()
- {
- $model = new EloquentModelStub(['name' => 'foo', 'age' => 'bar', 'id' => 'baz']);
- $model->setVisible(['name', 'id']);
- $model->setHidden(['name', 'age']);
- $array = $model->toArray();
- $this->assertArrayHasKey('name', $array);
- $this->assertArrayHasKey('id', $array);
- $this->assertArrayNotHasKey('age', $array);
- }
-
public function testDynamicHidden()
{
$model = new EloquentModelDynamicHiddenStub(['name' => 'foo', 'age' => 'bar', 'id' => 'baz']);
@@ -728,6 +717,20 @@ public function testWithHidden()
$this->assertArrayNotHasKey('id', $array);
}
+ public function testMakeHidden()
+ {
+ $model = new EloquentModelStub(['name' => 'foo', 'age' => 'bar', 'id' => 'baz']);
+ $array = $model->toArray();
+ $this->assertArrayHasKey('name', $array);
+ $this->assertArrayHasKey('age', $array);
+ $this->assertArrayHasKey('id', $array);
+
+ $array = $model->makeHidden(['name', 'age'])->toArray();
+ $this->assertArrayNotHasKey('name', $array);
+ $this->assertArrayNotHasKey('age', $array);
+ $this->assertArrayHasKey('id', $array);
+ }
+
public function testDynamicVisible()
{
$model = new EloquentModelDynamicVisibleStub(['name' => 'foo', 'age' => 'bar', 'id' => 'baz']); | true |
Other | laravel | framework | 3e576e399875a2d2e897334647b8e40fcf34bcd0.json | Use proper assertions (#14672) | tests/Database/DatabaseQueryBuilderTest.php | @@ -1200,7 +1200,7 @@ public function testUpdateOrInsertMethod()
$builder->shouldReceive('exists')->once()->andReturn(false);
$builder->shouldReceive('insert')->once()->with(['email' => 'foo', 'name' => 'bar'])->andReturn(true);
- $this->assertEquals(true, $builder->updateOrInsert(['email' => 'foo'], ['name' => 'bar']));
+ $this->assertTrue($builder->updateOrInsert(['email' => 'foo'], ['name' => 'bar']));
$builder = m::mock('Illuminate\Database\Query\Builder[where,exists,update]', [
m::mock('Illuminate\Database\ConnectionInterface'),
@@ -1213,7 +1213,7 @@ public function testUpdateOrInsertMethod()
$builder->shouldReceive('take')->andReturnSelf();
$builder->shouldReceive('update')->once()->with(['name' => 'bar'])->andReturn(1);
- $this->assertEquals(true, $builder->updateOrInsert(['email' => 'foo'], ['name' => 'bar']));
+ $this->assertTrue($builder->updateOrInsert(['email' => 'foo'], ['name' => 'bar']));
}
public function testDeleteMethod() | false |
Other | laravel | framework | a1a50bd612c71338fb9be6da8445e2ba6838a5b6.json | use message object | src/Illuminate/Foundation/Console/stubs/notification.stub | @@ -34,12 +34,12 @@ class DummyClass extends Notification
/**
* Get the notification message.
*
- * @return void
+ * @return \Illuminate\Notifications\Message
*/
- public function message()
+ public function message($notifiable)
{
- $this->line('The introduction to the notification.')
- ->action('Notification Action', 'https://laravel.com')
- ->line('Thank you for using our application!');
+ return $this->line('The introduction to the notification.')
+ ->action('Notification Action', 'https://laravel.com')
+ ->line('Thank you for using our application!');
}
} | true |
Other | laravel | framework | a1a50bd612c71338fb9be6da8445e2ba6838a5b6.json | use message object | src/Illuminate/Notifications/ChannelManager.php | @@ -46,8 +46,6 @@ public function send($notifiables, $notification)
*/
public function sendNow($notifiables, $notification)
{
- $notification->message();
-
if (! $notification->application) {
$notification->application(
$this->app['config']['app.name'], | true |
Other | laravel | framework | a1a50bd612c71338fb9be6da8445e2ba6838a5b6.json | use message object | src/Illuminate/Notifications/Channels/DatabaseChannel.php | @@ -29,13 +29,15 @@ public function send($notifiables, Notification $notification)
*/
protected function createNotification($notifiable, Notification $notification)
{
+ $message = $notification->message($notifiable);
+
return $notifiable->routeNotificationFor('database')->create([
'type' => get_class($notification),
- 'level' => $notification->level,
- 'intro' => $notification->introLines,
- 'outro' => $notification->outroLines,
- 'action_text' => $notification->actionText,
- 'action_url' => $notification->actionUrl,
+ 'level' => $message->level,
+ 'intro' => $message->introLines,
+ 'outro' => $message->outroLines,
+ 'action_text' => $message->actionText,
+ 'action_url' => $message->actionUrl,
'read' => false,
]);
} | true |
Other | laravel | framework | a1a50bd612c71338fb9be6da8445e2ba6838a5b6.json | use message object | src/Illuminate/Notifications/Channels/MailChannel.php | @@ -5,6 +5,7 @@
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
use Illuminate\Contracts\Mail\Mailer;
+use Illuminate\Notifications\Message;
use Illuminate\Notifications\Notification;
class MailChannel
@@ -36,39 +37,25 @@ public function __construct(Mailer $mailer)
*/
public function send($notifiables, Notification $notification)
{
- $data = $this->prepareNotificationData($notification);
-
- $emails = $notifiables->map(function ($n) {
- return $n->routeNotificationFor('mail');
- })->filter()->all();
-
- if (empty($emails)) {
- return;
- }
-
$view = data_get($notification, 'options.view', 'notifications::email');
- $this->mailer->send($view, $data, function ($m) use ($notifiables, $notification, $emails) {
- count($notifiables) === 1
- ? $m->to($emails) : $m->bcc($emails);
+ foreach ($notifiables as $notifiable) {
+ if (! $notifiable->routeNotificationFor('mail')) {
+ continue;
+ }
- $m->subject($notification->subject ?: Str::title(
- Str::snake(class_basename($notification), ' ')
- ));
- });
- }
+ $data = $notification->toArray($notifiable);
- /**
- * Prepare the data from the given notification.
- *
- * @param \Illuminate\Notifications\Notification $notification
- * @return array
- */
- protected function prepareNotificationData($notification)
- {
- $data = $notification->toArray();
+ Arr::set($data, 'actionColor', $this->actionColorForLevel($data['level']));
+
+ $this->mailer->send($view, $data, function ($m) use ($notifiable, $notification) {
+ $m->to($notifiable->routeNotificationFor('mail'));
- return Arr::set($data, 'actionColor', $this->actionColorForLevel($data['level']));
+ $m->subject($notification->message($notifiable)->subject ?: Str::title(
+ Str::snake(class_basename($notification), ' ')
+ ));
+ });
+ }
}
/** | true |
Other | laravel | framework | a1a50bd612c71338fb9be6da8445e2ba6838a5b6.json | use message object | src/Illuminate/Notifications/Channels/NexmoSmsChannel.php | @@ -52,28 +52,29 @@ public function send($notifiables, Notification $notification)
$this->nexmo->message()->send([
'from' => $this->from,
'to' => $to,
- 'text' => $this->formatNotification($notification),
+ 'text' => $this->formatNotification($notifiable, $notification),
]);
}
}
/**
* Format the given notification to a single string.
*
+ * @param mixed $notifiable
* @param \Illuminate\Notifications\Notification $notification
* @return string
*/
- protected function formatNotification(Notification $notification)
+ protected function formatNotification($notifiable, $notification)
{
- $data = $notification->toArray();
+ $message = $notification->message($notifiable);
- $actionText = $notification->actionText
- ? $notification->actionText.': ' : '';
+ $actionText = $message->actionText
+ ? $message->actionText.': ' : '';
return trim(implode(PHP_EOL.PHP_EOL, array_filter([
- implode(' ', Arr::get($data, 'introLines', [])),
- $actionText.Arr::get($data, 'actionUrl'),
- implode(' ', Arr::get($data, 'outroLines', [])),
+ implode(' ', $message->introLines),
+ $actionText.$message->actionUrl,
+ implode(' ', $message->outroLines),
])));
}
| true |
Other | laravel | framework | a1a50bd612c71338fb9be6da8445e2ba6838a5b6.json | use message object | src/Illuminate/Notifications/Channels/SlackWebhookChannel.php | @@ -3,6 +3,7 @@
namespace Illuminate\Notifications\Channels;
use GuzzleHttp\Client as HttpClient;
+use Illuminate\Notifications\Message;
use Illuminate\Notifications\Notification;
class SlackWebhookChannel
@@ -39,14 +40,16 @@ public function send($notifiables, Notification $notification)
continue;
}
+ $message = $notification->message($notifiable);
+
$this->http->post($url, [
'json' => [
'attachments' => [
array_filter([
- 'color' => $this->color($notification),
- 'title' => $notification->subject,
- 'title_link' => $notification->actionUrl ?: null,
- 'text' => $this->format($notification),
+ 'color' => $this->color($message->level),
+ 'title' => $message->subject,
+ 'title_link' => $message->actionUrl ?: null,
+ 'text' => $this->format($message),
]),
],
],
@@ -55,33 +58,33 @@ public function send($notifiables, Notification $notification)
}
/**
- * Format the given notification.
+ * Format the given notification message.
*
- * @param \Illuminate\Notifications\Notification $notification
+ * @param \Illuminate\Notifications\Message $message
* @return string
*/
- protected function format(Notification $notification)
+ protected function format(Message $message)
{
- $message = trim(implode(PHP_EOL.PHP_EOL, $notification->introLines));
+ $text = trim(implode(PHP_EOL.PHP_EOL, $message->introLines));
- if ($notification->actionText) {
- $message .= PHP_EOL.PHP_EOL.'<'.$notification->actionUrl.'|'.$notification->actionText.'>';
+ if ($message->actionText) {
+ $text .= PHP_EOL.PHP_EOL.'<'.$message->actionUrl.'|'.$message->actionText.'>';
}
- $message .= PHP_EOL.PHP_EOL.trim(implode(PHP_EOL.PHP_EOL, $notification->outroLines));
+ $text .= PHP_EOL.PHP_EOL.trim(implode(PHP_EOL.PHP_EOL, $message->outroLines));
- return trim($message);
+ return trim($text);
}
/**
* Get the color that should be applied to the notification.
*
- * @param \Illuminate\Notifications\Notification $notification
+ * @param string $level
* @return string|null
*/
- protected function color(Notification $notification)
+ protected function color($level)
{
- switch ($notification->level) {
+ switch ($level) {
case 'success':
return 'good';
case 'error': | true |
Other | laravel | framework | a1a50bd612c71338fb9be6da8445e2ba6838a5b6.json | use message object | src/Illuminate/Notifications/Message.php | @@ -0,0 +1,178 @@
+<?php
+
+namespace Illuminate\Notifications;
+
+class Message
+{
+ /**
+ * The "level" of the notification (info, success, error).
+ *
+ * @var string
+ */
+ public $level = 'info';
+
+ /**
+ * The subject of the notification.
+ *
+ * @var string
+ */
+ public $subject;
+
+ /**
+ * The "intro" lines of the notification.
+ *
+ * @var array
+ */
+ public $introLines = [];
+
+ /**
+ * The "outro" lines of the notification.
+ *
+ * @var array
+ */
+ public $outroLines = [];
+
+ /**
+ * The text / label for the action.
+ *
+ * @var string
+ */
+ public $actionText;
+
+ /**
+ * The action URL.
+ *
+ * @var string
+ */
+ public $actionUrl;
+
+ /**
+ * The notification's options.
+ *
+ * @var array
+ */
+ public $options = [];
+
+ /**
+ * Indicate that the notification gives information about a successful operation.
+ *
+ * @return $this
+ */
+ public function success()
+ {
+ $this->level = 'success';
+
+ return $this;
+ }
+
+ /**
+ * Indicate that the notification gives information about an error.
+ *
+ * @return $this
+ */
+ public function error()
+ {
+ $this->level = 'error';
+
+ return $this;
+ }
+
+ /**
+ * Set the "level" of the notification (success, error, etc.).
+ *
+ * @param string $level
+ * @return $this
+ */
+ public function level($level)
+ {
+ $this->level = $level;
+
+ return $this;
+ }
+
+ /**
+ * Set the subject of the notification.
+ *
+ * @param string $subject
+ * @return $this
+ */
+ public function subject($subject)
+ {
+ $this->subject = $subject;
+
+ return $this;
+ }
+
+ /**
+ * Add a line of text to the notification.
+ *
+ * @param \Illuminate\Notifications\Action|string $line
+ * @return $this
+ */
+ public function line($line)
+ {
+ return $this->with($line);
+ }
+
+ /**
+ * Add a line of text to the notification.
+ *
+ * @param \Illuminate\Notifications\Action|string|array $line
+ * @return $this
+ */
+ public function with($line)
+ {
+ if ($line instanceof Action) {
+ $this->action($line->text, $line->url);
+ } elseif (! $this->actionText) {
+ $this->introLines[] = $this->formatLine($line);
+ } else {
+ $this->outroLines[] = $this->formatLine($line);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Format the given line of text.
+ *
+ * @param string|array $line
+ * @return string
+ */
+ protected function formatLine($line)
+ {
+ if (is_array($line)) {
+ return implode(' ', array_map('trim', $line));
+ }
+
+ return trim(implode(' ', array_map('trim', explode(PHP_EOL, $line))));
+ }
+
+ /**
+ * Set the notification's options.
+ *
+ * @param array $options
+ * @return $this
+ */
+ public function options(array $options)
+ {
+ $this->options = $options;
+
+ return $this;
+ }
+
+ /**
+ * Configure the "call to action" button.
+ *
+ * @param string $text
+ * @param string $url
+ * @return $this
+ */
+ public function action($text, $url)
+ {
+ $this->actionText = $text;
+ $this->actionUrl = $url;
+
+ return $this;
+ }
+} | true |
Other | laravel | framework | a1a50bd612c71338fb9be6da8445e2ba6838a5b6.json | use message object | src/Illuminate/Notifications/Notification.php | @@ -2,6 +2,7 @@
namespace Illuminate\Notifications;
+use BadMethodCallException;
use Illuminate\Queue\SerializesModels;
class Notification
@@ -22,55 +23,6 @@ class Notification
*/
public $logoUrl;
- /**
- * The "level" of the notification (info, success, error).
- *
- * @var string
- */
- public $level = 'info';
-
- /**
- * The subject of the notification.
- *
- * @var string
- */
- public $subject;
-
- /**
- * The "intro" lines of the notification.
- *
- * @var array
- */
- public $introLines = [];
-
- /**
- * The "outro" lines of the notification.
- *
- * @var array
- */
- public $outroLines = [];
-
- /**
- * The text / label for the action.
- *
- * @var string
- */
- public $actionText;
-
- /**
- * The action URL.
- *
- * @var string
- */
- public $actionUrl;
-
- /**
- * The notification's options.
- *
- * @var array
- */
- public $options = [];
-
/**
* Specify the name of the application sending the notification.
*
@@ -87,144 +39,40 @@ public function application($application, $logoUrl = null)
}
/**
- * Indicate that the notification gives information about a successful operation.
- *
- * @return $this
- */
- public function success()
- {
- $this->level = 'success';
-
- return $this;
- }
-
- /**
- * Indicate that the notification gives information about an error.
- *
- * @return $this
- */
- public function error()
- {
- $this->level = 'error';
-
- return $this;
- }
-
- /**
- * Set the "level" of the notification (success, error, etc.).
- *
- * @param string $level
- * @return $this
- */
- public function level($level)
- {
- $this->level = $level;
-
- return $this;
- }
-
- /**
- * Set the subject of the notification.
- *
- * @param string $subject
- * @return $this
- */
- public function subject($subject)
- {
- $this->subject = $subject;
-
- return $this;
- }
-
- /**
- * Add a line of text to the notification.
- *
- * @param \Illuminate\Notifications\Action|string $line
- * @return $this
- */
- public function line($line)
- {
- return $this->with($line);
- }
-
- /**
- * Add a line of text to the notification.
+ * Get an array representation of the notification.
*
- * @param \Illuminate\Notifications\Action|string|array $line
- * @return $this
+ * @param mixed $notifiable
+ * @return array
*/
- public function with($line)
+ public function toArray($notifiable)
{
- if ($line instanceof Action) {
- $this->action($line->text, $line->url);
- } elseif (! $this->actionText) {
- $this->introLines[] = $this->formatLine($line);
- } else {
- $this->outroLines[] = $this->formatLine($line);
- }
+ $message = $this->message($notifiable);
- return $this;
+ return [
+ 'application' => $this->application,
+ 'logoUrl' => $this->logoUrl,
+ 'level' => $message->level,
+ 'subject' => $message->subject,
+ 'introLines' => $message->introLines,
+ 'outroLines' => $message->outroLines,
+ 'actionText' => $message->actionText,
+ 'actionUrl' => $message->actionUrl,
+ ];
}
/**
- * Format the given line of text.
+ * Dynamically pass calls to the message class.
*
- * @param string|array $line
- * @return string
+ * @param string $method
+ * @param array $parameters
+ * @return mixed
*/
- protected function formatLine($line)
+ public function __call($method, $parameters)
{
- if (is_array($line)) {
- return implode(' ', array_map('trim', $line));
+ if (method_exists(Message::class, $method)) {
+ return (new Message)->{$method}(...$parameters);
}
- return trim(implode(' ', array_map('trim', explode(PHP_EOL, $line))));
- }
-
- /**
- * Set the notification's options.
- *
- * @param array $options
- * @return $this
- */
- public function options(array $options)
- {
- $this->options = $options;
-
- return $this;
- }
-
- /**
- * Configure the "call to action" button.
- *
- * @param string $text
- * @param string $url
- * @return $this
- */
- public function action($text, $url)
- {
- $this->actionText = $text;
- $this->actionUrl = $url;
-
- return $this;
- }
-
- /**
- * Get the instance as an array.
- *
- * @return array
- */
- public function toArray()
- {
- return [
- 'application' => $this->application,
- 'logoUrl' => $this->logoUrl,
- 'level' => $this->level,
- 'subject' => $this->subject,
- 'introLines' => $this->introLines,
- 'outroLines' => $this->outroLines,
- 'actionText' => $this->actionText,
- 'actionUrl' => $this->actionUrl,
- ];
+ throw new BadMethodCallException("Call to undefined method [{$method}].");
}
} | true |
Other | laravel | framework | a1a50bd612c71338fb9be6da8445e2ba6838a5b6.json | use message object | tests/Notifications/NotificationBroadcastChannelTest.php | @@ -1,5 +1,6 @@
<?php
+use Illuminate\Notifications\Message;
use Illuminate\Notifications\Notification;
use Illuminate\Notifications\Channels\BroadcastChannel;
@@ -12,7 +13,7 @@ public function tearDown()
public function testBroadcastChannelCreatesDatabaseRecordWithProperData()
{
- $notification = new Notification;
+ $notification = new NotificationBroadcastChannelTestNotification;
$notifiables = collect([$notifiable = Mockery::mock()]);
$notifiable->shouldReceive('routeNotificationFor->create')->with([
@@ -32,3 +33,11 @@ public function testBroadcastChannelCreatesDatabaseRecordWithProperData()
$channel->send($notifiables, $notification);
}
}
+
+class NotificationBroadcastChannelTestNotification extends Notification
+{
+ public function message($notifiable)
+ {
+ return new Message;
+ }
+} | true |
Other | laravel | framework | a1a50bd612c71338fb9be6da8445e2ba6838a5b6.json | use message object | tests/Notifications/NotificationChannelManagerTest.php | @@ -23,9 +23,6 @@ public function testNotificationCanBeDispatchedToDriver()
$driver->shouldReceive('send')->andReturnUsing(function ($notifiables, $notification) {
$this->assertEquals('Name', $notification->application);
$this->assertEquals('Logo', $notification->logoUrl);
- $this->assertEquals('test', $notification->introLines[0]);
- $this->assertEquals('Text', $notification->actionText);
- $this->assertEquals('url', $notification->actionUrl);
});
$events->shouldReceive('fire')->with(Mockery::type(Illuminate\Notifications\Events\NotificationSent::class));
| true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.