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


PHP Sentry::getId方法代码示例

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


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

示例1: postCreate

 /**
  * Blog post create form processing.
  *
  * @return Redirect
  */
 public function postCreate()
 {
     // Declare the rules for the form validation
     $rules = array('title' => 'required|min:3', 'content' => 'required|min:3');
     // Validate the inputs
     $validator = Validator::make(Input::all(), $rules);
     // Check if the form validates with success
     if ($validator->passes()) {
         // Create a new blog post
         $post = new Post();
         // Update the blog post data
         $post->title = Input::get('title');
         $post->slug = convert_to_slug(Input::get('title'));
         $post->content = Input::get('content');
         $post->meta_title = Input::get('meta-title');
         $post->meta_description = Input::get('meta-description');
         $post->meta_keywords = Input::get('meta-keywords');
         $post->user_id = Sentry::getId();
         // Was the blog post created?
         if ($post->save()) {
             // Redirect to the new blog post page
             return Redirect::to('admin/blogs/' . $post->id . '/edit')->with('success', Lang::get('admin/blogs/messages.create.success'));
         }
         // Redirect to the blog post create page
         return Redirect::to('admin/blogs/create')->with('error', Lang::get('admin/blogs/messages.create.error'));
     }
     // Form validation failed
     return Redirect::to('admin/blogs/create')->withInput()->withErrors($validator);
 }
开发者ID:nozkok,项目名称:laravel-4-starter,代码行数:34,代码来源:AdminBlogsController.php

示例2: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     // Declare the rules for the form validation
     $rules = array('title' => 'required|min:3', 'content' => 'required|min:3|not_in:<p></p>', 'image' => 'image|max:30000000');
     // Create a new validator instance from our validation 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::back()->withInput()->withErrors($validator);
     }
     // Create a new portfolio post
     $post = new PortfolioPost();
     // Update the portfolio post data
     $post->title = e(Input::get('title'));
     if (empty($post->slug)) {
         $post->slug = e(Str::slug(Input::get('title')));
     } else {
         $post->slug = e(Str::slug(Input::get('slug')));
     }
     $post->content = e(Input::get('content'));
     $post->draft = e(Input::get('draft'));
     $post->lang = e(Input::get('lang'));
     $post->content = e(Input::get('content'));
     $post->meta_title = e(Input::get('meta-title'));
     $post->meta_description = e(Input::get('meta-description'));
     $post->meta_keywords = e(Input::get('meta-keywords'));
     $post->user_id = Sentry::getId();
     $image = Input::file('image');
     if (!empty($image)) {
         $filename = $post->slug . '_' . date('d-m-Y') . '.' . $image->getClientOriginalExtension();
         $uploadSuccess = Input::file('image')->move($this->destinationPath, $filename);
         $post->image = e($filename);
     }
     // Was the portfolio post created?
     if ($post->save()) {
         $tags = explode(',', Input::get('portfoliotags'));
         foreach ($tags as $tag) {
             if (PortfolioTag::where('name', '=', $tag)->count() == 0) {
                 $newTag = new PortfolioTag();
                 $newTag->name = ucwords($tag);
                 $newTag->slug = Str::slug($tag);
                 $newTag->save();
             } else {
                 $newTag = PortfolioTag::where('name', '=', $tag)->first();
             }
             $post->tags()->attach($newTag->id);
         }
         // Redirect to the new portfolio post page
         return Redirect::route('portfolio.show', array('portfolio' => $post->slug))->with('success', Lang::get('modules/portfolio/messages.success.create'));
     }
     // Redirect to the portfolio post create page
     return Redirect::route('portfolio.create')->with('error', Lang::get('modules/portfolio/messages.error.create'));
 }
开发者ID:ComradeHadi,项目名称:Tyloo,代码行数:59,代码来源:PortfolioController.php

