当前位置: 首页>>代码示例>>PHP>>正文


PHP Auth::user方法代码示例

本文整理汇总了PHP中Illuminate\Support\Facades\Auth::user方法的典型用法代码示例。如果您正苦于以下问题:PHP Auth::user方法的具体用法?PHP Auth::user怎么用?PHP Auth::user使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Illuminate\Support\Facades\Auth的用法示例。


在下文中一共展示了Auth::user方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: slots

 public function slots()
 {
     $user = Auth::user();
     $location = $user->location;
     $slot = Slot::where('location', '=', $location)->first();
     $input = Input::get('wager');
     $owner = User::where('name', '=', $slot->owner)->first();
     $num1 = rand(1, 10);
     $num2 = rand(5, 7);
     $num3 = rand(5, 7);
     if ($user->name != $owner->name) {
         if ($num1 & $num2 & $num3 == 6) {
             $money = rand(250, 300);
             $payment = $money += $input * 1.75;
             $user->money += $payment;
             $user->save();
             session()->flash('flash_message', 'You rolled three sixes!!');
             return redirect('/home');
         } else {
             $user->money -= $input;
             $user->save();
             $owner->money += $input;
             $owner->save();
             session()->flash('flash_message_important', 'You failed to roll three sixes!!');
             return redirect(action('SlotsController@show', [$slot->location]));
         }
     } else {
         session()->flash('flash_message_important', 'You own this slot!!');
         return redirect(action('SlotsController@show', [$slot->location]));
     }
 }
开发者ID:mathewsandi,项目名称:MafiaGame,代码行数:31,代码来源:SlotsController.php

示例2: create

 /**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function create($pid)
 {
     //获取当前用户的信息
     $uid = Auth::user()->id;
     //        dd(Auth::user()->toArray());
     $product = Product::getProductById($pid);
     $product = $product[0];
     $pastid = $pid . time();
     //订单随机号
     //如果订单没有生成
     if (!Past::exsitId($uid, $pid)) {
         $past = new Past();
         $past->pastid = $pastid;
         $past->uid = $uid;
         $past->pid = $pid;
         $past->pname = $product->name;
         $past->price = $product->price;
         $past->type = $product->type;
         $past->payway = $product->payway;
         $past->image = $product->images;
         $past->save();
     } else {
         $past = Past::getPastByUPid($uid, $pid);
         $past = $past[0];
         $pastid = $past->pastid;
     }
     //		dd($product);
     $this->show($pastid);
     return redirect('past/show' . "/" . $pastid);
 }
开发者ID:pgy1,项目名称:Laravel-Shop,代码行数:35,代码来源:PastController.php

示例3: update

 public function update()
 {
     $profile = Profile::where('user_id', Auth::user()->id)->first();
     $profile->fill(Input::all());
     $profile->save();
     return Redirect::to("/edit_profile");
 }
开发者ID:Volkan61,项目名称:begreat,代码行数:7,代码来源:ProfileController.php

示例4: rules

 /**
  * Get the validation rules that apply to the request.
  *
  * @return array
  */
 public function rules()
 {
     $validation['password'] = 'required|min:6|confirmed';
     $validation['current_password'] = 'required';
     $user = Auth::user();
     return $validation;
 }
开发者ID:mage2,项目名称:laravel-ecommerce,代码行数:12,代码来源:ChangePasswordRequest.php

