本文整理汇总了PHP中app\models\Categories::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Categories::create方法的具体用法?PHP Categories::create怎么用?PHP Categories::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Categories
的用法示例。
在下文中一共展示了Categories::create方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postForm
public function postForm(FormCategoryRequest $request)
{
if (!empty($request)) {
$pathImage = $request->get('picture', null);
$data = $request->all();
if ($request->hasfile('picture')) {
$validator = Validator::make($request->all(), ['picture' => ['mimes:jpg,png,jpeg']]);
if ($validator->fails()) {
return redirect(action('Admin\\CategoryController@postForm'))->withErrors($validator)->withInput();
}
$file = $request->file('picture');
$nameimage = date('Ymdhis') . rand(1, 1000) . '.' . $file->getClientOriginalExtension();
$file->move(public_path() . "/dinamic/category/", $nameimage);
$pathImage = '/dinamic/category/' . $nameimage;
$data['picture'] = $pathImage;
}
$data['flagactive'] = $request->get('flagactive', 1);
if ($request->id) {
$obj = Categories::find($request->id);
$obj->update($data);
$idTips = $obj->id;
} else {
$obj = Categories::create($data);
$idTips = $obj->id;
}
return redirect('admpanel/' . self::NAMEC)->with('messageSuccess', 'Caracteristicas Guardado');
}
return redirect('admpanel')->with('messageError', 'Error al guardar el tip');
}
示例2: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$categories = ['shoujitongxun' => ['display_name' => '手机通讯', 'sub' => [['zhinengshouji', '智能手机'], ['feizhinengshouji', '非智能手机'], ['duijiangji', '对讲机'], ['lanyaerji', '蓝牙耳机']]], 'sheyingshexiang' => ['display_name' => '摄影摄像', 'sub' => [['danfangjisheng', '单反机身'], ['weidanxiangji', '微单相机'], ['shumaxiangji', '数码相机'], ['jiayongshexiangji', '家用摄像机'], ['zhuanyeshexiangji', '专业摄像机']]], 'xiangjipeijian' => ['display_name' => '相机配件', 'sub' => [['shumapeijian', '数码配件'], ['chongdianqi', '充电器'], ['dianchi', '电池'], ['diannaozhijia', '电脑支架'], ['yidongdianyuan', '移动电源'], ['chukongbi', '触控笔'], ['qitashumapeijian', '其它数码配件']]]];
foreach ($categories as $name => $category) {
$parent = Categories::create(['slug' => $name, 'name' => $category['display_name'], 'parent_id' => -1]);
$subs = $category['sub'];
foreach ($subs as $sub_category) {
Categories::create(['slug' => $sub_category[0], 'name' => $sub_category[1], 'parent_id' => $parent->id]);
}
}
}
示例3: store
public function store($request)
{
$cacheTag = ['categories'];
$validator = $this->validate($request);
if (!$validator->fails()) {
Logs::create(['activity' => 'store', 'module' => 'categories']);
Cache::tags($cacheTag)->flush();
$request['company_id'] = config('global.companies.current.id');
return Categories::create($request);
} else {
return new \Exception($validator->errors()->first());
}
}
示例4: create
public function create()
{
if (Request::isMethod('get')) {
$data['page_title'] = 'Data Kategori';
return view('categories.create', $data);
} else {
if (Request::isMethod('post')) {
$nama = Input::get('nama');
$kode = Input::get('kode');
$item = array('name' => $nama);
Categories::create($item);
return redirect('categories');
}
}
}
示例5: store
public function store()
{
$name = Input::has("name") ? Input::get("name") : "";
$lang = Input::get("lang");
$name_lang = Input::has("name_lang") ? Input::get("name_lang") : "";
if ($name == "") {
Session::flash("error", trans("categories.notifications.field_name_missing"));
return Redirect::to("/categories/create")->withInput();
}
$category_id = Categories::create(array('name' => $name));
//dd($lang, $name_lang,$category_id->id ); exit;
if ($lang != "en" && $name_lang != " ") {
AppCategoriesI18n::create(array('category_id' => $category_id->id, 'lang' => $lang, 'name' => $name_lang));
}
Session::flash('success', trans("categories.notifications.register_successful"));
return Redirect::to("/categories");
}
示例6: add
public static function add()
{
if (!Request::is_admin()) {
Response::redirect('');
}
if ("POST" == Request::method()) {
$id_acc = Request::user()->id;
$name = Request::POST()->name;
$decsription = Request::POST()->description;
Categories::create($id_acc, $name, $decsription);
# push flash-message
Session::push('flash-message', 'That category has successfuly added!');
Response::redirect('categories');
} else {
$categories = Categories::all()->fetchAll(\PDO::FETCH_CLASS);
View::render('categories/add', ['categories' => $categories]);
}
}
示例7: newCategory
public function newCategory($id)
{
if ($_POST) {
$request = (object) $_POST;
$category = new Categories();
if (isset($id)) {
$category->update($id, $request->nombre, $request->descripcion);
newFlashMessage('test', 'Categoria ' . ucwords($request->nombre) . " actualizada.");
return redirect('admin/category');
} else {
$category->create($request->nombre, $request->descripcion);
newFlashMessage('test', 'Categoria ' . ucwords($request->nombre) . " creada.");
return redirect('admin/category/');
}
} elseif (isset($id)) {
$categories = new Categories();
$category = $categories->find($id);
return view('admin/categories/update', compact('category'), 'baseAdmin');
} else {
return view('admin/categories/create', '', 'baseAdmin');
}
}