當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ProductCategory::valid方法代碼示例

本文整理匯總了PHP中ProductCategory::valid方法的典型用法代碼示例。如果您正苦於以下問題:PHP ProductCategory::valid方法的具體用法?PHP ProductCategory::valid怎麽用?PHP ProductCategory::valid使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ProductCategory的用法示例。


在下文中一共展示了ProductCategory::valid方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: updateProductCategory

 public function updateProductCategory()
 {
     if (Input::has('pk')) {
         if (!Request::ajax()) {
             return App::abort(404);
         }
         return self::updateQuickEdit();
     }
     $prevURL = Request::header('referer');
     if (!Request::isMethod('post')) {
         return App::abort(404);
     }
     if (Input::has('id')) {
         $create = false;
         try {
             $category = ProductCategory::findorFail((int) Input::get('id'));
         } catch (Illuminate\Database\Eloquent\ModelNotFoundException $e) {
             return App::abort(404);
         }
         $message = 'has been updated successful';
     } else {
         $create = true;
         $category = new ProductCategory();
         $message = 'has been created successful';
     }
     $category->name = Input::get('name');
     $category->short_name = Str::slug($category->name);
     $category->parent_id = (int) Input::get('parent_id');
     $category->order_no = (int) Input::get('order_no');
     $category->active = Input::has('active') ? 1 : 0;
     $category->meta_title = e(Input::get('meta_title'));
     $category->meta_description = e(Input::get('meta_description'));
     $pass = $category->valid();
     if ($pass->passes()) {
         $action = Input::has('on_menu') ? 'add' : 'delete';
         $category = Menu::updateMenu($category, $action, 'collections/');
         $category->save();
         $imageId = 0;
         if (Input::hasFile('image')) {
             $imageId = VIImage::upload(Input::file('image'), public_path() . DS . 'assets' . DS . 'images' . DS . 'product_categories', 450, false);
         } else {
             if (Input::has('choose_image')) {
                 $imageId = Input::get('choose_image');
             }
         }
         if ($imageId) {
             $category->images()->detach();
             $category->images()->attach($imageId);
         }
         if (Input::has('continue')) {
             if ($create) {
                 $prevURL = URL . '/admin/categories/edit-category/' . $category->id;
             }
             return Redirect::to($prevURL)->with('flash_success', "<b>{$category->name}</b> {$message}.");
         }
         return Redirect::to(URL . '/admin/categories')->with('flash_success', "<b>{$category->name}</b> {$message}.");
     }
     return Redirect::to($prevURL)->with('flash_error', $pass->messages()->all())->withInput();
 }
開發者ID:nguyendaivu,項目名稱:imagestock,代碼行數:59,代碼來源:ProductCategoriesController.php


注:本文中的ProductCategory::valid方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。