Inheritance: extends NeoEloquent
Exemplo n.º 1
0
 public function save()
 {
     if (isset($this->reading) and $this->reading != '') {
         $savemodel = new Calibration();
         $savemodel->measure = 'mm';
         $savemodel->height = $this->reading;
         $savemodel->sensorid = $this->sensorid;
         $savemodel->datetime = $this->date;
         $savemodel->youremail = $this->youremail;
         $savemodel->yourname = $this->yourname;
         $result = $savemodel->save();
         $this->id = $savemodel->sensorid;
         return $result;
     } else {
         $savemodel = new File();
         $savemodel->sensorid = $this->sensorid;
         $savemodel->startdate = $this->date;
         $savemodel->enddate = $this->date;
         $savemodel->status = 'processed';
         $this->file = UploadedFile::getInstance($this, 'file');
         $savemodel->extension = end(explode(".", $this->file->name));
         $result = $savemodel->save();
         // save to get the ID
         $savemodel->filename = $savemodel->id . "_" . $this->file->name;
         $path = Yii::getAlias('@app') . Yii::$app->params['uploadPath'] . $savemodel->filename;
         if ($result) {
             $this->file->saveAs($path);
         }
         $result = $savemodel->save();
         $this->id = $savemodel->sensorid;
         return $result;
     }
 }
Exemplo n.º 2
0
 public static function UploadFile($request)
 {
     $type = FileType::findOrFail($request->input('file_type_id'));
     $file = new File();
     $filename = uniqid();
     $newname = $request->input('newname');
     if ($request->hasFile('file')) {
         if (isset($newname[0])) {
             $file->slug = str_replace(['/', '\\'], '', $newname);
         } else {
             $file->slug = $filename;
         }
         $file->filename = $filename;
         $file->file_ext = $request->file('file')->getClientOriginalExtension();
         $file->path_to_file = 'uploads/files/';
         if ($type->image) {
             $file->path_to_file = 'uploads/images/';
         }
         $destinationPath = public_path($file->path_to_file);
         $request->file('file')->move($destinationPath, $filename . '.' . $file->file_ext);
         $file->path_to_file = '/' . $file->path_to_file;
         $file->file_type_id = $type->id;
         $file->fullname = $file->filename . '.' . $file->file_ext;
         $file->description = $request->input('description');
         $file->alt_text = $request->input('alt_text');
         $file->uploader = null;
         $file->path_to_file = $file->path_to_file . $file->fullname;
         $file->save();
         return redirect()->action('FilesController@index');
     }
     return back()->withErrors(['File not found. Please try again']);
 }
Exemplo n.º 3
0
 public static function create(array $data = array())
 {
     $file = new File();
     $file->fill($data);
     $file->save();
     $element = new Element();
     $element->fill($data);
     $file->content()->save($element);
 }
Exemplo n.º 4
0
 public function testGenerateName()
 {
     $file = new File();
     $file->generateName('png');
     $pathinfo = pathinfo($file->name);
     expect($pathinfo)->hasKey('basename');
     expect($pathinfo)->hasKey('filename');
     expect($pathinfo)->hasKey('extension');
     expect($pathinfo['extension'])->equals('png');
 }
Exemplo n.º 5
0
 public function actionSave()
 {
     $item = new File();
     $periodStart = date('Y-m-d', strtotime($this->app->request->post->periodStart));
     $periodEnd = date('Y-m-d', strtotime($this->app->request->post->periodEnd));
     $this->app->request->post->periodStart = $periodStart;
     $this->app->request->post->periodEnd = $periodEnd;
     $item->fill($this->app->request->post);
     $item->save();
     $this->redirect('/sources/default/');
 }
