/** * Display a listing of the resource. * * @return Response */ public function index() { $cats = Cat::all(); $bizs = Biz::all(); $states = State::all(); return view('admin.index', compact('biz', 'states', 'featured'))->withCats($cats); }
public function storeReviewForBiz($bizID, $comment, $rating) { $biz = Biz::find($bizID); $this->user_id = \Auth::user()->id; $this->comment = $comment; $this->rating = $rating; $biz->reviews()->save($this); // recalculate ratings for the specified product $biz->recalculateRating(); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $biz = Biz::findOrFail($id); $cat = $biz->cats->lists('id')->all(); // dd($cat); $sub = $biz->subcats->lists('id')->all(); $biz->cats()->detach($cat); $biz->subcats()->detach($sub); $biz->address()->delete(); $biz->delete(); return redirect('/admin/biz')->withSuccess("The business '{$biz->name}' has been deleted."); }
public function bizprofilephoto(Request $request, $id) { $picture = ['image' => $request->file('image')]; $rules = ['image' => 'required|image|mimes:jpeg,jpg,bmp,png,gif']; $validator = \Validator::make($picture, $rules); if ($validator->passes()) { $biz_id = $request->get('id'); $biz = \App\Biz::findorFail($biz_id); $profilePhoto = $biz->profilePhoto; $image = $request->file('image'); $name = time() . $image->getClientOriginalName(); $image->move('biz/profile', $name); if (!isset($profilePhoto->image)) { $pic = new \App\BizProfilePhoto(); $pic->image = 'biz/profile/' . $name; $biz->profilePhoto()->save($pic); return \Redirect::back()->with('message', 'Biz profile photo added!!!'); } if (isset($profilePhoto->image)) { $profilePhoto->image = 'biz/profile/' . $name; $biz->profilePhoto()->save($profilePhoto); return \Redirect::back()->with('message', ' profile photo updated!'); } } return \Redirect::back()->with('errors', $validator->messages()); }
/** * Update the specified resource in storage. * * @param Request $request * @param int $id * @return Response */ public function update(Request $request, $id) { $biz = Biz::findorFail($id); $cat = $biz->cats->lists('id')->all(); $sub = $biz->subcats->lists('id')->all(); // dd($sub); $catList = Cat::lists('name', 'id'); $subList = SubCat::lists('name', 'id'); // dd($subList); $stateList = State::lists('name', 'id'); $lgaList = Lga::lists('name', 'id'); //$area= Address::lists //dd($biz->address->state->name); // foreach ($biz->subcats as $sub) { // $currentSubs[] = $sub->id; // } // if(empty($currentSubs)){ // $currentSubs = ''; // } return view('admin/biz/edit', compact('biz', 'catList', 'subList', 'stateList', 'cat', 'currentSubs', 'lgaList', 'sub')); }
public function featured() { $biz_id = \Input::get('id'); $newValue = \Input::get('data'); $biz = \App\Biz::whereId($biz_id)->first(); $biz->featured = $newValue; if ($biz->save()) { return \Response::json(array('status' => 1)); } else { return \Response::json(array('status' => 'error', 'msg' => 'could not be updated')); } }