jqh 5 年 前
コミット
f5c9a0b59e

+ 4 - 5
src/Controllers/LogController.php

@@ -43,11 +43,10 @@ class LogController extends Controller
             })
             ->responsive();
 
-        $grid->method(trans('admin.method'))->responsive()->display(function ($method) {
-            $color = Arr::get(OperationLogModel::$methodColors, $method, 'default');
-
-            return "<span class=\"label bg-$color\">$method</span>";
-        })->filterByValue();
+        $grid->method(trans('admin.method'))
+            ->responsive()
+            ->label(OperationLogModel::$methodColors)
+            ->filterByValue();
 
         $grid->path(trans('admin.uri'))->responsive()->display(function ($v) {
             return "<code>$v</code>";

+ 1 - 1
src/Form/Field/SelectResource.php

@@ -142,7 +142,7 @@ class SelectResource extends Field
     protected function setDefaultSource()
     {
         if (! $this->source) {
-            if (strpos($this->column, '.')) {
+            if (mb_strpos($this->column, '.')) {
                 $this->path(str_replace('_id', '', last(explode('.', $this->column))));
             } else {
                 $this->path(str_replace('_id', '', $this->column));

+ 1 - 1
src/Grid.php

@@ -243,7 +243,7 @@ class Grid
      */
     public function column($name, $label = '')
     {
-        if (strpos($name, '.') !== false) {
+        if (mb_strpos($name, '.') !== false) {
             [$relationName, $relationColumn] = explode('.', $name);
 
             $label = empty($label) ? admin_trans_field($relationColumn) : $label;

+ 1 - 1
src/Grid/Displayers/DropdownActions.php

@@ -103,7 +103,7 @@ JS;
     {
         $action = Helper::render($action);
 
-        if (strpos($action, '</a>') === false) {
+        if (mb_strpos($action, '</a>') === false) {
             return "<a>$action</a>";
         }
 

+ 1 - 1
src/Grid/Displayers/Image.php

@@ -14,7 +14,7 @@ class Image extends AbstractDisplayer
         }
 
         return collect((array) $this->value)->filter()->map(function ($path) use ($server, $width, $height) {
-            if (url()->isValidUrl($path) || strpos($path, 'data:image') === 0) {
+            if (url()->isValidUrl($path) || mb_strpos($path, 'data:image') === 0) {
                 $src = $path;
             } elseif ($server) {
                 $src = rtrim($server, '/').'/'.ltrim($path, '/');

+ 1 - 1
src/Grid/Filter/Presenter/SelectResource.php

@@ -160,7 +160,7 @@ class SelectResource extends Presenter
     {
         if (! $this->source) {
             $column = $this->filter->column();
-            if (strpos($column, '.')) {
+            if (mb_strpos($column, '.')) {
                 $this->path(str_replace('_id', '', last(explode('.', $column))));
             } else {
                 $this->path(str_replace('_id', '', $column));

+ 3 - 3
src/Layout/Asset.php

@@ -310,7 +310,7 @@ class Asset
             return $this->alias[$name] ?? [];
         }
 
-        if (strpos($name, '@') !== 0) {
+        if (mb_strpos($name, '@') !== 0) {
             $name = '@'.$name;
         }
 
@@ -341,7 +341,7 @@ class Asset
      */
     public function collect(string $alias)
     {
-        if (strpos($alias, '@') !== 0) {
+        if (mb_strpos($alias, '@') !== 0) {
             $alias = '@'.$alias;
         }
 
@@ -433,7 +433,7 @@ class Asset
 
         $path = $this->getRealPath($path);
 
-        if (strpos($path, '//') === false) {
+        if (mb_strpos($path, '//') === false) {
             $path = config('admin.assets_server').'/'.trim($path, '/');
         }
 

+ 2 - 2
src/Support/Helper.php

@@ -437,7 +437,7 @@ class Helper
 
         $hasPrefix = false;
 
-        if (strpos($color, '#') === 0) {
+        if (mb_strpos($color, '#') === 0) {
             $color = mb_substr($color, 1);
 
             $hasPrefix = true;
@@ -475,7 +475,7 @@ class Helper
             return $color;
         }
 
-        if (strpos($color, '#') === 0) {
+        if (mb_strpos($color, '#') === 0) {
             $color = mb_substr($color, 1);
         }
 

+ 1 - 1
src/Support/helpers.php

@@ -173,7 +173,7 @@ if (! function_exists('admin_trans')) {
             return $translator->$method($key, $replace, $locale);
         }
         if (
-            strpos($key, 'global.') !== 0
+            mb_strpos($key, 'global.') !== 0
             && count($arr = explode('.', $key)) > 1
         ) {
             unset($arr[0]);

+ 1 - 1
src/Widgets/Dropdown.php

@@ -292,7 +292,7 @@ HTML
             $v = $builder->call($this, $v, $k);
         }
 
-        $v = strpos($v, '</a>') ? $v : "<a href='javascript:void(0)'>$v</a>";
+        $v = mb_strpos($v, '</a>') ? $v : "<a href='javascript:void(0)'>$v</a>";
         $v = "<li class='dropdown-item'>$v</li>";
 
         if ($this->divider) {

+ 2 - 2
src/Widgets/Dump.php

@@ -86,8 +86,8 @@ class Dump extends Widget
         if (
             is_string($content) &&
             (
-                (strpos($content, '{') === 0 && strpos($content, '}', -1) !== false) ||
-                (strpos($content, '[') === 0 && strpos($content, ']', -1) !== false)
+                (mb_strpos($content, '{') === 0 && mb_strpos($content, '}', -1) !== false) ||
+                (mb_strpos($content, '[') === 0 && mb_strpos($content, ']', -1) !== false)
             )
         ) {
             return json_decode($content, true);

+ 1 - 1
src/Widgets/NavList.php

@@ -80,7 +80,7 @@ JS
 
             $active = $this->active === $k ? 'active' : '';
 
-            $item = strpos($item, '</a>') ? $item : "<a href='javascript:void(0)'>$item</a>";
+            $item = mb_strpos($item, '</a>') ? $item : "<a href='javascript:void(0)'>$item</a>";
 
             $html .= "<li class='$active bg-white'>$item</li>";
         }

+ 2 - 2
src/Widgets/Navbar.php

@@ -165,13 +165,13 @@ JS
             $item = $builder($item, $k);
         }
 
-        if (strpos($item, '</li>')) {
+        if (mb_strpos($item, '</li>')) {
             return $item;
         }
 
         $active = $this->active === $k ? 'active' : '';
 
-        $item = strpos($item, '</a>') ? $item : "<a href='javascript:void(0)'>$item</a>";
+        $item = mb_strpos($item, '</a>') ? $item : "<a href='javascript:void(0)'>$item</a>";
 
         return "<li class='nav-li $active'>$item</li>";
     }