本文整理汇总了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();
}