示例5: newComment

 /**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function newComment(CommentFormRequest $request)
 {
     $user_id = Auth::user()->id;
     $comment = new Comment(array('post_id' => $request->get('post_id'), 'content' => $request->get('content'), 'user_id' => $user_id));
     $comment->save();
     return redirect()->back()->with('custom_success', 'Your comment has been created!');
 }
开发者ID:ErtyGi,项目名称:wsapp,代码行数:12,代码来源:CommentsController.php

示例6: 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');
 }
开发者ID:ReyRodriguez,项目名称:laravel-reddit,代码行数:33,代码来源:PostsController.php

示例7: store

 /**
  * Handle an authentication attempt.
  *
  * @return Response
  */
 public function store()
 {
     $rules = array('email' => 'required|email', 'password' => 'required');
     $validate = Validator::make(Input::all(), $rules);
     if ($validate->fails()) {
         return Redirect::to('/');
     } else {
         if (Auth::attempt(array('email' => Input::get('email'), 'password' => Input::get('password'), 'status' => 'Activate'))) {
             /*$user = User::where('email','=',$email)->get();
               Session::put('user_type',$user[0]->role);
               $id = $user[0]->id;
               Session::put('created_by',$id);*/
             Session::put('user_id', Auth::user()->id);
             Session::put('user_name', Auth::user()->username);
             Session::put('user_role', Auth::user()->role);
             Session::flash('message', 'User has been Successfully Login.');
             $roles = Auth::user()->role;
             if ($roles = 'admin' || 'manager') {
                 return Redirect::to('dashboard');
             } elseif ($roles = 'user') {
                 return Redirect::to('profile');
             }
         } else {
             Session::flash('message', 'Your username or password incorrect');
             return Redirect::to('/');
         }
     }
 }
开发者ID:woakes070048,项目名称:cemcoErp,代码行数:33,代码来源:AuthController.php

示例8: process

 public function process(UploadedFile $file)
 {
     // File extension
     $this->extension = $file->getClientOriginalExtension();
     // Mimetype for the file
     $this->mimetype = $file->getMimeType();
     // Current user or 0
     $this->user_id = Auth::user() ? Auth::user()->id : 0;
     $this->size = $file->getSize();
     list($this->path, $this->filename) = $this->upload($file);
     $this->save();
     // Check to see if image thumbnail generation is enabled
     if (static::$app['config']->get('cabinet::image_manipulation')) {
         $thumbnails = $this->generateThumbnails($this->path, $this->filename);
         $uploads = array();
         foreach ($thumbnails as $thumbnail) {
             $upload = new $this();
             $upload->filename = $thumbnail->fileSystemName;
             $upload->path = static::$app['config']->get('cabinet::upload_folder_public_path') . $this->dateFolderPath . $thumbnail->fileSystemName;
             // File extension
             $upload->extension = $thumbnail->getClientOriginalExtension();
             // Mimetype for the file
             $upload->mimetype = $thumbnail->getMimeType();
             // Current user or 0
             $upload->user_id = $this->user_id;
             $upload->size = $thumbnail->getSize();
             $upload->parent_id = $this->id;
             $upload->save();
             $uploads[] = $upload;
         }
         $this->children = $uploads;
     }
 }
开发者ID:andrewelkins,项目名称:cabinet,代码行数:33,代码来源:CabinetUpload.php

示例9: compose

 /**
  * Bind data to the view.
  *
  * @param  View  $view
  * @return void
  */
 public function compose(View $view)
 {
     $user = Cache::remember('user', 1440, function () {
         return Auth::user();
     });
     $view->with('user', $user);
 }
开发者ID:jespersgaard,项目名称:tyloo,代码行数:13,代码来源:LoggedInUserViewComposer.php

示例10: showNews

 /**
  * @return mixed
  */
 public function showNews()
 {
     $slug = Request::segment(2);
     $news_title = "Not active";
     $news_text = "Either this news item is not active, or it does not exist";
     $active = 1;
     $news_id = 0;
     $results = DB::table('news')->where('slug', '=', $slug)->get();
     foreach ($results as $result) {
         $active = $result->active;
         if ($active > 0 || Auth::check() && Auth::user()->hasRole('news')) {
             if (Session::get('lang') == null || Session::get('lang') == "en") {
                 $news_title = $result->title;
                 $news_text = $result->news_text;
                 $news_id = $result->id;
             } else {
                 $news_title = $result->title_fr;
                 $news_text = $result->news_text_fr;
                 $news_id = $result->id;
             }
             $news_image = $result->image;
             $news_date = $result->news_date;
         }
     }
     return View::make('public.news')->with('news_title', $news_title)->with('news_text', $news_text)->with('page_content', $news_text)->with('active', $active)->with('news_id', $news_id)->with('news_date', $news_date)->with('news_image', $news_image)->with('menu', $this->menu)->with('page_category_id', 0)->with('page_title', $news_title);
 }
