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


PHP Sentry::getuser方法代码示例

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


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

示例1: store

 public function store()
 {
     if (Sentry::check()) {
         $ued = Sentry::getUser()->id;
     }
     $city = Sentry::getuser()->city;
     $product = new Product();
     $product->user_id = $ued;
     $product->metal = Input::get('metal');
     $product->supplier = Input::get('supplier');
     $product->grade_a = Input::get('grade_a');
     $product->grade_b = Input::get('grade_b');
     $product->shape = Input::get('shape');
     $product->size_a = Input::get('size_a');
     $product->size_b = Input::get('size_b');
     $product->size_c = Input::get('size_c');
     $product->thickness = Input::get('thickness');
     $product->volume = Input::get('volume');
     $product->bynumber = Input::get('bynumber');
     $product->perday = Input::get('perday');
     $product->city = $city;
     if ($image = Input::file('images')) {
         $filename = date('Y-m-d-H:i:s') . "-" . rand(1, 100);
         Image::make($image->getRealPath())->resize(488, 370)->save('public/images/' . $filename);
         $product->images = 'images/' . $filename;
     } else {
         $product->images = 'images/default.jpg';
     }
     $cadfilename = date('Y-m-d-H:i:s') . "-" . rand(1, 100);
     if (Input::hasfile('files')) {
         Input::file('files')->move('public/img/', $cadfilename);
         $product->files = 'img/' . $cadfilename;
     } else {
         $product->files = '0';
     }
     $product->save();
     return Redirect::to('/list')->with('flash_notice', 'Product added successfully');
 }
开发者ID:ArbindJain,项目名称:scrapkart,代码行数:38,代码来源:ProductsController.php

示例2: update

 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update()
 {
     // Fetch all request data.
     $data = Input::only('timezone', 'games');
     // Build the validation constraint set.
     $rules = array('timezone' => array('regex:([0-9a-zA-Z /+-]+)'));
     // Create a new validator instance.
     $validator = Validator::make($data, $rules);
     if ($validator->passes()) {
         try {
             // Find the user using the user id
             $user = User::find(Sentry::getuser()->id);
             // Update the user details
             $user->timezone = Input::get('timezone');
             $user_games = $user->userGame()->get();
             $games = Input::get('games');
             foreach ($user_games as $user_game) {
                 if ($games && !in_array($user_game->id, $games)) {
                     $user->userGame($user_game)->detach();
                 } elseif ($games == false) {
                     $user->userGame($user_game)->detach();
                 }
             }
             if ($games) {
                 foreach ($games as $game) {
                     $game_attach = Game::find($game);
                     if (!$user->userGame()->where('game_id', '=', $game_attach->id)->first()) {
                         $user->userGame()->attach($game_attach);
                     }
                 }
             }
             // Update the user
             if ($user->save()) {
                 return Redirect::to('/user/edit')->with('global_success', 'Profile has been updated.');
             } else {
                 return Redirect::to('/user/edit')->with('global_error', 'We couldn\'t update your profile, pelase try again or contactu us if situation repeats.');
             }
         } catch (Cartalyst\Sentry\Users\UserExistsException $e) {
             echo 'User with this login already exists.';
         } catch (Cartalyst\Sentry\Users\UserNotFoundException $e) {
             echo 'User was not found.';
         }
     }
     return Redirect::to('/user/edit')->withInput()->withErrors($validator)->with('message', 'Validation Errors!');
 }
开发者ID:Belar,项目名称:eventpotion,代码行数:51,代码来源:UserController.php


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