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


PHP Sitemap::leftJoin方法代码示例

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


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

示例1: allIndexData

    /**
     * Process datatables ajax request.
     * Used by 'admin.sitemap.menuIndex' via 'this.getMenuIndex()'
     * @return \Illuminate\Http\JsonResponse
     */
    public function allIndexData(Request $request, $sitemap_parent_id = 0)
    {
        /*
         * get sitemap with urlpath etc
         * */
        //dc($request->all());
        //$charts = Chart::with('company')->get();
        //$users = User::with('roles','locale','company')->get();
        $users = User::leftJoin('role_user', 'role_user.user_id', '=', 'users.id')->leftJoin('roles', 'roles.id', '=', 'role_user.role_id')->leftJoin('companies', 'companies.id', '=', 'users.company_id')->leftJoin('usertypes', 'usertypes.id', '=', 'users.usertype_id');
        //->leftJoin('sitemaps as sctest', 'sc.sitemap_category_id','=','sctest.id')
        //->leftJoin('sitemaptranslations as sctest_st','sctest.id','=','sctest_st.sitemap_id')
        $users->select(['users.id', 'users.name as user_name', 'companies.name as company_name', 'usertypes.name as usertype_name', 'users.updated_at', DB::raw("GROUP_CONCAT(roles.name SEPARATOR ', ') as roles_name")]);
        //$users->where('users.id',44);
        $users->groupBy('users.id');
        //$users = $users->get();
        //dc($users[0]);
        //$users  = User::with('roles');
        //dc($users);
        //return "view";
        //pluck('name')
        //dd($users[0]->roles->implode('label',','));
        //dd($users[0]->roles->pluck('label')->all());
        //dd($users[0]->roles[0]->label);
        $datatable = Datatables::of($users);
        //dd($datatable);
        $datatable->addColumn('action', function ($users) {
            //<input class="btn btn-cons btn-awesome btn btn-cons btn-awesome btn btn-danger" value="Delete" type="submit">
            $r = "<table><tr><td style='border:none'>";
            $r .= '<a href="' . route('admin::user.edit', ['id' => $users->id]) . '" class="btn btn-success btn-labeled fa fa-pencil mar-rgt">Wijzigen</a>';
            $r .= '</td><td>';
            $r .= "<a class=\"btn btn-danger btn-labeled fa fa-trash-o\" onclick=\"wiDeleteUser(" . $users->id . ")\">Verwijderen</a>";
            $r .= '</td></td></table>';
            return $r;
        });
        $var = '';
        /*
        $datatable->editColumn('xstatus', function ($test) use ($var) {
        	return  "asdf";
        	$statusValue = $test->status;
        	$labelValue = 'label-'.$test->status.'';
        
        	//label-concept
        	//label-pending_review
        	if ($test->status == 'pending_review'){
        		$statusValue = 'pending';
        	}
        	if ($test->status == 'public'){
        		//$statusValue = 'pun';
        		$labelValue = 'label-success';
        	}
        	if ($test->status == 'blueprint'){
        		//$statusValue = 'pun';
        		$labelValue = 'label-info';
        	}
        	return "<span class=\"labelx badge label-table ".$labelValue."\">".$statusValue."</span>";
        });
        
        $datatable->editColumn('xroles.name', function ($user) use ($var) {
        	//dc($user);
        	return "";
        	return $user->roles->implode('label',', ');
        });
        */
        $datatable->editColumn('users.updated_at', function ($user) use($var) {
            //dd($user->updated_at);
            //return 'test';
            //$retval = $user->user_updated_at ? with(new Carbon($user->user_updated_at))->diffForHumans() : '';
            //dd($retval);
            //dd($user);
            $retval = $user->updated_at ? with(new Carbon($user->updated_at))->diffForHumans() : '';
            $retval .= "<div class=\"extraDataxUIT\" style='display:none;'>";
            $retval .= "<br><date><i class=\"fa fa-clock-o\" aria-hidden=\"true\"></i> ";
            $retval .= $user->updated_at->formatLocalized('%a %d %B');
            $retval .= $user->updated_at->format(', h:i');
            $retval .= "</date>";
            $retval .= "</div>";
            //dc($user->updated_at);
            //dc($user->updated_at);
            return $retval;
            return $user->roles->implode('label', ',');
        });
        $datatable->editColumn('status', function ($test) use($sitemap_parent_id) {
            $statusValue = $test->status;
            if ($test->status == 'pending_review') {
                $statusValue = 'pending';
            }
            return "<span class=\"labelx badge label-table label-" . $test->status . "\">" . $statusValue . "</span>";
        });
        //$datatable->filter(function ($query) use ($request) {
        /*			if ($request->has('name')) {
        						$query->where('name', 'like', "%{$request->get('name')}%");
        					}
        
        					if ($request->has('email')) {
        						$query->where('email', 'like', "%{$request->get('email')}%");
//.........这里部分代码省略.........
开发者ID:wi-development,项目名称:user,代码行数:101,代码来源:UserController.php


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