Exemplo n.º 6
0
 /**
  * Save plugin file if its a valid file
  *
  * @param file object
  * @return String success/failure message
  */
 public static function saveDriver($file)
 {
     $fileName = $file->getClientOriginalName();
     $destination = app_path() . '/kblis/plugins/';
     try {
         $file->move($destination, $fileName);
     } catch (Exception $e) {
         Log::error($e);
         return trans('messages.unwriteable-destination-folder');
     }
     $className = "\\KBLIS\\Plugins\\" . head(explode(".", last(explode("/", $fileName))));
     // Check if the className is a valid plugin file
     if (class_exists($className)) {
         $dummyIP = "10.10.10.1";
         $instrument = new $className($dummyIP);
         if (is_subclass_of($instrument, '\\KBLIS\\Instrumentation\\AbstractInstrumentor')) {
             $instrument->getEquipmentInfo()['code'];
             return trans('messages.success-importing-driver');
         } else {
             Log::error("invalid-driver-file: " . $className);
         }
     }
     if (File::exists($destination . $fileName)) {
         File::delete($destination . $fileName);
     }
     return trans('messages.invalid-driver-file');
 }
 public function add()
 {
     $login = Auth::check('member');
     if ($this->request->data) {
         $software = Software::create($this->request->data);
         if ($software->save()) {
             $file = File::create();
             foreach ($this->request->data['myfile'] as $key => $value) {
                 $size = $this->request->data['myfile'][$key]['size'];
                 if ($size >= 600000001) {
                     $chunksize = $size / 20;
                 } else {
                     if ($size <= 600000000 && $size >= 100000000) {
                         $chunksize = $size / 10;
                     } else {
                         if ($size <= 100000000 && $size >= 10000000) {
                             $chunksize = 10000000;
                         } else {
                             $chunksize = 1000000;
                         }
                     }
                 }
                 $save = $file->save(array('file' => $value, 'software_id' => (string) $software->_id, 'chunkSize' => 10000000));
                 if (!$save) {
                     return compact('save');
                 }
             }
         }
     }
     $software = Software::create();
     return compact('login', 'software');
 }
Exemplo n.º 8
0
 public function actionEdit($id = null)
 {
     if (null === $id || 'new' === $id) {
         $this->data->item = new File();
     } else {
         $this->data->item = File::findByPK($id);
     }
 }
Exemplo n.º 9
0
 /**
  * Finds the File model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return File the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = File::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Exemplo n.º 10
0
 /**
  * Get the Complete Name for the user.
  *
  * @return string
  */
 public function setPathAttribute($path)
 {
     if (!empty($path)) {
         $title = Carbon::now()->second . $path->getClientOriginalName();
         $this->attributes['path'] = $title;
         \Storage::disk('local')->put($title, \File::get($path));
     }
 }
Exemplo n.º 11
0
 protected function saveFile(UploadedFile $file)
 {
     $upload_dir = public_path('img/avatar');
     $file_name = 'images-' . date('dmY-His') . '.' . $file->getClientOriginalExtension();
     try {
         if ($file->move($upload_dir, $file_name)) {
             $file = new File();
             $file->setAttribute('name', $file_name);
             $file->setAttribute('path', $upload_dir);
             $file->save();
             return $file->id;
         } else {
             return null;
         }
     } catch (\Exception $ex) {
         return abort(500, $ex->getMessage());
     }
 }
Exemplo n.º 12
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $filecount = \App\Models\File::where('file_type_id', $id)->count();
     if ($filecount > 0) {
         return back()->withMsg('There are files in the category');
     }
     FileType::findOrFail($id)->delete();
     return back();
 }
Exemplo n.º 13
0
 public function delete($id = null)
 {
     $user = Session::read('member');
     if ($user == "") {
         return $this->redirect('/');
     }
     $remove = File::remove('all', array('conditions' => array('documents_doc_id' => (string) $id)));
     $remove = Documents::remove('all', array('conditions' => array('_id' => (string) $id)));
     return $this->redirect('ex::dashboard');
 }
Exemplo n.º 14
0
 public function assignFileToRecord($fileId, $recordId, $record_video_type)
 {
     $file = File::findOne($fileId);
     if (!$file) {
         throw new HttpException(500, 'No file found');
     }
     $file->record_id = $recordId;
     $file->record_file_type = $record_video_type;
     return $file->save(false);
 }
Exemplo n.º 15
0
 public function delete(Request $request, $banqueId, $fileId)
 {
     // verify request inputs
     if (is_null($fileId)) {
         return response()->json(['error' => 'Bad request'], HttpResponse::HTTP_BAD_REQUEST);
     } else {
         $item = File::where('id_File', '=', $fileId)->delete();
         return is_null($item) ? response()->json(['error' => 'Bad request'], HttpResponse::HTTP_BAD_REQUEST) : $item;
     }
 }
