コード例 #1
0
ファイル: StorageController.php プロジェクト: hunglmtb/eb
 protected function afterSave($resultRecords, $occur_date)
 {
     //     	\DB::enableQueryLog();
     $tankDataValue = TankDataValue::getTableName();
     $tank = Tank::getTableName();
     $columns = [\DB::raw("sum(BEGIN_VOL) \tas\tBEGIN_VOL"), \DB::raw("sum(END_VOL) \t\t\tas\tEND_VOL"), \DB::raw("sum(BEGIN_LEVEL) \t\tas\tBEGIN_LEVEL"), \DB::raw("sum(END_LEVEL) \t\tas\tEND_LEVEL"), \DB::raw("sum(TANK_GRS_VOL) \t\tas\tGRS_VOL"), \DB::raw("sum(TANK_NET_VOL) \t\tas\tNET_VOL"), \DB::raw("sum(AVAIL_SHIPPING_VOL) as\tAVAIL_SHIPPING_VOL")];
     $attributes = ['OCCUR_DATE' => $occur_date];
     $storage_ids = [];
     foreach ($resultRecords as $mdlName => $records) {
         //     		$mdl = "App\Models\\".$mdlName;
         //     		$mdlRecords = $mdl::with('Tank')->whereIn();
         foreach ($records as $mdlRecord) {
             $storageID = $mdlRecord->getStorageId();
             if ($storageID) {
                 $storage_ids[] = $storageID;
             }
         }
     }
     $storage_ids = array_unique($storage_ids);
     foreach ($storage_ids as $storage_id) {
         $values = TankDataValue::join($tank, function ($query) use($tankDataValue, $tank, $storage_id) {
             $query->on("{$tank}.ID", '=', "{$tankDataValue}.TANK_ID")->where("{$tank}.STORAGE_ID", '=', $storage_id);
         })->whereDate('OCCUR_DATE', '=', $occur_date)->select($columns)->first();
         $attributes['STORAGE_ID'] = $storage_id;
         $values = $values->toArray();
         $values['STORAGE_ID'] = $storage_id;
         $values['OCCUR_DATE'] = $occur_date;
         StorageDataValue::updateOrCreate($attributes, $values);
     }
     //     	\Log::info(\DB::getQueryLog());
 }
コード例 #2
0
ファイル: ChartController.php プロジェクト: extjac/qops01
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index(Request $request)
 {
     $date = date('Y-m-');
     $compliance = TicketItem::select(\DB::raw("  IFNULL( Sum(`tickets_items`.`weight` * `tickets_items`.`score` ) ,0)  AS score "))->join('ticket', 'ticket.id', '=', 'tickets_items.id')->groupBy('requester')->get();
     $tickets = Ticket::select('requester', \DB::raw("count(ticket.requester) AS requesters "))->groupBy('requester')->get();
     return \Response::json(["legends" => $tickets->lists('requester'), "set1" => $tickets->lists('requesters'), "set2" => $compliance->lists('score')], 200, [], JSON_NUMERIC_CHECK);
 }
コード例 #3
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($type, $id)
 {
     if ($id == 'video') {
         $events = Video::all();
         return view('video.show', compact('events'));
     } elseif ($id == 'staff') {
         $events = Staff::all();
         return view('staff.show', compact('events'));
     } elseif ($id == 'gallery') {
         $events = Image::all();
         return view('gallery.show', compact('events'));
     } else {
         $event = Event::where('slug', $id)->where('type', $type)->first();
         $location = Location::where('event_id', $event->id)->first();
         $slider = EventImage::where('event_id', $event->id)->orderBy(\DB::raw('RAND()'))->take(4)->get();
         $gallery = EventImage::where('event_id', $event->id)->first();
         if ($event->type == $type) {
             if ($event->status == 1) {
                 return view($type . '.show', compact('event', 'location', 'slider', 'gallery'));
             } else {
                 return redirect('/' . $type . '/');
             }
         }
     }
 }
