/** * Execute the job. * * @return void */ public function handle() { $s3 = \Storage::disk('s3'); $filePath = '/jacobsgroupvegas/properties/' . env('APP_ENV') . '/' . $this->mls . '/' . $this->filename; $s3->put($filePath, file_get_contents('/tmp' . '/property-' . $this->mls . '-image-' . $this->filename), 'public'); dispatch((new KillImageFromDisk($this->localDiskImage))->onQueue('killImage')); }
/** * Run the database seeds. * * @return void */ public function run() { /** * Create Roles by giving it an array */ dispatch(new CreateRolesJob(['admin', 'manager', 'user'])); }
function handle($uri = '') { try { if (($matched = dispatch($uri)) != null) { if (!before()) { $handler = $matched['handler']; if (!empty($matched['options']['router'])) { $handler = call_user_func($handler, $matched); } if (!empty($matched['options']['create'])) { $controllerClass = $handler[0]; $handler[0] = new $controllerClass(); } if (isset($matched['params'])) { call_user_func_array($handler, $matched['params']); } else { call_user_func_array($handler, $matched['segments']); } after(); } } else { notFound(); } finish(); } catch (Exception $e) { error_log($e->getMessage()); error_log($e->getTraceAsString()); } exit; }
/** * Run the database seeds. * * @return void */ public function run() { /** * Login Api */ dispatch(new CreateAPIHelpJob(['route' => 'api.user.login', 'description' => 'Log the user in the system and returns a unique token', 'parameters' => json_encode(['credential' => 'Required - Username or Email', 'password' => 'Required - User Password']), 'response' => json_encode(["username" => "test", "email" => "*****@*****.**", "gender" => 'male', "country_id" => "30", "age_id" => 1, "api_token" => "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9...", "newsletter" => "0"]), 'response_error' => json_encode(['error' => 'invalid_username_or_password', "credential" => ["The credential field is required."], "password" => ["The password field is required."]])])); /** * Register Api */ dispatch(new CreateAPIHelpJob(['route' => 'api.user.register', 'description' => 'Register a new User into the database', 'parameters' => json_encode(['username' => 'Required - Unique Username', 'email' => 'Required - User Email', 'password' => 'Required - User Password', 'password_confirmation' => 'Required - Password Confirmation', 'terms' => 'Required - Accept the terms and conditions of usage', 'gender' => 'User Gender Male or Female', 'country_id' => 'Country id as on Country Api', 'newsletter' => 'Accept to Receive newsletter', 'age_id' => 'Age ID']), 'response' => json_encode(["username" => "test", "email" => "*****@*****.**", "gender" => null, "country_id" => "30", "age_id" => 2, "api_token" => "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9...", "newsletter" => "0"]), 'response_error' => json_encode(["error" => ["username" => ["The username field is required."], "email" => ["The email field is required. | The email has already been taken."], "password" => ["The password field is required."], "terms" => ["The terms field is required."]]])])); /** * Products Api */ dispatch(new CreateAPIHelpJob(['route' => 'api.product.index', 'description' => 'Return list with all available products', 'parameters' => json_encode(['api_token' => 'Required - User Token']), 'response' => json_encode([["id" => 1, "code" => "MF001", "name" => "Batman Stand Version I"], ["id" => 2, "code" => "MF002", "name" => "Superman Stand Version I"], ["id" => 3, "code" => "MF003", "name" => "Worderwoman Stand Version I"]]), 'response_error' => json_encode([["error" => "token_not_provided"], ["error" => "invalid_token"]])])); /** * Single Product Show */ dispatch(new CreateAPIHelpJob(['route' => 'api.product.show', 'description' => 'Return information about an specific product', 'parameters' => json_encode(['api_token' => 'Required - User Token', 'product_id' => 'Required - Product Code or ID', 'encode_image' => 'Optional - Determine whether retrieve image as a link or as Base64']), 'response' => json_encode(["id" => 1, "name" => "Batman Stand Version I", "code" => "MF001", "image" => ["image/products/MF001.png", ['mime' => "image/png", 'dirname' => "image/products", 'basename' => "MF001.png", 'extension' => "png", 'filename' => "MF001", 'encoder' => 'data:image/png;base64,iVBORw0KGgoAAAANSUh....']]]), 'response_error' => json_encode([["error" => "invalid_code"], ["error" => "token_not_provided"], ["error" => "invalid_token"]])])); /** * Product Register */ dispatch(new CreateAPIHelpJob(['route' => 'api.product.register', 'description' => 'Return information about an specific product', 'parameters' => json_encode(['api_token' => 'Required - User Token', 'code' => 'Required - Product Code']), 'response' => json_encode(["status" => 'okay']), 'response_error' => json_encode([["error" => "invalid_code"], ["error" => "token_not_provided"], ["error" => "invalid_token"], ["error" => " code_has_been_taken"]])])); /** * Forms Api */ /** * Countries */ dispatch(new CreateAPIHelpJob(['route' => 'api.form.countries', 'description' => 'Return a list with all countries', 'parameters' => null, 'response' => json_encode(["id" => 50, "code" => "CN", "name" => "China (中国)"]), 'response_error' => null])); /** * Ages */ dispatch(new CreateAPIHelpJob(['route' => 'api.form.ages', 'description' => 'Return a list with all ages', 'parameters' => null, 'response' => json_encode(["id" => 1, "from" => 10, "to" => 20]), 'response_error' => null])); }
public function removePermission($permission) { if ($permission = $this->collectPermissions($permission)) { $this->permissions()->detach($permission); dispatch(new EvictCachedRolePermissions($this)); } }
/** * Adds a Job to the queue only if one does not * already exist. * * @param $job * @param $args * * @return mixed */ public function addUniqueJob($job, JobPayloadContainer $args) { // Refuse to pop a job onto the queue if the admin // has not yet configured an administrative contact. // See: https://github.com/eveseat/seat/issues/77 (Request by CCP) if ($this->hasDefaultAdminContact()) { logger()->error('Default admin contact still set. Not queuing job for: ' . $args->api); return 'Failed to queue due to default config'; } // Look for an existing job $job_id = JobTracking::where('owner_id', $args->owner_id)->where('api', $args->api)->whereIn('status', ['Queued', 'Working'])->value('job_id'); // Just return if the job already exists if ($job_id) { logger()->warning('A job for Api ' . $args->api . ' and owner ' . $args->owner_id . ' already exists.'); return $job_id; } // Add a new job onto the queue... $new_job = (new $job($args))->onQueue($args->queue); $job_id = dispatch($new_job); // Check that the id we got back is a random // string and not 0. In fact, normal job_ids // are like a 32char string, so just check that // its more than 2. If its not, we can assume // the job itself was not sucesfully added. // If it actually is queued, it will get discarded // when trackOrDismiss() is called. if (strlen($job_id) < 2) { return; } // ...and add tracking information JobTracking::create(['job_id' => $job_id, 'owner_id' => $args->owner_id, 'api' => $args->api, 'scope' => $args->scope, 'status' => 'Queued']); return $job_id; }
public function actionBulk(Request $request) { $input = $request->all(); $ids = (isset($input['table_records']) and is_array($input['table_records'])) ? $input['table_records'] : [$input['table_records']]; // dd($ids); $message = ''; $error = 0; if (empty($ids)) { return redirect()->back(); } switch ($input['submit']) { case 'delete': foreach ($ids as $id) { ClassroomInterval::where('id', $id)->has('sessions', '=', 0)->delete(); } $message = 'تم الحذف بنجاح'; break; case 'generate': foreach (ClassroomInterval::whereIn('id', $ids)->waiting()->get() as $interval) { $interval->state = 'generating'; $interval->save(); dispatch(new CreateVirtualClassroomsJobs($interval)); return redirect()->route('classrooms.intervals.index'); } break; default: # code... break; } return redirect()->back()->with($error ? 'error' : 'success', $message); }
/** * Swap subscription. * * @return Response */ public function swapForFree(Subscription $subscription) { if ($subscription->price != 0) { return false; } dispatch(new swapSubscription($subscription, $this->user)); return true; }
function smarty_function_dispatch($params, $template) { //$saved_REQUEST = $_REQUEST; //$_REQUEST = $params; $str = dispatch($params['c'], $params['a']); //$_REQUEST = $saved_REQUEST; return $str; }
/** * Execute the console command. * * @return mixed */ public function handle() { \Redis::subscribe('demeterMiddle', function ($message) { $m = json_decode($message); echo var_dump($m); dispatch(new \App\Jobs\handleVmRequest($m)); }); }
/** * Execute the job. * * @return void */ public function handle() { $properties = \App\Property::all(); foreach ($properties as $property) { $property->delete(); } dispatch((new RemoveUnrelatedImages())->onQueue('killImage')); }
protected function execCommand() { $transaction = $this->order->transaction; $command = $transaction->command; if ($command) { dispatch(new $command($this->order)); } }
/** * Handle the event. * * @param Purchase $event * @return void */ public function handle(Purchase $event) { $customer = $event->customer; $order = $event->order; if (is_null(Order::where('customer_id', $customer->id)->where('order_status_id', '>=', 2)->where('id', '!=', $order->id)->first())) { dispatch(new FirstOrderFeedback($customer)); } }
/** * Handle the event. * * @param Purchase $event * @return void */ public function handle(Purchase $event) { $customer = $event->customer; $upper = $customer->getReferrer(); $order = $event->order; if ($upper && in_array($upper->doctorType(), ['A', 'B'])) { dispatch(new CashConsumeFeedback($upper, $order->cash_payment)); } }
/** * Creates a new scheduled maintenance "incident". * * @return \Illuminate\Http\RedirectResponse */ public function addScheduleAction() { try { $incident = dispatch(new ReportMaintenanceCommand(Binput::get('name'), Binput::get('message'), Binput::get('notify'), Binput::get('scheduled_at'))); } catch (ValidationException $e) { return Redirect::route('dashboard.schedule.add')->withInput(Binput::all())->withSuccess(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.schedule.add.failure')))->withErrors($e->getMessageBag()); } return Redirect::route('dashboard.schedule.index')->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.schedule.add.success'))); }
/** * Handle the event. * * @param Purchase $event * @return void */ public function handle(Purchase $event) { $customer = $event->customer; $upper = $customer->getReferrer(); $order = $event->order; if ($upper && is_null(Order::where('customer_id', $customer->id)->where('order_status_id', '>=', 2)->where('id', '!=', $order->id)->first())) { dispatch(new PatientFirstOrder($upper)); } }
/** * Post * @param Request $request * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function post(Request $request) { $this->validate($request, ['route' => 'required', 'description' => 'required']); /** * Create APIHelp */ dispatch(new CreateAPIHelpJob($request->toArray())); return redirect()->back()->with('success', 'Api Created Successfully'); }
public function postCoding() { if (\Input::get('token') == config('app.key')) { dispatch(new WebDeploy()); echo 'Send Deploy Request!'; } else { \Log::error('Deploy! But Token Error!'); } }
/** * Handle the disable repo command. * * @param \StyleCI\StyleCI\Commands\Repo\DisableRepoCommand $command * * @return void */ public function handle(DisableRepoCommand $command) { $repo = $command->repo; foreach ($repo->analyses as $analysis) { dispatch(new DeleteAnalysisCommand($analysis)); } event(new RepoWasDisabledEvent($repo)); $repo->delete(); }
/** * Handle the analysis has completed event. * * We have a 1 in 8 chance of performing a cleanup. * * @param \StyleCI\StyleCI\Events\Analysis\AnalysisHasCompletedEvent $event * * @return void */ public function handle(AnalysisHasCompletedEvent $event) { if (random_int(0, 7) > 0) { return; } foreach (Analysis::old()->pending()->orderBy('created_at', 'asc')->get() as $analysis) { dispatch(new CleanupAnalysisJob($analysis)); } }
/** * Execute the console command. * * @param \Seat\Eveapi\Helpers\JobPayloadContainer $job * * @return mixed */ public function handle(JobPayloadContainer $job) { $job->scope = 'Eve'; $job->api = 'Eve'; $job_id = $this->addUniqueJob(UpdatePublic::class, $job); $this->info('Job ' . $job_id . ' dispatched!'); // Analytics dispatch((new Analytics((new AnalyticsContainer())->set('type', 'event')->set('ec', 'queues')->set('ea', 'update_eve')->set('el', 'console')))->onQueue('medium')); }
/** * Updates the order of component groups. * * @return array */ public function postUpdateComponentGroupOrder() { $groupData = Binput::get('ids'); foreach ($groupData as $order => $groupId) { $group = ComponentGroup::find($groupId); dispatch(new UpdateComponentGroupCommand($group, $group->name, $order + 1, $group->collapsed)); } return $this->collection(ComponentGroup::query()->orderBy('order')->get()); }
protected function raiseIssue($title, $body, array $labels = []) { if (!$this->raise) { return; } if (strlen($body) == 0) { $body = $title; } dispatch(new CreateGitHubIssue('wasgeht-berlin', 'data-providers', $title, $body, $labels)); }
public function store($owner, $project) { $issueData = Input::get('issue'); try { $issue = dispatch(new AddIssueCommand(Auth::user()->id, $project->id, $issueData['title'], $issueData['description'])); } catch (ValidationException $e) { return Redirect::route('issue_new', ['owner' => $owner->slug, 'project' => $project->slug])->withInput(Input::all())->withErrors($e->getMessageBag()); } return Redirect::route('issue_show', ['owner' => $owner->slug, 'project' => $project->slug, $issue->iid])->withSuccess(sprintf('%s %s', trans('hifone.awesome'), trans('hifone.success'))); }
private function save_image($camera) { $client = new Client(['base_uri' => 'http://' . $camera['hostname'] . ':' . $camera['port'], 'timeout' => 2.0]); $uri = "/snapshot.cgi?user="******"&pwd=" . $camera['password'] . "&" . rand(1, 1000); \Log::info('http://' . $camera['hostname'] . ':' . $camera['port'] . $uri); $filepath = storage_path('app/' . $camera['hostname'] . '_' . date("y-m-d-his") . ".jpg"); $resource = fopen($filepath, 'w'); $client->request('GET', $uri, ['sink' => $resource]); dispatch(new UploadImage($filepath)); }
function require_role($roles) { if (has_role($roles)) { return true; } else { http_response_code(401); dispatch('siteuser/user_login'); exit; } }
/** * Execute the job. * * @return void */ public function handle() { if ($this->order->status != 'completed') { return; } $subscriptionId = $this->order->transaction->item_id; $subscription = Subscription::findOrFail($subscriptionId); event(new SubscriptionWasPurchased($subscription, $this->order)); dispatch(new swapSubscription($subscription, $this->order->user)); }
public function left() { if ($GLOBALS['frame'] == 1) { $this->_tpl->assign('target', 'main'); } else { $this->_tpl->assign('target', '_self'); } return dispatch('user', 'left'); //return $this->_tpl->fetch('user/left.html'); }
public function removeClosedImages($closedImages) { foreach ($closedImages as $image) { $propertyImage = \App\Image::find($image->id); if ($propertyImage) { $propertyImage->delete(); } dispatch((new KillImageFromDisk($image->dataUri))->onQueue('killImage')); } }
/** * Update User * * @param Request $request * @param User $user * @return \Illuminate\Http\RedirectResponse */ public function update(Request $request, User $user) { $update = $user && $user->email === $request->get('email') ? ',id,' . $user->id : ''; $this->validate($request, ['username' => 'required|alpha_dash', 'email' => 'required|email|unique:users' . $update, 'password' => 'sometimes|confirmed|min:6', 'gender' => 'string', 'age_id' => 'exists:ages,id', 'terms' => 'required|accepted', 'role_id' => 'required|exists:roles,id', 'country_id' => 'required|exists:countries,id']); /** * Update User */ dispatch(new UpdateUserJob($user, $request->only('username', 'password', 'email', 'gender', 'newsletter'), $request->only('role_id', 'country_id', 'age_id'))); return redirect()->route('user.edit', $user->id)->withSuccess('User updated successfully'); }