本文整理匯總了PHP中Illuminate\Support\Facades\Auth::User方法的典型用法代碼示例。如果您正苦於以下問題:PHP Auth::User方法的具體用法?PHP Auth::User怎麽用?PHP Auth::User使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Illuminate\Support\Facades\Auth
的用法示例。
在下文中一共展示了Auth::User方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
*
* @return mixed
*/
public function handle($request, Closure $next)
{
if (Auth::User()->role != 4) {
return view('errors.403');
}
return $next($request);
}
示例2: update_messages
public function update_messages()
{
$from_id = Auth::User()->id;
$message = new Message();
$new_msg = $message->get_new_messages($from_id);
echo json_encode(array('new_msg' => $new_msg));
}
示例3: store
public function store()
{
$this->record = new Activity(array_merge(Request::all(), ['adder_id' => Auth::User()->id, 'modifier_id' => Auth::User()->id]));
try {
switch ($this->related_type) {
case 'lead':
$this->relatedObj = new \App\Lead();
break;
case 'contact':
$this->relatedObj = new \App\Contact();
break;
case 'account':
$this->relatedObj = new \App\Account();
break;
case 'opportunity':
$this->relatedObj = new \App\Opportunity();
break;
default:
}
$obj = $this->relatedObj->find($this->related_id);
if ($this->validated()) {
$obj->activities()->save($this->record);
}
} catch (\Exception $e) {
Session::flash('pageError', 'Error saving activity.' . $e->getMessage());
return View('activity/activity-new', ['record' => $this->record, 'relates_to' => $this->relates_to]);
}
$redirectURL = Request::input('action') == 'saveNew' ? '/activity/create?related_type=' . $this->related_type . '&related_id=' . $this->related_id : '/' . $this->related_type . '/' . $this->related_id;
return redirect($redirectURL)->with('pageSuccess', 'Activity saved successfully.');
}
示例4: compose
/**
* Bind data to the view.
*
* @param View $view
* @return void
*/
public function compose(View $view)
{
$view->with('disposition_check', ['use as is', 'ncmr#', 'rework', 'split lot', 'shutdown', 'shipback']);
$view->with('cod_check', ['production', 'process', 'maintenance', 'facilities', 'quality assurance', 'others']);
$view->with('approvers', ['production', 'process', 'quality assurance', 'others']);
$view->with('names', Employee::select('name')->orderBy('name')->where('name', '<>', Auth::User()->employee->name)->get());
}
示例5: place_order
public function place_order(Order $orderModel, OrderItems $orderItems, CheckoutService $checkoutService)
{
if (!Session::has('cart')) {
return false;
}
$cart = Session::get('cart');
$categories = Category::all();
if ($cart->getTotal() > 0) {
$order = $orderModel::create(['user_id' => Auth::User()->id, 'total' => $cart->getTotal(), 'status' => '0']);
foreach ($cart->all() as $id => $item) {
$order->items()->create(['order_id' => $order->id, 'product_id' => $id, 'price' => $item['price'], 'qtd' => $item['qtd']]);
}
$checkout = $checkoutService->createCheckoutBuilder();
$checkout->setReference($order->id);
foreach ($order->items as $order_item) {
$checkout->addItem(new Item($order_item->product_id, $order_item->product->name, $order_item->price));
}
$response = $checkoutService->checkout($checkout->getCheckout());
$order->update(['payment_code' => $response->getCode()]);
event(new CheckoutEvent($order, Auth::user()));
$cart->clear();
return redirect($response->getRedirectionUrl());
//return view('checkout.place_order', ['order'=>$order, 'cart'=>'saved', 'categories'=>$categories]);
}
return view('checkout.place_order', ['cart' => 'empty', 'categories' => $categories]);
}
示例6: composeNavigation
/**
* Bind variables to the navigation bar.
*/
private function composeNavigation()
{
view()->composer('nav', function ($view) {
$view->with('projects', Project::all());
$view->with('user', Auth::User());
});
}
示例7: account
public function account()
{
if (Auth::User()) {
$user_data = Auth::User();
}
$requests = array();
$user = new user();
$image = new image();
$feature_img = $image->get_feature_image();
$friend = new friend();
$friend_request = $friend->show_friend_request();
if (is_array($friend_request) && count($friend_request) >= 1) {
foreach ($friend_request as $request) {
$requests[] = $user->get_user($request->user_id);
}
}
$get_friends = $friend->get_friends();
foreach ($get_friends as $get_all_friend) {
$all_friends[] = $user->get_user($get_all_friend->friend_id);
}
if (isset($all_friends) && count($all_friends) != 0) {
return view('account')->with(array('image' => $feature_img, 'requests' => $requests, 'user_data' => $user_data, 'all_friends' => $all_friends));
} else {
return view('account')->with(array('image' => $feature_img, 'requests' => $requests, 'user_data' => $user_data));
}
}
示例8: __construct
public function __construct()
{
$this->loggedInUser = Auth::User();
$this->loggedInViaRememberMe = Auth::viaRemember();
view()->share('isSignedIn', Auth::check());
view()->share('user', $this->loggedInUser);
}
示例9: updateStatus
protected function updateStatus(\App\Request $request, $status)
{
if ($status['Approve'] == 2) {
$request->status_id = 5;
$json['status'] = 'Approved';
LayoutStatus::create(['request_id' => $request->id, 'layout_status' => "Waiting for Layout Update", 'submitted_by' => Auth::User()->id]);
Event::fire(new FinalStatusSubmitted($request));
Event::fire(new ActionItemApproved($request));
} elseif ($status['Approve'] == 1 && $status['Reject'] == 1) {
$request->status_id = 2;
$json['status'] = 'Open/Needs Further Review';
} elseif ($status['Approve'] == 0 && $status['Reject'] == 1) {
$request->status_id = 2;
$json['status'] = 'Open/Needs Further Review';
} elseif ($status['Reject'] == 2) {
$request->status_id = 4;
$json['status'] = 'Rejected';
Event::fire(new FinalStatusSubmitted($request));
} elseif ($status['Approve'] == 0 && $status['Reject'] == 0) {
$request->status_id = 1;
$json['status'] = 'New';
} elseif ($status['Approve'] == 1 && $status['Reject'] == 0) {
$request->status_id = 3;
$json['status'] = 'Waiting for Approval';
} else {
$request->status_id = 3;
$json['status'] = 'Waiting for Approval';
}
$request->save();
return $json;
}
示例10: checkCode
public function checkCode(Request $request)
{
$code = $request->input('code');
$currentPeriod = $this->period->checkPeriod();
$user = Auth::User();
$this->validate($request, ['code' => 'required|min:6|alpha_num|unique:keycodes,code,' . $code . ',id,used,1']);
if ($this->user->checkIfParticipated($user)) {
$this->user->hasParticipated($user);
if ($this->validateCode->checkIfCodeIsValid($code)) {
$result = $this->validateCode->checkIfCodeIsValid($code);
if ($this->winner->checkWinner($code)) {
$this->validateCode->changeStateOfCode($result);
Mail::send('mails.winner', ['user' => $user], function ($ms) use($user) {
$ms->to($user->email, $user->name)->subject('U hebt gewonnen!');
});
$alreadyplayed = false;
$win = true;
return view('code/result', compact('win', 'alreadyplayed', 'currentPeriod'));
}
} else {
$win = false;
$alreadyplayed = false;
return view('code/result', compact('win', 'alreadyplayed'));
}
} else {
$win = false;
$alreadyplayed = true;
return view('code/result', compact('win', 'alreadyplayed'));
}
}
示例11: profile
public function profile($id)
{
$images = Auth::User()->uploaded_pictures;
$categories = Category::lists('category_name', 'category_id');
$user = User::findOrFail($id);
return view('templates/singleProfile')->with(compact('user', 'images', 'categories'));
}
示例12: scopeMine
/**
* Modifies query to match only leases that belong to the given user.
* Allows passing userId to simplify unit tests.
*
* @param $query
* @param null $userId
*/
public function scopeMine($query, $userId = null)
{
if (is_null($userId)) {
$userId = Auth::User()->id;
}
$query->where('user_id', '=', $userId);
}
示例13: __construct
public function __construct()
{
$this->user = $this->signedIn = Auth::User();
view()->share('user', Auth::user());
//@if($signedIN)
view()->share('signedIn', Auth::check());
}
示例14: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$user_id = Auth::User()->id;
if (Input::file()) {
$file_image = array('image' => Input::file('file_image'));
$rules = array('image' => 'required');
$validator = validator::make($file_image, $rules);
if ($validator->fails()) {
return redirect::to('photo')->withInput()->withErrors($validator);
} else {
if (Input::file('file_image')->isValid()) {
$path = '../public/images';
$extension = Input::file('file_image')->getClientOriginalExtension();
$fileName = rand() . '.' . $extension;
Input::file('file_image')->move($path, $fileName);
Image::create(array('user_id' => $user_id, 'path' => $fileName));
Session::flash('success', 'Upload successfully');
return Redirect::to('photo');
} else {
Session::flash('error', 'uploaded file is not valid');
return Redirect::to('photo');
}
}
}
}
示例15: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store(TipoRenglonesForm $tipoRenglonesForm)
{
$trenglon = new \App\TipoRenglon();
$trenglon->id_almacen = Auth::User()->id_almacen;
$trenglon->descrip_tipo_renglon = \Request::Input('descripcion');
$trenglon->save();
return redirect('tiporenglon')->with('message', 'Se ha Añadido un Nuevo Tipo de Articulo');
}