コード例 #4
0
ファイル: publiController.php プロジェクト: vik0x/enfoque
 public function index2()
 {
     $data = ['publicidades' => \App\publicidad::leftJoin('tipo_galeria as tg', 'tg.id_tipo_galeria', '=', 'publicidad.seccion')->select('id_publicidad', 'cliente', \DB::raw('DATE(fecha_inicio) as fecha_inicio'), 'tg.nombre as seccion', 'posicion', 'url', 'link', 'publicidad.activo')->get(), 'categorias' => \App\tipo_galeria::select('id_tipo_galeria as id', 'nombre')->get()];
     // dd($data);
     return view('admin.publicidades', $data);
     // return view('admin.publicidades',$data);
 }
コード例 #5
0
 public function index(Request $request)
 {
     /*
      * session()->keep here is used to retain the lesson id even if the user refreshes the page
      * this keeps the lesson id hidden to the user and inaccessible by anyone else
      * the lesson id is not retained when navigating away from the page so the page will be inaccessible once done
      */
     $lessonId = session('lessonId');
     // If lesson id does not exist in the session, do not allow access to the page
     if (!isset($lessonId)) {
         return redirect('lessons');
     }
     $user = auth()->user();
     $words = Word::orderBy(\DB::raw('RAND()'))->take(80)->get();
     $questions = LessonWord::with('word')->where('lesson_id', $lessonId)->get();
     session()->flash('maxQuestions', count($questions));
     if (empty(session('questionIndex'))) {
         session()->flash('questionIndex', 0);
         // Start with index zero
     } else {
         session()->keep('questionIndex');
     }
     $generatedOptions = $this->generateOptions($questions, $words);
     // Pass this to view
     if ($generatedOptions == null) {
         return redirect('lessons');
         // Return users to lesson page if they try to go back to the finished exam
     }
     return view('lessons.exam', ['user' => $user, 'questions' => $questions, 'options' => $generatedOptions]);
 }
コード例 #6
0
ファイル: DriverController.php プロジェクト: acmadi/diantaksi
 /**
  * [FunctionName description]
  * @param string $value [description]
  */
 public function activity()
 {
     $lastdate = \Carbon\Carbon::now()->subMonths(3);
     $checkins = $this->checkins->with('driver')->select(\DB::raw("*, COUNT(*) as activity , \n                            MONTHNAME(operasi_time) as mountname,\n                            MONTH(operasi_time) as mount"))->where('pool_id', $this->user->pool_id)->where('operasi_status_id', 1)->where('operasi_time', '>=', $lastdate->format('Y-m-d'))->where(\DB::raw('YEAR(operasi_time)'), date('Y'))->groupBy('driver_id')->groupBy(\DB::raw('MONTH(operasi_time)'))->get();
     //dd($drivers);
     return view('drivers.activity', compact('checkins'));
 }
コード例 #7
0
 public function divideTeam($team, $min, $max, $boolit, $compID)
 {
     $len = count($team);
     $numTeam = $len / $min;
     $totalTeam = array();
     //$team = array_flip($team);
     //return $team;
     if ($boolit) {
         $a = array_keys($team);
     } else {
         $a = $team;
     }
     //print_r($a);
     while (count($a) >= $min) {
         $t = array();
         while (count($t) < $min) {
             array_push($t, array_pop($a));
             $a = array_reverse($a);
         }
         array_push($totalTeam, $t);
     }
     if (count($a) > 0 && count($totalTeam) > 0) {
         $i = 0;
         foreach ($a as $b) {
             array_push($totalTeam[$i % count($totalTeam)], $b);
             $i = $i + 1;
         }
     }
     $unsorted = array();
     $teamteam = array();
     //return $totalTeam;
     foreach ($totalTeam as $c) {
         if (count($c) > $max) {
             while (count($c) > $max) {
                 print_r($c);
                 array_push($unsorted, array_pop($c));
             }
             array_push($teamteam, $c);
         } else {
             array_push($teamteam, $c);
         }
     }
     if (count($teamteam) > 0) {
         foreach ($teamteam as $t) {
             team::create(['competition' => $compID, 'teamName' => 'Unnamed Team']);
             $val = \DB::select(\DB::raw('(SELECT max(teamID) as i FROM team)'));
             $teamID = $val[0]->i;
             foreach ($t as $s) {
                 //print_r($s);
                 //print_r(',');
                 team_contents::create(['teamID' => $teamID, 'studentID' => $s]);
                 \DB::table('student_competition')->where('studentID', '=', $s)->delete();
             }
         }
     }
     if (count($totalTeam == 0)) {
         return $a;
     }
     return $unsorted;
 }
