本文整理汇总了PHP中Illuminate\Support\Facades\Request::ip方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::ip方法的具体用法?PHP Request::ip怎么用?PHP Request::ip使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Support\Facades\Request
的用法示例。
在下文中一共展示了Request::ip方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: log
/**
* @param $model
* @param $event
* @return mixed|void
*/
public function log($model, $event)
{
$attributes = $model->getAttributes();
$original = $model->getOriginal();
$activity = new UserActivity(['user_id' => Auth::user() ? Auth::user()->id : null, 'ip_address' => Request::ip(), 'event' => $event, 'before' => $event == 'deleted' ? json_encode($attributes) : json_encode(array_diff_assoc($original, $attributes)), 'after' => json_encode(array_diff_assoc($attributes, $original)), 'description' => $model->activityDescription($event, Auth::user() ? Auth::user() : null)]);
$model->activities()->save($activity);
}
示例2: log
/**
* Log event
*
* @param $model
* @param $event
* @return mixed
*/
public function log($model, $event)
{
$attributes = $model->getAttributes();
$original = $model->getOriginal();
$activity = ['user_id' => Auth::user() ? Auth::user()->id : null, 'ip_address' => Request::ip(), 'event' => $event, 'before' => $event == 'deleted' ? json_encode($attributes) : json_encode(array_diff_assoc($original, $attributes)), 'after' => json_encode(array_diff_assoc($attributes, $original)), 'description' => $model->activityDescription($event, Auth::user() ? Auth::user() : null)];
Log::info('[' . strtoupper($event) . ']', $activity);
return true;
}
示例3: allowed
public function allowed($procedure)
{
$key = $procedure . ':' . Request::ip() . ':lockout';
$decayMinutes = (int) config('auth.email_lockout') ?: -1;
if (!Cache::has($key)) {
Cache::put($key, '', $decayMinutes);
return true;
}
return false;
}
示例4: revisit
/**
* Perform revisit or unique visitor.
*/
public function revisit()
{
$cookie_visitor = "infogue-visitor";
$cookie_ip = Request::ip();
setcookie($cookie_visitor, $cookie_ip, time() + 86400, "/");
$current_date = date("Y-m-d");
$result = $this->where('date', $current_date)->first();
if (count($result) > 0) {
$result->unique = $result->unique + 1;
$result->save();
} else {
$visitor = new Visitor();
$visitor->date = $current_date;
$visitor->unique = 1;
$visitor->hit = 0;
$visitor->save();
}
}
示例5: createSession
public function createSession($userid)
{
$current_time = Carbon::now()->timestamp;
$token = str_random(10) . $current_time;
$ip = Request::ip();
$session_status = 1000;
$session = new Session();
$session->user_id = $userid;
$session->session_id = $token;
$session->datetime = $current_time;
$session->ip_address = $ip;
$session->session_status = $session_status;
if ($session->save()) {
$response = array("session_status" => "True", "session" => $session);
} else {
$response = array("session_status" => "False", "session" => "");
}
return $response;
}
示例6: updateUserInfo
/**
* 寫入登入時間及IP 位址
*
* @param \Illuminate\Contracts\Auth\Authenticatable $user
* @return void
*/
public function updateUserInfo(UserContract $user)
{
// 寫入登入IP & 時間
$user->ip_address = Request::ip();
$user->last_login = Carbon::now();
$user->save();
// 寫入可用權限以供nav 選單使用
$role = json_decode($user->role->permissions);
if (in_array('all', $role)) {
$permissions = Permission::select('slug')->where('status', true)->get()->toArray();
// dd($permissions);
} else {
$permissions = Permission::select('slug')->whereIn('slug', $role)->where('status', true)->get()->toArray();
}
// dd($role);
foreach ($permissions as $value) {
$permission[] = $value['slug'];
}
// dd($permission);
session(['permissions' => $permission]);
// dd(session('permissions'));
}
示例7: getResponse
public function getResponse()
{
$this->buildHeader();
$responseData = [];
$responseData['status'] = ['http_code' => $this->statusCode, 'type' => $this->status, 'message' => $this->message];
// only if an api key is given
if ($this->apiKey) {
$responseData['status']['rate_limit'] = RateLimiter::get($this->apiKey->public_key);
}
$dataObject = [];
if ($this->data) {
$this->buildPagination($this->data);
$dataObject = ['data' => $this->data];
}
// only if pagination is needed
// if($this->pagination)
// {
// $responseData['status']['pagination'] = $this->pagination;
// }
// auto-check for error status codes and log to the db
if ($this->statusCode > 400 && $this->apiKey) {
$log = new ApiLog();
$log->api_key_id = $this->apiKey->id;
$log->status = $this->status;
$log->message = $this->message;
$log->ip_address = Request::ip();
$log->save();
}
$responseData = array_merge($responseData, $dataObject);
return Response::json($responseData, $this->statusCode, $this->headers);
}
示例8: getMetaAttributes
public function getMetaAttributes()
{
return ['meta_ip_address' => \Illuminate\Support\Facades\Request::ip()];
}
示例9: __construct
/**
* Create a new job instance.
*
* @return void
*/
public function __construct($params)
{
$this->log = ['user_id' => $params['userId'], 'title' => $params['title'], 'type' => $params['type'], 'object' => $params['object'], 'object_id' => $params['object_id'], 'data' => $params['data'], 'sql' => $params['sql'], 'ip' => Request::ip(), 'pushed_at' => date('Y-m-d H:i:s')];
}
示例10: function
| Model Factories
|--------------------------------------------------------------------------
|
| Here you may define all of your model factories. Model factories give
| you a convenient way to create models for testing and seeding your
| database. Just tell the factory how a default model should look.
|
*/
use App\Proposal;
use App\State;
use App\User;
use Illuminate\Support\Facades\Request;
$factory->define(App\User::class, function (Faker\Generator $faker) {
return ['name' => $faker->name, 'email' => $faker->email, 'password' => Hash::make('123456'), 'remember_token' => str_random(10), 'role_id' => $faker->randomElement([1, 2, 99]), 'uf' => State::all()->shuffle()->first()->uf, 'cpf' => $faker->cpf, 'uuid' => $faker->uuid];
});
$factory->defineAs(App\User::class, 'admin', function (Faker\Generator $faker) use($factory) {
$user = $factory->raw(App\User::class);
//Admin 0
return array_merge($user, ['role_id' => 0]);
});
$factory->define(App\Proposal::class, function (Faker\Generator $faker) {
$random = $faker->boolean($chanceOfGettingTrue = 20);
return ['name' => $faker->sentence($nbWords = 6, $variableNbWords = true), 'user_id' => User::all()->shuffle()->first()->id, 'open' => true, 'idea_central' => $faker->text($maxNbChars = 100), 'problem' => $faker->paragraph($nbSentences = 3, $variableNbSentences = true), 'idea_exposition' => $faker->realText($maxNbChars = 200, $indexSize = 2), 'response' => $response = $faker->randomElement($array = [null, $faker->realText($maxNbChars = 100, $indexSize = 2), $faker->text($maxNbChars = 50)]), 'responder_id' => !$response ? null : User::all()->where('role_id', 1)->shuffle()->first()->id, 'disapproved_at' => !$response ? null : \Carbon\Carbon::now(), 'disapproved_by' => !$response ? null : User::all()->where('role_id', 1)->shuffle()->first()->id, 'approved_at' => $response ? null : ($random ? null : \Carbon\Carbon::now()), 'approved_by' => $response ? null : ($random ? null : User::all()->where('role_id', 1)->shuffle()->first()->id), 'created_at' => \Carbon\Carbon::now(), 'updated_at' => \Carbon\Carbon::now(), 'pub_date' => \Carbon\Carbon::now(), 'limit_date' => \Carbon\Carbon::now()->addMonth(config('global.timeLimitMonth'))];
});
$factory->define(App\Like::class, function (Faker\Generator $faker) {
$user_id = User::all()->shuffle()->first()->id;
return ['user_id' => $user_id, 'proposal_id' => Proposal::all()->shuffle()->first()->id, 'uuid' => User::where('id', $user_id)->first()->uuid, 'like' => $faker->boolean($chanceOfGettingTrue = 70), 'ip_address' => Request::ip()];
});
$factory->define(App\ProposalFollow::class, function (Faker\Generator $faker) {
return ['user_id' => User::all()->shuffle()->first()->id, 'proposal_id' => Proposal::all()->shuffle()->first()->id];
});
示例11: createActivity
/**
* Create user login activity
*
* @param $user_id
* @param $event_name
* @param bool $remember
* @return UserLoginActivity
*/
protected function createActivity($user_id, $event_name, $remember = false)
{
$activity = new UserLoginActivity();
$activity->user_id = $user_id;
$activity->remember = $remember;
$activity->ip_address = Request::ip();
$activity->event = $event_name;
$activity->save();
return $activity;
}
示例12: getPropertyPayment
public function getPropertyPayment($id)
{
$property = Property::findOrFail($id);
$order = $property->order;
$existingPayments = $order->payments;
if ($existingPayments->count() < 1) {
return redirect()->route('frontend.property.review', ['id' => $property->id]);
}
$payment_method = $existingPayments->first()->payment_method;
switch ($payment_method) {
case Payment::METHOD_DOKU_CREDIT_CARD:
$payment = $existingPayments->first();
//Building the required external form fields
$user = Auth::user();
$user->load(['profile']);
$shared_key = config('myshortcart.shared_key');
$msc_transaction_id = config('myshortcart.prefix') . '_' . $payment->id;
foreach ($order->items as $item) {
$items[] = ['name' => $item->item_type == 'feature' ? trans('property.package.feature.' . $item->getItem()->code) : $item->item, 'price' => $item->net_price, 'quantity' => $item->quantity];
}
$orderData = ['ip_address' => \Illuminate\Support\Facades\Request::ip(), 'transaction_id' => $payment->id, 'msc_transaction_id' => $msc_transaction_id, 'amount' => $payment->total_amount, 'basket' => MyShortCart::formatBasket($items), 'words' => sha1(trim($payment->total_amount) . trim($shared_key) . trim($msc_transaction_id)), 'url' => route('frontend.property.payment', ['id' => $property->id]), 'customer_name' => $user->profile->first_name . ' ' . $user->profile->last_name, 'customer_email' => $user->email, 'customer_phone' => $user->profile->home_phone_number, 'customer_work_phone' => $user->profile->mobile_phone_number, 'customer_mobile_phone' => $user->profile->mobile_phone_number, 'customer_address' => trim(str_replace(["\r", "\n"], ' ', $user->profile->address)), 'customer_postal_code' => trim($user->profile->postal_code), 'customer_city' => $user->profile->city ? trim(AddressHelper::getAddressLabel($user->profile->city, 'city')) : '', 'customer_state' => $user->profile->province ? trim(AddressHelper::getAddressLabel($user->profile->province, 'province')) : '', 'customer_country' => 360, 'customer_birthday' => ''];
$orderData += ['shipping_address' => $orderData['customer_address'], 'shipping_postal_code' => $orderData['customer_postal_code'], 'shipping_city' => $orderData['customer_city'], 'shipping_state' => $orderData['customer_state'], 'shipping_country' => $orderData['customer_country']];
MyShortCart::saveRequestTransaction($orderData);
return MyShortCart::renderForm($orderData);
break;
default:
return redirect()->route('frontend.property.success', ['id' => $property->id]);
break;
}
}
示例13: updateLog
public function updateLog(User $user)
{
$user->last_login = Carbon::now();
$user->last_ip = Request::ip();
$user->save();
}
示例14: likeUnlike
public function likeUnlike($id, $action)
{
//Get Proposal
$proposal = $this->proposalsRepository->find($id);
//Get User
if (!Auth::check()) {
// The user is not logged in...
// Retrieve UUID from Cookie
$user_id = null;
$unique = Cookie::get('uuid');
} else {
//Retrieve UUID from User
$user_id = Auth::user()->id;
$unique = Auth::user()->uuid;
}
//Possible Values: Null, 0 or 1
$existing_like = Like::where('uuid', $unique)->where('proposal_id', $id)->value('like');
switch ($existing_like) {
// Already Unliked
case '0':
switch ($action) {
case 'like':
Like::where('uuid', $unique)->where('proposal_id', $id)->update(['like' => $action == 'like']);
Session::flash('flash_msg', 'Você voltou a curtir essa Ideia Legislativa!');
break;
case 'unlike':
Session::flash('error_msg', 'Você já deixou de curtir essa Ideia Legislativa!');
break;
}
break;
// Already Liked
// Already Liked
case '1':
switch ($action) {
case 'like':
Session::flash('error_msg', 'Você já curtiu essa Ideia Legislativa!');
break;
case 'unlike':
Like::where('uuid', $unique)->where('proposal_id', $id)->update(['like' => $action == 'like']);
Session::flash('flash_msg', 'Você deixou de curtir essa Ideia Legislativa!');
break;
}
break;
// New Like
// New Like
case null:
//dd($existing_like, $action, $str_action);
Like::create(['user_id' => $user_id, 'uuid' => $unique, 'proposal_id' => $proposal->id, 'like' => $action == 'like', 'ip_address' => Request::ip()]);
$approval_url = route('proposal.approval', $id);
$msg = 'Sua curtida foi computada com sucesso. Caso queira apoiar oficialmente esta proposta, <a href="' . $approval_url . '">clique aqui</a>.';
Session::flash('flash_msg', $msg);
break;
}
return redirect()->back();
}
示例15: postForgotPasswordConfirm
/**
* Forgot Password Confirmation form processing page.
*
* @param number $userId
* @param string $passwordResetCode
* @return Redirect
*/
public function postForgotPasswordConfirm($userId, $passwordResetCode)
{
// Declare the rules for the form validation
$rules = array('password' => 'required|between:3,32', 'password_confirm' => 'required|same:password');
// Create a new validator instance from our dynamic rules
$validator = Validator::make(Input::all(), $rules);
// If validation fails, we'll exit the operation now.
if ($validator->fails()) {
// Ooops.. something went wrong
return Redirect::route('forgot-password-confirm', compact(['userId', 'passwordResetCode']))->withInput()->withErrors($validator);
}
// Find the user using the password reset code
$user = Sentinel::findById($userId);
if (!($reminder = Reminder::complete($user, $passwordResetCode, Input::get('password')))) {
Base::Log('Forgot password confirm failed for ' . $user->username . ' (' . $user->first_name . ' ' . $user->last_name . ') from IP ' . Request::ip());
// Ooops.. something went wrong
return Redirect::route('login')->with('error', Lang::get('base.auth.forgot_password_confirm.error'));
} else {
// Send the activation code through email
Mail::queue('emails.auth.password-changed', ['user' => $user], function ($m) use($user) {
$m->to($user->email, $user->first_name . ' ' . $user->last_name);
$m->subject(Lang::get('base.mails.password_changed'));
});
}
Base::Log('Forgot password confirmed for ' . $user->username . ' (' . $user->first_name . ' ' . $user->last_name . ') from IP ' . Request::ip());
// Password successfully reseted
return Redirect::route('login')->with('success', Lang::get('base.auth.forgot_password_confirm.success'));
}