@@ -4,16 +4,8 @@ |
||
| 4 | 4 | |
| 5 | 5 | use Event; |
| 6 | 6 | use Illuminate\Support\Facades\Storage; |
| 7 | -use Illuminate\Pagination\Paginator; |
|
| 8 | -use Illuminate\Foundation\Application; |
|
| 9 | -use Maatwebsite\Excel\Classes\LaravelExcelWorksheet; |
|
| 10 | -use Maatwebsite\Excel\Excel; |
|
| 11 | -use Maatwebsite\Excel\Writers\LaravelExcelWriter; |
|
| 12 | 7 | use Nayjest\Grids\Components\Base\RenderableComponent; |
| 13 | 8 | use Nayjest\Grids\Components\Base\RenderableRegistry; |
| 14 | -use Nayjest\Grids\DataProvider; |
|
| 15 | -use Nayjest\Grids\DataRow; |
|
| 16 | -use Nayjest\Grids\FieldConfig; |
|
| 17 | 9 | use Nayjest\Grids\Grid; |
| 18 | 10 | |
| 19 | 11 | class ExcelDownload extends RenderableComponent |
@@ -67,12 +67,12 @@ |
||
| 67 | 67 | public function initialize(Grid $grid) |
| 68 | 68 | { |
| 69 | 69 | parent::initialize($grid); |
| 70 | - Event::listen(Grid::EVENT_PREPARE, function (Grid $grid) { |
|
| 70 | + Event::listen(Grid::EVENT_PREPARE, function(Grid $grid) { |
|
| 71 | 71 | if ($this->grid !== $grid) { |
| 72 | 72 | return; |
| 73 | 73 | } |
| 74 | 74 | if ($grid->getInputProcessor()->getValue(static::INPUT_PARAM, false)) { |
| 75 | - foreach (glob(Storage::disk('local')->getDriver()->getAdapter()->getPathPrefix() . 'public/excels/*.xlsx', GLOB_BRACE) as $fileName) { |
|
| 75 | + foreach (glob(Storage::disk('local')->getDriver()->getAdapter()->getPathPrefix().'public/excels/*.xlsx', GLOB_BRACE) as $fileName) { |
|
| 76 | 76 | if (strpos($fileName, $this->getBaseName())) { |
| 77 | 77 | $this->responseWithProtectedFile($fileName); |
| 78 | 78 | } |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | /** |
| 208 | 208 | * Returns footer component. |
| 209 | 209 | * |
| 210 | - * @return TFoot|null |
|
| 210 | + * @return null|Components\Base\ComponentInterface |
|
| 211 | 211 | */ |
| 212 | 212 | public function footer() |
| 213 | 213 | { |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | /** |
| 218 | 218 | * Returns header component. |
| 219 | 219 | * |
| 220 | - * @return THead|null |
|
| 220 | + * @return null|Components\Base\ComponentInterface |
|
| 221 | 221 | */ |
| 222 | 222 | public function header() |
| 223 | 223 | { |
@@ -99,7 +99,7 @@ |
||
| 99 | 99 | if (empty($trace['class']) || !$this instanceof $trace['class']) { |
| 100 | 100 | # may be closure |
| 101 | 101 | if (isset($trace['file'], $trace['line'])) { |
| 102 | - $str .= $trace['file'] . $trace['line']; |
|
| 102 | + $str .= $trace['file'].$trace['line']; |
|
| 103 | 103 | } |
| 104 | 104 | } |
| 105 | 105 | } |
@@ -103,7 +103,6 @@ discard block |
||
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | /** |
| 106 | - * @param mixed $config |
|
| 107 | 106 | */ |
| 108 | 107 | public function setClassName($className) |
| 109 | 108 | { |
@@ -120,7 +119,6 @@ discard block |
||
| 120 | 119 | } |
| 121 | 120 | |
| 122 | 121 | /** |
| 123 | - * @param mixed $config |
|
| 124 | 122 | */ |
| 125 | 123 | public function setUserId($userId) |
| 126 | 124 | { |
@@ -4,13 +4,10 @@ |
||
| 4 | 4 | |
| 5 | 5 | use App\Components\Grid\ExtendedTableRow; |
| 6 | 6 | use App\Components\Grid\GridsToComponents; |
| 7 | -use App\Http\Controllers\SupportersController; |
|
| 8 | 7 | use App\Topic; |
| 9 | 8 | use App\User; |
| 10 | -use Event; |
|
| 11 | 9 | use Illuminate\Pagination\Paginator; |
| 12 | 10 | use Illuminate\Foundation\Application; |
| 13 | -use Illuminate\Support\Facades\DB; |
|
| 14 | 11 | use Maatwebsite\Excel\Classes\LaravelExcelWorksheet; |
| 15 | 12 | use Maatwebsite\Excel\Excel; |
| 16 | 13 | use Maatwebsite\Excel\Writers\LaravelExcelWriter; |
@@ -140,17 +140,17 @@ discard block |
||
| 140 | 140 | $user = User::find($this->userId); |
| 141 | 141 | |
| 142 | 142 | $controllers = GridsToComponents::getGridsControllers(); |
| 143 | - $className = 'App\\Http\\Controllers\\' . $controllers[$sheetName]; |
|
| 143 | + $className = 'App\\Http\\Controllers\\'.$controllers[$sheetName]; |
|
| 144 | 144 | |
| 145 | - if($sheetName == 'topicQuestionsGrid') { |
|
| 145 | + if ($sheetName == 'topicQuestionsGrid') { |
|
| 146 | 146 | $topic = Topic::find($showId); |
| 147 | 147 | $this->config = $className::getQuestionsGridConfig($topic); |
| 148 | 148 | } |
| 149 | - else{ |
|
| 149 | + else { |
|
| 150 | 150 | $this->config = $className::getGridConfig($user); |
| 151 | 151 | } |
| 152 | 152 | |
| 153 | - $grid = (new Grid($this->config->setRowComponent(new ExtendedTableRow(function ($model) { |
|
| 153 | + $grid = (new Grid($this->config->setRowComponent(new ExtendedTableRow(function($model) { |
|
| 154 | 154 | return $className::getRowAttributes($model); |
| 155 | 155 | })))); |
| 156 | 156 | |
@@ -248,7 +248,7 @@ discard block |
||
| 248 | 248 | if (version_compare(Application::VERSION, '5.0.0', '<')) { |
| 249 | 249 | $provider->getPaginationFactory()->setPageName('page_unused'); |
| 250 | 250 | } else { |
| 251 | - Paginator::currentPageResolver(function () { |
|
| 251 | + Paginator::currentPageResolver(function() { |
|
| 252 | 252 | return 1; |
| 253 | 253 | }); |
| 254 | 254 | } |
@@ -301,7 +301,7 @@ discard block |
||
| 301 | 301 | $excel = app('excel'); |
| 302 | 302 | $excel |
| 303 | 303 | ->create($this->getFileName(), $this->getOnFileCreate()) |
| 304 | - ->store('xlsx',Storage::disk('local')->getDriver()->getAdapter()->getPathPrefix() . 'public/excels/'); |
|
| 304 | + ->store('xlsx', Storage::disk('local')->getDriver()->getAdapter()->getPathPrefix().'public/excels/'); |
|
| 305 | 305 | } |
| 306 | 306 | |
| 307 | 307 | protected function escapeString($str) |
@@ -362,7 +362,7 @@ discard block |
||
| 362 | 362 | public function getOnFileCreate() |
| 363 | 363 | { |
| 364 | 364 | if ($this->on_file_create === null) { |
| 365 | - $this->on_file_create = function (LaravelExcelWriter $excel) { |
|
| 365 | + $this->on_file_create = function(LaravelExcelWriter $excel) { |
|
| 366 | 366 | $excel->sheet($this->getSheetName(), $this->getOnSheetCreate()); |
| 367 | 367 | |
| 368 | 368 | }; |
@@ -387,7 +387,7 @@ discard block |
||
| 387 | 387 | public function getOnSheetCreate() |
| 388 | 388 | { |
| 389 | 389 | if ($this->on_sheet_create === null) { |
| 390 | - $this->on_sheet_create = function (LaravelExcelWorksheet $sheet) { |
|
| 390 | + $this->on_sheet_create = function(LaravelExcelWorksheet $sheet) { |
|
| 391 | 391 | // for($i = 0; $i < count($data); $i++) { |
| 392 | 392 | // for ($j = 0; $j < count($data[$i]); $j++) { |
| 393 | 393 | // $sheet->appendRow(($i * 1000) + $j + 1, $data[$i][$j]); |
@@ -145,8 +145,7 @@ |
||
| 145 | 145 | if($sheetName == 'topicQuestionsGrid') { |
| 146 | 146 | $topic = Topic::find($showId); |
| 147 | 147 | $this->config = $className::getQuestionsGridConfig($topic); |
| 148 | - } |
|
| 149 | - else{ |
|
| 148 | + } else{ |
|
| 150 | 149 | $this->config = $className::getGridConfig($user); |
| 151 | 150 | } |
| 152 | 151 | |
@@ -6,9 +6,9 @@ |
||
| 6 | 6 | */ |
| 7 | 7 | use Nayjest\Grids\Components\ExcelDownload; |
| 8 | 8 | $gridName = $grid->getConfig()->getName(); |
| 9 | -$visibility = DB::table('jobs')->select('id')->where('payload', 'LIKE', '%ExportExcel%')->where('payload','LIKE',"%$gridName%")->get(); |
|
| 9 | +$visibility = DB::table('jobs')->select('id')->where('payload', 'LIKE', '%ExportExcel%')->where('payload', 'LIKE', "%$gridName%")->get(); |
|
| 10 | 10 | ?> |
| 11 | -<span style="visibility:<?=file_exists(storage_path() . '/app/public/excels/' . $gridName . '.xlsx') && !!!count($visibility) ? "visible" : "hidden" ?>" > |
|
| 11 | +<span style="visibility:<?=file_exists(storage_path().'/app/public/excels/'.$gridName.'.xlsx') && !!!count($visibility) ? "visible" : "hidden" ?>" > |
|
| 12 | 12 | <a |
| 13 | 13 | href="/download/<?= $gridName ?>" target="_blank" |
| 14 | 14 | class="btn btn-sm btn-default" |
@@ -56,8 +56,8 @@ |
||
| 56 | 56 | public function initialize(Grid $grid) |
| 57 | 57 | { |
| 58 | 58 | parent::initialize($grid); |
| 59 | - $this->showId = substr(url()->current(), strrpos(url()->current(), '/' )+1); |
|
| 60 | - Event::listen(Grid::EVENT_PREPARE, function (Grid $grid) { |
|
| 59 | + $this->showId = substr(url()->current(), strrpos(url()->current(), '/') + 1); |
|
| 60 | + Event::listen(Grid::EVENT_PREPARE, function(Grid $grid) { |
|
| 61 | 61 | if ($grid->getInputProcessor()->getValue(static::INPUT_PARAM, false)) { |
| 62 | 62 | dispatch((new ExportExcel($this->getDate(), $grid->getConfig()->getName(), auth()->user()->id, $this->showId))->onQueue('default')); |
| 63 | 63 | } |