本文整理汇总了PHP中app\Category类的典型用法代码示例。如果您正苦于以下问题:PHP Category类的具体用法?PHP Category怎么用?PHP Category使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Category类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param Category $category
* @return \Illuminate\Http\Response
*/
public function store(Request $request, Category $category)
{
$this->validate($request, ['name' => 'required|unique:categories', 'slug' => 'required|unique:categories']);
$input = $request->except(['_token']);
$category->fill($input)->save();
return redirect('categories')->with('success', $category->name . ' category successfully added.');
}
示例2: store
/**
* Store a newly created resource in storage.
*
* @param Request $request
* @return Response
*/
public function store(Request $request)
{
$category = new Category();
$category->name = $request->name;
$category->save();
return redirect('movie');
}
示例3: postComment
public function postComment(Category $category, Post $post, CommentRepository $repository, PostNewComment $request, Comment $comment)
{
$fields = array_merge($request->all(), array('post_id' => $post->id));
$comment->create($fields);
Session::flash('success', 'Comment added succesfully !');
return view('blog.post', ['post' => $post, 'categories' => $category->all()]);
}
示例4: index
/**
* Display a listing of categories and the category members (parent-children) and their social media.
*
* @return Response
*/
public function index($slug)
{
// get links in footer
$linksArr = \App\Links::orderBy('rank', 'ASC')->lists('link', 'name');
if ($slug != 'all') {
$catObj = Category::whereSlug($slug)->first();
if (is_null($catObj)) {
\Session::flash('message', 'Invalid category');
return redirect('/socialmedia/all');
}
$catPathArr = $catObj->getCategoryPath($slug);
$catArr = $catObj->getChildren($catObj->id);
} else {
$catPathArr = array();
$catObj = new Category();
$catArr = $catObj->getParents();
}
$getChildren = $this->getChildrenBool($catPathArr, $slug, $catObj);
// eg. get the teammates on the Lakers, don't get teams in the Pacific Coast division
if ($getChildren) {
$memberArr = $this->memberObj->getMembersWithinSingleCategory($catObj->id);
list($memberArr, $contentArr) = $this->memberSocialObj->getSocialMediaWithMemberIds($memberArr);
return view('socialmedia.child', compact('memberArr', 'contentArr', 'catPathArr', 'linksArr'));
} else {
$parentArr['contentArr'] = [];
foreach ($catArr as $catId => $catName) {
$memberArr = $this->memberObj->getMembersWithinSingleCategory($catId);
$tmpMemberArr = array($memberArr[0]);
list(, $contentArr) = $this->memberSocialObj->getSocialMediaWithMemberIds($tmpMemberArr);
$parentArr['memberArr'][$catId] = $memberArr;
$parentArr['contentArr'] = $parentArr['contentArr'] + $contentArr;
}
return view('socialmedia.parent', compact('parentArr', 'catArr', 'catPathArr', 'linksArr'));
}
}
示例5: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$category = new Category();
$category->category_name = $request->category_name;
$category->save();
\Session::flash('success', 'Category created successfully');
}
示例6: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$category1 = new Category();
$category1->name = 'Cat 1';
$category1->save();
$category2 = new Category();
$category2->name = 'Cat 2';
$category2->save();
$nice_action = new NiceAction();
$nice_action->name = 'Greet';
$nice_action->niceness = 3;
$nice_action->save();
$category1->nice_actions()->attach($nice_action);
$category2->nice_actions()->attach($nice_action);
$nice_action = new NiceAction();
$nice_action->name = 'Hug';
$nice_action->niceness = 6;
$nice_action->save();
$category2->nice_actions()->attach($nice_action);
$nice_action = new NiceAction();
$nice_action->name = 'Kiss';
$nice_action->niceness = 12;
$nice_action->save();
$category1->nice_actions()->attach($nice_action);
$nice_action = new NiceAction();
$nice_action->name = 'Wave';
$nice_action->niceness = 2;
$nice_action->save();
$category2->nice_actions()->attach($nice_action);
}
示例7: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store()
{
$category = new Category();
$category->name = Input::get('name');
$category->under_category = Input::get('under_category');
$category->save();
return redirect()->route('category-list');
}
示例8: store
public function store(CategoryFormRequest $request)
{
$category = new Category(['name' => $request->get('name')]);
$category->save();
return redirect('admin/categories/create')->with('status', 'A new category has been created!');
// Session::flash('status', 'A new category has been created!');
// return view('backend.categories.create');
}
示例9: categorylist
/**
* List of categories in parent - child hierarchy
*
* @return Response
*/
public function categorylist()
{
$categoryPAndCObj = new \App\CategoryParentAndChildren();
$category = new \App\Category();
$categoriesObj = $category->all();
$categoriesArr = $category->getCategoriesArr($categoriesObj);
$parentChildArr = $categoryPAndCObj->getHierarchy();
return view('socialmedia.categorylist', compact('categoriesObj', 'parentChildArr', 'categoriesArr'));
}
示例10: delete
public function delete(Request $request, Category $category)
{
$category->delete();
if ($request->isXmlHttpRequest()) {
return response(json_encode(['success' => true]))->header('Content-type', 'application/json');
} else {
return redirect('/category');
}
}
示例11: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$categories = ['Safari', 'Safari Adventure', 'Cruise / Boats', 'City Tours', 'Bus Tours', 'Air Tours', 'Fishing & Yachting', 'Water Parks / Entertainment', 'UAE Attractions', 'Shopping Malls', 'Souks'];
foreach ($categories as $category) {
$new_category = new Category();
$new_category->name = $category;
$new_category->save();
}
}
示例12: update
public function update(Request $request)
{
$category = new Category();
$category->id = $request->id;
$category->name = $request->name;
$category->save();
echo json_encode(true);
exit;
}
示例13: postAdd
public function postAdd(Request $request)
{
$data = $request->all();
$rules = $rules = array('category' => 'required|min:3|max:200|unique:categories,name');
$this->validate($request, $rules);
$category = new Category();
$category->name = $data['category'];
$category->save();
return redirect('admin')->withMessage('Category added!');
}
示例14: store
/**
* Store the new category
*
* @param Request $request
* @return Response
*/
public function store(Request $request)
{
$this->validate($request, ['title' => 'required|max:32|min:3', 'description' => 'max:128|min:3'], ['title.*' => 'หัวข้อต้องมีความยาว 3-32 ตัวอักษร', 'description.*' => 'คำบรรยายต้องมีความยาว 3-128 ตัวอักษร']);
$category = new App\Category();
$category->title = $request->title;
$category->description = $request->description;
$category->status = 1;
$category->save();
return redirect()->action('CategoryController@create');
}
示例15: getEdit
public function getEdit($id)
{
$categories = new Category();
$allCategory = $categories->getCategoriesDropDown();
$branches = new Branch();
$branchAll = $branches->getBranchesDropDown();
$subCategories = new SubCategory();
$allSubCategory = $subCategories->getSubCategoriesDropDown();
$products = Product::find($id);
return view('Products.edit', compact('branchAll'))->with('products', $products)->with('categoryAll', $allCategory)->with('subCategoryAll', $allSubCategory);
}