コード例 #8
0
 public function indexjson($month, $year)
 {
     $eventList1 = Events::where('e_type', 'single')->where(\DB::raw('MONTH(e_date)'), '=', $month)->where(\DB::raw('YEAR(e_date)'), '=', $year)->orWhere('e_type', 'annual')->where(\DB::raw('MONTH(e_date)'), '=', $month)->where(\DB::raw('YEAR(e_date)'), '<=', $year)->get();
     $eventList2 = Events::where('e_type', '!=', 'single')->where('e_type', '!=', 'annual')->get();
     $eventList = $eventList1->merge($eventList2);
     return response()->json($eventList);
 }
コード例 #9
0
ファイル: HomeController.php プロジェクト: thuatnt2/QLNV-l5
 /**
  * Show the application dashboard.
  *
  * @return Response
  */
 public function index()
 {
     $users = \DB::table('users')->join('orders', 'orders.manager', '=', 'users.id')->groupBy('orders.manager')->select('users.*', \DB::raw('count(manager) as total'))->get();
     $orders = new OrderRepository(new Order());
     $managers = $orders->findAllManager('success', 'monitor', ['*'], true);
     return view('home', compact('users', 'managers'));
 }
コード例 #10
0
ファイル: PageController.php プロジェクト: kjellberg/affecms
 /**
  * Display FRONT PAGE
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $programs = \App\Program::orderBy(\DB::raw('RAND()'))->take(4)->get();
     $programs_high_bonus = \App\Program::orderBy(\DB::raw('RAND()'))->take(4)->get();
     $program_logos = \App\Program::get(array('logo_bgcolor', 'slug'));
     return view(\App\Template::view('page.front-page'))->with(['menu_item' => 'home', 'edit_mode' => false, 'programs' => $programs, 'programs_high_bonus' => $programs_high_bonus, 'program_logos' => $program_logos]);
 }
コード例 #11
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $status = Input::get('status');
     if ($status == 'comment') {
         $comment_new = User_App_Comment::join('apps', 'apps.id', '=', 'user__app__comments.a_id')->join('users', 'users.id', '=', 'user__app__comments.u_id')->select('user__app__comments.id', 'users.name as user_name', 'users.id as user_id', 'apps.name as app_name', 'apps.id as app_id', 'apps.img_url as app_img', 'comment', 'user__app__comments.created_at')->orderBy('user__app__comments.created_at', 'desc')->take(5)->get();
         return $comment_new;
     }
     //multisearch
     $app_list = App::leftjoin('user__app__favorite', 'user__app__favorite.a_id', '=', 'apps.id')->select('apps.id', 'apps.name', 'apps.img_url', 'apps.rating_users', 'apps.genre', 'apps.rating', \DB::raw('count(user__app__favorite.id) as favorite_count'))->groupBy('apps.id')->orderBy('apps.rating_users', 'desc')->orderBy('id', 'asc');
     if (Input::has('name')) {
         $name = Input::get('name');
         $app_list->where('apps.name', 'LIKE', '%' . $name . '%');
     }
     if (Input::has('genre')) {
         $genre = Input::get('genre');
         $app_list->where('apps.genre', '=', $genre);
     }
     if (Input::has('skip')) {
         $skip = Input::get('skip');
         $app_list->skip($skip);
     }
     $apps = $app_list->take(10)->get();
     if (empty($apps->first())) {
         return Response::json(array('message' => 'Empty Query Man~', 'status' => 'error'));
     } else {
         foreach ($apps as $key => $value) {
             $app_comment_counts = App::join('user__app__comments', 'user__app__comments.a_id', '=', 'apps.id')->where('apps.id', '=', $value['id'])->count();
             //$value->suck_count = $app_suck_counts;
             $value->app_comment = $app_comment_counts;
         }
         return $apps;
     }
 }
コード例 #12
0
 public function login_auth()
 {
     $user_id = Request::get('user_id');
     $user_password = Request::get('user_password');
     $result_list = \DB::select(\DB::raw("SELECT * FROM user_table"));
     foreach ($result_list as $result) {
         if ($result->user_id == $user_id) {
             if ($result->user_password == $user_password) {
                 if ($result->user_type == 'admin') {
                     $_SESSION['TICKET_USER_ID'] = $user_id;
                     $_SESSION['TICKET_USER_TYPE'] = $user_type;
                     return view('ticket_views.home');
                 }
                 if ($result->user_type == 'user') {
                     $client_id = $result->client_id;
                     if ($client_id == 'c_robi') {
                         $_SESSION['TICKET_USER_ID'] = $user_id;
                         $_SESSION['TICKET_USER_TYPE'] = $result->user_type;
                         $_SESSION['TICKET_USER_CLIENT_ID'] = $client_id;
                         $_SESSION['TICKET_USER_CLIENT_TYPE'] = 'telco';
                         return view('ticket_views.create_ticket_client');
                     }
                 }
             }
         }
     }
 }
コード例 #13
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show(Request $request)
 {
     $fromDate = $request['fromDate'] . " 00:00:00";
     $toDate = $request['toDate'] . " 23:59:59";
     $precinct = $request['precinct'];
     if ($precinct == "0") {
         $precinct = "%";
     }
     $department = $request['department'];
     if ($department == "0") {
         $department = "%";
     }
     $category = $request['category'];
     if ($category == "0") {
         $category = "%";
     }
     $status = $request['status'];
     if ($status == "0") {
         $status = "%";
     }
     $reporter = $request['reporter'];
     if ($reporter == "0") {
         $reporter = "%";
     }
     $cases = \DB::table('cases')->join('departments', 'cases.department', '=', 'departments.id')->join('municipalities', 'cases.precinct', '=', 'municipalities.id')->join('users', 'cases.reporter', '=', 'users.id')->join('categories', 'cases.category', '=', 'categories.id')->select(\DB::raw("\n                                        cases.id,\n                                        cases.created_at,\n                                        cases.description,\n                                        cases.status,\n                                        cases.priority,\n                                        cases.severity,\n                                        departments.name as department,\n                                        municipalities.name as precinct,\n                                        IF(`cases`.`addressbook` = 1,(SELECT CONCAT(`FirstName`, ' ', `Surname`) FROM `addressbook` WHERE `addressbook`.`id`= `cases`.`reporter`), (SELECT CONCAT(users.`name`, ' ', users.`surname`) FROM `users` WHERE `users`.`id`= `cases`.`reporter`)) as reporterName,\n                                        categories.name as category\n                                    "))->whereBetween('cases.created_at', array($fromDate, $toDate))->where('municipalities.slug', 'LIKE', $precinct)->where('departments.slug', 'LIKE', $department)->where('categories.slug', 'LIKE', $category)->where('cases.status', 'LIKE', $status)->whereRaw("CONCAT(`users`.`name`, ' ', `users`.`surname`) LIKE '{$reporter}'")->groupBy('cases.id');
     return \Datatables::of($cases)->addColumn('actions', '<a class="btn btn-xs btn-alt" data-toggle="modal" onClick="launchCaseModal({{$id}});" data-target=".modalCase">View</a>')->make(true);
 }
コード例 #14
0
ファイル: HomeController.php プロジェクト: J1Duran/adminPh
 /**
  * Show the application dashboard.
  *
  * @return Response
  */
 public function index()
 {
     $days = Input::get('days', 7);
     $range = \Carbon\Carbon::now()->subDays($days);
     $stats = User::where('created_at', '>=', $range)->groupBy('date')->orderBy('date', 'DESC')->remember(1440)->get([DB::raw('Date(created_at) as date'), DB::raw('COUNT(*) as value')])->toJSON();
     // return view('home');
     $this->layout->content = View::make('home', compact('stats'));
 }