Exemplo n.º 16
0
 /**
  * Создает экземпляр класса App\Models\File заданный путём $filePath
  * @param $filePath - относительный (от проекта), либо абсолютный путь к файлу
  * @return bool|\App\Models\File
  */
 public function createFileByPath($filePath)
 {
     $file = false;
     $filePath = File::normalizeFilePath($filePath);
     if (\File::exists($filePath)) {
         $file = $this->createFileFromUploadedFile(new SymphonyFile($filePath, false));
     } else {
         $this->setErrors(array('message' => 'File not found'));
     }
     return $file;
 }
 public function load($envName)
 {
     $cnt = 0;
     $settingsFileName = ".settings-" . $envName;
     $settingsPath = self::$app->environmentPath();
     $settingsFullFileName = $settingsPath . '/' . $settingsFileName;
     if (\File::exists($settingsFullFileName)) {
         $cnt = SettingDotEnv::load($settingsPath, $settingsFileName);
     } else {
         throw new FileNotFoundException($settingsFullFileName);
     }
     return $cnt;
 }
Exemplo n.º 18
0
 public function uploadFile(Request $request)
 {
     $user = Auth::user();
     $type = $request->type;
     $file = $request->file('file');
     $ext = strtolower($file->getClientOriginalExtension());
     $size = $file->getSize();
     $validator = Validator::make(['file' => $file, 'extension' => $ext, 'size' => $size], ['file' => 'required', 'extension' => 'required|in:csv', 'size' => 'max:100000']);
     if ($validator->fails()) {
         //dd($validator->errors());
         return Ajax::info('file format error');
     }
     $destinationPath = Config::get('app.file_path') . '/' . date('Ym', time());
     $save_path = public_path() . '/' . $destinationPath;
     $file_name = md5($file->getClientOriginalName() . time()) . '.' . $ext;
     if (!is_dir($save_path)) {
         mkdir($save_path, 755, true);
     }
     if ($file->move($save_path, $file_name)) {
         $url = url($destinationPath . '/' . $file_name);
         $file = new File();
         $file->ext = $ext;
         $file->type = $type;
         $file->name = $file_name;
         $file->path = $destinationPath . '/' . $file_name;
         $file->uid = $user->id;
         $file->url = $url;
         $file->size = $size;
         $file->created_at = time();
         $fid = $file->save();
         if ($fid) {
             return AJAX::success($result = array('url' => $url, 'name' => $file_name));
         } else {
             return AJAX::serverError();
         }
     } else {
         return AJAX::info('upload file error');
     }
 }
Exemplo n.º 19
0
 public function upload()
 {
     if ($this->validate()) {
         foreach ($this->files as $file) {
             $model = new File();
             $model->collection_id = $this->collection_id;
             $model->name = str_replace('.' . $file->extension, '', $file->name);
             $model->type = $file->type;
             $model->extension = $file->extension;
             $model->size = $file->size;
             if ($model->save()) {
                 if (!is_dir($model->filePath)) {
                     mkdir($model->filePath, 0777, true);
                 }
                 $file->saveAs($model->filePath . '/' . $model->fileName);
             }
         }
         return true;
     } else {
         return false;
     }
 }
