50 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			50 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php
 | |
| 
 | |
| /**
 | |
|  * @var \Illuminate\Database\Eloquent\Collection $event
 | |
|  */
 | |
| 
 | |
| use Itguild\EloquentTable\ViewEloquentTable;
 | |
| use Itguild\EloquentTable\ViewJsonTableEloquentModel;
 | |
| use kernel\app_modules\event\models\Event;
 | |
| use kernel\widgets\IconBtn\IconBtnDeleteWidget;
 | |
| use kernel\widgets\IconBtn\IconBtnEditWidget;
 | |
| use kernel\widgets\IconBtn\IconBtnListWidget;
 | |
| 
 | |
| $table = new ViewEloquentTable(new ViewJsonTableEloquentModel($event, [
 | |
|     'params' => ["class" => "table table-bordered", "border" => "2"],
 | |
|     'baseUrl' => "/admin/event",
 | |
| ]));
 | |
| 
 | |
| $entityRelation = new \kernel\EntityRelation();
 | |
| $additionals = $entityRelation->getEntityAdditionalProperty("event", $event);
 | |
| 
 | |
| foreach ($additionals as $key => $additional) {
 | |
|     $table->addRow($key, function () use ($additional) {
 | |
|         return $additional;
 | |
|     }, ['after' => 'additional_info']);
 | |
| }
 | |
| 
 | |
| $table->rows([
 | |
|     'date_start' => [
 | |
|         'format' => 'date:d-m-Y',
 | |
|     ],
 | |
|     'date_end' => [
 | |
|         'format' => 'date:d-m-Y',
 | |
|     ],
 | |
|     'status' => [
 | |
|         'value' => function ($data) {
 | |
|             return Event::getStatus()[$data];
 | |
|         }
 | |
|     ]
 | |
| ]);
 | |
| 
 | |
| $table->beforePrint(function () use ($event) {
 | |
|     $btn = IconBtnListWidget::create(['url' => '/admin/event'])->run();
 | |
|     $btn .= IconBtnEditWidget::create(['url' => '/admin/event/update/' . $event->id])->run();
 | |
|     $btn .= IconBtnDeleteWidget::create(['url' => '/admin/event/delete/' . $event->id])->run();
 | |
|     return $btn;
 | |
| });
 | |
| 
 | |
| $table->create();
 | |
| $table->render(); |