diff --git a/src/Prettus/Repository/Criteria/RequestCriteria.php b/src/Prettus/Repository/Criteria/RequestCriteria.php index 40fc304a..b8d63436 100644 --- a/src/Prettus/Repository/Criteria/RequestCriteria.php +++ b/src/Prettus/Repository/Criteria/RequestCriteria.php @@ -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; @@ -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'; } diff --git a/src/Prettus/Repository/Generators/Commands/RepositoryCommand.php b/src/Prettus/Repository/Generators/Commands/RepositoryCommand.php index 2d0a0aa9..012f88c8 100644 --- a/src/Prettus/Repository/Generators/Commands/RepositoryCommand.php +++ b/src/Prettus/Repository/Generators/Commands/RepositoryCommand.php @@ -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; @@ -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'), ]); diff --git a/src/Prettus/Repository/Generators/ControllerGenerator.php b/src/Prettus/Repository/Generators/ControllerGenerator.php index b3377cb5..b9385977 100644 --- a/src/Prettus/Repository/Generators/ControllerGenerator.php +++ b/src/Prettus/Repository/Generators/ControllerGenerator.php @@ -1,6 +1,8 @@ getClass()))); + return Str::plural(lcfirst(ucwords($this->getClass()))); } /** @@ -103,7 +105,7 @@ public function getReplacements() */ public function getSingularName() { - return str_singular(lcfirst(ucwords($this->getClass()))); + return Str::singular(lcfirst(ucwords($this->getClass()))); } /** diff --git a/src/Prettus/Repository/Generators/Generator.php b/src/Prettus/Repository/Generators/Generator.php index e6192922..afc42096 100644 --- a/src/Prettus/Repository/Generators/Generator.php +++ b/src/Prettus/Repository/Generators/Generator.php @@ -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); } diff --git a/src/Prettus/Repository/Generators/Migrations/RulesParser.php b/src/Prettus/Repository/Generators/Migrations/RulesParser.php index 1bda2694..72637646 100644 --- a/src/Prettus/Repository/Generators/Migrations/RulesParser.php +++ b/src/Prettus/Repository/Generators/Migrations/RulesParser.php @@ -2,6 +2,7 @@ namespace Prettus\Repository\Generators\Migrations; use Illuminate\Contracts\Support\Arrayable; +use Illuminate\Support\Arr; /** * Class RulesParser @@ -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; }); } diff --git a/src/Prettus/Repository/Generators/Migrations/SchemaParser.php b/src/Prettus/Repository/Generators/Migrations/SchemaParser.php index a9270968..c97c49ec 100644 --- a/src/Prettus/Repository/Generators/Migrations/SchemaParser.php +++ b/src/Prettus/Repository/Generators/Migrations/SchemaParser.php @@ -2,6 +2,8 @@ namespace Prettus\Repository\Generators\Migrations; use Illuminate\Contracts\Support\Arrayable; +use Illuminate\Support\Arr; +use Illuminate\Support\Str; /** * Class SchemaParser @@ -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; }); } @@ -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; }