示例3: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     // Declare the rules for the form validation
     $rules = array('title' => 'required|min:3', 'content' => 'required|min:3|not_in:<p></p>');
     // Create a new validator instance from our validation 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::back()->withInput()->withErrors($validator);
     }
     // Create a new page
     $page = new Page();
     // Update the page data
     $page->title = e(Input::get('title'));
     if (empty($page->slug)) {
         $page->slug = e(Str::slug(Input::get('title')));
     } else {
         $page->slug = e(Str::slug(Input::get('slug')));
     }
     $page->content = e(Input::get('content'));
     $page->draft = e(Input::get('draft'));
     $page->in_menu = e(Input::get('in_menu'));
     $page->lang = e(Input::get('lang'));
     $page->content = e(Input::get('content'));
     $page->meta_title = e(Input::get('meta-title'));
     $page->meta_description = e(Input::get('meta-description'));
     $page->meta_keywords = e(Input::get('meta-keywords'));
     $page->user_id = Sentry::getId();
     // Was the page created?
     if ($page->save()) {
         // Redirect to the new page page
         return Redirect::route('page.show', array('slug' => $page->slug))->with('success', Lang::get('modules/page/messages.success.create'));
     }
     // Redirect to the page create page
     return Redirect::route('page.create')->with('error', Lang::get('modules/page/messages.error.create'));
 }
开发者ID:ComradeHadi,项目名称:Tyloo,代码行数:42,代码来源:PageController.php

示例4: getDelete

 /**
  * Delete the given user, beware that the logged in user
  * can't be deleted, makes sense, right?
  *
  * @param  int  $userId
  * @return Redirect
  */
 public function getDelete($userId = null)
 {
     try {
         // Get user information
         $user = Sentry::getUserProvider()->findById($userId);
         // Check if we are not trying to delete ourselves
         if ($user->id === Sentry::getId()) {
             // Redirect to the user management page
             return Redirect::to('admin/users')->with('error', Lang::get('admin/users/messages.delete.impossible'));
         }
         // Was the user deleted?
         if ($user->delete()) {
             // Redirect to the user management page
             return Redirect::to('admin/users')->with('success', Lang::get('admin/users/messages.delete.success'));
         }
         // There was a problem deleting the user
         return Redirect::to('admin/users')->with('error', Lang::get('admin/users/messages.delete.error'));
     } catch (Cartalyst\Sentry\Users\UserNotFoundException $e) {
         // Redirect to the user management page
         return Redirect::to('admin/users')->with('error', Lang::get('admin/users/messages.not_found'));
     }
 }
开发者ID:nozkok,项目名称:laravel-4-starter,代码行数:29,代码来源:AdminUsersController.php

示例5: getDelete

 /**
  * Delete the given user.
  *
  * @param  int  $id
  * @return Redirect
  */
 public function getDelete($id = null)
 {
     try {
         // Get user information
         $user = Sentry::getUserProvider()->findById($id);
         // Check if we are not trying to delete ourselves
         if ($user->id === Sentry::getId()) {
             // Prepare the error message
             $error = Lang::get('admin/users/message.error.delete');
             // Redirect to the user management page
             return Redirect::route('users')->with('error', $error);
         }
         // Do we have permission to delete this user?
         if ($user->isSuperUser() and !Sentry::getUser()->isSuperUser()) {
             // Redirect to the user management page
             return Redirect::route('users')->with('error', 'Insufficient permissions!');
         }
         // Delete the user
         $user->delete();
         // Prepare the success message
         $success = Lang::get('admin/users/message.success.delete');
         // Redirect to the user management page
         return Redirect::route('users')->with('success', $success);
     } catch (UserNotFoundException $e) {
         // Prepare the error message
         $error = Lang::get('admin/users/message.user_not_found', compact('id'));
         // Redirect to the user management page
         return Redirect::route('users')->with('error', $error);
     }
 }
开发者ID:soarmorrow,项目名称:refercom,代码行数:36,代码来源:FormTemplateController.php


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