如何从其他方法调用所有变量并在同一视图中返回

时间:2019-04-20 16:50:04

标签: php laravel controller routes

我需要帮助。我想传递所有变量,在索引中调用并在同一视图中返回。如何调用perFolder方法以及如何在perFolder方法(如userj)中调用variabel。


class fileCount extends Controller {

    public function index() {
        $fj = $this->perFolder();
        $users = DB::table('files')->where('created_by_id', '=', '1')->count();
        $users2 = DB::table('files')->where('created_by_id', '=', '2')->count();
        $users3 = DB::table('files')->where('created_by_id', '=', '3')->count();
        $users4 = DB::table('files')->where('created_by_id', '=', '4')->count();
        $users5 = DB::table('files')->where('created_by_id', '=', '5')->count();
        $users6 = DB::table('files')->where('created_by_id', '=', '6')->count();
        $users7 = DB::table('files')->where('created_by_id', '=', '7')->count();
        $users8 = DB::table('files')->where('created_by_id', '=', '8')->count();
        $users9 = DB::table('files')->where('created_by_id', '=', '9')->count();
        $users10 = DB::table('files')->where('created_by_id', '=', '10')->count();
        $users71 = DB::table('files')->where('created_by_id', '=', '11')->count();


        //$row_count=DB::table('media')->where('file_name', '>', '1')->count();
        $row_count = DB::table('media')
                ->select('file_name', DB::raw('COUNT(*) as `count`'))
                ->groupBy('file_name')
                ->havingRaw('COUNT(*) > 1')
                ->get();
        //$row_count = DB::table('media')->where('file_name', '=', $file_name)->count();

        return view('admin.report.index2', compact('users', 'users2', 'users3', 'users4', 'users5', 'users6', 'users7', 'users8', 'users9', 'users10', 'users71', 'row_count'));

    }

    public function perFolder() {

        $userj = DB::table('files')->where('created_by_id', '=', '1')->where('folder_id', '=', '1')->count();
        $userj2 = DB::table('files')->where('created_by_id', '=', '2')->where('folder_id', '=', '2')->count();

        return view('admin.report.index2', compact('userj','userj2'));
    }

}

0 个答案:

没有答案