Пример #1
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $propertyId = $request->route('id');
     $property = Property::withTrashed()->findOrFail($propertyId);
     if (!$property->canEdit($this->auth->user())) {
         if ($request->ajax()) {
             return response('Unauthorized.', 401);
         } else {
             return redirect()->back()->withErrors(['You are not authorized to do this action']);
         }
     }
     return $next($request);
 }
Пример #2
0
 public function generateListingCode()
 {
     if (empty($this->checkout_at) || !empty($this->listing_code)) {
         abort(403, 'Can\'t generate listing code action.');
     }
     $getLastProperty = Property::withTrashed()->hasCheckout()->whereNotNull('listing_code')->orderBy(DB::raw('CAST(SUBSTR(listing_code, 6) as UNSIGNED)'), 'DESC')->whereRaw("DATE_FORMAT(checkout_at, '%m-%Y') = ?", [$this->checkout_at->format('m-Y')])->first();
     if ($getLastProperty) {
         $lastListingNumber = intval(substr($getLastProperty->listing_code, 6));
     } else {
         $lastListingNumber = 0;
     }
     $listingNumber = $lastListingNumber + 1;
     $currentDateCode = $this->checkout_at->format('ym');
     $this->listing_code = 'GO' . $currentDateCode . str_pad($listingNumber, 2, '0', STR_PAD_LEFT);
 }
Пример #3
0
 public function photosRotate(Request $request, $id, $dir = 'right', $attachment_id)
 {
     $property = Property::withTrashed()->findOrFail($id);
     $this->attachmentBelongsToProperty($attachment_id, $property);
     $propertyAttachment = PropertyAttachment::findOrFail($attachment_id);
     $propertyAttachment->rotate($dir);
     if ($propertyAttachment->type == 'photo') {
         return redirect()->back()->with('messages', ['Photo has been rotated']);
     } elseif ($propertyAttachment->type == 'floorplan') {
         return redirect()->back()->with('messages', ['Floorplan has been rotated']);
     }
 }