コード例 #15
0
 public function customer_data()
 {
     \DB::statement(\DB::raw('set @rownum=0'));
     $customers = Customer::select([\DB::raw('@rownum  := @rownum  + 1 AS rownum'), 'id', 'name', 'address', 'phone', 'membership']);
     return Datatables::of($customers)->addColumn('action', function ($customer) {
         return '<a href="./customer/edit/' . $customer->id . '" class="btn btn-xs btn-primary"><i class="glyphicon glyphicon-edit"></i> Edit</a>';
     })->make(true);
 }
コード例 #16
0
 public function index()
 {
     $products = Product::get();
     $articles = Blog::orderBy('id', 'DESC')->take(4)->get();
     $galleries = Gallery::orderBy(\DB::raw('RAND()'))->take(5)->get();
     $setting = Setting::first();
     return view('sites.index', compact('products', 'articles', 'galleries', 'setting'));
 }
コード例 #17
0
ファイル: HomeController.php プロジェクト: RuseHackV2/MeetUpr
 public function index()
 {
     $boardgames = Boardgame::all();
     $mostPlayedGames = \DB::table('events')->join('boardgames', 'boardgames.id', '=', 'events.boardgame_id')->whereNotNull('events.boardgame_id')->groupBy('events.boardgame_id')->select(array('boardgames.*', \DB::raw('count(*) AS c')))->take(10)->orderBy('c', 'desc')->get();
     $nearEvents = \DB::table('events')->join('users', 'events.user_id', '=', 'users.id')->join('boardgames', 'boardgames.id', '=', 'events.boardgame_id')->where('event_date', '>', date('Y-m-d H:i'))->take(10)->orderBy('event_date', 'asc')->get(['users.name as host', 'users.avatar as host_avatar', 'events.name', 'boardgames.name as game_name', 'boardgames.image as game_image', 'boardgames.url as game_url']);
     $var = ["mostPlayedGames" => $mostPlayedGames, "boardgames" => $boardgames, "nearEvents" => $nearEvents];
     return view('home.index', $var);
 }
