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


PHP Acl::addAdmin方法代码示例

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


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

示例1: createHandle

 public function createHandle()
 {
     $path = DirectoryHelpers::seoString(e(Input::get('path')));
     $nice_input_names = ['is_root' => trans('directory.is_root'), 'name' => trans('directory.name'), 'path' => trans('directory.path'), 'description' => trans('directory.description'), 'keywords' => trans('directory.keywords')];
     $rules = ['is_root' => 'required', 'name' => 'required|between:2,50|unique:categories', 'path' => 'required|between:2,50|unique:categories', 'description' => 'between:5,1000', 'keywords' => 'between:5,255'];
     $is_root = Input::get('is_root');
     if ('no' == $is_root) {
         $nice_input_names['parent_id'] = trans('directory.parent');
         $rules['parent_id'] = 'not_in:0';
     }
     $validator = Validator::make(Input::all(), $rules, [], $nice_input_names);
     if ($validator->fails()) {
         return Redirect::route('category.create')->withErrors($validator)->withInput();
     }
     try {
         if ('yes' == $is_root) {
             $status = Acl::isSuperAdmin() ? 1 : 0;
             $node = Category::create(['status' => $status, 'name' => e(Input::get('name')), 'slug' => $path, 'path' => $path, 'description' => e(Input::get('description')), 'keywords' => e(Input::get('keywords'))])->makeRoot();
         }
         if ('no' == $is_root) {
             $parent = Category::find(e(Input::get('parent_id')));
             $node = Category::create(['status' => $status, 'name' => e(Input::get('name')), 'slug' => $path, 'path' => $path, 'description' => e(Input::get('description')), 'keywords' => e(Input::get('keywords'))])->makeChildOf($parent);
         }
         Acl::addAdmin($node);
         return Redirect::route('category.create')->with('success', Lang::get('directory.category_added', ['name' => Input::get('name')]));
     } catch (Exception $ex) {
         return Redirect::route('category.create')->withErrors($ex->getMessage())->withInput();
     }
 }
开发者ID:CalinB,项目名称:web-directory,代码行数:29,代码来源:CategoriesController.php

示例2: createHandle

 public function createHandle()
 {
     $pr = DirectoryHelpers::getPagerank(e(Input::get('url')));
     $valid_domain = function ($domain_name) {
         return preg_match("/^([a-z\\d](-*[a-z\\d])*)(\\.([a-z\\d](-*[a-z\\d])*))*\$/i", $domain_name) && preg_match("/^.{1,253}\$/", $domain_name) && preg_match("/^[^\\.]{1,63}(\\.[^\\.]{1,63})*\$/", $domain_name);
         //length of each label
     };
     $format_url = rtrim(str_replace(['http://', 'https://'], '', e(Input::get('url'))), '/');
     if (!$valid_domain($format_url)) {
         Session::put('category_id', e(Input::get('category_id')));
         return Redirect::back()->with('url_error', trans('directory.invalid_url'))->withInput();
     }
     $url_details = parse_url(e(Input::get('url')));
     $final_url = isset($url_details['scheme']) ? $url_details['scheme'] . '://' . $format_url : 'http://' . $format_url;
     Input::merge(array('url' => $final_url));
     $nice_input_names = ['category_id' => trans('directory.select_category'), 'name' => trans('directory.name'), 'url' => trans('directory.url'), 'format_url' => trans('directory.url'), 'description' => trans('directory.description'), 'keywords' => trans('directory.keywords')];
     $rules = ['category_id' => 'not_in:"0"', 'name' => 'required|between:6,260', 'url' => 'required|url|between:6,100|unique:domains', 'description' => 'required|between:200,1000', 'keywords' => 'between:5,255'];
     if (!Auth::check()) {
         $nice_input_names['g-recaptcha-response'] = 'captcha';
         $rules['g-recaptcha-response'] = 'required|recaptcha';
     }
     $coma_replace = function ($string) {
         return str_replace(',', ', ', $string);
     };
     if (strlen(str_replace(' ', '', e(Input::get('description')))) < 200 && Auth::user()->type != User::ADMIN_USER) {
         $attempt = new Attempt();
         $attempt->user_id = Auth::check() ? Auth::user()->id : null;
         $attempt->category_id = (int) e(Input::get('category_id'));
         $attempt->url = 'http://' . $format_url;
         $attempt->name = e(Input::get('name'));
         $attempt->description = $coma_replace(DirectoryHelpers::correctText(e(Input::get('description')), '.'));
         $attempt->keywords = $coma_replace(e(Input::get('keywords')));
         $attempt->save();
         return Redirect::back()->with('error', 'Descrierea este prea scurt&#259;')->withInput();
     }
     $validator = Validator::make(array_map('trim', Input::all()), $rules, [], $nice_input_names);
     if ($validator->fails()) {
         Session::put('category_id', e(Input::get('category_id')));
         return Redirect::back()->withErrors($validator)->withInput();
     }
     $status = Acl::isSuperAdmin() ? 1 : 0;
     $domain = new Domain();
     $domain->category_id = (int) e(Input::get('category_id'));
     $domain->status = $status;
     $domain->name = $coma_replace(e(Input::get('name')));
     $domain->url = 'http://' . $format_url;
     $domain->page_rank = $pr;
     $domain->description = $coma_replace(DirectoryHelpers::correctText(e(Input::get('description')), '.'));
     $domain->keywords = $coma_replace(e(Input::get('keywords')));
     try {
         $domain->thumb = DirectoryHelpers::generateThumb($domain->url);
     } catch (Exception $ex) {
         Log::error($ex->getMessage());
     }
     if ($domain->save()) {
         Acl::addAdmin($domain);
         return Redirect::route('domain.create')->with('success', trans('directory.domain_added'));
     }
     return Redirect::back()->with('error', trans('directory.domain_add_error'));
 }
开发者ID:CalinB,项目名称:web-directory,代码行数:60,代码来源:DomainsController.php


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