コード例 #1
0
ファイル: PageController.php プロジェクト: yohanes1989/goprop
 public function home()
 {
     $packageCategories = PackageCategory::all();
     $serviceSection = Page::where('identifier', 'home-service')->first();
     $overviewSection = Page::where('identifier', 'home-overview')->first();
     $testimonials = Testimonial::orderBy(DB::raw('RAND()'))->take(5)->get();
     return view('frontend.page.home', ['packageCategories' => $packageCategories, 'serviceSection' => $serviceSection, 'overviewSection' => $overviewSection, 'testimonials' => $testimonials]);
 }
コード例 #2
0
 public function edit($id)
 {
     $property = Property::withTrashed()->findOrFail($id);
     $owner = $property->user ? $property->user->email : '';
     $defaultLatitude = empty($property->latitude) ? config('app.default_latitude') : $property->latitude;
     $defaultLongitude = empty($property->longitude) ? config('app.default_longitude') : $property->longitude;
     if (empty($property->latitude) || empty($property->longitude)) {
         $mapDefault = true;
     } else {
         $mapDefault = false;
     }
     $sellPackage = old('sell_package') ? Package::findOrFail(old('sell_package')) : null;
     $rentPackage = old('rent_package') ? Package::findOrFail(old('rent_package')) : null;
     $packages = $property->packages()->with('category')->get();
     foreach ($packages as $package) {
         if ($package->category->slug == 'rent' && !$rentPackage) {
             $rentPackage = $package;
         } elseif ($package->category->slug == 'sell' && !$sellPackage) {
             $sellPackage = $package;
         }
     }
     $viewData = ['owner' => $owner, 'property' => $property, 'defaultLatitude' => $defaultLatitude, 'defaultLongitude' => $defaultLongitude, 'mapDefault' => $mapDefault, 'sellPackage' => $sellPackage, 'rentPackage' => $rentPackage];
     foreach (PackageCategory::all() as $packageCategory) {
         ${$packageCategory->slug . 'PackageOptions'} = $packageCategory->packages->pluck('name', 'id')->all();
         $viewData[$packageCategory->slug . 'PackageOptions'] = ${$packageCategory->slug . 'PackageOptions'};
     }
     return view('admin.property.edit', $viewData);
 }
コード例 #3
0
 public function getPropertyPackages($id)
 {
     $property = Property::findOrFail($id);
     $packageCategories = [];
     if ($property->for_sell) {
         $packageCategories[] = PackageCategory::where('slug', 'sell')->firstOrFail();
     }
     if ($property->for_rent) {
         $packageCategories[] = PackageCategory::where('slug', 'rent')->firstOrFail();
     }
     $selectedAddons = [];
     $globalCartOrder = ProjectHelper::getGlobalCartOrder();
     $packageOrder = $property->getCartOrder();
     $order = NULL;
     if (empty($packageOrder)) {
         if (!is_null($globalCartOrder)) {
             $order = $globalCartOrder;
             $order->property()->associate($property);
             $order->save();
             $addons = [];
             foreach ($order->getAddons() as $addon) {
                 $addons[] = $addon->id;
             }
             $property->packages()->attach([$order->package->id => ['addons' => implode('|', $addons)]]);
             ProjectHelper::forgetGlobalCartOrder();
             //Redirect to review because package is already selected from homepage
             return redirect()->route('frontend.property.review', ['id' => $property->id]);
         }
     } else {
         $order = $packageOrder;
     }
     if ($order) {
         foreach ($property->packages as $package) {
             $selectedAddons[$package->id] = explode('|', $package->pivot->addons);
         }
     }
     return view('frontend.property.property_packages', ['model' => $property, 'packageCategories' => $packageCategories, 'selectedAddons' => $selectedAddons]);
 }