本文整理汇总了PHP中Input::only方法的典型用法代码示例。如果您正苦于以下问题:PHP Input::only方法的具体用法?PHP Input::only怎么用?PHP Input::only使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Input
的用法示例。
在下文中一共展示了Input::only方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postSignin
/**
* postSignin
* --------------------------------------------------
* @return Processes the signin request, signs in the user
* --------------------------------------------------
*/
public function postSignin()
{
/* Validation */
$rules = array('email' => 'required|email', 'password' => 'required');
/* run the validation rules on the inputs */
$validator = Validator::make(Input::all(), $rules);
/* Everything is OK */
if (!$validator->fails() and Auth::attempt(Input::only('email', 'password'))) {
/* Track event | SIGN IN */
$tracker = new GlobalTracker();
$tracker->trackAll('lazy', array('en' => 'Sign in', 'el' => Auth::user()->email));
/* Make welcome message */
if (Auth::user()->name) {
$message = 'Welcome back, ' . Auth::user()->name . '!';
} else {
$message = 'Welcome back.';
}
/* Redirect to dashboard */
return Redirect::route('dashboard.dashboard')->with('success', $message);
/* Something is not OK (bad credentials) */
} else {
/* Redirect to signin with error message */
return Redirect::route('auth.signin')->with('error', 'The provided email address or password is incorrect.')->withInput(Input::except('password'));
}
}
示例2: postEdit
public function postEdit($id)
{
if (!$this->checkRoute()) {
return Redirect::route('index');
}
$title = 'Edit A Modpack Creator - ' . $this->site_name;
$creator = Creator::find($id);
$input = Input::only('name', 'deck', 'website', 'donate_link', 'bio', 'slug');
$messages = ['unique' => 'The modpack creator already exists in the database.', 'url' => 'The :attribute field is not a valid URL.'];
$validator = Validator::make($input, ['name' => 'required|unique:creators,name,' . $creator->id, 'website' => 'url', 'donate_link' => 'url'], $messages);
if ($validator->fails()) {
return Redirect::action('CreatorController@getAdd')->withErrors($validator)->withInput();
}
$creator->name = $input['name'];
$creator->deck = $input['deck'];
$creator->website = $input['website'];
$creator->donate_link = $input['donate_link'];
$creator->bio = $input['bio'];
if ($input['slug'] == '' || $input['slug'] == $creator->slug) {
$slug = Str::slug($input['name']);
} else {
$slug = $input['slug'];
}
$creator->slug = $slug;
$creator->last_ip = Request::getClientIp();
$success = $creator->save();
if ($success) {
return View::make('creators.edit', ['title' => $title, 'creator' => $creator, 'success' => true]);
}
return Redirect::action('CreatorController@getEdit', [$id])->withErrors(['message' => 'Unable to edit modpack creator.'])->withInput();
}
示例3: join
public function join()
{
$data = Input::only(['name', 'room_id']);
print_r($data);
$room = Room::find($data['room_id']);
if (!$room) {
return Redirect::action('PrepareController@room');
}
if ($room->state !== 'open') {
throw new BadRequestHttpException('既にゲームは開始しています。');
}
if ($room->mates->count() >= $room->member_number) {
throw new BadRequestHttpException('全ユーザーが揃っています');
}
if (!isset($data['name']) || $data['name'] == '') {
//名前指定していない場合
return Redirect::action('PrepareController@rooms');
}
$i = 0;
do {
$hash = sha1(date("Y/m/d H:i:s.u") . 'zCeZu12X' . $data['name'] . $data['room_id']);
$hashed_mate = Mate::where('hash', $hash)->select('hash')->first();
$i++;
if ($i > 50) {
throw new InternalErrorException('ユーザー作成に失敗しました hash衝突しまくり');
}
} while ($hashed_mate && $i < 100);
$mate = Mate::create(['name' => $data['name'], 'last_state' => 'open', 'hash' => $hash, 'cast_id' => 0, 'room_id' => $data['room_id'], 'select_user_id' => '', 'is_alive' => 1]);
if (!$mate) {
throw new InternalErrorException('ユーザー作成に失敗しました');
}
$room->touch();
return Redirect::action('PlayController@index', ['hash' => $hash]);
}
示例4: store
/**
* Store a newly created resource in storage.
* POST /sessions
*
* @return Response
*/
public function store()
{
if (Auth::attempt(Input::only('email', 'password'))) {
return Redirect::to('/reservation');
}
return Redirect::back();
}
示例5: getAvailableSchoolsAttribute
public function getAvailableSchoolsAttribute()
{
$filters = array_filter(Input::only('specialty', 'district', 'municipality', 'city', 'type', 'search'));
$filters['financing'][] = $this->id;
$schools_data = new School();
return $schools_data->filterSchools($filters)->get()->count();
}
示例6: update
/**
* Update the specified karyawan in storage.
*
* @param int $id
* @return Response
*/
public function update($id)
{
$rules = array('first_name' => 'required', 'unit_kerja' => 'required|exists:unitkerjas,id', 'unit' => 'required|exists:units,id', 'jabatan' => 'required|exists:jabatans,id');
$karyawan = User::findOrFail($id);
$validator = Validator::make($data = Input::only('first_name', 'last_name', 'nip', 'unit_kerja', 'unit', 'jabatan'), $rules);
if ($validator->fails()) {
return Redirect::back()->withErrors($validator)->withInput();
} else {
//code
DB::table('users')->where('id', $id)->update(array('first_name' => Input::get('first_name'), 'last_name' => Input::get('last_name'), 'nip' => Input::get('nip'), 'unit_kerja' => Input::get('unit_kerja'), 'unit' => Input::get('unit'), 'jabatan' => Input::get('jabatan')));
// Find the user using the user id
//$usergroupremove = Sentry::getUserProvider()->findById($id);
// Find the group using the group id
//$groupremove = Sentry::findGroupById($usergroupremove->getGroups());
// Assign the group to the user
//$usergroupremove->removeGroup($groupsremove);
// Find the user using the user id
//$user = Sentry::findUserById($id);
// Find the group using the group id
//$adminGroup = Sentry::findGroupById(Input::get('group'));
// Assign the group to the user
//$user->addGroup($adminGroup);
//$user->save();
}
$karyawan->update($data);
return Redirect::route('admin.karyawan.index')->with("successMessage", "Berhasil menyimpan {$karyawan->first_name}. ");
}
示例7: postNewUser
public function postNewUser()
{
// Grab the inputs and validate them
$new_user = Input::only('email', 'username', 'password', 'first_name', 'last_name', 'is_admin');
$validation = new Validators\SeatUserRegisterValidator();
// Should the form validation pass, continue to attempt to add this user
if ($validation->passes()) {
// Because users are soft deleted, we need to check if if
// it doesnt actually exist first.
$user = \User::withTrashed()->where('email', Input::get('email'))->orWhere('username', Input::get('username'))->first();
// If we found the user, restore it and set the
// new values found in the post
if ($user) {
$user->restore();
} else {
$user = new \User();
}
// With the user object ready, work the update
$user->email = Input::get('email');
$user->username = Input::get('username');
$user->password = Hash::make(Input::get('password'));
$user->activated = 1;
$user->save();
// After user is saved and has a user_id
// we can add it to the admin group if necessary
if (Input::get('is_admin') == 'yes') {
$adminGroup = \Auth::findGroupByName('Administrators');
Auth::addUserToGroup($user, $adminGroup);
}
return Redirect::action('UserController@getAll')->with('success', 'User ' . Input::get('email') . ' has been added');
} else {
return Redirect::back()->withInput()->withErrors($validation->errors);
}
}
示例8: store
/**
* Creates a new user
*
* @return String
*/
public function store()
{
$this->RegistrationForm->validate(Input::all());
$user = User::create(Input::only('email', 'password'));
Auth::login($user);
return Redirect::home();
}
示例9: store
/**
* Authenticate the user
* @return [type] [description]
*/
public function store()
{
if (Auth::attempt(Input::only('email', 'password'), true)) {
return Redirect::intended('/');
}
return Redirect::back()->withInput()->withErrors(['Invalid Email or Password']);
}
示例10: login
public function login()
{
$data = Input::only('email', 'password', 'remember');
$credeciales = ['email' => $data['email'], 'password' => $data['password']];
if (Auth::attempt($credeciales, $data['remember'])) {
$data = [Auth::user()->full_name, Auth::user()->email, Auth::user()->tipo];
if (Auth::user()->tipo == 'asistente') {
if (Auth::user()->available_email === 1 && Auth::user()->available_vendedor === 1) {
$this->setAuditoria('acceso', 'login', $data);
Session::put('id', Auth::user()->id);
} else {
if (Auth::user()->available_email === 1) {
Session::flash('aviso', 'Debe tener la autorización de su vendedor.');
} else {
Session::flash('aviso', 'Debe confirmar su correo.');
}
Auth::logout();
return Redirect::back();
}
}
if (Auth::user()->tipo == 'administrador' || Auth::user()->tipo == 'vendedor') {
$this->setAuditoria('acceso', 'login', $data);
}
return Redirect::route('inicio');
}
return Redirect::back()->with('login_error', 1)->withInput();
}
示例11: post
public function post()
{
//step 1: validate input-data
$validate_data = Input::only('contestant_id', 'keystone');
$validate_rules = array('contestant_id' => 'required|integer', 'keystone' => 'required|min:8');
$validator = Validator::make($validate_data, $validate_rules);
if ($validator->fails()) {
$validate_messages = $validator->messages()->toArray();
$this->messageController->send($validate_messages, $this::MESSAGE_KEY);
return Redirect::to('login');
}
//step 2: check empty collection from 'contestant_id', bcs it may not exist
$contestant = Contestant::find(Input::get('contestant_id'));
if (!$contestant) {
$this->messageController->send(array('contestant_id' => ['contestant_id:wrong']), $this::MESSAGE_KEY);
return Redirect::to('login');
}
//step 3: compare hashed-value, if equal, allow login
//what we get after find is a 'collection', not a Contestant's instance, so fetch it, first()
if (Hash::check(Input::get('keystone'), $contestant->keystone)) {
Auth::login($contestant);
if ($contestant->id == 1) {
//admin after 'login' refer go to 'admin' page
return Redirect::to('admin');
} else {
//contestant after 'login' refer goto 'test' page
return Redirect::to('test');
}
} else {
$this->messageController->send(array('keystone' => ['keystone:wrong']), $this::MESSAGE_KEY);
}
//as a fall-back, return to login
return Redirect::to('login');
}
示例12: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store()
{
$this->loginForm->validate($input = Input::only('email', 'password'));
try {
Sentry::authenticate($input, true);
} catch (\Cartalyst\Sentry\Users\UserNotFoundException $e) {
$mjs = array('success' => false, 'mgs' => trans('main.mgs_invalid_credential'), 'url' => '');
return Response::json($mjs);
} catch (\Cartalyst\Sentry\Users\UserNotActivatedException $e) {
$mjs = array('success' => false, 'mgs' => trans('main.user_not_activated'), 'url' => '');
return Response::json($mjs);
} catch (\Cartalyst\Sentry\Throttling\UserSuspendedException $e) {
$mjs = array('success' => false, 'mgs' => trans('main.user_suspended'), 'url' => '');
return Response::json($mjs);
}
// Logged in successfully - redirect based on type of user
$user = Sentry::getUser();
$admin = Sentry::findGroupByName('Admins');
$users = Sentry::findGroupByName('Patients');
$doctors = Sentry::findGroupByName('Doctors');
$company = Sentry::findGroupByName('Clinics');
$recepcion = Sentry::findGroupByName('Receptionist');
if ($user->inGroup($admin)) {
$mjs = array('success' => true, 'mgs' => trans('main.mgs_access'), 'url' => url() . '/admin');
return Response::json($mjs);
} elseif ($user->inGroup($company) or $user->inGroup($recepcion)) {
$mjs = array('success' => true, 'mgs' => trans('main.mgs_access'), 'url' => url() . '/clinic');
return Response::json($mjs);
} elseif ($user->inGroup($doctors)) {
$mjs = array('success' => true, 'mgs' => trans('main.mgs_access'), 'url' => url() . '/doctor');
return Response::json($mjs);
} elseif ($user->inGroup($users)) {
return Redirect::to(url());
}
}
示例13: store
public function store()
{
if (Auth::attempt(Input::only('username', 'password'))) {
return "Welcome " . Auth::user()->username;
}
return Redirect::back()->withInput();
}
示例14: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store()
{
if (Auth::attempt(Input::only('email', 'password'))) {
return Redirect::route('portfolio.index')->withMessage('Welcome, ' . Auth::user()->name)->withFlash_type('success');
}
return Redirect::route('sessions.create')->with('message', 'Failed! Check password: justdoit')->with('flash_type', 'alert')->withInput();
}
示例15: store
/**
* Store a newly created conversation in storage.
*
* @return Response
*/
public function store()
{
$rules = array('users' => 'required|array', 'body' => 'required');
$validator = Validator::make(Input::only('users', 'body'), $rules);
if ($validator->fails()) {
return Response::json(['success' => false, 'result' => $validator->messages()]);
}
// Create Conversation
$params = array('created_at' => new DateTime(), 'name' => str_random(30), 'author_id' => Auth::user()->id);
$conversation = Conversation::create($params);
$conversation->users()->attach(Input::get('users'));
$conversation->users()->attach(array(Auth::user()->id));
// Create Message
$params = array('conversation_id' => $conversation->id, 'body' => Input::get('body'), 'user_id' => Auth::user()->id, 'created_at' => new DateTime());
$message = Message::create($params);
// Create Message Notifications
$messages_notifications = array();
foreach (Input::get('users') as $user_id) {
array_push($messages_notifications, new MessageNotification(array('user_id' => $user_id, 'read' => false, 'conversation_id' => $conversation->id)));
// Publish Data To Redis
$data = array('room' => $user_id, 'message' => array('conversation_id' => $conversation->id));
Event::fire(ChatConversationsEventHandler::EVENT, array(json_encode($data)));
}
$message->messages_notifications()->saveMany($messages_notifications);
return Redirect::route('chat.index', array('conversation', $conversation->name));
}