public function index($username) { $user = User::where('first_name', $username)->first(); var_dump(\DB::getQueryLog()); var_dump($user); return $user->first_name; }
public function getExercise() { $json_data = file_get_contents(public_path() . "/js/ejercicio4.json"); $json = json_decode($json_data); DB::transaction(function () use(&$json) { $results = DB::select("insert into Exercises (id, description) SELECT COALESCE(MAX(id),0) + 1, 'Interfaz de Constantes' FROM exercises RETURNING id "); $exercise_id = $results[0]->id; echo $exercise_id; $step_number = 0; foreach ($json->excercises as $step) { $step_number++; $results = DB::select("insert into explanations(id, description,exercise_id,step_number,incremental_example,progress) SELECT COALESCE(MAX(id),0) + 1, ?,?,?,?,? FROM explanations RETURNING id ", array($step->explanation, $exercise_id, $step_number, implode("\n", $step->incrementalText), $step->progress)); $explanation_id = $results[0]->id; foreach ($step->answers as $answer) { if (isset($answer->error)) { $error = $answer->error; } else { $error = ""; } $description = implode("\n", $answer->text); $correct = $answer->rightAnswer ? 1 : 0; $results = DB::select("insert into answers (id, description,exercise_id,error,correct,step_number) SELECT COALESCE(MAX(id),0) + 1, ?,?,?,?,? FROM answers RETURNING id ", array($description, $exercise_id, $error, $correct, $step_number)); } } }); echo var_dump(DB::getQueryLog()); }
/** * Display a listing of the resource. * * @return Response */ public function index() { $page_title = "Beneficiaries"; if (Request::wantsJson()) { if ($organizationUid = Input::get('org')) { $org = $this->org->find($organizationUid); $query = $this->model->whereOrganizationId($org->id); if (Input::get('past')) { $query = $query->whereHas('campaigns', function ($q) { $q->whereCampaignId($this->campaign->current()->id); }, '=', 0); // i.e. where does NOT have } else { $query = $query->whereHas('campaigns', function ($q) { $q->whereCampaignId($this->campaign->current()->id); }); } $beneficiaries = $query->get(); $beneficiaries = array_map(function ($b) { return ['name' => $b->name, 'logo' => $b->logo, 'url' => $b->url, 'description' => $b->description, 'uid' => $b->uid, 'show_location' => $b->show_location, 'slots_taken' => $b->slots_taken, 'sponsorships_taken' => $b->sponsorships_taken]; }, $beneficiaries->all()); } else { $beneficiaries = $this->model->with('organization')->get(); $beneficiaries = array_map(function ($b) { return ['uid' => $b->uid, 'name' => $b->name, 'organization' => $b->organization->name]; }, $beneficiaries->all()); } return Response::json(['status' => 'success', 'num_queries' => count(\DB::getQueryLog()), 'models' => $beneficiaries]); } else { return View::make($this->package . '::backend.' . $this->modelName . '.index', ['page_title' => $page_title]); } }
/** * Outputs gathered data to make Profiler * * @return html? */ public function outputData() { // Check if profiler config file is present if (\Config::get('profiler::profiler')) { // Sort the view data alphabetically ksort($this->view_data); $this->time->totalTime(); $data = array('times' => $this->time->getTimes(), 'view_data' => $this->view_data, 'app_logs' => $this->logs, 'includedFiles' => get_included_files(), 'counts' => $this->getCounts(), 'assetPath' => __DIR__ . '/../../../public/'); // Check if SQL connection can be established try { $data['sql_log'] = \DB::getQueryLog(); } catch (\PDOException $exception) { $data['sql_log'] = array(); } // Check if btns.storage config option is set if (\Config::get('profiler::btns.storage')) { // get last 24 webserver log entries $data['storageLogs'] = $this->getStorageLogs(24); } // Check if btns.config config option is set if (\Config::get('profiler::btns.config')) { // get all Laravel config options and store in array $data['config'] = array_dot(\Config::getItems()); } return \View::make('profiler::profiler.core', $data); } }
public function testLists() { $lists = Post::where('views', '>=', 10)->lists('id', 'title'); $debug = last(DB::getQueryLog()); $this->assertEquals(['Bar' => 2, 'FooBar' => 3], $lists); $this->assertEquals('select "id", "title" from "posts" where "published" = ? and "views" >= ? and "status" = ?', $debug['query']); }
/** * Last query performeds * * @author Luca Brognara * @date Aprile 2015 * * @return void */ public static function last_query() { $query = DB::getQueryLog(); $last_query = end($query); echo "<pre>"; print_r($last_query); echo "</pre>"; }
public function terminate($request, $response) { \Log::debug('=== Start queries ==='); foreach (\DB::getQueryLog() as $i => $query) { \Log::debug("Query #{$i}", ['query' => $query]); } \Log::debug('=== End queries ==='); }
/** * Updates the selected package. * * @param $id * @param PackageRequest $request * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector */ public function update($id, PackageRequest $request) { $queries = \DB::getQueryLog(); $package = Package::findOrFail($id); $package->update($request->all()); flash()->message('Successfully updated: ' . $package->name, 'success'); return redirect()->route('admin.packages.edit', [$package->id]); }
public function index($orgPermalink = null) { $this->dataSource->forOrganization($orgPermalink); $rows = $this->dataSource->getData(); // TODO cache this $result = ['datetime' => Carbon::now(), 'opps' => $this->transformer->transformArray($rows)]; return Response::json(['status' => 'success', 'num_queries' => count(\DB::getQueryLog()), 'time_last_run' => '' . $result['datetime'], 'hostname' => gethostname(), 'models' => $result['opps']]); }
public function test_getAll() { $items = $this->service->getAll(['columns' => ['id', 'model'], 'page_index' => 1, 'page_size' => 20000, 'includes' => ['productDescriptions'], 'criteria' => []])->getItems(); $queries = DB::getQueryLog(); $last_query = end($queries); foreach ($items as $item) { } print_r(json_encode($items, JSON_PRETTY_PRINT)); }
function showQuery($last = false) { $queries = DB::getQueryLog(); if ($last) { pr(end($queries)); } else { pr($queries); } }
public function test_query() { $items = Category::select('c.category_id', 'c.parent_id', 'cd.name', DB::raw('(SELECT count(category_id) FROM oc_category) AS childrenCount'))->from('oc_category as c')->where('c.parent_id', 0)->where('cd.language_id', 1)->join('oc_category_description as cd', 'c.category_id', '=', 'cd.category_id')->orderBy('c.sort_order')->get(); $queries = DB::getQueryLog(); $last_query = end($queries); var_dump($last_query['query']); var_dump(count($items)); var_dump($items->count()); $this->assertNotNull($items->count()); }
/** * Outputs gathered data to make Profiler * * @return html? */ public function outputData() { if (\Config::get('omni::profiler')) { // Sort the view data alphabetically ksort($this->view_data); $this->time->totalTime(); $data = array('times' => $this->time->getTimes(), 'view_data' => $this->view_data, 'sql_log' => array_reverse(\DB::getQueryLog()), 'app_logs' => $this->logs); return \View::make('omni::profiler.core', $data); } }
public static function queryLog($queryLog = null) { if (is_null($queryLog)) { $queryLog = \DB::getQueryLog(); } $queryString = ""; foreach ($queryLog as $i => $query) { $queryString .= "#{$i} " . L4ToString::query($query['query'], $query['bindings'], $query['time']) . "\n"; } return $queryString; }
public function terminate($request, $response) { if (!\App::runningInConsole() && \App::bound('veer') && app('veer')->isBooted()) { $timeToLoad = empty(app('veer')->statistics['loading']) ? 0 : app('veer')->statistics['loading']; if ($timeToLoad > config('veer.loadingtime')) { \Log::alert('Slowness detected: ' . $timeToLoad . ': ', app('veer')->statistics()); info('Queries: ', \DB::getQueryLog()); } \Veer\Jobs\TrackingUser::run(); (new \Veer\Commands\HttpQueueWorkerCommand(config('queue.default')))->handle(); } }
protected function returnJson($code = 200, $data = [], $headers = []) { $data['statusCode'] = $code; if (env('APP_DEBUG', false)) { $data[$this->appName()] = 'debug'; $data['url'] = $this->rq->fullUrl(); $data['SQL Queries'] = count(\DB::getQueryLog()); $data['response_time'] = microtime(true) - LARAVEL_START; } $headers['Content-Type'] = 'application/json'; return response()->json($data, $code, $headers, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); }
function get_last_query() { $queries = DB::getQueryLog(); $sql = end($queries); if (!empty($sql['bindings'])) { $pdo = DB::getPdo(); foreach ($sql['bindings'] as $binding) { $sql['query'] = preg_replace('/\\?/', $pdo->quote($binding), $sql['query'], 1); } } return $sql['query']; }
/** * Execute the console command. * * @return mixed */ public function handle() { $sessions = ClassroomSession::select('id', 'classroom_id')->whereIn('classroom_id', [157, 168, 176, 186, 198, 213, 217])->get(); // $this->comment(PHP_EOL.$sessions->count().PHP_EOL); foreach ($sessions as $session) { $students = ClassroomStudent::select('student_id')->where('student_id', 1841)->where('classroom_id', $session->classroom_id)->get(); // $this->comment(PHP_EOL.$students->count().PHP_EOL); foreach ($students as $student) { $exist = StudentClassroomSession::where('classroom_session_id', $session->id)->where('student_id', $student->student_id)->value('id'); if ($exist) { $this->comment(PHP_EOL . ' HAS ' . $exist . PHP_EOL); } else { $data = ['student_id' => $student->student_id, 'attendee_id' => $student->student_id, 'classroom_session_id' => $session->id, 'student_link' => '', 'semester_id' => 9]; $attendance = ['entry_time' => null, 'exit_time' => null, 'attended_minutes' => null, 'teacher_id' => null, 'classroom_session_id' => $session->id, 'student_id' => $student->id, 'valid' => 0, 'manual' => 0]; StudentClassroomSession::create($data); ClassroomSessionAttendance::create($attendance); $this->comment(PHP_EOL . ' NOT ' . PHP_EOL); } } } // Student::with('classrooms', 'subjects')->has('classrooms', '=', 3)->leftJoin('subject_sub') exit; \DB::connection()->enableQueryLog(); Exam::select('exams.type', 'exams.start_at', 'exams.finish_at', 'exams.name', 'exams.id')->join('subject_subjects as subsub', 'subsub.id', '=', 'exams.subject_id')->join('student_subjects as stusub', function ($j) { $j->on('stusub.subject_id', '=', 'subsub.id')->where('stusub.student_id', '=', 10001)->where('stusub.state', '=', 'study'); })->where(function ($query) { $query->orWhereIn('exams.type', ['midterm', 'remidterm', 'activity'])->orWhereRaw('exams.id IN (SELECT ce.exam_id FROM classrooms_exam as ce JOIN classrooms as c ON c.id = ce.classroom_id JOIN classroom_students as cs ON cs.classroom_id = c.id AND cs.student_id = 10001 WHERE exam_id = exams.id GROUP BY ce.id)'); // if ($request->has('finalExam') == 'true') { // $query->orWhereIn('exams.type', // [ // 'final', // 'summer', // 'refinal' // ]); // } })->where('exams.semester_id', 9)->where('finish_at', '>=', date('Y-m-d H:i:s'))->groupBy('exams.id')->orderBy('exams.start_at', 'ASC')->get(); // Exam::count(); $query = \DB::getQueryLog(); $lastQuery = end($query); var_dump($lastQuery); // echo "done"; exit; // $sessions = ClassroomSession::select('id')->whereIn('interval_id', [2,14,15])->get(); // foreach ($sessions as $session) { // ClassroomSessionAttendance::where('classroom_session_id', $session->id)->update(['valid' => 1]); // } }
public function testQueryLog() { $this->assertEquals(0, count(DB::getQueryLog())); DB::collection('items')->get(); $this->assertEquals(1, count(DB::getQueryLog())); DB::collection('items')->insert(array('name' => 'test')); $this->assertEquals(2, count(DB::getQueryLog())); DB::collection('items')->count(); $this->assertEquals(3, count(DB::getQueryLog())); DB::collection('items')->where('name', 'test')->update(array('name' => 'test')); $this->assertEquals(4, count(DB::getQueryLog())); DB::collection('items')->where('name', 'test')->delete(); $this->assertEquals(5, count(DB::getQueryLog())); }
/** * A basic functional test example. * * @return void */ public function testBasicExample() { // DB::table('lessons')->delete(); // DB::table('lessons')->delete(); DB::enableQueryLog(); // App\Next\Models\User::find(60830) var_dump(App\Next\Data\SportsZoneSource::update()); // var_dump(App\Next\Models\User::find(60829)->next_lesson_of('Economics', \Carbon\Carbon::now()->addDay())); $queries = DB::getQueryLog(); $last_query = end($queries); // var_dump($last_query); // var_dump(App\Next\Models\User::find(60829)->lessons->first()); // $response = $this->call('GET', '/'); // $this->assertEquals(200, $response->getStatusCode()); }
/** * This method calls a sub method handleLogic() if possible and contain the execution logic */ public function handle() { /* * Step 1. Check if we should activate the queries log by looking at the option --with-sql * ----------- */ if ($this->_count_queries == true || $this->option('with-sql') === true) { \DB::enableQueryLog(); $this->_count_queries = true; } $command_name = substr($this->signature, 0, strpos($this->signature, ' ')); $this->info('[*] Beginning of the command ' . $command_name, OutputInterface::VERBOSITY_VERBOSE); /* * Step 2. Execute the logic and catch exception to display as "error" * ----------- */ $starting_time = microtime(true); try { $return = $this->handleLogic(); if (is_array($return)) { $this->_return = array_merge($this->_return, $return); } $this->onSuccess(); } catch (\Exception $e) { $this->onError($e); } $this->_return['execution_time'] = round(microtime(true) - $starting_time, 2); $this->onComplete(); $this->info('[*] End of the command', OutputInterface::VERBOSITY_VERBOSE); $this->comment('- Execution time: ' . $this->_return['execution_time'], OutputInterface::VERBOSITY_VERBOSE, 1); /* * Step 3. Count and display the queries (if activated) * ----------- */ if ($this->_count_queries === true) { $queries = \DB::getQueryLog(); $this->_return['nb_queries'] = count($queries); $this->comment('- Queries: ' . $this->_return['nb_queries'], OutputInterface::VERBOSITY_VERBOSE, 1); // If we are in -vvv, then we want to know more about the queries executed if ($this->getOutput()->getVerbosity() == OutputInterface::VERBOSITY_VERY_VERBOSE) { foreach ($queries as $query) { $this->comment('- ' . $query['query'], null, 1); } } unset($queries); } }
/** * Fetch common form data needed for subclass controllers * The 2 main items are the organization list participating in the specified CTA * and the specified church (either passed in URI or set in cookie by WP site) * * @return Array */ protected function getFormData($permalink = null, $withs = []) { $orgs = $this->getOrgsForDropdown($withs); \Log::debug('------------ QUERIES --------------'); \Log::debug(print_r(\DB::getQueryLog(), true)); // pass in the church to override, fall back to the cookie if it exists $churchId = 0; $churchUid = ''; if ($permalink === null) { // RT - cannot use Laravel Cookie b/c it's expecting encrypted junk $permalink = array_key_exists('church', $_COOKIE) ? $_COOKIE['church'] : null; if (empty($permalink)) { $permalink = null; } // just in case empty string } if ($permalink !== null) { $church = array_find($orgs, function ($o) use($permalink) { return $o->permalink == $permalink; }); if ($church) { $churchId = $church->id; $churchUid = $church->uid; } } $orgs4dropdown = ['0' => '-- Select Your Church --']; foreach ($orgs as $o) { $location = ''; if (!empty($o->effective_meeting_city)) { $location = $o->effective_meeting_city; } if (!empty(trim($o->effective_meeting_country)) && ($o->effective_meeting_country != 'US' && $o->effective_meeting_country != 'CA')) { $location .= ", " . $o->full_effective_meeting_country; } else { if (trim($o->effective_meeting_state)) { $location .= ", " . $o->effective_meeting_state; } } if (!empty(trim($location))) { $location = ": " . $location; } $orgs4dropdown[$o->id] = $o->name . $location; $o->dropdownLabel = $o->name . $location; } $orgs4dropdown[null] = 'Other'; return ['organizations' => $orgs, 'orgsDropdown' => $orgs4dropdown, 'churchId' => $churchId, 'churchUid' => $churchUid, 'permalink' => $permalink]; }
/** * @SWG\Operation( * partial="sincronizacion.index", * summary="Regresa el listado de todos los sincronizacion", * @SWG\Parameter( * name="paginate", * description="Paginar el listado", * required=false, * type="string", * paramType="query", * allowMultiple=false * ), * type="array[users]" * ) */ public function index() { log::info("listada"); $data = Input::all(); $informacion = array(); //log::info($data); if (isset($data['categorias'])) { $informacion['categorias'] = Categoria::all()->toArray(); //log::info(var_export($categorias,true)); //log::info(var_export($informacion,true)); log::info("query"); $last = DB::getQueryLog(); $la = end($last); log::info(var_export($la, true)); } return $informacion; }
/** * Display a listing of the resource. * * @return Response */ public function index() { $data = Input::all(); if ($data) { $resource = 'Patient'; $table = 'demographics'; $table_primary_key = 'pid'; $table_key = ['name' => ['lastname', 'firstname'], 'identifier' => 'pid', 'telcom' => ['phone_home', 'phone_work', 'phone_cell'], 'gender' => 'sex', 'birthDate' => 'dob', 'address' => ['address', 'city', 'state', 'zip'], 'contact.relationship' => 'guardian_relationship', 'contact.name' => ['guardian_lastname', 'guardian_firstname'], 'contact.telcom' => 'guardian_phone_home', 'active' => 'active']; $result = $this->resource_translation($data, $table, $table_primary_key, $table_key); $queries = DB::getQueryLog(); $sql = end($queries); if (!empty($sql['bindings'])) { $pdo = DB::getPdo(); foreach ($sql['bindings'] as $binding) { $sql['query'] = preg_replace('/\\?/', $pdo->quote($binding), $sql['query'], 1); } } if ($result['response'] == true) { $statusCode = 200; $time = date('c', time()); $reference_uuid = $this->gen_uuid(); $response['resourceType'] = 'Bundle'; $response['title'] = 'Search result'; $response['id'] = 'urn:uuid:' . $this->gen_uuid(); $response['updated'] = $time; $response['category'][] = ['scheme' => 'http://hl7.org/fhir/tag', 'term' => 'http://hl7.org/fhir/tag/message', 'label' => 'http://ht7.org/fhir/tag/label']; $practice = DB::table('practiceinfo')->where('practice_id', '=', '1')->first(); $response['author'][] = ['name' => $practice->practice_name, 'uri' => route('home') . '/fhir']; $response['totalResults'] = $result['total']; foreach ($result['data'] as $row_id) { $row = DB::table($table)->where($table_primary_key, '=', $row_id)->first(); $resource_content = $this->resource_detail($row, $resource); $response['entry'][] = ['title' => 'Resource of type ' . $resource . ' with id = ' . $row_id . ' and version = 1', 'link' => ['rel' => 'self', 'href' => Request::url() . '/' . $row_id], 'id' => Request::url() . '/' . $row_id, 'updated' => $time, 'published' => $time, 'author' => ['name' => $practice->practice_name, 'uri' => route('home') . '/fhir'], 'category' => ['scheme' => 'http://hl7.org/fhir/tag', 'term' => 'http://hl7.org/fhir/tag/message', 'label' => 'http://ht7.org/fhir/tag/label'], 'content' => $resource_content, 'summary' => '<div><h5>' . $row->lastname . ', ' . $row->firstname . '. MRN: ' . $row->pid . '</h5></div>']; } } else { $response = ['error' => "Query returned 0 records."]; $statusCode = 404; } } else { $response = ['error' => "Invalid query."]; $statusCode = 404; } $response['code'] = $sql['query']; return Response::json($response, $statusCode); }
public function obj() { $condition = array('大柚子', '大柚', '柚子'); // $result=Test::all()->toArray(); // print_r(DB::getQueryLog()); $obj = new Test(); $i = 0; print_r($obj); foreach ($condition as $value) { $i++; echo $value; $total = $obj->where(function ($query) use($value) { $q = $query->where('id', $value); //$q = $q->orWhere('content',$value); return $q; })->count(); print_r(DB::getQueryLog()); } }
public function returnJSON($data = array(), $additional_params = array(), $extra = array(), $debug = array()) { $json = array('version' => \Config::get('api.using_version'), 'route' => \Request::path()); $json['url_params'] = \Route::getCurrentRoute()->parameters(); $params = $this->params; if (isset($this->params['filter'])) { $params['filter'] = json_decode($this->params['filter']); } if (sizeof($additional_params) > 0) { $params = array_merge($params, $additional_params); } $json['params'] = $params; if (sizeof($extra) > 0) { $json = array_merge($json, $extra); } $json['data'] = $data; if (\Config::get('app.debug')) { $json['debug'] = array('sql' => \DB::getQueryLog()); $json['debug'] = array_merge($json['debug'], $debug); } return \Response::json($json); }
/** * Display a listing of the resource. * * @return Response */ public function getIndex() { // echo "<pre>"; // dd(Input::all()); $c = Input::get('collection', 'Entity'); $collection = $this->repository->returnCollectionObjectFor($c); if (Input::has('field')) { $collection = $this->processFields($collection); } if (!array_key_exists('noCache', Input::all())) { $collection = $collection->remember(1, md5(serialize(array_values(Input::except('pretty'))))); } $start = (int) Input::get('start', 0); $limit = (int) Input::get('limit', 100); $only = Input::get('only', array()); if (Input::has('datatables')) { $start = (int) Input::get('iDisplayStart', 0); $limit = (int) Input::get('iDisplayLength', 100); $sortingColumnIndex = (int) Input::get('iSortCol_0', 0); $sortingColumnName = Input::get('mDataProp_' . $sortingColumnIndex, '_id'); $sortingDirection = Input::get('sSortDir_0', 'asc'); $sortingColumnName = $sortingColumnName == "_id" ? "natural" : $sortingColumnName; $count = new Entity(); $count = $this->processFields($count); $count = $count->count(); $collection = $collection->skip($start)->orderBy($sortingColumnName, $sortingDirection)->take($limit)->get($only); return Response::json(["sEcho" => Input::get('sEcho', 10), "iTotalRecords" => $count, "iTotalDisplayRecords" => $count, "aaData" => $collection->toArray()]); } $collection = $collection->skip($start)->take($limit)->get($only); if (array_key_exists('getQueryLog', Input::all())) { return Response::json(\DB::getQueryLog()); } if (array_key_exists('pretty', Input::all())) { echo "<pre>"; return json_encode($collection->toArray(), JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); } return Response::json($collection); }
/** * Display a listing of the resource. * * @return Response */ public function index() { $data = Input::all(); if ($data) { $resource = 'Patient'; $table = 'demographics'; $table_primary_key = 'pid'; $table_key = ['name' => ['lastname', 'firstname'], 'identifier' => 'pid', '_id' => 'pid', 'telcom' => ['phone_home', 'phone_work', 'phone_cell'], 'gender' => 'sex', 'birthDate' => 'dob', 'address' => ['address', 'city', 'state', 'zip'], 'contact.relationship' => 'guardian_relationship', 'contact.name' => ['guardian_lastname', 'guardian_firstname'], 'contact.telcom' => 'guardian_phone_home', 'active' => 'active']; $result = $this->resource_translation($data, $table, $table_primary_key, $table_key); $queries = DB::getQueryLog(); $sql = end($queries); if (!empty($sql['bindings'])) { $pdo = DB::getPdo(); foreach ($sql['bindings'] as $binding) { $sql['query'] = preg_replace('/\\?/', $pdo->quote($binding), $sql['query'], 1); } } if ($result['response'] == true) { $statusCode = 200; $response['resourceType'] = 'Bundle'; $response['type'] = 'searchset'; $response['id'] = 'urn:uuid:' . $this->gen_uuid(); $response['total'] = $result['total']; foreach ($result['data'] as $row_id) { $row = DB::table($table)->where($table_primary_key, '=', $row_id)->first(); $resource_content = $this->resource_detail($row, $resource); $response['entry'][] = ['fullUrl' => Request::url() . '/' . $row_id, 'resource' => $resource_content]; } } else { $response = ['error' => "Query returned 0 records."]; $statusCode = 404; } } else { $response = ['error' => "Invalid query."]; $statusCode = 404; } return Response::json($response, $statusCode); }
public function SendChat() { /* * get the recipient */ if (Input::get('contact_list') == '') { $target = DB::select("SELECT target_user_id,source_user_id from mradi_messages where message_hash = ?", array(Input::get('message_'))); $target = $target[0]->source_user_id == Session::get('account_id') ? $target[0]->target_user_id : $target[0]->source_user_id; } else { $target = Input::get('contact_list'); } $source = Session::get('account_id'); DB::select("update mradi_messages set message_hash=? where (source_user_id = ? and target_user_id = ?) \n or (source_user_id = ? and target_user_id = ?)", array(Input::get('message_'), $source, $target, $target, $source)); $queries = DB::getQueryLog(); $last_query = end($queries); Helpers::logData(print_r($last_query, true)); DB::table('mradi_messages')->insert(array('target_user_id' => $target, 'source_user_id' => Session::get('account_id'), 'message' => Input::get('message'), 'message_hash' => Input::get('message_'))); if (Input::get('contact_list') != '') { return Redirect::to(URL::previous()); } else { return Response::make('OK', 200); } }
public function runWorkFlow(Request $request) { $data = $request->all(); TmWorkflow::where(['ID' => $data['ID']])->update(['ISRUN' => 'yes']); \DB::enableQueryLog(); $tmWorkflowTask = TmWorkflowTask::where(['WF_ID' => $data['ID'], 'ISBEGIN' => 1])->first(); \Log::info(\DB::getQueryLog()); if (count($tmWorkflowTask) > 0) { TmWorkflowTask::where(['WF_ID' => $data['ID']])->where('ID', '<>', $tmWorkflowTask['id'])->update(['ISRUN' => 0]); $objRun = new WorkflowProcessController(null, $tmWorkflowTask); $objRun->runTask(null, $tmWorkflowTask); /* $job = (new runAllocation(null, $tmWorkflowTask)); $this->dispatch($job); */ } $result = $this->getTmWorkflow(); return response()->json(['result' => $result]); }