コード例 #18
0
 public function getIndex()
 {
     $list = Recipes::with('item', 'item.name')->select('*', 'recipes.id AS recipe_id')->join('items AS i', 'i.id', '=', 'recipes.item_id')->join('translations AS t', 't.id', '=', 'i.name_' . Config::get('language'))->orderBy(\DB::raw('RAND()'))->paginate(10);
     $crafting_job_list = ClassJob::with('name', 'en_abbr')->whereIn('id', Config::get('site.job_ids.crafting'))->get();
     $job_list = ClassJob::get_name_abbr_list();
     $crafting_list_ids = array_keys(Session::get('list', []));
     return view('recipes.index', compact('list', 'crafting_job_list', 'job_list', 'crafting_list_ids'));
 }
コード例 #19
0
ファイル: ItemController.php プロジェクト: thesaputra/xyz-prx
 public function item_data()
 {
     \DB::statement(\DB::raw('set @rownum=0'));
     $items = Item::select([\DB::raw('@rownum  := @rownum  + 1 AS rownum'), 'id', 'name']);
     return Datatables::of($items)->addColumn('action', function ($item) {
         return '<a href="./item/edit/' . $item->id . '" class="btn btn-xs btn-primary"><i class="glyphicon glyphicon-edit"></i> Edit</a>';
     })->make(true);
 }
