/**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     $router->bind('article', function ($value) {
         return $this->getArticle()->where('slug', $value)->firstOrFail();
     });
     $router->bind('cong-ty', function ($value) {
         return \App\Company::where('slug', $value)->firstOrFail();
     });
     $router->bind('thiet-ke-thi-cong', function ($value) {
         return $this->designModel->getDesigns()->where('designs.slug', $value)->firstOrFail();
     });
     $router->bind('house', function ($value) {
         return $this->houseModel->getHouses()->where('houses.slug', $value)->firstOrFail();
     });
     $router->bind('company', function ($value) {
         return \App\Company::where('slug', $value)->firstOrFail();
     });
     $router->bind('project', function ($value) {
         return $this->projectModel->getProjects()->where('projects.slug', $value)->firstOrFail();
     });
     $router->model('owner', 'App\\House');
     $router->model('agency', 'App\\House');
     $router->model('message', 'App\\Message');
     parent::boot($router);
 }
 /**
  * Hiển thị 10 bài viết mới nhất ở sidebar (layout)
  *
  * @return void
  */
 public function composeSidebar()
 {
     view()->composer('_sidebar', function ($view) {
         // recommend
         $view->with('houseSaleRecommend', $this->houseModel->getHouses()->saleType(SaleTypeOptions::BAN)->first());
         $view->with('houseRentRecommend', $this->houseModel->getHouses()->saleType(SaleTypeOptions::CHO_THUE)->first());
         $view->with('houseProjectRecommend', $this->projectModel->getProjects()->first());
         $view->with('designRecommend', $this->designModel->getDesigns()->first());
     });
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index($filter = 'chinh-chu')
 {
     $userId = Auth::user()->id;
     switch ($filter) {
         case ConstHelper::URI_CHINH_CHU:
             $resources = $this->houseModel->getHousesManagement()->isOwner(OwnerTypeOptions::CHINH_CHU)->where('user_id', $userId)->paginate(6);
             break;
         case ConstHelper::URI_MOI_GIOI:
             $resources = $this->houseModel->getHousesManagement()->isOwner(OwnerTypeOptions::MOI_GIOI)->where('user_id', $userId)->paginate(6);
             break;
         case ConstHelper::URI_DU_AN:
             $resources = $this->projectModel->getProjectsManagement()->where('user_id', $userId)->paginate(6);
             break;
     }
     return view('manage.house.managements.index', compact('resources', 'filter'));
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int $id
  * @return Response
  */
 public function edit($id)
 {
     $bank = Bank::findOrFail($id);
     $accounttypes = AccountType::lists('code', 'id');
     $houses = House::lists('house_code', 'id');
     return view('bank.edit', compact('bank', 'accounttypes', 'houses'));
 }
Exemple #5
0
 public function searchMarkerForDetail(MapRequest $request)
 {
     if ($request->ajax()) {
         switch ($request->input('type')) {
             case 'house':
                 $markers = House::select('title', 'slug', 'category', 'images', 'lat', 'lng', 'user_id', 'price', 'money_unit', 'sale_type')->where('id', $request->input('id'));
                 break;
             case 'project':
                 $markers = Project::select('title', 'slug', 'category', 'images', 'lat', 'lng', 'user_id')->where('id', $request->input('id'));
                 break;
         }
         return response()->json($markers->get());
     }
 }
 public function approved($type, $id, $isApproved)
 {
     if (3 == $type) {
         $resource = Project::find($id);
     } else {
         $resource = House::find($id);
     }
     $resource->update(['is_approved' => $isApproved]);
     $message = 'Bài viết đã bị từ chối hiển thị';
     if (1 == $isApproved) {
         $message = 'Bài viết đã được cho phép hiển thị';
     }
     return redirect()->back()->with('flash_message', $message);
 }
 /**
  * Check Unique Url
  *
  * @param Request $request
  * @return string Jquery Validation plugin only expect returns value string true or false
  */
 public function checkUniqueUrl(Request $request, $type, $id = null)
 {
     if ($request->ajax()) {
         $title = $request->input('title');
         switch ($type) {
             case 'house':
                 $resource = House::where('title', $title);
                 break;
             case 'project':
                 $resource = Project::where('title', $title);
                 break;
             case 'design':
                 $resource = Design::where('title', $title);
                 break;
         }
         if (!is_null($id)) {
             $resource = $resource->where('id', '<>', $id);
         }
         return 0 == $resource->count() ? 'true' : 'false';
     }
 }
Exemple #8
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy(House $house)
 {
     foreach ($house->images as $image) {
         $this->delete($image);
     }
     $house->delete();
     return redirect('m/danh-sach-nha-dat/chinh-chu')->with('flash_message', Lang::get('system.destroy'));
 }
 /**
  * Save a new House
  *
  * @param HouseRequest $request
  * @return mixed
  */
 protected function createHouse(HouseRequest $request)
 {
     $house = House::create($request->all());
     $this->syncBanks($house, $request->input('bank_list'));
     return $house;
 }
 public function deleteHouse($id)
 {
     $house = House::findOrFail($id);
     $house->delete();
     flash()->error('Dom o ID <b>' . $id . '</b> został usunięty z bazy danych!');
     return redirect('/admin/house');
 }
Exemple #11
0
 public function search(Request $request)
 {
     $label = 'Kết quả tìm kiếm';
     $houses = $this->houseModel->getHouses()->where('title', 'like', "%{$request->get('search')}%")->simplePaginate(12);
     return view('front.houses.index', compact('houses', 'label'));
 }
Exemple #12
0
 private function _soldHouseList(Company $company)
 {
     return House::where('user_id', $company->user_id)->isOwner(OwnerTypeOptions::MOI_GIOI)->isSold(IsSoldOption::DA_BAN)->isApproved(1)->orderBy('id', 'desc');
 }
Exemple #13
0
 /**
  * Display the specified resource.
  *
  * @param House $house
  * @return \Illuminate\View\View
  */
 public function show(House $house)
 {
     $houseModel = new House();
     $housesRelation = $houseModel->getHouses()->saleType($house->sale_type)->limit(3)->get();
     $contactInfo = User::join('profiles', 'users.id', '=', 'profiles.user_id')->where('user_id', $house->user_id)->first();
     $preview = $houseModel->saleType($house->sale_type)->where('houses.id', '<', $house->id)->first();
     $next = $houseModel->saleType($house->sale_type)->where('houses.id', '>', $house->id)->first();
     return view('front.houses.show', compact('house', 'housesRelation', 'contactInfo', 'preview', 'next'));
 }
Exemple #14
0
 public function update($id, CreateHouseRequest $request)
 {
     $house = House::findOrFail($id);
     $house->update($request->all());
     return redirect('houses');
 }