/** * Run the database seeds. * * @return void */ public function run() { Category::updateOrCreate(['slug' => 'garage'], ['strategy' => 'dateslot', 'name' => 'Garage', 'description' => 'Vehicle repair and services']); Category::updateOrCreate(['slug' => 'doctor'], ['strategy' => 'timeslot', 'name' => 'Doctor', 'description' => 'Clinical Doctor']); Category::updateOrCreate(['slug' => 'photography'], ['strategy' => 'timeslot', 'name' => 'Photographer', 'description' => 'Photographer']); Category::updateOrCreate(['slug' => 'spa'], ['strategy' => 'timeslot', 'name' => 'Spa', 'description' => 'Spa & Beauty']); Category::updateOrCreate(['slug' => 'martial-arts'], ['strategy' => 'timeslot', 'name' => 'Martial Arts', 'description' => 'Martial Arts']); Category::updateOrCreate(['slug' => 'yoga'], ['strategy' => 'timeslot', 'name' => 'Yoga', 'description' => 'Yoga']); Category::updateOrCreate(['slug' => 'consulting'], ['strategy' => 'timeslot', 'name' => 'Consulting', 'description' => 'Consulting']); Category::updateOrCreate(['slug' => 'hairdresser'], ['strategy' => 'timeslot', 'name' => 'Hairdresser', 'description' => 'Hairdresser']); Category::updateOrCreate(['slug' => 'beauty'], ['strategy' => 'timeslot', 'name' => 'Beauty & Healthcare', 'description' => 'Beauty & Healthcare']); }
/** @test */ public function it_has_many_businesses() { $category = new Category(); $this->assertInstanceOf(HasMany::class, $category->businesses()); }
/** * get business category list. * * TODO: SHOULD BE USED WITH VIEW COMPOSER * * @return array list of categories for combo */ protected function listCategories() { return Category::pluck('slug', 'id')->transform(function ($item) { return trans('app.business.category.' . $item); }); }
/** * Set category to a Business and save. * * @param Business $business * @param int $category * * @return Timegridio\Concierge\Models\Business */ public function setCategory(Business $business, $category) { $category = Category::find($category); $business->category()->associate($category); $business->save(); return $business; }