public function boot() { if (!($model = $this->getModelClass())) { return; } parent::boot(); // Flush nested set caches related to the object if (Config::get('app.debug')) { Log::info('Binding heirarchical caches', ['model' => $model]); } // Trigger save events after move events // Flushing parent caches directly causes an infinite recursion $touch = function ($node) { if (Config::get('app.debug')) { Log::debug('Touching parents to trigger cache flushing.', ['parent' => $node->parent]); } // Force parent caches to flush if ($node->parent) { $node->parent->touch(); } }; $model::moved($touch); // Flush caches related to the ancestors $flush = function ($node) { $tags = $this->make($node)->getParentTags(); if (Config::get('app.debug')) { Log::debug('Flushing parent caches', ['tags' => $tags]); } Cache::tags($tags)->flush(); }; $model::saved($flush); $model::deleted($flush); }
/** * Listens for and stores PayPal IPN requests. * * @throws InvalidIpnException * * @return IpnOrder */ public function getOrder() { $ipnMessage = null; $listenerBuilder = new ListenerBuilder(); if ($this->getEnvironment() == 'sandbox') { $listenerBuilder->useSandbox(); // use PayPal sandbox } $listener = $listenerBuilder->build(); $listener->onVerified(function (MessageVerifiedEvent $event) { $ipnMessage = $event->getMessage(); Log::info('IPN message verified - ' . $ipnMessage); $this->order = $this->store($ipnMessage); }); $listener->onInvalid(function (MessageInvalidEvent $event) { $report = $event->getMessage(); Log::warning('Paypal returned invalid for ' . $report); }); $listener->onVerificationFailure(function (MessageVerificationFailureEvent $event) { $error = $event->getError(); // Something bad happend when trying to communicate with PayPal! Log::error('Paypal verification error - ' . $error); }); $listener->listen(); return $this->order; }
/** * 处理微信调用的请求 */ public function index() { $message = file_get_contents("php://input"); Log::info($message); $message = simplexml_load_string($message, 'SimpleXMLElement', LIBXML_NOCDATA); if ($message) { $msgType = $message->MsgType; $fromUser = $message->FromUserName; $content = $message->Content; if ($msgType == self::WX_MSG_TYPE_TEXT) { //处理用户文字 return $this->handleUserMassage($message); } if ($msgType == self::WX_MSG_TYPE_EVENT) { if ($message->Event == self::WX_MSG_EVENT_SUBSCRIBE) { //处理用户订阅事件 return $this->handleSubscribeEvent($message); } if ($message->Event == self::WX_MSG_EVENT_CLICK) { if ($message->EventKey == self::WX_MENU_KEY_ABOUT_XY) { //处理用户点击关于菜单事件 return $this->handleClickAboutMenu($message); } } } \Log::info("msgType = {$msgType}"); } return ""; }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { // $inputs = $request->all(); rainsensor::create(['raining' => $inputs['rainSensor']]); Log::info($inputs); }
public function save($diskName, $destination, $uploadFile = array()) { $this->init($diskName, $destination, $uploadFile); if ($this->checkSameNameFile()) { if ($this->checkUploadFileMd5()) { return UPLOAD_FILE_EXIST; } return UPLOAD_FILE_SAME_NAME_DIFFERENT_CONTENT; } if ($this->checkChunk()) { return UPLOAD_CHUNK_FILE_EXIST; } if (!$this->moveFile()) { // Move the upload file to the target directory return UPLOAD_CHUNK_FILE_FAILURE; } // Get all chunks $chunkfiles = $this->disk->files($this->chunkFile['targetPath']); // check the file upload finished if (count($chunkfiles) * $this->chunkFile['fileSize'] >= $this->saveFile['fileSize'] - $this->chunkFile['fileSize'] + 1) { if (!$this->createFileFromChunks($chunkfiles)) { return UPLOAD_FILE_FAILURE; } Log::info('-------------------------------------------------------'); Log::info(__CLASS__ . ': save ' . $this->saveFile['fileRealPath'] . ' successfully!'); Log::info('-------------------------------------------------------'); return UPLOAD_FILE_SUCCESS; } return UPLOAD_CHUNK_FILE_SUCCESS; }
public function boot() { Event::listen('illuminate.query', function ($query, $params, $time, $conn) { Log::info($query); }); $this->app['router']->post('datagridview', '\\mkdesignn\\datagridview\\DataGridViewController@postIndex'); }
private function runProcess($processName) { // use this code to run a bat file $processFilename = $processName . '.bat'; exec('C:\\xampp\\htdocs\\smart\\process\\' . $processFilename); Log::info('Running process: ' . $processName); }
/** * Bootstrap any application services. * * 这里面能做很多跟监控有关的事情 * * @return void */ public function boot() { // 监听数据库查询 打印LOG DB::listen(function ($sql, $bindings, $time) { Log::info('query db' . $sql . ' and the time is ' . $time); }); }
/** * Execute the console command. * * @return mixed */ public function handle() { Log::info('Begin the check-cycle-bill command.'); $now = Carbon::now(); $cycleBillList = CompanyCycleBill::where('next_date', '>=', $now->format('Y-m-01 00:00:00'))->where('next_date', '<=', $now->format('Y-m-31 23:59:59'))->get(); foreach ($cycleBillList as $cycleBill) { $companyBill = new CompanyBill(); $item = $cycleBill->item; if ($cycleBill->rule = '1m') { $item = $item . "(" . $now->month . "月)"; } elseif ($cycleBill->rule = '3m') { $item = $item . "(" . (int) ($now->month / 4 + 1) . "季度)"; } elseif ($cycleBill->rule = '12m') { $item = $item . "(" . $now->year . "年)"; } $companyBill->item = $item; $companyBill->user_id = $cycleBill->user_id; $companyBill->remarks = $cycleBill->remarks; $companyBill->company_id = $cycleBill->company_id; $companyBill->operator_id = $cycleBill->operator_id; $companyBill->grand_total = $cycleBill->grand_total; $companyBill->deadline = $cycleBill->next_date; $companyBill->cycle_bill_id = $cycleBill->id; $companyBill->save(); $cycleBill->next_date = $cycleBill->next_date->addMonth(intval($cycleBill->rule)); $cycleBill->save(); } Log::info('End the check-cycle-bill command.'); }
/** * Execute the console command. * * @return mixed */ public function fire() { // Check not 'sync' if (Config::get('queue.default') == "sync") { Artisan::call('down'); $this->info("Application maintenance mode enabled."); return; } // Push job onto queue Queue::push(function ($job) { // Take Application down. Artisan::call('down'); // Add Log message Log::info("Application is down, pausing queue while maintenance happens."); // Loop, waiting for app to come back up while (App::isDownForMaintenance()) { echo "."; sleep(5); } // App is back online, kill worker to restart daemon. Log::info("Application is up, rebooting queue."); Artisan::call('queue:restart'); $job->delete(); }); // Wait until Maintenance Mode enabled. while (!App::isDownForMaintenance()) { sleep(1); } $this->info("Application maintenance mode enabled."); }
/** * Execute the console command. * * @return mixed */ public function handle() { Log::info('Iniciando proceso de actualizacion de referencia de ventas'); $sales = Sales::where('transaction_id', '-1')->get(); foreach ($sales as $sale) { $ventasPorAplicar = DB::table('contabilidad_sales')->select('*')->whereRaw('credit_debit = ? and reference = ? ', ['credit', $sale->reference])->where('transaction_id', '<>', '-1')->groupBy('reference')->get(); if (count($ventasPorAplicar) > 0) { // se encontraron referencias de venta nuevas foreach ($ventasPorAplicar as $ventaPorAplicar) { $depositoAplicacionAnterior = DepositoAplicacion::where('venta_id', $sale->id)->get(); foreach ($depositoAplicacionAnterior as $depositoAplicacion) { echo $depositoAplicacion->cantidad . ' ' . $depositoAplicacion->deposito_id . ' -- ' . $ventaPorAplicar->ammount . '-- ' . $ventaPorAplicar->ammount_applied . '-------'; if ($depositoAplicacion->estatus == 1) { $deposito = new DepositoAplicacion(['deposito_id' => $depositoAplicacion->deposito_id, 'venta_id' => $ventaPorAplicar->id, 'estatus' => $depositoAplicacion->estatus, 'usuario_id' => $depositoAplicacion->usuario_id, 'cantidad' => $depositoAplicacion->cantidad]); $ventaPorAplicar->ammount_applied = $depositoAplicacion->cantidad + ($ventaPorAplicar->ammount - $ventaPorAplicar->ammount_applied); } else { if (abs($depositoAplicacion->cantidad) >= $ventaPorAplicar->ammount - $ventaPorAplicar->ammount_applied) { $ventaPorAplicar->ammount_applied = $depositoAplicacion->ammount; $depositoAplicacion->cantidad = $depositoAplicacion->cantidad - ($ventaPorAplicar->ammount - $ventaPorAplicar->ammount_applied); } else { $ventaPorAplicar->ammount_applied = $ventaPorAplicar->ammount - $ventaPorAplicar->ammount_applied - $depositoAplicacion->cantidad; $depositoAplicacion->cantidad = 0; } $deposito = new DepositoAplicacion(['deposito_id' => $depositoAplicacion->deposito_id, 'venta_id' => $ventaPorAplicar->id, 'estatus' => $depositoAplicacion->estatus, 'usuario_id' => $depositoAplicacion->usuario_id, 'cantidad' => -1 * ($ventaPorAplicar->ammount_applied - $ventaPorAplicar->ammount)]); } $deposito->save(); ${$ventaPorAplicar}->update(); $depositoAplicacion->delete(); } } } } Log::info('Finalizando proceso de actualizacion de referencia de ventas'); }
/** * Finaliza o pedido recebendo a mesa como parametro da requisicao * abre o pedido, salva, e salva os itens no pedido. * @param Request $request */ public function finalizarCarrinho(Request $request) { $itens = Cart::content(); $pedido = new Pedido(); $pedido->mesa = $request->mesa; $pedido->total = Cart::total(); if (Cart::count() != 0) { $pedido->save(); } else { Flash::success("Por favor, adicione algum item no pedido!"); } Log::info($pedido); //por enquanto vai ser assim, mas pense numa maneira melhor //de retornar o pedido criado. $pedidoAtual = Pedido::orderBy('id', 'desc')->first(); $itensPedidos = array(); foreach ($itens as $iten) { $itemPedido = new ItemPedido(); $itemPedido->nome = $iten->name; $itemPedido->preco = $iten->price; $itemPedido->quantidade = $iten->qty; $itensPedidos[] = $itemPedido; } if (Cart::count() != 0) { $pedidoAtual->itens()->saveMany($itensPedidos); $pedidoAtual->save(); Cart::destroy(); Flash::success("Pedido finalizado!"); } else { Flash::error("Por favor, adicione algum item no pedido!"); } return redirect()->back(); }
/** * 通过code换取网页授权access_token * { * "access_token": "OezXcEiiBSKSxW0eoylIeLbTirX__QgA7uW8WJE0Z2izAbnXV7DHbdHni-j9OoCq2Xqh5gLlPt0uAHtfYByOH80h1dwMrq74iALd_K359JYEN5KWKB7_sEz3T19V86sP9lSO5ZGbc-qoXUD3XZjEPw", * "expires_in": 7200, * "refresh_token": "OezXcEiiBSKSxW0eoylIeLbTirX__QgA7uW8WJE0Z2izAbnXV7DHbdHni-j9OoCqgBFR_ApctbH4Tk5buv8Rr3zb7T3_27zZXWIdJrmbGFoFzGUfOvnwX249iPoeNJ2HYDbzW5sEfZHkC5zS4Qr8ug", * "openid": "oMzBIuI7ctx3n-kZZiixjchzBKLw", * "scope": "snsapi_base" * } **/ public function getOAuth2AccessToken(Request $request) { $code = $request->input('code'); $res = AccessTokenService::getOAuth2AccessToken($code); Log::info($res); return response($res)->header('Content-Type', 'JSON'); }
function updateCommand($git, $branch, $location, $domainId) { return Remote::run(['cd ' . base_path() . '; ~/.composer/vendor/bin/envoy run update --git=' . $git . ' --branch=' . $branch . ' --location=' . $location], function ($line) { Log::info($line); echo $line . '<br />'; }); }
/** * 针对notify_url验证消息是否是支付宝发出的合法消息 * @return 验证结果 */ function verifyNotify() { if (empty($_POST)) { //判断POST来的数组是否为空 return false; } else { //生成签名结果 $isSign = $this->getSignVerify($_POST, $_POST["sign"], true); //获取支付宝远程服务器ATN结果(验证是否是支付宝发来的消息) $responseTxt = 'true'; if (!empty($_POST["notify_id"])) { $responseTxt = $this->getResponse($_POST["notify_id"]); } //写日志记录 if ($this->alipay_config['log'] || true) { if ($isSign) { $isSignStr = 'true'; } else { $isSignStr = 'false'; } $log_text = "[===AliPay Notify===]responseTxt=" . $responseTxt . "\n notify_url_log:isSign=" . $isSignStr . "\n"; $log_text = $log_text . $this->createLinkString($_POST); Log::info($log_text); } //验证 //$responseTxt的结果不是true,与服务器设置问题、合作身份者ID、notify_id一分钟失效有关 //isSign的结果不是true,与安全校验码、请求时的参数格式(如:带自定义参数等)、编码格式有关 if (preg_match("/true\$/i", $responseTxt) && $isSign) { return true; } else { return false; } } }
public function friend($hash) { $friend = Friend::where(['verification_hash' => $hash])->firstOrFail(); $friend->markVerified(); Log::info('Friend number verified: ' . print_r($friend, true)); return "Verified!"; }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { // $inputs = $request->all(); WaterLevel::create(['watervalue' => $inputs['waterlevel']]); Log::info($inputs); }
public function handle() { $users = User::all(); foreach ($users as $user) { if ($user->message) { $client = new Client(['base_uri' => 'https://app.asana.com/api/1.0/', 'headers' => ['Authorization' => 'Bearer ' . $user->access_token]]); $response = $client->get('workspaces/8231054812149/tasks', ['query' => ['assignee' => $user->asana_id, 'completed_since' => 'now']]); $tasks = json_decode($response->getBody()); $latestTaskId = $user->getLatestTask($tasks->data); if (!$user->latest_task_id) { $user->latest_task_id = $latestTaskId; $user->save(); continue; } $newTasks = $user->getNewTasks($tasks->data); if (!$newTasks) { continue; } foreach ($newTasks as $newTask) { $client->post('tasks/' . $newTask->id . '/stories', ['form_params' => ['text' => $user->message]]); } $user->latest_task_id = $latestTaskId; $user->save(); Log::info('Message posted successfully', ['user' => $user->name, 'message' => $user->message, 'tasks' => $newTasks]); } } }
/** * Execute the console command. * * @return mixed */ public function handle() { $keyword = $this->argument('keyword'); $channel = Yt::getChannelByName('allocine'); if (!empty($channel)) { $manager = new \MongoDB\Driver\Manager('mongodb://localhost:27017'); $collection = new \MongoDB\Collection($manager, 'laravel.stats'); $collection->deleteMany([]); $collection = new \MongoDB\Collection($manager, 'laravel.stats'); $stat = ['origin' => 'Youtube', 'type' => 'search', 'data' => $channel, 'created' => new \MongoDB\BSON\UTCDatetime(time())]; $collection->insertOne($stat); } $params = ['q' => $keyword, 'type' => 'video', 'part' => 'id, snippet', 'maxResults' => 30]; $videos = Yt::searchAdvanced($params, true)['results']; if (!empty($videos)) { $collection = new \MongoDB\Collection($manager, 'laravel.videos'); $collection->deleteMany([]); foreach ($videos as $video) { $collection = new \MongoDB\Collection($manager, 'laravel.videos'); $stat = ['data' => $video, 'created' => new \MongoDB\BSON\UTCDatetime(time())]; $collection->insertOne($stat); } } Log::info("Import de l'API Youtube video done! "); }
public function createList(array $deviceArray) { //Get App User $appUserObj = $this->axl->getAppUser(env('CUCM_LOGIN')); Log::info('getAppUser(),$appUserObj,', [$appUserObj]); //Create Device Array $appUserDeviceArray = createDeviceArray($appUserObj, $deviceArray); Log::info('createDeviceArray(),$appUserDeviceArray,', [$appUserDeviceArray]); //Associate Devices to App User $res = $this->axl->updateAppUser(env('CUCM_LOGIN'), $appUserDeviceArray); Log::info('updateAppUser(),$res,', [$res]); //Create RIS Port Phone Array $risArray = createRisPhoneArray($deviceArray); Log::info('createRisPhoneArray(),$risArray,', [$risArray]); //Get Device IP's from RIS Port $SelectCmDeviceResult = $this->sxml->getDeviceIp($risArray); Log::info('getDeviceIp(),$SelectCmDeviceResult,', [$SelectCmDeviceResult]); //Process RIS Port Results $risPortResults = processRisResults($SelectCmDeviceResult, $risArray); //Fetch device model from type product for ($i = 0; $i < count($risPortResults); $i++) { if ($risPortResults[$i]['IsRegistered']) { $results = $this->axl->executeSQLQuery('SELECT name FROM typeproduct WHERE enum = "' . $risPortResults[$i]['Product'] . '"'); $risPortResults[$i]['Model'] = $results->return->row->name; } } Log::info('processRisResults(),$risPortResults,', [$risPortResults]); return $risPortResults; }
/** * Test store, update and delete. */ public function testStoreUpdateAndDelete() { $requestBody = <<<EOT { "data" : { "type" : "pricelists", "attributes" : { "company_id" : "1", "name": "pricelist_1" } } } EOT; // Create $response = $this->callPost(self::API_URL, $requestBody); $this->assertEquals(Response::HTTP_CREATED, $response->getStatusCode()); $this->assertNotNull($obj = json_decode($response->getContent())->data); $this->assertNotEmpty($obj->id); //$this->assertNotEmpty($obj->headers->get('Location')); // re-read and check $this->assertNotNull($obj = json_decode($this->callGet(self::API_URL . $obj->id)->getContent())->data); $this->assertEquals('pricelist_1', $obj->attributes->name); // Update $requestBody = "{\n \"data\" : {\n \"type\" : \"pricelists\",\n \"id\" : \"{$obj->id}\",\n \"attributes\" : {\n \"company_id\" : \"1\",\n \"name\" : \"pricelist_2\"\n }\n }\n }"; Log::info($requestBody); $response = $this->callPatch(self::API_URL . $obj->id, $requestBody); Log::info($response); $this->assertEquals(Response::HTTP_NO_CONTENT, $response->getStatusCode()); // re-read and check $this->assertNotNull($obj = json_decode($this->callGet(self::API_URL . $obj->id)->getContent())->data); $this->assertEquals('pricelist_2', $obj->attributes->name); // Delete $response = $this->callDelete(self::API_URL . $obj->id); $this->assertEquals(Response::HTTP_NO_CONTENT, $response->getStatusCode()); }
/** * Store a newly created resource in storage. * * @return Response */ public function ctlStore(Request $request) { Log::info('Received CTL Erase request for: ' . $request->input('macAddress')); $this->dispatch(new EraseTrustList($request->input('macAddress'), 'ctl')); Flash::success('Processed Request. Check table below for status.'); return redirect('ctl'); }
/** * Insert all Genus/Species into the BOLD table. * * @param array $genusSpeciesList * An array of the Genus/Species list. * * @return void */ public function insertRecords($genusSpeciesList) { foreach ($genusSpeciesList as $gs) { DB::insert('INSERT INTO bold (genus_species) VALUES (?)', [$gs]); } Log::info("Done adding records to the BOLD table."); print "Done adding records to the BOLD table." . PHP_EOL; }
/** * Create user login activity * * @param Authenticatable $user * @param $event_name * @return bool */ protected function createActivity($user, $event_name) { if (!$user) { return false; } Log::info('[' . strtoupper($event_name) . '] User #' . $user->id, $user->toArray()); return true; }
public function handle(Services_Twilio $twilio) { $recordings = $twilio->account->recordings->getIterator(0, 1000, ['DateCreated<' => Carbon::now()->subDays(2)->format('Y-m-d')]); foreach ($recordings as $recording) { Log::info("Deleting recording {$recording->sid}."); $twilio->account->recordings->delete($recording->sid); } }
/** * Log event * * @param $model * @param $event * @return mixed */ public function log($model, $event) { $attributes = $model->getAttributes(); $original = $model->getOriginal(); $activity = ['user_id' => Auth::user() ? Auth::user()->id : null, 'ip_address' => Request::ip(), 'event' => $event, 'before' => $event == 'deleted' ? json_encode($attributes) : json_encode(array_diff_assoc($original, $attributes)), 'after' => json_encode(array_diff_assoc($attributes, $original)), 'description' => $model->activityDescription($event, Auth::user() ? Auth::user() : null)]; Log::info('[' . strtoupper($event) . ']', $activity); return true; }
/** * Logs in a student * @param Request $request * @return \Illuminate\Http\RedirectResponse */ public function login(Request $request) { Log::info($request->all()); if (Auth::attempt(['examination_no' => $request->examination_no, 'password' => $request->password])) { return redirect()->to('/'); } return back(); }
/** * Display a listing of the resource. * * @return Response */ public function index() { Log::info('infoメッセージ'); Log::debug('debugメッセージ'); Log::warning('warningメッセージ'); Log::error('errorメッセージ'); return view('welcome'); }
/** * Handle the event. * * @param QueryExecuted $event * @return void */ public function handle(QueryExecuted $event) { if (env('APP_ENV', 'production') == 'local') { $sql = str_replace("?", "'%s'", $event->sql); $log = vsprintf($sql, $event->bindings); Log::info($log); } }
/** * Render an exception into an HTTP response. * * @param \Illuminate\Http\Request $request * @param \Exception $e * @return \Illuminate\Http\Response */ public function render($request, Exception $e) { if ($e instanceof MethodNotAllowedHttpException) { Log::info('Excepcion MethodNotAllowedHttpException', ['message' => $e->getMessage()]); return response()->view('errors.404', [], 404); } return parent::render($request, $e); }