├── .github └── FUNDING.yml ├── .gitignore ├── LICENSE ├── README.md ├── composer.json └── src ├── Actions.php └── Grid.php /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | custom: https://james.dmzfa.com/about#pay 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | phpunit.phar 3 | /vendor 4 | composer.phar 5 | composer.lock 6 | *.project 7 | .idea/ -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Jens Segers 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## laravel-admin Grid 2 | 3 | ## Screenshot 4 | 5 | ![screenshot](https://github.com/xiaoxuan6/laravel-admin-sortable/blob/master/20190225154750.png) 6 | 7 | Installation 8 | First, install dependencies: 9 | 10 | composer require james.xue/laravel-admin-grid 11 | 12 | ### 注意事项 13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 |
VersionLaravel-Admin Version
1.1.0< 1.7
1.2.0>= 1.7
28 |
29 | 30 | User 31 | 32 | 将控制器中 33 | 34 | use Encore\Admin\Grid; 35 | 36 | 替换 37 | 38 | use James\Admin\Grid; 39 | 40 | # 已知问题 41 | James\Admin\Actions::{closure}() 报错 42 | 43 | 解决方法: 44 | 45 | $grid->actions(function ($actions) 46 | 47 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "james.xue/laravel-admin-grid", 3 | "description": "laravel-admin Grid", 4 | "type": "library", 5 | "keywords": ["laravel-admin", "extension"], 6 | "homepage": "https://github.com/xiaoxuan6/laravel-admin-grid", 7 | "license": "MIT", 8 | "authors": [ 9 | { 10 | "name": "xiaoxuan6", 11 | "email": "1527736751@qq.com" 12 | } 13 | ], 14 | "autoload": { 15 | "psr-4": { 16 | "James\\Admin\\": "src/" 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/Actions.php: -------------------------------------------------------------------------------- 1 | appends, $action); 42 | 43 | return $this; 44 | } 45 | 46 | /** 47 | * Prepend a action. 48 | * 49 | * @param $action 50 | * 51 | * @return $this 52 | */ 53 | public function prepend($action) 54 | { 55 | array_unshift($this->prepends, $action); 56 | 57 | return $this; 58 | } 59 | 60 | /** 61 | * Disable view action. 62 | * 63 | * @return $this 64 | */ 65 | public function disableView() 66 | { 67 | array_delete($this->actions, 'view'); 68 | 69 | return $this; 70 | } 71 | 72 | /** 73 | * Disable delete. 74 | * 75 | * @return $this. 76 | */ 77 | public function disableDelete() 78 | { 79 | array_delete($this->actions, 'delete'); 80 | 81 | return $this; 82 | } 83 | 84 | /** 85 | * Disable edit. 86 | * 87 | * @return $this. 88 | */ 89 | public function disableEdit() 90 | { 91 | array_delete($this->actions, 'edit'); 92 | 93 | return $this; 94 | } 95 | 96 | /** 97 | * Set resource of current resource. 98 | * 99 | * @param $resource 100 | * 101 | * @return $this 102 | */ 103 | public function setResource($resource) 104 | { 105 | $this->resource = $resource; 106 | 107 | return $this; 108 | } 109 | 110 | /** 111 | * Get resource of current resource. 112 | * 113 | * @return string 114 | */ 115 | public function getResource() 116 | { 117 | return $this->resource ?: parent::getResource(); 118 | } 119 | 120 | /** 121 | * {@inheritdoc} 122 | */ 123 | public function display($callback = null) 124 | { 125 | if ($callback instanceof \Closure) { 126 | $callback->call($this, $this); 127 | } 128 | 129 | $actions = $this->prepends; 130 | 131 | foreach ($this->actions as $action) { 132 | $method = 'render'.ucfirst($action); 133 | array_push($actions, $this->{$method}()); 134 | } 135 | 136 | $actions = array_merge($actions, $this->appends); 137 | 138 | return implode('', $actions); 139 | } 140 | 141 | /** 142 | * Render view action. 143 | * 144 | * @return string 145 | */ 146 | protected function renderView() 147 | { 148 | return << 150 | 查看 151 |   152 | EOT; 153 | } 154 | 155 | /** 156 | * Render edit action. 157 | * 158 | * @return string 159 | */ 160 | protected function renderEdit() 161 | { 162 | return << 164 | 编辑 165 |   166 | EOT; 167 | } 168 | 169 | /** 170 | * Render delete action. 171 | * 172 | * @return string 173 | */ 174 | protected function renderDelete() 175 | { 176 | $deleteConfirm = trans('admin.delete_confirm'); 177 | $confirm = trans('admin.confirm'); 178 | $cancel = trans('admin.cancel'); 179 | 180 | $script = <<