public function save(\Illuminate\Http\Request $request) { $id = Input::get('id'); //TODO set max $validator = \Illuminate\Support\Facades\Validator::make($request->all(), ['title' => 'required', 'subTitle' => 'required', 'preview' => 'required', 'editor-content' => 'required', 'category' => 'required']); if ($validator->fails()) { return redirect('home')->withErrors($validator)->withInput(); } $post = Post::where('id', '=', $id)->first(); $post->title = Input::get('title'); $post->sub_title = Input::get('subTitle'); $post->lang = Input::get('lang'); $post->preview = Input::get('preview'); $post->content = Input::get('editor-content'); if (Input::has('illustration')) { $destinationPath = 'uploads'; // upload path $extension = Input::file('illustration')->getClientOriginalExtension(); // getting image extension $fileName = rand(11111, 99999) . '.' . $extension; // renameing image Input::file('illustration')->move($destinationPath, $fileName); // uploading file to given path $post->img_path = $fileName; } $post->save(); $category = Category::where('post_id', '=', $post->id)->first(); $category->name = Input::get('category'); $category->save(); return Redirect::to('home'); }
public function update() { $appcodes = Appcodes::find(Input::get("id")); if (!$appcodes) { Session::flash('error', trans("appcodes.notifications.no_exists")); return Redirect::to("/appcodes/" . $appcodes->benefit_id); } $benefit_id = Input::has("benefit_id") ? Input::get("benefit_id") : ""; $number = Input::has("number") ? Input::get("number") : ""; $bar_code = "data:image/png;base64," . \DNS1D::getBarcodePNG($number, "C39+"); $client = Input::has("client") ? Input::get("client") : ""; $single_use = Input::has("single_use") ? Input::get("single_use") : ""; if ($number == "" || $bar_code == "" || $client == "" || $benefit_id == "") { Session::flash("error", trans("appcodes.notifications.field_name_missing")); return Redirect::to("/appcodes/{$appcodes->id}/edit")->withInput(); } $appcodes->benefit_id = $benefit_id; $appcodes->number = $number; $appcodes->bar_code = $bar_code; $appcodes->client = $client; $appcodes->single_use = $single_use; $appcodes->save(); Session::flash('success', trans("appcodes.notifications.update_successful")); return Redirect::to("/appcodes/" . $benefit_id); }
public function store(PostRequest $request) { if (Input::has('link')) { $input['link'] = Input::get('link'); $info = Embed::create($input['link']); if ($info->image == null) { $embed_data = ['text' => $info->description]; } else { if ($info->description == null) { $embed_data = ['text' => '']; } else { $orig = pathinfo($info->image, PATHINFO_EXTENSION); $qmark = str_contains($orig, '?'); if ($qmark == false) { $extension = $orig; } else { $extension = substr($orig, 0, strpos($orig, '?')); } $newName = public_path() . '/images/' . str_random(8) . ".{$extension}"; if (File::exists($newName)) { $imageToken = substr(sha1(mt_rand()), 0, 5); $newName = public_path() . '/images/' . str_random(8) . '-' . $imageToken . ".{$extension}"; } $image = Image::make($info->image)->fit(70, 70)->save($newName); $embed_data = ['text' => $info->description, 'image' => basename($newName)]; } } Auth::user()->posts()->create(array_merge($request->all(), $embed_data)); return redirect('/subreddit'); } Auth::user()->posts()->create($request->all()); return redirect('/subreddit'); }
/** * set pasword * * 1. get activation link * 2. validate activation * @param activation link * @return array of employee */ public function setPassword($activation_link) { if (!Input::has('activation')) { return new JSend('error', (array) Input::all(), 'Tidak ada data activation.'); } $errors = new MessageBag(); DB::beginTransaction(); //1. Validate activation Parameter $activation = Input::get('activation'); //1. get activation link $employee = Employee::activationlink($activation_link)->first(); if (!$employee) { $errors->add('Activation', 'Invalid activation link'); } //2. validate activation $rules = ['password' => 'required|min:8|confirmed']; $validator = Validator::make($activation, $rules); if ($validator->passes()) { $employee->password = $activation['password']; $employee->activation_link = ''; if (!$employee->save()) { $errors->add('Activation', $employee->getError()); } } else { $errors->add('Activation', $validator->errors()); } if ($errors->count()) { DB::rollback(); return new JSend('error', (array) Input::all(), $errors); } DB::commit(); return new JSend('success', ['employee' => $employee->toArray()]); }
/** * Display all EmployeeDocuments * * @param search, skip, take * @return JSend Response */ public function index($org_id = null, $employ_id = null) { $employee = \App\Models\Employee::organisationid($org_id)->id($employ_id)->first(); if (!$employee) { return new JSend('error', (array) Input::all(), 'Karyawan tidak valid.'); } $result = \App\Models\EmploymentDocument::personid($employ_id); if (Input::has('search')) { $search = Input::get('search'); foreach ($search as $key => $value) { switch (strtolower($key)) { default: # code... break; } } } $count = $result->count(); if (Input::has('skip')) { $skip = Input::get('skip'); $result = $result->skip($skip); } if (Input::has('take')) { $take = Input::get('take'); $result = $result->take($take); } $result = $result->with(['document', 'documentdetails', 'documentdetails.template'])->get()->toArray(); return new JSend('success', (array) ['count' => $count, 'data' => $result]); }
/** * Handles incoming requests from Gitlab or PHPCI to trigger deploy. * * @param string $hash The webhook hash * @return Response */ public function webhook($hash) { $project = $this->projectRepository->getByHash($hash); $success = false; if ($project->servers->where('deploy_code', true)->count() > 0) { // Get the branch if it is the rquest, otherwise deploy the default branch $branch = Input::has('branch') ? Input::get('branch') : $project->branch; $do_deploy = true; if (Input::has('update_only') && Input::get('update_only') !== false) { // Get the latest deployment and check the branch matches $deployment = $this->deploymentRepository->getLatestSuccessful($project->id); if (!$deployment || $deployment->branch !== $branch) { $do_deploy = false; } } if ($do_deploy) { $optional = []; // Check if the commands input is set, if so explode on comma and filter out any invalid commands if (Input::has('commands')) { $valid = $project->commands->lists('id'); $optional = collect(explode(',', Input::get('commands')))->unique()->intersect($valid); } // TODO: Validate URL and only accept it if source is set? $this->deploymentRepository->create(['reason' => Input::get('reason'), 'project_id' => $project->id, 'branch' => $branch, 'optional' => $optional, 'source' => Input::get('source'), 'build_url' => Input::get('url')]); $success = true; } } return ['success' => $success]; }
/** * Upload an image/file and (for images) create thumbnail * * @param UploadRequest $request * @return string */ public function upload() { try { $res = $this->uploadValidator(); if (true !== $res) { return Lang::get('laravel-filemanager::lfm.error-invalid'); } } catch (\Exception $e) { return $e->getMessage(); } $file = Input::file('upload'); $new_filename = $this->getNewName($file); $dest_path = parent::getPath('directory'); if (File::exists($dest_path . $new_filename)) { return Lang::get('laravel-filemanager::lfm.error-file-exist'); } $file->move($dest_path, $new_filename); if ('Images' === $this->file_type) { $this->makeThumb($dest_path, $new_filename); } Event::fire(new ImageWasUploaded(realpath($dest_path . '/' . $new_filename))); // upload via ckeditor 'Upload' tab if (!Input::has('show_list')) { return $this->useFile($new_filename); } return 'OK'; }
/** * Display a list of employee * @return \Illuminate\View\View */ public function index() { $title = 'EMPLOYEE'; if (Input::has('eid')) { $id = Input::get('eid'); $employees = Employee::where('eid', $id)->paginate(5); } elseif (Input::has('name')) { $name = Input::get('name'); $employees = Employee::where('name', 'like', '%' . $name . '%')->paginate(5); } elseif (Input::has('license')) { $license = Input::get('license'); $employees = Employee::where('license', 'like', '%' . $license . '%')->paginate(5); } elseif (Input::has('visa')) { $visa = Input::get('visa'); $employees = Employee::where('visa', 'like', '%' . $visa . '%')->paginate(5); } elseif (Input::has('per_country')) { $country = Input::get('per_country'); $employees = Employee::where('per_country', $country)->paginate(5); } else { $employees = Employee::paginate(10); } $repository = $this->repository; //dd($employees); return view('employee.index', compact('title', 'employees', 'repository')); }
public static function request() { $class = new static(); !Input::has('deleteShippingMethod') ?: $class->delete(Input::get('deleteShippingMethod')); !Input::has('updateShippingMethod') ?: $class->update(Input::get('updateShippingMethod'))->with(Input::get('shipping.fill')); !Input::has('addShippingMethod') ?: $class->add()->with(Input::get('shipping.fill')); }
public function dologin() { // validate the info, create rules for the inputs $rules = array('username' => 'required', 'password' => 'required'); // run the validation rules on the inputs from the form $validator = Validator::make(Input::all(), $rules); // if the validator fails, redirect back to the form if ($validator->fails()) { return Redirect::to('/')->withErrors($validator)->withInput(Input::except('password')); // send back the input (not the password) so that we can repopulate the form } else { // create our user data for the authentication $userdata = array('username' => Input::get('username'), 'password' => Input::get('password')); $remember = Input::has('remember_me') ? true : false; // attempt to do the login if (Auth::attempt($userdata, $remember)) { // validation successful! // redirect them to the secure section or whatever // return Redirect::to('secure'); // for now we'll just echo success (even though echoing in a controller is bad) return Redirect::to('user/dashboard'); } else { // validation not successful, send back to form return Redirect::to('login')->with('message', 'session broken'); } } }
public function postLogin() { $email = Input::get('email'); $password = Input::get('password'); $filter = $this->validateEmail($email); if ($filter) { return $filter; } $user = DB::table('users')->where('email', $email)->first(); if ($user == NULL) { $this->data['code'] = 4; $this->data['message'] = trans('rest.4'); $this->data['data']['authenticated'] = false; $this->data['data']['role'] = 'guest'; } elseif ($user->isActive) { if (Auth::attempt(['email' => $email, 'password' => $password, 'isActive' => 1, 'role' => 1], Input::has('remember'))) { $this->data['message'] = trans('rest.successfully'); $this->data['data']['authenticated'] = true; $this->data['data']['role'] = Auth::user()->role ? 'admin' : 'user'; $this->data['data']['user'][] = Auth::user(); } else { $this->data['code'] = 3; $this->data['message'] = trans('rest.3'); $this->data['data']['authenticated'] = false; $this->data['data']['role'] = 'guest'; } } else { $this->data['code'] = 5; $this->data['message'] = trans('rest.5'); $this->data['data']['authenticated'] = false; $this->data['data']['role'] = 'guest'; } return !isset($this->data['code']) ? redirect('admin/users') : view('login', ['errors' => $this->data['message']]); }
public function getIndex() { $limit = 100; $chat = $this->chat->leftJoin('tbl_server', 'tbl_chatlog.ServerID', '=', 'tbl_server.ServerID')->select('tbl_chatlog.*', 'tbl_server.ServerName')->orderBy('logDate', 'desc'); if (Input::has('limit') && in_array(Input::get('limit'), range(10, 100, 10))) { $limit = Input::get('limit'); } if (Input::has('nospam') && Input::get('nospam') == 1) { $chat = $chat->excludeSpam(); } if (Input::has('between')) { $between = explode(',', Input::get('between')); $startDate = Carbon::createFromFormat('Y-m-d H:i:s', $between[0]); if (count($between) == 1) { $endDate = Carbon::now(); } else { $endDate = Carbon::createFromFormat('Y-m-d H:i:s', $between[1]); } if ($startDate->gte($endDate)) { return MainHelper::response(null, sprintf("%s is greater than %s. Please adjust your dates.", $startDate->toDateTimeString(), $endDate->toDateTimeString()), 'error', null, false, true); } $chat = $chat->whereBetween('logDate', [$startDate->toDateTimeString(), $endDate->toDateTimeString()])->paginate($limit); } else { $chat = $chat->simplePaginate($limit); } return MainHelper::response($chat, null, null, null, false, true); }
public function getLogin() { if (Input::has('login')) { $this->login = Input::get('login'); $this->password = md5(Input::get('password')); $this->remember = Input::has('remember') ? true : false; } $this->queryU = $this->DBquery->queryU . "a.usernam = '{$this->login}' AND a.passwd='{$this->password}'"; $result = $this->DBquery->query($this->queryU); if ($result) { $this->ID = $result[0]['CLIENTID']; $_SESSION['valid_user'] = $result[0]['USERNAM']; $_SESSION['userCheck'] = '1'; if ($this->remember === 'true') { setcookie(['login' => $this->login, 'password' => $this->password]); } } // print_r( $_COOKIE); $validator = \Validator::make(array('login' => $this->login, 'password' => $this->password), array('login' => 'required|min:2|max:50', 'password' => 'required|min:6'), array('required' => 'Вы не ввели воле :attribute', 'max' => 'Поле :attribute не должно содержать больше :max символов', 'min' => 'Поле :attribute не должно содержать меньше :min символов')); /* if ($validator->fails()){ $errorMsg = $validator->messages(); $errors = ''; // foreach ($errorMsg->all() as $messages){ // $errors .=$messages."\n".nl2br('\n'); // } } else { if (\Auth::attempt(array('login'=>'login','password'=>'password'), $this->remember)){ return \Redirect::intended('main'); } else { $errors = 'Ошибка аутентификации'; } }*/ }
public function update(SubscriptionService $subscriptionService, DeltaVCalculator $deltaV, $object_id) { if (Input::has(['status', 'visibility'])) { $object = Object::find($object_id); if (Input::get('status') == ObjectPublicationStatus::PublishedStatus) { DB::transaction(function () use($object, $subscriptionService, $deltaV) { // Put the necessary files to S3 (and maybe local) if (Input::get('visibility') == VisibilityStatus::PublicStatus) { $object->putToLocal(); } $job = (new PutObjectToCloudJob($object))->onQueue('uploads'); $this->dispatch($job); // Update the object properties $object->fill(Input::only(['status', 'visibility'])); $object->actioned_at = Carbon::now(); // Save the object if there's no errors $object->save(); // Add the object to our elasticsearch node Search::index($object->search()); // Create an award wih DeltaV $award = Award::create(['user_id' => $object->user_id, 'object_id' => $object->object_id, 'type' => 'Created', 'value' => $deltaV->calculate($object)]); // Once done, extend subscription $subscriptionService->incrementSubscription($object->user, $award); }); } elseif (Input::get('status') == "Deleted") { $object->delete(); } return response()->json(null, 204); } return response()->json(false, 400); }
public function update($id) { try { $server = Server::findOrFail($id); $setting = $server->setting; if (Input::has('rcon_password') && !empty(trim(Input::get('rcon_password')))) { $password = Input::get('rcon_password'); $setting->rcon_password = trim($password); } if (Input::has('filter')) { $chars = array_map('trim', explode(',', Input::get('filter'))); $setting->filter = implode(',', $chars); } else { $setting->filter = null; } if (Input::has('battlelog_guid')) { $setting->battlelog_guid = trim(Input::get('battlelog_guid')); } else { $setting->battlelog_guid = null; } $setting->save(); $server->ConnectionState = Input::get('status', 'off'); $server->save(); return Redirect::route('admin.site.servers.index')->with('messages', [sprintf('Successfully Updated %s', $server->ServerName)]); } catch (ModelNotFoundException $e) { return Redirect::route('admin.site.servers.index')->withErrors(['Server doesn\'t exist.']); } }
/** * Get the includes asked in the request * * @return array|null */ protected function includes() { if (Input::has('includes')) { return (array) Input::get('includes'); } return null; }
/** * Get parameters. * * @return array */ protected function getParams() { $keys = array(); foreach (func_get_args() as $k) { if (is_string($k)) { $keys[] = $k; } } $params = $returnedParams = Input::all(); list($offset, $limit) = $this->apiOffsetLimit(); $params['offset'] = $offset; $params['limit'] = $limit; if (Input::has('includes') && is_array(Input::get('includes'))) { $params['includes'] = (array) Input::get('includes'); } /* * Clean */ if (!empty($key) && !empty($params)) { $returnedParams = array(); foreach ($params as $key => $value) { if (in_array($key, $keys)) { $returnedParams[$key] = $value; } } } return $returnedParams; }
/** * Display a listing of the resource. * * @return Response */ public function index() { $title = 'ROUTE MANAGEMENT'; if (Input::has('client')) { $client = Input::get('client'); $routes = Routes::where('client', 'like', '%' . $client . '%')->orderBy('id', 'desc')->paginate(10); } elseif (Input::has('vehicle')) { $vehicle = Input::get('vehicle'); $routes = Routes::where('vehicle', 'like', '%' . $vehicle . '%')->orderBy('id', 'desc')->paginate(10); } elseif (Input::has('employee')) { $employee = Input::get('employee'); $routes = Routes::where('employee', 'like', '%' . $employee . '%')->orderBy('id', 'desc')->paginate(10); } elseif (Input::has('start') && Input::has('end')) { $start = Input::get('start'); $end = Input::get('end'); $routes = Routes::whereBetween('date', [$start, $end])->orderBy('id', 'desc')->paginate(10); } elseif (Input::has('start')) { $start = Input::get('start'); $routes = Routes::where('date', $start)->orderBy('id', 'desc')->paginate(10); } elseif (Input::has('end')) { $end = Input::get('end'); $routes = Routes::where('date', $end)->orderBy('id', 'desc')->paginate(10); } else { $routes = Routes::orderBy('id', 'desc')->paginate(10); } $repository = $this->repository; return view('route.index', compact('title', 'routes', 'repository')); }
public function update_schedule($display_room = null) { if (Input::has('timeslots')) { $formvalues = Input::all(); $timeslots = $formvalues['timeslots']; //Here we assign presentations to timeslots foreach ($timeslots as $timeslot) { if (Input::has($timeslot)) { foreach ($formvalues[$timeslot] as $identifier) { $presentation = Presentation::findOrFail(explode('_', $identifier)[1]); $presentation->timeslot = $timeslot; $presentation->save(); } } //Here we 'unassign' presentations that were dropped back in the //unnasigned box if (Input::has('drag-elements')) { foreach ($formvalues['drag-elements'] as $identifier) { $presentation = Presentation::findOrFail(explode('_', $identifier)[1]); $presentation->timeslot = null; $presentation->save(); } } } } return redirect()->route('timeslot.show', compact('display_room')); }
public function anyIndex() { $breadcrumbs = array(array("Kompetensi" => url("admin/competency/type")), array("Kamus Kompetensi" => "")); // return Input::all(); if (Input::has('type') && Input::has('parent')) { if (Input::get('parent') == 'all') { if (Input::get('type') == 'all') { $listData = CompetencyDictionary::getByParentType(null, null); } else { $listData = CompetencyDictionary::getByParentType(null, Input::get('type')); } } elseif (Input::get('parent') == 0) { if (Input::get('type') == 'all') { $listData = CompetencyDictionary::getByParentType("parent", null); } else { $listData = CompetencyDictionary::getByParentType("parent", Input::get('type')); } } else { $listData = CompetencyDictionary::getByParentType(Input::get('parent'), Input::get('type')); } } else { $listData = CompetencyDictionary::getByParentType(null, null); } $listDataParent = CompetencyDictionary::where('parent', '=', '0')->get(); $listDataType = CompetencyType::all(); $this->layout->breadcrumbs = View::make('layouts.breadcrumb', compact('breadcrumbs')); $this->layout->content = View::make('competency::adminDictionary.index', compact('listData', 'listDataParent', 'listDataType')); }
public function __construct() { if (!Input::has('_method')) { $this->generateSpecificsArray(); } $this->rules = ['role' => 'required|exists:roles,hash']; }
/** * Update To-Do * @param $id * @return \Illuminate\Http\JsonResponse */ public function updateTodo($id) { $success = false; $message = ''; $errors = array(); $httpCode = 200; $validator = Validator::make(array('id' => $id, 'title' => Input::get('title')), array('id' => 'exists:todos,id', 'title' => 'string', 'done' => 'boolean')); if (!$validator->fails()) { $todo = Todo::whereId($id)->first(); if ($todo) { if (Input::has('title')) { $todo->title = Input::get('title'); } if (Input::has('done')) { $todo->done = Input::get('done') ? 1 : 0; } if ($todo->save()) { $success = true; $message = "Record updated"; } } else { $message = "Error occurred"; $httpCode = 500; } } else { $errors = $validator->messages(); $message = "Some fields are invalid"; $httpCode = 422; } return response()->json(['success' => $success, 'message' => $message, 'errors' => $errors], $httpCode); }
public function index() { switch (Input::get('filter')) { case 'all': $conferences = EloquentConference::all(); break; case 'future': $conferences = EloquentConference::future()->get(); break; case 'open_cfp': $conferences = EloquentConference::openCfp()->get(); break; case 'unclosed_cfp': // Pass through // Pass through default: $conferences = EloquentConference::unclosedCfp()->get(); break; } $sort = 'closing_next'; $sortDir = 'asc'; if (Input::has('sort')) { $sort = Input::get('sort'); if (substr($sort, 0, 1) == '-') { $sort = substr($sort, 1); $sortDir = 'desc'; } } switch ($sort) { case 'alpha': $conferences->sortBy(function (EloquentConference $model) { return strtolower($model->title); }); break; case 'date': $conferences->sortBy(function (EloquentConference $model) { return $model->starts_at; }); break; case 'closing_next': // Pass through // Pass through default: // Forces closed CFPs to the end. I feel dirty. Even dirtier with the 500 thing. $conferences->sortBy(function (EloquentConference $model) { if ($model->cfp_ends_at > Carbon::now()) { return $model->cfp_ends_at; } elseif ($model->cfp_ends_at === null) { return Carbon::now()->addYear(500); } else { return $model->cfp_ends_at->addYear(1000); } }); break; } if ($sortDir == 'desc') { $conferences->reverse(); } return response()->jsonApi(['data' => $conferences->values()]); }
/** * Save the changes made to the users account * * @return Redirect */ public function saveAccountSettings() { $user = \Auth::user(); $email = trim(Input::get('email', null)); $lang = trim(Input::get('language', null)); $password = trim(Input::get('password', null)); $password_confirmation = trim(Input::get('password_confirmation', null)); $v = Validator::make(Input::all(), ['email' => 'required|email|unique:bfacp_users,email,' . $user->id, 'language' => 'required|in:' . implode(',', array_keys(Config::get('bfacp.site.languages'))), 'password' => 'min:8|confirmed']); if ($v->fails()) { return Redirect::route('user.account')->withErrors($v)->withInput(); } // Update email if ($email != $user->email) { $user->email = $email; $this->messages[] = Lang::get('user.notifications.account.email.changed', ['addr' => $email]); } // Update the user language if it's been changed if ($lang != $user->setting->lang) { $user->setting()->update(['lang' => $lang]); $langHuman = Config::get('bfacp.site.languages')[$lang]; $this->messages[] = Lang::get('user.notifications.account.language.changed', ['lang' => $langHuman]); } // Change the user password if they filled out the fields and new passwords match if (Input::has('password') && Input::has('password_confirmation') && $password == $password_confirmation) { $user->password = $password; $user->password_confirmation = $password; $this->messages[] = Lang::get('user.notifications.password.email.changed'); } $user->save(); return Redirect::route('user.account')->withMessages($this->messages); }
public function markAcceptance($policyCode, $userUid) { // get inputs // $policy = Policy::where('policy_code', '=', $policyCode)->first(); $user = User::getIndex($userUid); $acceptFlag = Input::has('accept_flag'); // check inputs // if (!$user || !$policy || !$acceptFlag) { return Response::make('Invalid input.', 404); } // check privileges // if (!$user->isAdmin() && $user->user_uid != Session::get('user_uid')) { return Response::make('Insufficient privileges to mark policy acceptance.', 401); } // get or create new user policy // $userPolicy = UserPolicy::where('user_uid', '=', $userUid)->where('policy_code', '=', $policyCode)->first(); if (!$userPolicy) { $userPolicy = new UserPolicy(array('user_policy_uid' => GUID::create(), 'user_uid' => $userUid, 'policy_code' => $policyCode)); } $userPolicy->accept_flag = $acceptFlag; $userPolicy->save(); return $userPolicy; }
public function postCreate() { if (Input::has('invitee_uid')) { // create a single admin invitation // $adminInvitation = new AdminInvitation(array('invitation_key' => GUID::create(), 'inviter_uid' => Input::get('inviter_uid'), 'invitee_uid' => Input::get('invitee_uid'))); $adminInvitation->save(); $adminInvitation->send(Input::get('invitee_name'), Input::get('confirm_route')); return $adminInvitation; } else { // create an array of admin invitations // $invitations = Input::all(); $adminInvitations = new Collection(); for ($i = 0; $i < sizeOf($invitations); $i++) { $invitation = $invitations[$i]; $adminInvitation = new AdminInvitation(array('invitation_key' => GUID::create(), 'inviter_uid' => $invitation['inviter_uid'], 'invitee_uid' => $invitation['invitee_uid'])); $adminInvitations->push($adminInvitation); $adminInvitation->save(); $adminInvitation->send(); $adminInvitation->send($invitation['invitee_name'], $invitation['confirm_route']); } return $adminInvitations; } }
public function index(Request $request) { //Input::get('active') $sort = Input::get('sort') == null ? 'id' : Input::get('sort'); $sortDirection = Input::get('sortDirection') == null ? 'DESC' : Input::get('sortDirection'); $tariffs = Tariff::orderBy($sort, $sortDirection); if (Input::has('deactive')) { if (Input::has('active')) { $tariffs = $tariffs->get(); } else { $tariffs = $tariffs->where('active', '=', false); $tariffs = $tariffs->get(); } } else { if (Input::has('active')) { $tariffs = $tariffs->where('active', '=', true); $tariffs = $tariffs->get(); } } if ($request->ajax()) { return view('tariffs.indexAjax', ['tariffs' => $tariffs]); } else { return view('tariffs.index', ['tariffs' => $tariffs]); } }
/** * @param Builder $query * * @return Builder */ public function scopeSearch($query) { if (Input::has('q')) { $q = Input::get('q'); $model = $this; $query->where(function ($query2) use($q, $model) { foreach ($model->getColumns() as $searchColumn) { $table = $model->getTable(); $searchColumnExplode = explode('.', $searchColumn); if (count($searchColumnExplode) > 1) { $table = $searchColumnExplode[0]; $searchColumn = $searchColumnExplode[1]; } switch (Schema::getColumnType($table, $searchColumn)) { case 'integer': case 'bigint': case 'smallint': case 'float': if (is_numeric($q)) { $query2->orWhere($table . '.' . $searchColumn, '=', (int) $q); } break; case 'string': case 'text': $query2->orWhere($table . '.' . $searchColumn, 'ilike', "%{$q}%"); break; } } }); } return $query; }
public function editRoles($userId = null) { if (is_null($userId)) { return editRoles(Auth::id()); } //if you can't edit roles, abort. if (!Gate::allows('edit-roles')) { abort(403); } $user = User::find($userId); //example posted data: adminRole=Add Role::all()->each(function ($role) { if (Input::has($role->description . "Role")) { Input::get($role->description . "Role"); $action = Input::get($inputName); if ($action === "Add") { $user->roles()->attach($role); } elseif ($action === "Remove") { $user->roles()->detach($role); } else { Redirect::to('/error/whatAreYouEvenTryingToDo'); } } }); return Redirect::to('/user/' . $user->id); }
/** * Display the specified resource. * * @param $slug * @return \Illuminate\Http\Response */ public function show($slug) { $guild = Guild::where('slug', $slug)->firstOrFail(); $now = Carbon::now(); if (Input::has('month')) { $now->month = Input::get('month'); } if (Input::has('year')) { $now->year = Input::get('year'); } $startOfMonth = $now->copy()->startOfMonth(); $endOfMonth = $now->copy()->endOfMonth(); $occurrences = EventOccurrence::where('begin_at', '<', $endOfMonth)->where('end_at', '>', $startOfMonth)->whereHas('event', function ($query) use($guild) { $query->where('guild_id', $guild->id); })->with('event')->get(); $events = []; foreach ($occurrences as $occurrence) { $events[$occurrence->begin_at->day][] = $occurrence; } $monthNames = [1 => 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']; $dayNames = [1 => 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']; $month = $this->makeMonth($monthNames, $now); $lastRaids = EventOccurrence::with(['event', 'event.guild'])->whereHas('event.guild', function ($query) use($guild) { $query->where('id', $guild->id); })->where('begin_at', '<', Carbon::now())->orderBy('begin_at', 'desc')->limit(2)->get(); $lastRaids = $lastRaids->reverse(); $nextRaids = EventOccurrence::with(['event', 'event.guild'])->whereHas('event.guild', function ($query) use($guild) { $query->where('id', $guild->id); })->where('begin_at', '>', Carbon::now())->orderBy('begin_at')->limit(2)->get(); return view('guilds.show', compact('guild', 'events', 'now', 'month', 'monthNames', 'dayNames', 'lastRaids', 'nextRaids')); }