本文整理汇总了PHP中Illuminate\Support\Facades\Input::has方法的典型用法代码示例。如果您正苦于以下问题:PHP Input::has方法的具体用法?PHP Input::has怎么用?PHP Input::has使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Support\Facades\Input
的用法示例。
在下文中一共展示了Input::has方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save
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');
}
示例2: update
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);
}
示例3: store
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');
}
示例4: setPassword
/**
* 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()]);
}
示例5: index
/**
* 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]);
}
示例6: webhook
/**
* 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];
}
示例7: upload
/**
* 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';
}
示例8: index
/**
* 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'));
}
示例9: request
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'));
}
示例10: dologin
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');
}
}
}
示例11: postLogin
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']]);
}
示例12: getIndex
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);
}
示例13: getLogin
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 = 'Ошибка аутентификации';
}
}*/
}
示例14: update
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);
}
示例15: update
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.']);
}
}