Inheritance: extends Illuminate\Database\Eloquent\Model
コード例 #1
0
 /**
  * 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
0
 /**
  * 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
0
 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
0
 /**
  * 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
0
 /**
  * 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
0
ファイル: NiceActionSeeder.php プロジェクト: pedreyesjr/test
 /**
  * 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
0
 /**
  * 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
0
 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
0
 /**
  * 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
0
 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
0
 /**
  * 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
0
 public function update(Request $request)
 {
     $category = new Category();
     $category->id = $request->id;
     $category->name = $request->name;
     $category->save();
     echo json_encode(true);
     exit;
 }
コード例 #13
0
 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
0
 /**
  * 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
0
 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);
 }
コード例 #16
0
ファイル: Category.php プロジェクト: blyp/blyp.api
 /**
  *  Create a new category from request.
  *
  * @param $request input form data
  * @return User
  */
 public function pushCategory($request)
 {
     $input = $request->all();
     if (isset($input['name'])) {
         $input['slug'] = str_slug($input['name'], "-");
     }
     $category = new Category();
     $category->fill($input);
     $category->save();
     return $category;
 }
コード例 #17
0
 /**
  * Update the specified resource in storage.
  *
  * @param  Request  $request
  * @param  int  $id
  * @return Response
  */
 public function update(Request $request, \App\Menu $menu, \App\Category $category)
 {
     $validation = \Validator::make($request->all(), ['name' => 'min:3']);
     if ($validation->fails()) {
         return response($validation->errors()->all(), 400);
     }
     if ($category->accessable($menu)) {
         $category->update($request->all());
         $category->savePhoto($request->file('photo'));
         return $category;
     }
 }
コード例 #18
0
ファイル: CategoriesController.php プロジェクト: giang69/NEWS
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['name' => 'required|min:4', 'slug' => 'unique:category,slug', 'description' => 'min:6|max:1000', 'parent_id' => 'exists:category,id']);
     $input = $request->all();
     $cat = new Category($input);
     if (isset($input['parent_id']) && !empty($input['parent_id'])) {
         $cat->parent_id = $input['parent_id'];
     }
     if ($cat->save()) {
         return redirect()->action('CategoriesController@index');
     }
 }
コード例 #19
0
 public function index($slug, Product $product, Category $category)
 {
     if ($data['product'] = $product->getProductBySlug($slug)) {
         $id = $data['product']->id;
         //Получаем категорию продукта
         $category_id = $product->getCategoryByProduct($id)->id;
         //Получаем коллекцию предков для заданной категории
         $data['route'] = $category->getRouteCategories($category_id);
         return view('product_page', $data);
     } else {
         abort(404);
     }
 }
コード例 #20
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $parent = !empty($request->input('parent_id')) ? Category::find($request->input('parent_id')) : null;
     $data = $request->only(['name', 'name_ru', 'parent_id']);
     $category = new Category($data);
     if (($messages = $category->validate()) === true) {
         Category::create($data, $parent);
         $response = array('result' => "{$request->input('name')} successfully added!");
         return \Response::json($response, 200);
     } else {
         return \Response::json($messages);
     }
 }
コード例 #21
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request, \App\Menu $menu, \App\Category $category)
 {
     $validation = \Validator::make($request->all(), ['name' => 'required|min:3', 'price' => 'required|integer|min:1']);
     if ($validation->fails()) {
         return response($validation->errors()->all(), 400);
     }
     if ($category->accessable($menu)) {
         $food = new \App\Food($request->all());
         $category->foods()->save($food);
         $food->savePhotos(['photos' => $request->file('photos'), 'remove_photos' => $request->get('remove_photos'), 'main_photo' => $request->get('main_photo')]);
         return $food;
     }
 }
