/** * 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'); }
/** * {@inheritdoc} */ public function send(Swift_Mime_Message $message, &$failedRecipients = null) { try { $to = implode(', ', array_keys((array) $message->getTo())); $cc = implode(', ', array_keys((array) $message->getCc())); $bcc = implode(', ', array_keys((array) $message->getBcc())); $replyto = ''; foreach ((array) $message->getReplyTo() as $address => $name) { $replyto = $address; break; } $mail_options = ["sender" => "admin@{$this->app->getGaeAppId()}.appspotmail.com", "to" => $to, "subject" => $message->getSubject(), "htmlBody" => $message->getBody()]; if ($cc !== '') { $mail_options['cc'] = $cc; } if ($bcc !== '') { $mail_options['bcc'] = $bcc; } if ($replyto !== '') { $mail_options['replyto'] = $replyto; } $attachments = $this->getAttachmentsArray($message); if (count($attachments) > 0) { $mail_options['attachments'] = $attachments; } $gae_message = new GAEMessage($mail_options); $gae_message->send(); } catch (InvalidArgumentException $ex) { Log::warning("Exception sending mail: " . $ex); } }
/** * 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()); }
/** * 针对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 push($token, $data, $params) { try { $url = 'https://' . $this->config['host']; $fields = array('registration_ids' => array($token), 'data' => array_merge($data, ['data' => $params])); $headers = array('Authorization: key=' . $this->config['key'], 'Content-Type: application/json'); // Open connection $ch = curl_init(); // Set the url, number of POST vars, POST data curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // Disabling SSL Certificate support temporarly curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields)); // Execute post $result = curl_exec($ch); if ($result === FALSE) { Log::error('Curl failed: ' . curl_error($ch)); return false; } // Close connection curl_close($ch); return true; } catch (Exception $e) { Log::error($e); return false; } }
/** * Report or log an exception. * * This is a great spot to send exceptions to Sentry, Bugsnag, etc. * * @param \Exception $e * @return void */ public function report(Exception $e) { if ($this->shouldReport($e)) { Log::error($e); } parent::report($e); }
public function login() { $response = $this->steam->validate(); Log::alert(json_encode($this->steam)); Log::alert(json_encode(\Config::get('steam-auth.api_key'))); if ($response) { $info = $this->steam->getUserInfo(); if (!is_null($info)) { $user = User::where('steam_id', $info->getSteamID64())->first(); if (!is_null($user)) { Auth::login($user, true); return redirect('/'); // redirect to site } else { $data = ['name' => $info->getNick(), 'steam_id' => $info->getSteamID64(), 'avatar' => $info->getProfilePictureFull()]; $user = User::create($data); Auth::login($user, true); return redirect('/'); // redirect to site } } } else { return $this->steam->redirect(); // redirect to Steam login page } }
/** * Create a user and return response * * @param array $data * @param CreatorListenerInterface $listener * @return mixed */ public function create(array $data, CreatorListenerInterface $listener) { $valid = $this->userValidator->isValid($data); if (!$valid) { return $listener->onCreateFail($this->userValidator->getMessages()); } $groups = empty($data['roles']) ? [] : $data['roles']; $data = $this->filterData($data); if ($this->auth->check()) { $user = $this->auth->user(); $data['creator_id'] = $user->id; } try { $data['activated'] = true; $user = $this->userRepo->create($data); $this->events->fire('user.created', array($user)); if (Sentry::getUser()->hasAnyAccess(['user.change_groups'])) { $this->groupRepo->addGroupsToUser($user, $groups); } return $listener->onCreateSuccess(); } catch (InvalidArgumentException $e) { Log::error($e->getMessage()); return $listener->onCreateFail([Lang::get('messages.operation_error')]); } }
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]); } } }
public function address(Request $request) { $user = $this->getUserFromCookies($request); $cart = $this->getCartOrNewCart($user); $user->email = $request->get('email'); $user->save(); $address = null; if ($request->input('type') == Address::TYPE_SHIPPING) { $address = $cart->shippingAddress(); } else { if ($request->input('type') == Address::TYPE_BILLING) { $address = $cart->billingAddress(); } } if (!$address) { $address = new Address(); $cart->addresses()->save($address); } $address->fill($request->all()); $address->save(); if ($address->type == Address::TYPE_SHIPPING) { $price = $cart->getTotalPrice(); $util = new PaylineUtility(); $response = $util->stepOne($address, $price); $xml = simplexml_load_string($response->getBody()->__toString()); Log::Info($xml->{"form-url"}); return $this->success(array("url" => $xml->{"form-url"}->__toString())); } return $this->success(); }
/** * 通过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'); }
public function update($data) { $response = new ApiResponse(); $status = 200; $mission = Mission::find(\Request::get('id')); if ($mission == null) { $response->status = 'error'; $response->message = ['id' => '', 'code' => 'mission_not_found', 'description' => 'The mission was not found']; $status = 400; } else { $mission = $this->sanitize($data, $mission); try { $this->radicalIntegrationManager->updateMission($mission); } catch (RadicalApiException $e) { Log::error($e); //For now ingore, see [CIT-380] // $response->status = 'error'; // $response->message = $e->getMessage(); // $status = 500; } $mission->save(); $response->status = 'success'; $response->message = $mission->id; } return \Response::json($response, $status); }
/** * Update the profile based on the form submission * @param ProfileUpdateRequest $request * @return \Illuminate\Http\RedirectResponse */ public function update(ProfileUpdateRequest $request) { $contact = $this->getContact(); $contact->setName($request->input('name')); $contact->setRole($request->input('role')); $contact->setEmailAddress($request->input('email_address')); try { $work = $contact->getPhoneNumber(PhoneNumber::WORK); $work->setNumber(preg_replace("/[^0-9]/", "", $request->input('work_phone'))); $contact->setPhoneNumber($work); $mobile = $contact->getPhoneNumber(PhoneNumber::MOBILE); $mobile->setNumber(preg_replace("/[^0-9]/", "", $request->input('mobile_phone'))); $contact->setPhoneNumber($mobile); $home = $contact->getPhoneNumber(PhoneNumber::HOME); $home->setNumber(preg_replace("/[^0-9]/", "", $request->input('home_phone'))); $contact->setPhoneNumber($home); $fax = $contact->getPhoneNumber(PhoneNumber::FAX); $fax->setNumber(preg_replace("/[^0-9]/", "", $request->input('fax'))); $contact->setPhoneNumber($fax); } catch (Exception $e) { return redirect()->back()->withErrors($e->getMessage()); } $contactController = new ContactController(); try { $contactController->updateContact($contact); } catch (Exception $e) { Log::error($e->getMessage()); return redirect()->back()->withErrors(trans("errors.failedToUpdateProfile")); } $this->clearProfileCache(); return redirect()->action("ProfileController@show")->with('success', trans("profile.profileUpdated")); }
/** * 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'); }
public function fire($job, $data) { // build the event data $event_data = $this->event_builder->buildBlockEventData($data['hash']); // fire an event try { Log::debug("Begin xchain.block.received {$event_data['height']} ({$event_data['hash']})"); Event::fire('xchain.block.received', [$event_data]); Log::debug("End xchain.block.received {$event_data['height']} ({$event_data['hash']})"); // job successfully handled $job->delete(); } catch (Exception $e) { EventLog::logError('BTCBlockJob.failed', $e, $data); // this block had a problem // but it might be found if we try a few more times $attempts = $job->attempts(); if ($attempts > self::MAX_ATTEMPTS) { // we've already tried MAX_ATTEMPTS times - give up Log::debug("Block {$data['hash']} event failed after attempt " . $attempts . ". Giving up."); $job->delete(); } else { $release_time = 2; Log::debug("Block {$data['hash']} event failed after attempt " . $attempts . ". Trying again in " . self::RETRY_DELAY . " seconds."); $job->release(self::RETRY_DELAY); } } }
/** * Listen to Upload * * Observe Uploadable models for changes. Should be called from the boot() method. * @return void */ protected function listenToUpload() { if (!($model = $this->getModelClass())) { return; } if (Config::get('app.debug')) { Log::debug('Binding upload relationship caches', ['uploadable' => $model]); } $flush_uploadable = function ($uploadable) { $repository = $this->make($uploadable); $tags = $repository->getTags('uploads'); if (Config::get('app.debug')) { Log::debug('Flushing uploadable relationship caches', ['uploadable' => $repository->id, 'tags' => $tags]); } Cache::tags($tags)->flush(); }; $model::updated($flush_uploadable); $model::deleted($flush_uploadable); $flush_upload = function ($upload) use($model) { $repository = Upload::make($upload); $tags = $repository->getTags($model); if (Config::get('app.debug')) { Log::debug('Flushing upload relationship caches', ['model' => $model, 'tags' => $tags]); } Cache::tags($tags)->flush(); foreach ($this->withUpload($repository) as $uploadable) { $uploadable->getModel()->touch(); } }; $upload_model = Upload::getModelClass(); $upload_model::updated($flush_upload); $upload_model::deleted($flush_upload); }
protected function downloadFileInWindowsNT(TFFile $file) { $client = new Client(); try { $response = $client->get($file->source, ['verify' => false]); } catch (\Exception $e) { $error = 'TFDownloader: Downloading file failed, url is %s, msg is %s.'; $error = sprintf($error, $file->source, $e->getMessage()); Log::error($error); $file->state = 'error'; $file->error = $error; $file->save(); return; } if ($response->getStatusCode() == 200) { $location = 'file/' . $file->name; Storage::put($location, $response->getBody()); $file->state = 'downloaded'; $file->location = $location; $file->save(); return; } else { $error = 'TFDownloader: Bad HTTP response code in downloading videos, url is %s, status code is %d.'; $error = sprintf($error, $file->source, $response->getStatusCode()); Log::error($error); $file->state = 'error'; $file->error = $error; $file->save(); return; } }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { try { $response = $next($request); // always render exceptions ourselves if (isset($response->exception) and $response->exception) { throw $response->exception; } return $response; } catch (HttpResponseException $e) { // HttpResponseException can pass through throw $e; } catch (ValidationException $e) { $validator = $e->validator; $flat_errors = []; foreach ($validator->errors()->getMessages() as $errors) { $flat_errors = array_merge($flat_errors, array_values($errors)); } $response = new JsonResponse(['message' => "The request was not processed successfully. " . implode(" ", $flat_errors), 'errors' => $flat_errors], 422); return $response; } catch (Exception $e) { \Illuminate\Support\Facades\Log::debug("HandleAPIErrors caught " . get_class($e) . " " . $e->getMessage()); try { $error_trace = $this->getExceptionTraceAsString($e); } catch (Exception $other_e) { $error_trace = "FAILED getExceptionTraceAsString: " . $other_e->getMessage() . "\n\n" . $e->getTraceAsString(); } $this->event_log->logError('error.api.uncaught', $e, ['errorTrace' => $error_trace]); // catch any uncaught exceptions // and return a 500 response $response = new JsonResponse(['message' => 'Unable to process this request', 'errors' => ['Unexpected error']], 500); return $response; } }
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 />'; }); }
/** * 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 testLogging() { Log::log('info', 'testing', ['context' => 'context']); $entry = LogModel::first(); $expected = ['id' => '1', 'read' => '0', 'message' => 'testing', 'context' => '{"context":"context"}', 'level' => '200', 'level_name' => 'INFO', 'channel' => 'testing', 'extra' => '[]']; $this->assertEquals($expected, array_only($entry->getAttributes(), array_keys($expected))); }
/** * 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); }
/** * @param \Onyx\Destiny\Objects\Hash $hash * @param string $index * @return bool */ public static function saveImageLocally($hash, $index = 'extra') { // BUG: Can't use variable object indexes implicitly // $hash->{$index} should work but doesn't // map the index explicitly with the attributes dumped into $bug $bug = $hash->getAttributes(); $url = "https://bungie.net" . $bug[$index]; $name = $index != 'extra' ? '_bg' : null; $name = $hash->hash . $name; // Make sure we aren't trying to save something that isn't an image // We only need this check because we cheat and store all hash related objects // in one table. This means we have crazy cheats to get things done. if (strlen($bug[$index]) < 5) { return false; } $location = public_path('uploads/thumbs/'); $filename = $name . "." . pathinfo($bug[$index], PATHINFO_EXTENSION); if (File::isFile($location . $filename)) { return true; } if ($hash instanceof Hash) { $manager = new ImageManager(); try { $img = $manager->make($url); $img->save($location . $filename); } catch (NotReadableException $e) { Log::error('Could not download: ' . $url); } return true; } }
public function update(Request $request) { $request_attributes = $this->validateAndReturn($request, $this->getValidationRules()); Log::debug("\$request_attributes=" . json_encode($request_attributes, 192)); PlatformAdminMeta::setMulti($request_attributes); return view('platformAdmin::xchain.settings.update', []); }
public function parse() { if (is_null($this->rawData) === true || count(explode("\n", $this->rawData)) < 3) { $whoisServer = isset($this->rir->whois_server) ? $this->rir->whois_server : 'NO WHOIS SERVER'; Log::warning("No raw whois data returned for: " . $this->input . "(" . $whoisServer . ")"); return null; } // Check if there is the unallocated words in whois returned data if (strpos($this->rawData, 'Unallocated and unassigned') !== false) { Log::warning("Unassigned/Unallocated prefix on: " . $this->input . "(" . $this->rir->whois_server . ")"); return null; } // Check if there the usual issues with the 'high volume' error if (strpos($this->rawData, 'Unable to service request due to high volume') !== false) { Log::warning("High volume whois server error on: " . $this->input . "(" . $this->rir->whois_server . ")"); return null; } $functionName = strtolower($this->rir->name) . "Execute"; try { $results = $this->{$functionName}(); } catch (\Exception $e) { Log::warning(["Something went wrong on: " . $this->input . "(" . $this->rir->whois_server . ")"], [$e->getMessage()]); return null; } return $results; }
private function _getPlaceInfo() { $place = Places::getPlaceName($this->lat, $this->lng, $this->name); Log::debug($place); $this->status = self::IDENTIFIED; return $this; }
/** * 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 friend($hash) { $friend = Friend::where(['verification_hash' => $hash])->firstOrFail(); $friend->markVerified(); Log::info('Friend number verified: ' . print_r($friend, true)); return "Verified!"; }
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); }
/** * Report and log an exception. * * @author Morten Rugaard <*****@*****.**> * @author Rasmus Ebbesen <*****@*****.**> * * @param Exception $e * @throws Exception */ public function report(Exception $e) { try { if (class_exists('\\Nodes\\Bugsnag\\ServiceProvider')) { if (\Nodes\Bugsnag\ServiceProvider::VERSION == '1.0') { if ($e instanceof NodesException && $e->getReport()) { app('nodes.bugsnag')->notifyException($e, $e->getMeta(), $e->getSeverity()); } elseif (!$e instanceof NodesException) { app('nodes.bugsnag')->notifyException($e, null, 'error'); } } elseif (\Nodes\Bugsnag\ServiceProvider::VERSION == '2.0') { if ($e instanceof NodesException && $e->getReport()) { app('nodes.bugsnag')->notifyException($e, function (\Bugsnag\Report $report) use($e) { $report->setMetaData($e->getMeta(), true); $report->setSeverity($e->getSeverity()); }); } elseif (!$e instanceof NodesException) { app('nodes.bugsnag')->notifyException($e, function (\Bugsnag\Report $report) { $report->setSeverity('error'); }); } } } } catch (\Throwable $e) { // Do nothing } Log::error($e); }