Exemplo n.º 20
0
 public function document()
 {
     $user = Session::read('member');
     $id = md5($user['email']);
     $document = Details::find('first', array('conditions' => array('user_id' => (string) $user['_id'])));
     //		if(count($document)==0){return $this->redirect('/');}
     $uploadOk = 1;
     if ($this->request->data) {
         $extension = pathinfo($this->request->data['file']['name'], PATHINFO_EXTENSION);
         $allowed = array('pdf');
         if (!in_array(strtolower($extension), $allowed)) {
             $msg = "Sorry, only PDF files are allowed.";
             $uploadOk = 0;
         }
         if ($uploadOk = 1) {
             $option = 'doc';
             $data = array('details_' . $option . '_id' => (string) $document['_id'], 'docname' => $this->request->data['docname'], 'date' => $this->request->data['date'], 'DateTime' => new \MongoDate(), 'keywords' => $this->request->data['keywords'], 'description' => $this->request->data['description'], $option => $this->request->data['file'], $option . '.verified' => 'No', $option . '.IP' => $_SERVER['REMOTE_ADDR']);
             $field = 'details_' . $option . '_id';
             $Documents = Documents::create($data);
             $saved = $Documents->save();
             $fileData = array('file' => $this->request->data['file'], 'documents_' . $option . '_id' => (string) $Documents->_id);
             $file = File::create();
             if ($file->save($fileData)) {
                 $msg = "Upload OK";
             }
             $image_address = File::find('first', array('conditions' => array('documents_doc_id' => (string) $Documents->_id)));
             if ($image_address['filename'] != "") {
                 $imagename_address = $image_address['_id'] . '_' . $image_address['filename'];
                 $path = LITHIUM_APP_PATH . '/webroot/download/' . $imagename_address;
                 file_put_contents($path, $image_address->file->getBytes());
             }
             //		print_r($path);
             $pages = $this->getPDFPages($path);
             // Output: 13
             //				print_r($pages);exit;
             unlink($path);
             $docdata = array();
             foreach ($pages as $page) {
                 $params = explode(":", $page);
                 $left = $params[0];
                 $right = $params[1];
                 $docdata = array_merge($docdata, array($left => trim($right)));
             }
             $data = array("document" => $docdata);
             $conditions = array("_id" => (string) $Documents->_id);
             Documents::update($data, $conditions);
             // Use the function
         }
     }
     return $this->redirect('ex::save');
 }
Exemplo n.º 21
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = File::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'rec_id' => $this->rec_id, 'type_id' => $this->type_id, 'rec_status_id' => $this->rec_status_id, 'user_id' => $this->user_id, 'dc' => $this->dc]);
     $query->andFilterWhere(['like', 'table_name', $this->table_name])->andFilterWhere(['like', 'class_name', $this->class_name])->andFilterWhere(['like', 'file_name', $this->file_name])->andFilterWhere(['like', 'file_path', $this->file_path])->andFilterWhere(['like', 'note', $this->note]);
     return $dataProvider;
 }
Exemplo n.º 22
0
Arquivo: Car.php Projeto: x-Zyte/nhp
 public static function boot()
 {
     parent::boot();
     static::creating(function ($model) {
         $model->issold = false;
         $model->isregistered = false;
         $model->isdelivered = false;
         $model->dodate = date('Y-m-d', strtotime($model->dodate));
         $model->receiveddate = date('Y-m-d', strtotime($model->receiveddate));
         $model->createdby = Auth::user()->id;
         $model->createddate = date("Y-m-d H:i:s");
         $model->modifiedby = Auth::user()->id;
         $model->modifieddate = date("Y-m-d H:i:s");
     });
     static::created(function ($model) {
         Log::create(['employeeid' => Auth::user()->id, 'operation' => 'Add', 'date' => date("Y-m-d H:i:s"), 'model' => class_basename(get_class($model)), 'detail' => $model->toJson()]);
         $rs = DB::select('call running_number("' . $model->provinceid . date("Y") . '","' . $model->receivetype . '")');
         $model->no = $rs[0]->no;
         $min = KeySlot::where('provinceid', $model->provinceid)->where('active', true)->min('no');
         if ($min == null) {
             $branch = Branch::where('provinceid', $model->provinceid)->where('isheadquarter', true)->first();
             $branch->keyslot = $branch->keyslot + 1;
             $branch->save();
             $model->keyno = $branch->keyslot;
         } else {
             $model->keyno = $min;
         }
         $model->save();
         KeySlot::where('provinceid', $model->provinceid)->where('no', $model->keyno)->update(['active' => false]);
     });
     static::updating(function ($model) {
         $model->dodate = date('Y-m-d', strtotime($model->dodate));
         $model->receiveddate = date('Y-m-d', strtotime($model->receiveddate));
         $model->modifiedby = Auth::user()->id;
         $model->modifieddate = date("Y-m-d H:i:s");
     });
     static::updated(function ($model) {
         Log::create(['employeeid' => Auth::user()->id, 'operation' => 'Update', 'date' => date("Y-m-d H:i:s"), 'model' => class_basename(get_class($model)), 'detail' => $model->toJson()]);
     });
     static::deleted(function ($model) {
         Log::create(['employeeid' => Auth::user()->id, 'operation' => 'Delete', 'date' => date("Y-m-d H:i:s"), 'model' => class_basename(get_class($model)), 'detail' => $model->toJson()]);
         if ($model->receivecarfilepath != '') {
             File::delete(public_path() . $model->receivecarfilepath);
         }
         if ($model->deliverycarfilepath != '') {
             File::delete(public_path() . $model->deliverycarfilepath);
         }
         KeySlot::where('provinceid', $model->provinceid)->where('no', $model->keyno)->update(['active' => true]);
     });
 }