コード例 #22
0
 /**
  * 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->type = $request->type;
     $category->name = ucfirst($request->name);
     $category->parent_is = $request->parent_is;
     if ($category->save()) {
         Flash::success('Data added successfully!');
     } else {
         Flash::error('Data could not be added right now. Please try later.');
     }
     return redirect('/categories');
 }
コード例 #23
0
 public function destroy(Request $request, Category $categories, Product $products)
 {
     $id = $request->category_id;
     //Проверяет наличие потомков заданной категории
     $category = $categories->checkByChild($id);
     //Проверяет наличие товаров в заданной категории
     $product = $products->checkByCategories($id);
     if (!empty($category) or !empty($product)) {
         return redirect()->back()->with('message', "<script>alert('Нельзя удалить категорию, в которой есть дочерние элементы или в которой есть товары')</script>");
     } else {
         Category::destroy($id);
         return redirect()->back();
     }
 }
コード例 #24
0
 public function run()
 {
     $faker = Factory::create();
     foreach (range(1, 10) as $index) {
         Category::create(['name' => $faker->firstName, 'description' => $faker->text(130), 'active' => $faker->boolean(85)]);
     }
 }
コード例 #25
0
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     // Create level 0 : member
     Level::create(['level' => 0, 'name' => 'membre']);
     // Create level 1 : band_creator
     Level::create(['level' => 1, 'name' => 'manager']);
     // Create level 2 : teacher
     Level::create(['level' => 2, 'name' => 'professeur']);
     // Create level 3 : admin
     Level::create(['level' => 3, 'name' => 'admin']);
     // Create level 10 : webmaster
     Level::create(['level' => 10, 'name' => 'webmaster']);
     // Create departement : "aucun"
     Department::create(['name' => 'Aucun', 'short_name' => 'Aucun']);
     // Create user : Webmaster (lvl 10)
     User::create(['first_name' => 'Webmaster', 'last_name' => 'Webmaster', 'email' => 'webm@ster', 'school_year' => 0, 'department_id' => 1, 'password' => bcrypt('webmastercmt'), 'level_id' => 5, 'slug' => 'webmaster-webmaster-1']);
     Category::create(['name' => 'Aucune']);
     Category::create(['name' => 'Autre']);
     Category::create(['name' => 'Présentation']);
     Category::create(['name' => 'Création de groupe']);
     Category::create(['name' => 'Recherche de groupe']);
     Category::create(['name' => 'Échange/Vente']);
     //Creation basic instruments :
     $instruments = ['autre', 'guitare', 'piano', 'basse', 'chant', 'flûte', 'violon', 'contrebasse', 'clarinette', 'saxophone', 'batterie', 'violoncelle', 'guitare électrique', 'flûte traversière', 'trompette', 'cor', 'trombone', 'tuba'];
     $this->create_instrument($instruments);
 }
コード例 #26
0
 /**
  * Bootstrap the application services.
  *
  * @return void
  */
 public function boot()
 {
     if (Schema::hasTable('categories')) {
         $categories = Category::getAllFromCache();
         view()->share('categories', $categories);
     }
 }