开发者ID:tsawler,项目名称:catra,代码行数:29,代码来源:NewsController.php

示例11: boot

 public static function boot()
 {
     parent::boot();
     Type::creating(function ($type) {
         $type->company_id = $type->company_id ?: Auth::user()['company_id'];
     });
 }
开发者ID:alientronics,项目名称:fleetany-web,代码行数:7,代码来源:Type.php

示例12: edit

 /**
  * Show the form for editing the specified user addresses.
  *
  * @param int $id
  *
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     $user = Auth::user();
     $address = Address::findorfail($id);
     $countries = Country::all();
     return view('address.my-account.edit-address')->with('user', $user)->with('address', $address)->with('countries', $countries);
 }
开发者ID:mage2,项目名称:laravel-ecommerce,代码行数:14,代码来源:AddressController.php

示例13: countMyDisposisi

 /**
  * Method ini digunakan untuk mendapatkan
  * jumlah formka5 yang di disposisikan ke user yang sedang login
  *
  * Data dari form di dapatkan dari formka5
  * dan table disposisi pada field kepada
  *
  * Jumlah id FormKA5 ini digunakan pada FormKA6 dan FormKA7
  */
 public static function countMyDisposisi($year = null)
 {
     $myUser = Auth::user();
     if ($year != null) {
         $form = Form::whereRaw('YEAR(`tanggal`) = ?', array($year))->get();
     } else {
         $form = Form::all();
     }
     $mydis = [];
     $i = 0;
     foreach ($form as $fm) {
         $dis = $fm->disposisi->first();
         if ($dis != NULL && $fm->nama == "ka5") {
             $kepada = json_decode($dis->kepada);
             foreach ($kepada as $user) {
                 if ($user->id == $myUser->id) {
                     if (strftime("%Y", strtotime($dis->form->tanggal)) == $year) {
                         $mydis[$i] = $dis->form->id;
                         $i++;
                     }
                 }
             }
         }
     }
     return $mydis;
 }
开发者ID:beecode,项目名称:lpantbweb,代码行数:35,代码来源:KA5DiposisiHelper.php

示例14: composeFullname

 private function composeFullname()
 {
     view()->composer('admin.app', function ($view) {
         $view->with('fullname', Auth::user()->admin->fullname);
         return;
     });
     //        view()->composer('partial.header', function ($view) {
     //            if (Auth::check()){
     //                $user = Auth::user();
     //                if ($user->role=='0'){
     //                    $view->with('role','0');
     //                    $view->with('fullname',$user->admin->fullname);
     //                    return;
     //                }
     //                if ($user->role=='1'){
     //                    $view->with('role','1');
     //                    $view->with('fullname',$user->customer->firstname);
     //                    return;
     //                }
     //
     //            }
     //        });
     //        view()->composer('admin.partial.header', function ($view) {
     //            if (Auth::check()){
     //                $user = Auth::user();
     //                if ($user->role=='0'){
     //                    $view->with('fullname',$user->admin->fullname);
     //                    return;
     //                }
     //            }
     //        });
 }
开发者ID:jentleyow,项目名称:megadeal,代码行数:32,代码来源:UserDetailServiceProvider.php

示例15: dashboard

 public function dashboard()
 {
     $messages = Redis::lrange('messages', 0, -1);
     $messages = $messages ? $messages : [];
     $tasks = Auth::user()->tasks()->get();
     return view('dashboard', compact('messages', 'tasks'));
 }
开发者ID:ColDog,项目名称:laravel-first,代码行数:7,代码来源:PagesController.php


注:本文中的Illuminate\Support\Facades\Auth::user方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。