当前位置: 首页>>代码示例>>PHP>>正文


PHP File::selectRaw方法代码示例

本文整理汇总了PHP中app\models\File::selectRaw方法的典型用法代码示例。如果您正苦于以下问题:PHP File::selectRaw方法的具体用法?PHP File::selectRaw怎么用?PHP File::selectRaw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\models\File的用法示例。


在下文中一共展示了File::selectRaw方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: onPageDownload

 /**
  * Index ONDownloadPage
  *
  * @return @Theme View
  */
 public function onPageDownload()
 {
     Meta::title(Lang::get('meta.file download'));
     Meta::meta('description', Lang::get('meta.file download description'));
     /*$query = \App\Models\File::leftJoin('users', 'users.id', '=' ,'files.created_by')
     		->leftJoin('companies', 'companies.id', '=' ,'files.company_id')
     		->select('files.*')
     		->selectRaw("YEAR(files.created_at) as year")
     		->addSelect("users.first_name as upload_name")
     		->addSelect("files.created_at as upload_at")
     		->addSelect("companies._id as company_id")
     		->addSelect("companies.name as company_name")
     		->where('files.active', '=', '1');
     		
     		if(Auth::user()->authorize() == 0) {
     			$query = $query->leftJoin('file_users', 'file_users.file_id', '=' ,'files.id')
     			->where('file_users.user_id','=',Auth::user()->id)
     			->where('files.company_id','=',Auth::user()->company_id)
     			->groupBy(DB::raw('YEAR(files.created_at)'));
     		} else if(Auth::user()->authorize() == 2) {
     			$query = $query->where('files.company_id','=',Auth::user()->company_id)
     			->groupBy(DB::raw('YEAR(files.created_at),MONTH(files.created_at)'));
     		}*/
     if (Auth::user()->authorize() == 0) {
         $groups = \App\Models\File::selectRaw("YEAR(files.date) as periode")->leftJoin('file_users', 'file_users.file_id', '=', 'files.id')->where('file_users.user_id', '=', Auth::user()->id)->groupBy(DB::raw('YEAR(files.date)'));
     } else {
         if (Auth::user()->authorize() == 2) {
             $groups = \App\Models\File::selectRaw("CONCAT(MONTHNAME(files.date),' ',YEAR(files.date)) as periode,MONTH(date) as month,YEAR(date) as year")->where('files.company_id', '=', Auth::user()->company_id)->groupBy(DB::raw('YEAR(files.date),MONTH(files.date)'));
         } else {
             //administrator
             $groups = \App\Models\File::selectRaw("CONCAT(MONTHNAME(files.date),' ',YEAR(files.date)) as periode,MONTH(date) as month,YEAR(date) as year")->groupBy(DB::raw('YEAR(files.date),MONTH(files.date)'));
         }
     }
     $groups = $groups->get();
     $var["grid"] = '';
     $i = 1;
     foreach ($groups as $group) {
         $var["grid"] .= '<tr id="' . $i . '" class="accordion-toggle" data-toggle="collapse" data-target=".' . $i . '">';
         $var["grid"] .= '<td colspan = "2" >' . $group->periode . '</td>';
         $var["grid"] .= '<td><i class="indicator glyphicon glyphicon-chevron-up pull-right"></i></td>';
         $var["grid"] .= '</tr>';
         $var["grid"] .= '<tr>';
         $var["grid"] .= '<td colspan="3" class="hiddenRow">';
         $var["grid"] .= '<div class="row accordion accordion-body collapse ' . $i . '"  toogle="' . $i . '">';
         if (Auth::user()->authorize() == 0) {
             $query = \App\Models\File::leftJoin('users', 'users.id', '=', 'files.created_by')->leftJoin('file_users', 'file_users.file_id', '=', 'files.id')->selectRaw("files.name,DATE_FORMAT(date,'%d/%m/%Y') as date,files.description,users.first_name as upload_name,files.created_at as upload_at");
             $query = $query->whereRaw("files.active=1 and YEAR(date) = '" . $group->periode . "' and file_users.user_id = " . Auth::user()->id)->get();
         } else {
             if (Auth::user()->authorize() == 2) {
                 $query = \App\Models\File::leftJoin('users', 'users.id', '=', 'files.created_by')->selectRaw("files.name,DATE_FORMAT(date,'%d/%m/%Y') as date,files.description,users.first_name as upload_name,files.created_at as upload_at");
                 $query = $query->whereRaw("files.active=1 and YEAR(date) = '" . $group->year . "' and MONTH(date) = '" . $group->month . "' and files.company_id = " . Auth::user()->company_id)->get();
             } else {
                 $query = \App\Models\File::leftJoin('users', 'users.id', '=', 'files.created_by')->selectRaw("files.name,DATE_FORMAT(date,'%d/%m/%Y') as date,files.description,users.first_name as upload_name,files.created_at as upload_at");
                 $query = $query->whereRaw("files.active=1 and YEAR(date) = '" . $group->year . "' and MONTH(date) = '" . $group->month . "'")->get();
             }
         }
         if ($query) {
             $var["grid"] .= '<table class="table table-striped">';
             foreach ($query as $row) {
                 $var["grid"] .= '<tr>';
                 $var["grid"] .= '<td class="col-sm-1">' . $row->date . '</td>';
                 $var["grid"] .= '<td class="col-sm-5"><a href="' . url('file/download/' . $row->name) . '">' . $row->name . '</a></td>';
                 $var["grid"] .= '<td class="col-sm-6">' . $row->description . '</td>';
                 $var["grid"] .= '</tr>';
             }
             $var["grid"] .= '</table>';
         }
         $i++;
     }
     /*$grid = new Grid(
     			 (new GridConfig)
     				->setDataProvider(
     					new EloquentDataProvider (
     						$query
     						
     					)
     				)
     				->setName('grid')
     				->setPageSize(15)
     				->setColumns([
     					(new FieldConfig)
     					->setName('year')
     					->setLabel(Lang::get('label.year'))
     					->setSortable(false)
     					->setCallback(function ($val) {
     							return '<a href="#" onclick ="detail(this,'.$val.');return false;"><i class="fa fa-plus"></i></a>';
     					})
     						,
     					(new FieldConfig)
                             ->setName('name')
                             ->setLabel(Lang::get('label.name'))
                             ->setSortable(false)
     						->setCallback(function ($val) {
     							return '<a href="'.url('file/download/'.$val).'">'.$val.'</a>';
     						})
//.........这里部分代码省略.........
开发者ID:suhe,项目名称:bdoportal,代码行数:101,代码来源:FileController.php


注:本文中的app\models\File::selectRaw方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。