コード例 #27
0
 public function run()
 {
     $woodworking = App\Category::where('name', 'Woodworking')->first();
     $woodworking->skills()->create(['name' => 'Carpentry', 'description' => 'Making or repairing things in wood', 'created_by_id' => 1, 'approved' => true, 'approved_by_id' => 1]);
     $woodworking->skills()->create(['name' => 'Table Saw', 'description' => 'Using and maintaining a table saw', 'created_by_id' => 1, 'approved' => true, 'approved_by_id' => 1]);
     $woodworking->skills()->create(['name' => 'Bandsaw', 'description' => 'Using and maintaining a band saw', 'created_by_id' => 1, 'approved' => true, 'approved_by_id' => 1]);
     $woodworking->skills()->create(['name' => 'Lathe', 'description' => 'Using and maintaining a lathe', 'created_by_id' => 1, 'approved' => true, 'approved_by_id' => 1]);
     $woodworking->skills()->create(['name' => 'Bandsaw Box', 'description' => 'Making a bandsaw box', 'created_by_id' => 1, 'approved' => true, 'approved_by_id' => 1]);
     $digital = App\Category::where('name', 'Digital Fabrication')->first();
     $digital->skills()->create(['name' => '3D printing', 'description' => 'Repair and use of 3D printers', 'created_by_id' => 1, 'approved' => true, 'approved_by_id' => 1]);
     $digital->skills()->create(['name' => 'Laser Cutter', 'description' => 'Use and maintainence of laser cutters', 'created_by_id' => 1, 'approved' => true, 'approved_by_id' => 1]);
     $electronics = App\Category::where('name', 'Electronics')->first();
     $electronics->skills()->create(['name' => 'PCB Making', 'description' => 'Making printed circuit boards', 'created_by_id' => 1, 'approved' => true, 'approved_by_id' => 1]);
     $electronics->skills()->create(['name' => 'Embedded Programming', 'description' => 'programming embedded systems', 'created_by_id' => 1, 'approved' => true, 'approved_by_id' => 1]);
     $electronics->skills()->create(['name' => 'Soldering', 'description' => 'Soldering', 'created_by_id' => 1, 'approved' => true, 'approved_by_id' => 1]);
     $electronics->skills()->create(['name' => 'Robotics', 'description' => 'Making robots', 'created_by_id' => 1, 'approved' => true, 'approved_by_id' => 1]);
     $technology = App\Category::where('name', 'Technology')->first();
     $technology->skills()->create(['name' => 'Web Programming', 'description' => 'Programming for the web', 'created_by_id' => 1, 'approved' => true, 'approved_by_id' => 1]);
     $technology->skills()->create(['name' => 'PC Building', 'description' => 'Building PCs from components', 'created_by_id' => 1, 'approved' => true, 'approved_by_id' => 1]);
     $arts = App\Category::where('name', 'Arts')->first();
     $arts->skills()->create(['name' => 'Fabrics', 'description' => 'Fabrics', 'created_by_id' => 1, 'approved' => true, 'approved_by_id' => 1]);
     $arts->skills()->create(['name' => 'Photography', 'description' => 'Photography', 'created_by_id' => 1, 'approved' => true, 'approved_by_id' => 1]);
     $science = App\Category::where('name', 'Science')->first();
     $science->skills()->create(['name' => 'Nutrition', 'description' => 'Basic Nutrition', 'created_by_id' => 1, 'approved' => true, 'approved_by_id' => 1]);
     $science->skills()->create(['name' => 'Science?', 'description' => 'Is this even a valid category?', 'created_by_id' => 1, 'approved' => true, 'approved_by_id' => 1]);
 }
コード例 #28
0
 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     // bind article
     $router->model('article', 'App\\Article');
     $router->bind('admin.article', function ($id) {
         return \App\Article::findOrFail($id);
     });
     // bind category
     $router->model('category', 'App\\Category');
     $router->bind('admin.category', function ($id) {
         return \App\Category::findOrFail($id);
     });
     // bind language
     $router->model('language', 'App\\Language');
     $router->bind('admin.language', function ($id) {
         return \App\Language::findOrFail($id);
     });
     // bind language
     $router->model('page', 'App\\Page');
     $router->bind('admin.page', function ($id) {
         return \App\Page::findOrFail($id);
     });
     // bind setting
     $router->model('setting', 'App\\Setting');
     $router->bind('admin.setting', function ($id) {
         return \App\Setting::findOrFail($id);
     });
     // bind user
     $router->model('user', 'App\\User');
     $router->bind('admin.user', function ($id) {
         return \App\User::findOrFail($id);
     });
     parent::boot($router);
 }
コード例 #29
0
 public function __construct()
 {
     View::composer('layouts.master', function ($view) {
         $categories = Category::all();
         $view->with(compact('categories'));
     });
 }
コード例 #30
0
 public function edit($id)
 {
     $book = Books::find($id);
     $categories = Category::get_form_list();
     $authors = Authors::get_form_list();
     return view('admin.books.edit', compact('book', 'categories', 'authors'));
 }