Skip to content
This repository has been archived by the owner on Jun 19, 2019. It is now read-only.

Commit

Permalink
update str and arr helpers to Str and Arr helpers for Laravel 5.8 sup…
Browse files Browse the repository at this point in the history
…port (#530)
  • Loading branch information
jmlallier authored and freekmurze committed Feb 28, 2019
1 parent 9210019 commit 6af1940
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 28 deletions.
3 changes: 2 additions & 1 deletion app/Console/Commands/ImportFragments.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use App\Models\Fragment;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
use Illuminate\Console\Command;
use Symfony\Component\Yaml\Yaml;

Expand All @@ -20,7 +21,7 @@ public function handle()
$fragments = collect()->glob("{$root}/*.yml")->map(function (string $path) use ($root) {
$fragments = Yaml::parse(file_get_contents($path));

$group = str_before(str_after($path, "{$root}/"), '.yml');
$group = Str::before(Str::after($path, "{$root}/"), '.yml');

return $this->importFragmentGroup($group, $fragments);
});
Expand Down
11 changes: 6 additions & 5 deletions app/Http/Controllers/Back/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@

namespace App\Http\Controllers\Back;

use App\Models\Scopes\NonDraftScope;
use Illuminate\Database\Eloquent\Model as Eloquent;
use Illuminate\Foundation\Validation\ValidatesRequests;
use ReflectionClass;
use Illuminate\Support\Str;
use Illuminate\Http\Request;
use Illuminate\Support\Collection;
use App\Models\Scopes\NonDraftScope;
use Illuminate\Support\Facades\Cache;
use ReflectionClass;
use Illuminate\Database\Eloquent\Model as Eloquent;
use Illuminate\Foundation\Validation\ValidatesRequests;

abstract class Controller
{
Expand Down Expand Up @@ -127,7 +128,7 @@ protected function determineModelClass(): string

protected function determineModuleName(): string
{
return lcfirst(str_replace_last('Controller', '', class_basename($this)));
return lcfirst(Str::replaceLast('Controller', '', class_basename($this)));
}

protected function updateModel(Eloquent $model, Request $request)
Expand Down
9 changes: 5 additions & 4 deletions app/Http/Middleware/LoginAs.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

namespace App\Http\Middleware;

use App\Services\Auth\Back\User as BackUser;
use App\Services\Auth\Front\User as FrontUser;
use Closure;
use Exception;
use Illuminate\Support\Str;
use App\Services\Auth\Back\User as BackUser;
use App\Services\Auth\Front\User as FrontUser;
use Illuminate\Contracts\Auth\Authenticatable;

class LoginAs
Expand Down Expand Up @@ -33,7 +34,7 @@ protected function canLoginAs(): bool
return false;
}

if (! ends_with(request()->getHost(), '.dev')) {
if (! Str::endsWith(request()->getHost(), '.dev')) {
return false;
}

Expand Down Expand Up @@ -61,7 +62,7 @@ protected function loginAsAndRedirect(string $identifier)

protected function getUser(string $identifier): Authenticatable
{
if (! str_contains($identifier, '@')) {
if (! Str::contains($identifier, '@')) {
$identifier .= '@spatie.be';
}

Expand Down
3 changes: 2 additions & 1 deletion app/Http/Middleware/RobotsMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

namespace App\Http\Middleware;

use Illuminate\Support\Str;
use Illuminate\Http\Request;
use Spatie\RobotsMiddleware\RobotsMiddleware as BaseRobotsMiddleware;

class RobotsMiddleware extends BaseRobotsMiddleware
{
protected function shouldIndex(Request $request): bool
{
if (ends_with($request->getHost(), 'spatie.be')) {
if (Str::endsWith($request->getHost(), 'spatie.be')) {
return false;
}

Expand Down
5 changes: 3 additions & 2 deletions app/Providers/HorizonServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

namespace App\Providers;

use Illuminate\Support\Str;
use Illuminate\Http\Request;
use Illuminate\Support\ServiceProvider;
use Laravel\Horizon\Horizon;
use Illuminate\Support\ServiceProvider;

class HorizonServiceProvider extends ServiceProvider
{
Expand All @@ -25,7 +26,7 @@ public function boot()
return false;
}

return ends_with($backUser->email, '@spatie.be');
return Str::endsWith($backUser->email, '@spatie.be');
});
}
}
9 changes: 5 additions & 4 deletions app/Services/Auth/Front/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@

namespace App\Services\Auth\Front;

use Illuminate\Support\Arr;
use Illuminate\Support\Facades\Mail;
use App\Services\Auth\User as BaseUser;
use App\Services\Auth\Front\Enums\UserRole;
use App\Services\Auth\Front\Enums\UserStatus;
use App\Services\Auth\Front\Mail\ResetPassword;
use App\Services\Auth\Front\Events\UserRegistered;
use App\Services\Auth\Front\Exceptions\UserIsAlreadyActivated;
use App\Services\Auth\Front\Mail\ResetPassword;
use App\Services\Auth\User as BaseUser;
use Illuminate\Support\Facades\Mail;

/**
* @property string $address
Expand All @@ -30,7 +31,7 @@ public static function register(array $input): self
'status' => UserStatus::ACTIVE,
];

$user = static::create($defaults + array_only($input, [
$user = static::create($defaults + Arr::only($input, [
'first_name',
'last_name',
'address',
Expand Down
4 changes: 3 additions & 1 deletion app/Services/Auth/UserPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace App\Services\Auth;

use Illuminate\Support\Str;

trait UserPresenter
{
public function getFullNameAttribute(): string
Expand All @@ -22,7 +24,7 @@ public function getLastActivityDateAttribute(): string

$lastActivityDate = diff_date_for_humans($this->last_activity);

if (str_contains($lastActivityDate, 'second')) {
if (Str::contains($lastActivityDate, 'second')) {
$lastActivityDate = 'Just now';
}

Expand Down
13 changes: 7 additions & 6 deletions app/Services/Html/Concerns/Forms.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@

namespace App\Services\Html\Concerns;

use App\Http\Resources\Media as MediaResource;
use App\Models\ContentBlock;
use App\Models\Tag;
use App\Models\Transformers\ContentBlockTransformer;
use Illuminate\Support\Collection;
use Illuminate\Support\Str;
use App\Models\ContentBlock;
use Spatie\Html\Elements\Div;
use Spatie\Html\Elements\Element;
use Spatie\Html\Elements\Input;
use Spatie\Html\Elements\Select;
use Spatie\Html\Elements\Element;
use Illuminate\Support\Collection;
use Spatie\Html\Elements\Textarea;
use App\Http\Resources\Media as MediaResource;
use App\Models\Transformers\ContentBlockTransformer;

trait Forms
{
Expand Down Expand Up @@ -196,7 +197,7 @@ public function seo(): Div

protected function seoLabel(string $attribute): string
{
if (starts_with($attribute, 'meta_')) {
if (Str::startsWith($attribute, 'meta_')) {
return 'Meta: '.substr($attribute, 5);
}

Expand Down
9 changes: 5 additions & 4 deletions app/helpers.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
<?php

use Carbon\Carbon;
use App\Models\Article;
use App\Models\Fragment;
use App\Models\Recipient;
use App\Services\Seo\Meta;
use App\Services\Auth\User;
use App\Services\Html\Html;
use App\Services\Seo\Meta;
use Illuminate\Support\Str;
use App\Services\Seo\Schema;
use Carbon\Carbon;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\HtmlString;
use Illuminate\Support\Facades\Validator;

function article(string $specialArticle): Article
{
Expand Down Expand Up @@ -47,7 +48,7 @@ function diff_date_for_humans(Carbon $date) : string

function fragment_image($name, $conversion = 'thumb'): string
{
if (! str_contains($name, '.')) {
if (! Str::contains($name, '.')) {
return $name;
}

Expand Down

0 comments on commit 6af1940

Please sign in to comment.