Example #1
0
 /**
  * Initiate Excel sheet
  *
  * @param string $model
  * @param string $type
  * @return Excel
  */
 public function __construct($model, $type)
 {
     $model = class_replace($model);
     $this->model = $model;
     if (isset($model::$export_fields) && !empty($model::$export_fields)) {
         $fields = $model::$export_fields;
         $this->fields[] = 'id';
         foreach ($fields as $field => $properties) {
             if (!isset($properties['relation'])) {
                 $this->fields[] = $field;
             }
         }
     } else {
         $this->fields = Schema::getColumnListing((new $model())->getTable());
     }
     $this->createDocument($type);
 }
Example #2
0
 /**
  * Delete an instance of a model
  * POST request
  *
  * @param int $id
  * @param string $model
  * @return void
  */
 public function postDelete($id, $model)
 {
     $model = class_replace($model);
     $model::find($id)->delete();
     return redirect(Session::get('last_page'));
 }