コード例 #20
0
 public function getSuggestions(Request $request)
 {
     $username = $request->username;
     try {
         //$user1ID = User::where('username', $username)->get();
         //return response()->json(['status' => 200, 'suggestions' => $user1ID], 200);
         $userId = User::where('username', $username)->get(['id'])[0]->id;
         $userPreferences = self::userPreferences($userId);
         $orientation = User::where('username', $username)->get()[0]->orientation;
         $gender = User::where('username', $username)->get()[0]->gender;
         $location = $userPreferences[0]->location;
         $minage = $userPreferences[0]->mixage;
         $maxage = $userPreferences[0]->maxage;
         $status = $userPreferences[0]->status;
         $shortterm = $userPreferences[0]->shortterm;
         $longterm = $userPreferences[0]->longtterm;
         $causalsex = $userPreferences[0]->casualsex;
         //$result = User::orderBy(\DB::raw('RAND()'))->limit(3)->get();
         $users = User::orderBy(\DB::raw('RAND()'))->limit(3)->get();
         $suggestedUsers = [];
         foreach ($users as $user) {
             //changed id ///
             $id = 1;
             $takenUserPreferences = self::userPreferences($id);
             $usernameT = User::where('id', $id)->get()[0]->username;
             $orientationT = User::where('id', $id)->get()[0]->orientation;
             $genderT = User::where('id', $id)->get()[0]->gender;
             if ($orientation == $orientationT && $gender == $genderT && $username == $usernameT) {
                 break;
             }
             $locationT = $takenUserPreferences[0]->location;
             $minageT = $takenUserPreferences[0]->mixage;
             $maxageT = $takenUserPreferences[0]->maxage;
             $statusT = $takenUserPreferences[0]->status;
             $shorttermT = $takenUserPreferences[0]->shortterm;
             $longtermT = $takenUserPreferences[0]->longterm;
             $causalsexT = $takenUserPreferences[0]->casualsex;
             $locationMatch = self::matchLocation($userId, $id, $location, $locationT);
             $ageMatch = self::matchAge($minage, $maxage, $minageT, $maxageT);
             $statusMatch = self::matchStatus($status, $statusT);
             $shortTermMatch = self::matchLongTermRel($shortterm, $shorttermT);
             $longTermMatch = self::matchShortTermRel($longterm, $longtermT);
             $casualSexMatch = self::matchCasualSex($causalsex, $causalsexT);
             $matchPercentage = self::calculateMatchPercentage($locationMatch, $ageMatch, $statusMatch, $longTermMatch, $shortTermMatch, $casualSexMatch);
             if ($matchPercentage >= 0.45) {
                 array_push($suggestedUsers, $user);
             }
         }
         if ($suggestedUsers) {
             return response()->json(['status' => 200, 'suggestions' => $suggestedUsers], 200);
         } else {
             return response()->json(['status' => 200, 'suggestions' => null], 200);
         }
     } catch (Illuminate\Database\QueryException $e) {
         return response()->json(['status' => 200], 200);
     }
 }
コード例 #21
0
ファイル: HomeController.php プロジェクト: davila7/kayra
 public function IndexAdmin()
 {
     $opex = Opex::whereYear('fecha', '=', date('Y'))->selectRaw('sum(monto) as monto, fecha as mes')->groupBy(\DB::raw('MONTH(fecha)'))->get();
     $alumnos_activos = Role::find(1)->users()->where('cuenta_activa', true)->count();
     $alumnos_totales = Role::find(1)->users()->count();
     $coachs = Role::find(2)->users()->where('cuenta_activa', true)->count();
     $pagos = PagoMensualidad::whereYear('fecha_pago', '=', date('Y'))->selectRaw('sum(monto) as monto, fecha_pago as mes')->groupBy(\DB::raw('MONTH(fecha_pago)'))->get();
     return view('admin_home', compact('opex', 'alumnos_activos', 'alumnos_totales', 'pagos', 'coachs'));
 }
コード例 #22
0
ファイル: PagesController.php プロジェクト: noorxbyte/vultex
 /**
  * Home page
  *
  * @return \Illuminate\Http\Response
  */
 public function home(Request $request)
 {
     $movies = Product::where('type', 'MOVIE')->orderBy(\DB::raw('RAND()'))->take(5)->get();
     $series = Product::where('type', 'SERIES')->orderBy(\DB::raw('RAND()'))->take(5)->get();
     $animes = Product::where('type', 'ANIME')->orderBy(\DB::raw('RAND()'))->take(5)->get();
     $videos = Product::where('type', 'VIDEO')->orderBy(\DB::raw('RAND()'))->take(5)->get();
     $games = Product::where('type', 'GAME')->orderBy(\DB::raw('RAND()'))->take(5)->get();
     return view('pages.index', compact('movies', 'series', 'animes', 'videos', 'games'))->with('title', 'Home')->with('heading', 'Welcome');
 }
