Skip to content

Commit

Permalink
Laravel 6.0 compatibility (#625)
Browse files Browse the repository at this point in the history
* Laravel 6.0 compatibility

* replace all deprecated laravel 5.x array_* to Arr helper static call
  • Loading branch information
khairilanuar authored and bsormagec committed Dec 9, 2019
1 parent c4f56cf commit 3442bb4
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 9 deletions.
3 changes: 2 additions & 1 deletion src/Prettus/Repository/Criteria/RequestCriteria.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Http\Request;
use Illuminate\Support\Str;
use Prettus\Repository\Contracts\CriteriaInterface;
use Prettus\Repository\Contracts\RepositoryInterface;

Expand Down Expand Up @@ -136,7 +137,7 @@ public function apply($model, RepositoryInterface $repository)
* ex.
* products -> product_id
*/
$prefix = str_singular($sortTable);
$prefix = Str::singular($sortTable);
$keyName = $table.'.'.$prefix.'_id';
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

use Illuminate\Console\Command;
use Illuminate\Support\Collection;
use Illuminate\Support\Str;
use Prettus\Repository\Generators\FileAlreadyExistsException;
use Prettus\Repository\Generators\MigrationGenerator;
use Prettus\Repository\Generators\ModelGenerator;
Expand Down Expand Up @@ -66,7 +67,7 @@ public function fire()
$this->generators = new Collection();

$migrationGenerator = new MigrationGenerator([
'name' => 'create_' . snake_case(str_plural($this->argument('name'))) . '_table',
'name' => 'create_' . Str::snake(Str::plural($this->argument('name'))) . '_table',
'fields' => $this->option('fillable'),
'force' => $this->option('force'),
]);
Expand Down
6 changes: 4 additions & 2 deletions src/Prettus/Repository/Generators/ControllerGenerator.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php
namespace Prettus\Repository\Generators;

use Illuminate\Support\Str;

/**
* Class ControllerGenerator
* @package Prettus\Repository\Generators
Expand Down Expand Up @@ -75,7 +77,7 @@ public function getControllerName()
public function getPluralName()
{

return str_plural(lcfirst(ucwords($this->getClass())));
return Str::plural(lcfirst(ucwords($this->getClass())));
}

/**
Expand Down Expand Up @@ -103,7 +105,7 @@ public function getReplacements()
*/
public function getSingularName()
{
return str_singular(lcfirst(ucwords($this->getClass())));
return Str::singular(lcfirst(ucwords($this->getClass())));
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Prettus/Repository/Generators/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,10 @@ public function getPath()
public function getName()
{
$name = $this->name;
if (str_contains($this->name, '\\')) {
if (Str::contains($this->name, '\\')) {
$name = str_replace('\\', '/', $this->name);
}
if (str_contains($this->name, '/')) {
if (Str::contains($this->name, '/')) {
$name = str_replace('/', '/', $this->name);
}

Expand Down
3 changes: 2 additions & 1 deletion src/Prettus/Repository/Generators/Migrations/RulesParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
namespace Prettus\Repository\Generators\Migrations;

use Illuminate\Contracts\Support\Arrayable;
use Illuminate\Support\Arr;

/**
* Class RulesParser
Expand Down Expand Up @@ -82,7 +83,7 @@ public function getRules()
*/
public function getColumn($rules)
{
return array_first(explode('=>', $rules), function ($key, $value) {
return Arr::first(explode('=>', $rules), function ($key, $value) {
return $value;
});
}
Expand Down
6 changes: 4 additions & 2 deletions src/Prettus/Repository/Generators/Migrations/SchemaParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
namespace Prettus\Repository\Generators\Migrations;

use Illuminate\Contracts\Support\Arrayable;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;

/**
* Class SchemaParser
Expand Down Expand Up @@ -114,7 +116,7 @@ public function getSchemas()
*/
public function getColumn($schema)
{
return array_first(explode(':', $schema), function ($key, $value) {
return Arr::first(explode(':', $schema), function ($key, $value) {
return $value;
});
}
Expand Down Expand Up @@ -208,7 +210,7 @@ protected function addColumn($key, $field, $column)
if ($key == 0) {
return '->' . $field . "('" . $column . "')";
}
if (str_contains($field, '(')) {
if (Str::contains($field, '(')) {
return '->' . $field;
}

Expand Down

0 comments on commit 3442bb4

Please sign in to comment.