本文整理汇总了PHP中app\Category::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Category::create方法的具体用法?PHP Category::create怎么用?PHP Category::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Category
的用法示例。
在下文中一共展示了Category::create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store(Request $request)
{
if ($Category = $this->Category->create($request->all())) {
Flash::success(trans('app.Successful operation'));
return redirect()->route('dashboard.category.index', ['typeId' => $Category->type_id]);
} else {
Flash::error(trans('app.Operation failed'));
return redirect()->back()->withInput($request->all());
}
}
示例2: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(CategoryFormRequest $request)
{
// Save new category
Category::create($request->all());
flash()->success('New category has been added!');
return redirect('categories');
}
示例3: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$faker = Faker\Factory::create('it_IT');
Category::create(['name' => 'News', 'slug' => 'news', 'description' => $faker->paragraph(3)]);
Category::create(['name' => 'Interviste', 'slug' => 'interviste', 'description' => $faker->paragraph(3)]);
Category::create(['name' => 'Reportage', 'slug' => 'reportage', 'description' => $faker->paragraph(3)]);
}
示例4: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$this->validate($request, ['title' => 'required|string|max:255|unique:categories', 'parent_id' => 'exists:categories,id']);
Category::create($request->all());
\Flash::success('Category saved.');
return redirect()->route('categories.index');
}
示例5: run
public function run()
{
DB::table('categories')->truncate();
\App\Category::create(['name' => 'Tips & Tutorials', 'slug' => 'tips-tutorials']);
\App\Category::create(['name' => 'Packages', 'slug' => 'packages']);
\App\Category::create(['name' => 'Applications', 'slug' => 'apps']);
}
示例6: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(StoreCategoryRequest $request)
{
//
Category::create($request->all());
$status = 'New category added.';
return \Redirect::route('categories.index')->with(['status' => $status]);
}
示例7: store
public function store(CategoryRequest $request)
{
$input = $request->all();
$category = Category::create($input);
session()->flash('flash_message', 'You have been addded 1 category!');
return redirect()->route('settings.category');
}
示例8: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
DB::table('tbl_categories')->truncate();
\App\Category::create(['category' => 'Clothes']);
\App\Category::create(['category' => 'Miscellaneous']);
\App\Category::create(['category' => 'Music']);
}
示例9: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
DB::table('locations')->truncate();
Location::create(['name' => 'Phase 1, Level 1']);
Location::create(['name' => 'Phase 1, Level 2']);
Location::create(['name' => 'Phase 1, Level 3']);
Location::create(['name' => 'Phase 2, Level 1']);
Location::create(['name' => 'Phase 2, Level 2']);
Location::create(['name' => 'Phase 2, Level 3']);
Location::create(['name' => 'Phase 3, Level 1']);
Location::create(['name' => 'Phase 3, Level 2']);
Location::create(['name' => 'Phase 3, Level 3']);
DB::table('areas')->truncate();
Area::create(['name' => 'AME']);
Area::create(['name' => 'M&W']);
Area::create(['name' => 'Ramp']);
Area::create(['name' => 'SCI']);
Area::create(['name' => 'Tool Install']);
DB::table('categories')->truncate();
Category::create(['name' => 'Spec Gas']);
Category::create(['name' => 'Electrical']);
Category::create(['name' => 'Base Build']);
Category::create(['name' => 'Design Request']);
Category::create(['name' => 'Layout Optimization']);
Category::create(['name' => 'Safety']);
DB::table('status')->truncate();
Status::create(['name' => 'New', 'slug' => 'new']);
Status::create(['name' => 'Open/Needs Further Review', 'slug' => 'open-needs-further-review']);
Status::create(['name' => 'Waiting for Approval', 'slug' => 'waiting-for-approval']);
Status::create(['name' => 'Rejected', 'slug' => 'rejected']);
Status::create(['name' => 'Approved', 'slug' => 'approved']);
}
示例10: run
public function run()
{
DB::table('categories')->delete();
Category::create(array('id' => 3, 'created_at' => '2015-11-09 16:10:46', 'updated_at' => '2015-11-09 16:10:46', 'name' => 'Fruits'));
Category::create(array('id' => 4, 'created_at' => '2015-11-09 16:11:39', 'updated_at' => '2015-11-09 16:11:39', 'name' => 'Vegetables'));
Category::create(array('id' => 5, 'created_at' => '2015-11-09 16:13:46', 'updated_at' => '2015-11-09 16:13:46', 'name' => 'Grains'));
}
示例11: store
/**
* Store a newly created resource in storage.
*
* @param Request $request
* @return Response
*/
public function store(Request $request)
{
$this->validate($request, ['name' => 'required|unique:categories|max:255', 'color' => 'required']);
$category = Category::create(['name' => $request->get('name'), 'slug' => str_slug($request->get('name')), 'description' => $request->get('description'), 'color' => $request->get('color')]);
$message = $category ? 'Categoria agregada correctamente!' : 'La categoria NO pudo agregarse!';
return redirect()->route('admin.category.index')->with('message', $message);
}
示例12: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store(Request $request)
{
$this->validate($request, $this->rules);
$input = Input::all();
Category::create($input);
return Redirect::route('categories.index')->with('message', 'New category created!');
}
示例13: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$faker = Faker\Factory::create();
foreach (range(1, 10) as $index) {
Category::create(['title' => $faker->sentence, 'description' => $faker->paragraph(1), 'parent_id' => NULL, 'created_by' => 1, 'updated_by' => 1, 'ordering' => 1, 'status' => true]);
}
}
示例14: run
public function run()
{
DB::table('categories')->delete();
Category::create(array('name' => 'Category 1'));
Category::create(array('name' => 'Category 2'));
Category::create(array('name' => 'Category 3'));
}
示例15: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store(CategoryRequest $request)
{
Category::create($request->all());
flash()->success('Your category has been created!');
\Cache::tags('categories')->flush();
return redirect('admin/categories/index');
}