コード例 #23
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $arr = ['id' => 'id', 'username' => 'username', 'joined' => 'created_at', 'post_count' => 'post_count'];
     //paginate
     //tiny avatars?
     $this->data['users'] = App\User::select('users.*', \DB::raw('COUNT(posts.id) as post_count'))->join('posts', 'posts.user_id', '=', 'users.id')->groupBy('users.id')->paginate(20);
     $pagination = $this->data['users']->appends(array('order' => $by));
     return view('forum.users.index', $this->data);
 }
コード例 #24
0
 /**
  * Show the application dashboard to the user.
  *
  * @return Response
  */
 public function index()
 {
     $stato = 2;
     $orders = \DB::select(\DB::raw("select count(1) as new_orders from (select * from ordini_stato where (data_creazione,ordine) in (select max(data_creazione), ordine from ordini_stato group by ordine) order by ordine desc) os where stato ='" . $stato . "'"));
     $newOrders = $orders[0]->new_orders;
     $users = \DB::table('utenti')->select(\DB::raw('count(1) as new_users'))->where('cancellato', '=', false)->where('confermato', '=', false)->first();
     $newUsers = $users->new_users;
     return view('dash', compact('newOrders', 'newUsers'));
 }
コード例 #25
0
 /**
  * checks key value from request object and returns results according to.
  *
  * @param object        $request
  *
  *
  * @return json
  */
 public function search(Request $request)
 {
     $key = $request->key;
     $username = $request->username;
     //return $username;
     try {
         $data = User::where('username', $username)->get(['id', 'orientation', 'gender']);
         $userID = $data[0]->id;
         $orientation = $data[0]->orientation;
         $gender = $data[0]->gender;
         if ($orientation == 'straight' && $gender == 'female') {
             if ($users = \DB::select(\DB::raw("\n                        SELECT id,firstname,lastname,username,gender,profilepic from(\n                            SELECT id,firstname, lastname,username,orientation,gender,profilepic,role FROM `users` WHERE\n                                                    status = 'active' and\n                                                    firstname like '" . $key . "%' or \n                                                    lastname like '" . $key . "%') as t where orientation='straight' and gender='male' \n                                                    and role='user' and id NOT IN (\n                                                        Select blocked_user_id\n                                                        from `blocked`\n                                                        where user_id=" . $userID . '
                                                 ) 
                 '))) {
                 return response()->json(['users' => $users, 'status' => 201], 201);
             } elseif ($users == null) {
                 return response()->json(['users' => null, 'status' => 200], 200);
             }
         } elseif ($orientation == 'straight' && $gender == 'male') {
             $gender = 'female';
             if ($users = \DB::select(\DB::raw("\n                    SELECT id,firstname,lastname,username,gender,profilepic from(\n                        SELECT id,firstname, lastname,username,orientation,gender,profilepic,role FROM `users` WHERE        \n                                                status = 'active' and\n                                                firstname like '" . $key . "%' or \n                                                lastname like '" . $key . "%') as t where orientation='straight' and gender='female' \n                                                and role='user' and id NOT IN (\n                                                    Select blocked_user_id\n                                                    from `blocked`\n                                                    where user_id=" . $userID . '
                             ) 
                 '))) {
                 return response()->json(['users' => $users, 'status' => 201], 201);
             } else {
                 return response()->json(['users' => null, 'status' => 200], 200);
             }
         } elseif ($orientation == 'lesbian' && $gender == 'female') {
             if ($users = \DB::select(\DB::raw("\n                    SELECT id,firstname,lastname,username,gender,profilepic from(\n                        SELECT id,firstname, lastname,username,orientation,gender,profilepic,role FROM `users` WHERE        \n                                                status = 'active' and\n                                                firstname like '" . $key . "%' or \n                                                lastname like '" . $key . "%') as t where orientation='lesbian' and gender='female' \n                                                and role='user' and id NOT IN (\n                                                    Select blocked_user_id\n                                                    from `blocked`\n                                                    where user_id=" . $userID . '
                                             ) 
                 '))) {
                 return response()->json(['users' => $users, 'status' => 201], 201);
             } else {
                 return response()->json(['users' => null, 'status' => 200], 200);
             }
         } elseif ($orientation == 'gay' && $gender == 'male') {
             if ($users = \DB::select(\DB::raw("\n                    SELECT id,firstname,lastname,gender,profilepic from(\n                        SELECT id,firstname, lastname,username,orientation,gender,profilepic,role FROM `users` WHERE        \n                                                status = 'active' and\n                                                firstname like '" . $key . "%' or \n                                                lastname like '" . $key . "%') as t where orientation='gay' and gender='male' \n                                                and role='user' and id NOT IN (\n                                                    Select blocked_user_id\n                                                    from `blocked`\n                                                    where user_id=" . $userID . '
                                             ) 
                 '))) {
                 return response()->json(['users' => $users, 'status' => 201], 201);
             } else {
                 return response()->json(['users' => null, 'status' => 200], 200);
             }
         } elseif ($orientation == 'bisexual') {
             if ($users = \DB::select(\DB::raw("\n                    SELECT id,firstname,username,lastname,gender,profilepic from(\n                        SELECT id,firstname, lastname,username,orientation,gender,profilepic,role FROM `users` WHERE        \n                                                status = 'active' and\n                                                firstname like '" . $key . "%' or \n                                                lastname like '" . $key . "%') as t where orientation='bisexual' and (gender='male' or gender='female')  \n                                                and role='user' and id NOT IN (\n                                                    Select blocked_user_id\n                                                    from `blocked`\n                                                    where user_id=" . $userID . '
                                             ) 
                 '))) {
                 return response()->json(['users' => $users, 'status' => 201], 201);
             } else {
                 return response()->json(['users' => null, 'status' => 200], 200);
             }
         }
     } catch (QueryException $e) {
         return response()->json(['status' => 200, 'error' => true], 200);
     }
 }
コード例 #26
0
ファイル: TaskController.php プロジェクト: jtpenny/laratasks
 private function _getAllTasks()
 {
     $tasks = TaskModel::where('userID', $this->getAuthenticatedUser()->id)->where('done', 0)->orderBy(\DB::raw('ISNULL(duedate)'), 'ASC')->orderBy('duedate', 'asc')->get();
     foreach ($tasks as $i => $task) {
         if ($task->duedate) {
             $tasks[$i]['duedate'] = date('Y-m-d\\TH:i:s', strtotime($task->duedate));
         }
     }
     return $tasks;
 }
コード例 #27
0
ファイル: TicketController.php プロジェクト: hunglmtb/eb
 public function getHistoryData($mdl, $field, $rowData, $where, $limit)
 {
     $row_id = $rowData['ID'];
     if ($row_id <= 0) {
         return [];
     }
     $occur_date = $rowData['OCCUR_DATE'];
     $history = $mdl::where($where)->whereDate('OCCUR_DATE', '<', $occur_date)->whereNotNull($field)->orderBy('OCCUR_DATE', 'desc')->skip(0)->take($limit)->select(\DB::raw("concat(concat(OCCUR_DATE,' '), LOADING_TIME) as OCCUR_DATE"), "{$field} as VALUE")->get();
     return $history;
 }
コード例 #28
0
 public function asset_type_data()
 {
     \DB::statement(\DB::raw('set @rownum=0'));
     $asset_types = AssetType::select([\DB::raw('@rownum  := @rownum  + 1 AS rownum'), 'id', 'code', 'name']);
     return Datatables::of($asset_types)->addColumn('action', function ($asset_type) {
         return '
           <a href="./asset_type/edit/' . $asset_type->id . '" class="btn btn-xs btn-warning"><i class="glyphicon glyphicon-edit"></i> Edit</a>
           ';
     })->make(true);
 }
コード例 #29
0
 public function listActions()
 {
     $collection = $this->model->select(\DB::raw('
         data,
         ST_X(location) AS lng,
         ST_Y(location) AS lat,
         ST_AsText(location) AS location
     '))->get();
     return Response::json($collection);
 }
コード例 #30
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $coatch = Coatch::findOrFail($id);
     $functionMY = \DB::select(\DB::raw("select nazwa({$id})"));
     $licences = CoatchLicence::get();
     if (empty($licences)) {
         return redirect()->route('coatch_licences.index')->with('message', 'Najpierw dodaj  licencje.');
     }
     return view('coatches.show', compact('coatch'))->with('list', self::getLicence($licences))->with('MYK', $functionMY);
 }