Exemplo n.º 23
0
 /**
  * Register any other events for your application.
  *
  * @param \Illuminate\Contracts\Events\Dispatcher $events
  */
 public function boot(DispatcherContract $events)
 {
     parent::boot($events);
     // Generate a unique hash for a song from its path to be the ID
     Song::creating(function ($song) {
         $song->id = File::getHash($song->path);
     });
     // Remove the cover file if the album is deleted
     Album::deleted(function ($album) {
         if ($album->hasCover) {
             @unlink(app()->publicPath() . '/public/img/covers/' . $album->cover);
         }
     });
 }
Exemplo n.º 24
0
 /**
 * Creates data provider instance with search query applied
 *
 * @param array $params
 *
 * @return ActiveDataProvider
 */
 public function search($params)
 {
     $query = File::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'startdate' => $this->startdate, 'enddate' => $this->enddate, 'sensorid' => $this->sensorid]);
     $query->andFilterWhere(['like', 'filelink', $this->filelink])->andFilterWhere(['like', 'filename', $this->filename])->andFilterWhere(['like', 'extension', $this->extension])->andFilterWhere(['like', 'status', $this->status]);
     return $dataProvider;
 }
Exemplo n.º 25
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = File::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'user_id' => $this->user_id, 'size' => $this->size, 'date_entered' => $this->date_entered, 'date_updated' => $this->date_updated]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'type', $this->type])->andFilterWhere(['like', 'description', $this->description]);
     return $dataProvider;
 }
Exemplo n.º 26
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = File::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['file_id' => $this->file_id, 'file_time' => $this->file_time, 'file_msg_id' => $this->file_msg_id, 'file_user_id' => $this->file_user_id, 'file_size' => $this->file_size]);
     $query->andFilterWhere(['like', 'file_orig_name', $this->file_orig_name])->andFilterWhere(['like', 'file_type', $this->file_type])->andFilterWhere(['like', 'file_name', $this->file_name]);
     return $dataProvider;
 }
Exemplo n.º 27
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = File::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'filename', $this->filename])->andFilterWhere(['like', 'avatar', $this->avatar])->andFilterWhere(['like', 'type', $this->type]);
     return $dataProvider;
 }
Exemplo n.º 28
0
 private function saveHeaders($file, $fileID)
 {
     //create the path
     $fileName = base_path() . "/public/files/" . $file->getClientOriginalName();
     //create the empty arrays
     $columnTitles = [];
     $taxonomyArray = [];
     $fieldArray = [];
     //load the file
     $rows = Excel::load($fileName, function ($reader) {
     })->get();
     //set the values of the columns as the header
     foreach ($rows as $title => $value) {
         //set the row data
         foreach ($value as $key => $column) {
             $columnTitles[$key][] = $column;
         }
     }
     $files = File::find($fileID);
     foreach ($columnTitles as $key => $value) {
         $field_tax = Field_Taxonomy::where('title', '=', $key);
         $fieldTaxID = 0;
         $count = 1;
         //if the title doesn't exist as a record in the field_tax table
         if ($field_tax->count() === 0) {
             //grab the id of the newly inserted taxonomy record
             $fieldTaxID = Field_Taxonomy::insertGetId(['title' => $key]);
             foreach ($value as $data) {
                 Field::insert(['value' => $data, 'field_taxonomy_id' => $fieldTaxID, 'row_in_file' => $count]);
                 $count++;
             }
             File_Field_Taxonomy::insert(['file_id' => $fileID, 'field_taxonomy_id' => $fieldTaxID]);
         } else {
             $fileArr = explode(".", $file->getClientOriginalName());
             $fileTitleArr = explode("_", $fileArr[0]);
             $fieldTax = Field_Taxonomy::take(1)->select('field_taxonomy_table.id')->join('file_field_taxonomy_table', 'file_field_taxonomy_table.field_taxonomy_id', '=', 'field_taxonomy_table.id')->join('files', 'files.id', '=', 'file_field_taxonomy_table.file_id')->where('title', '=', $key)->where('parsed_title', '=', $fileTitleArr[0])->get();
             if (count($fieldTax) > 0) {
                 $fieldTaxID = $fieldTax[0]->id;
             } else {
                 $fieldTaxID = Field_Taxonomy::insertGetId(['title' => $key]);
             }
             foreach ($value as $data) {
                 Field::insert(['value' => $data, 'field_taxonomy_id' => $fieldTaxID, 'row_in_file' => $count]);
                 $count++;
             }
             File_Field_Taxonomy::insert(['file_id' => $fileID, 'field_taxonomy_id' => $fieldTaxID]);
         }
     }
 }
Exemplo n.º 29
0
 public function search($input)
 {
     $query = File::query();
     $columns = Schema::getColumnListing('files');
     $attributes = array();
     foreach ($columns as $attribute) {
         if (isset($input[$attribute]) and !empty($input[$attribute])) {
             $query->where($attribute, $input[$attribute]);
             $attributes[$attribute] = $input[$attribute];
         } else {
             $attributes[$attribute] = null;
         }
     }
     return [$query->get(), $attributes];
 }
Exemplo n.º 30
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index($date, $file)
 {
     /*$fields = Field::select('fields.value', 'field_taxonomy_table.title')
           ->join('field_taxonomy_table', 'fields.field_taxonomy_id', '=', 'field_taxonomy_table.id')
           ->join('files', 'field_taxonomy_table.file_id', '=', 'files.id')
           ->where('files.parsed_title', '=', $file)
           ->get();
       dd($fields);*/
     $fields = File::join('file_field_taxonomy_table as fftt', 'fftt.file_id', '=', 'files.id')->join('field_taxonomy_table as ftt', 'fftt.field_taxonomy_id', '=', 'ftt.id')->where('files.parsed_title', '=', $file)->select('ftt.title', 'ftt.id')->groupBy('ftt.title');
     if ($file === "claimsbybatch") {
         $fields = $fields->where('title', '=', 'claim_status_ud')->orWhere('title', '=', 'claim_procedure_status_ud')->orWhere('title', '=', 'from_service_date')->orWhere('title', '=', 'clean_claim_date')->orWhere('title', '=', 'received_date')->orWhere('title', '=', 'benefitplan_ud');
     }
     $titleArr = [];
     //loop through all of the results
     foreach ($fields->get() as $field) {
         //split the title at the underscore
         $title = explode('_', $field->title);
         $count = 0;
         $isDate = false;
         $type = "string";
         $arrValues = [];
         //loop through the title arr
         foreach ($title as $word) {
             if ($word === "date") {
                 $isDate = true;
             }
             //remove the "ud" from the title arr
             if ($word === "ud") {
                 unset($title[$count]);
             } else {
                 //if it's benefit plan, then split it up
                 if ($title[$count] === "benefitplan") {
                     $title[$count] = "benefit plan";
                 }
                 //make each word proper case
                 $title[$count] = ucfirst($title[$count]);
             }
             $count++;
         }
         if ($isDate) {
             $titleArr['date'][] = ['title' => implode(' ', $title), 'db_title' => $field->title, 'value' => $arrValues];
         } else {
             $arrValues = Field_Taxonomy::select('value')->distinct()->join('fields', 'fields.field_taxonomy_id', '=', 'field_taxonomy_table.id')->where('title', '=', $field->title)->get();
             $titleArr['other'][] = ['title' => implode(' ', $title), 'db_title' => $field->title, 'value' => $arrValues];
         }
     }
     return view("reports.main")->with('data', $titleArr);
 }