예제 #1
0
 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     parent::boot($router);
     $router->model('contact', 'App\\Contact');
     $router->model('business', 'App\\Business');
     $router->model('service', 'App\\Service');
     $router->model('appointment', 'App\\Appointment');
     $router->bind('business_slug', function ($business_slug) {
         return Business::where('slug', $business_slug)->get();
     });
 }
예제 #2
0
 public function area($slug)
 {
     $filter = "Average Credit Period";
     $nature = $slug;
     $ids = [];
     $users = Business::where('service_areas', 'LIKE', '%' . $slug . '%')->get();
     foreach ($users as $user) {
         $ids[$user->user_id] = $user->user_id;
     }
     $products = Product::whereIn('user_id', $ids)->paginate(12);
     return view('search.search', compact('products', 'nature', 'filter'));
     /*if($slug==='local_only'){
           $products = Product::paginate(12);
           return view('search.search', compact('products', 'nature','filter'));
       }
       if($slug==='country_wide'){
           $users = Business::where('service_areas', '=', $slug)->get();
           foreach ($users as $user) {
               $ids[$user->user_id] = $user->user_id;
           }
           $products = Product::whereIn('user_id', $ids)->paginate(12);
           return view('search.search', compact('products', 'nature','filter'));
       }
       if($slug==='abroad'){
           $users = Business::where('service_areas', '=', $slug)->get();
           foreach ($users as $user) {
               $ids[$user->user_id] = $user->user_id;
           }
           $products = Product::whereIn('user_id', $ids)->paginate(12);
           return view('search.search', compact('products', 'nature','filter'));
       }*/
 }
예제 #3
0
 public function rateSeller(Request $request)
 {
     $order_id = $request->get('order_id');
     $seller_rate = $request->get('seller_rate');
     $seller_comment = $request->get('seller_comment');
     $user = \Auth::user();
     if ($user) {
         $order = Order::where('id', $order_id)->where('user_id', $user->id)->first();
         if ($order && $order->rate == '') {
             $seller = Business::where('user_id', $order->seller_id)->first();
             $seller_old_rate_val = $seller->rate_val ?: 0;
             $seller_old_rate_count = $seller->rate_count ?: 0;
             //Checks if the order has already been rated by the user
             if ($seller_old_rate_count == 0) {
                 $seller->rate_val = $seller_rate;
                 $seller->rate_count = 1;
             } else {
                 //Checks if the new value should add to the rates or not
                 if ($order->rate) {
                     if ($seller_old_rate_val > $seller_rate) {
                         $seller->rate_val = $seller_old_rate_val - ($seller_old_rate_val - $seller_rate) / $seller_old_rate_count;
                     }
                     if ($seller_old_rate_val < $seller_rate) {
                         $seller->rate_val = $seller_old_rate_val + ($seller_rate - $seller_old_rate_val) / $seller_old_rate_count;
                     }
                 } else {
                     if ($seller_old_rate_val > $seller_rate) {
                         $seller->rate_val = $seller_old_rate_val - ($seller_old_rate_val - $seller_rate) / ($seller_old_rate_count + 1);
                     }
                     if ($seller_old_rate_val < $seller_rate) {
                         $seller->rate_val = $seller_old_rate_val + ($seller_rate - $seller_old_rate_val) / ($seller_old_rate_count + 1);
                     }
                     $seller->rate_count = $seller_old_rate_count + 1;
                 }
             }
             $seller_user = User::find($order->seller_id);
             $email = $seller_user->email;
             $mail_subject = trans('email.order_rated.subject');
             $data = ['order_id' => $order_id, 'subject' => $mail_subject, 'email_message' => $mail_subject, 'email' => $email];
             Mail::queue('emails.order_rated', $data, function ($message) use($user, $data) {
                 $message->to($data['email'])->subject($data['subject']);
             });
             $order->rate = $seller_rate;
             $order->rate_comment = $seller_comment;
             $order->save();
             $seller->save();
             $noticeType = trim($seller_comment) != '' ? '3' : '14';
             Notice::create(['user_id' => $seller->user_id, 'sender_id' => $user->id, 'action_type_id' => 14, 'source_id' => $order->id, 'status' => 'new']);
             return \Response::json(array('success' => true, 'message' => trans('store.order_rate_view.http_messages.success'), 'order_id' => $order_id, 'seller_rate' => $seller_rate), 200);
         } else {
             return \Response::json(array('success' => false, 'message' => trans('store.order_rate_view.http_messages.no_order'), 'order_id' => $order_id, 'seller_rate' => $seller_rate), 200);
         }
     } else {
         return \Response::json(array('success' => false, 'message' => trans('store.order_rate_view.http_messages.no_user'), 'order_id' => $order_id, 'seller_rate' => $seller_rate), 200);
     }
 }
 public function paymentListBusinessIssuerDetail(Business $busi)
 {
     $business = Business::where('id', '=', $busi->id)->first();
     //find total people of respective investors
     $no_of_investor = Investment::where('business_id', '=', $business->id)->where('agreement', '=', 'accept')->count();
     //find total of eligible offers from respective investors
     // $total_eligible_offers = DB::table('investments')
     // ->where('business_id','=',$business->id)
     // ->where('agreement','=','accept')
     // ->sum('amount_to_invest');
     //get the percentage funded and round up the value
     //$percentage_funded =  round($total_eligible_offers / $business->amount * 100);
     //find the minimum offer from investors
     //$minimum_offer = DB::table('investments')->where('business_id','=',$business->id)->where('agreement','=','accept')->min('amount_to_invest');
     //find the maximum offer from investors
     //$maximum_offer = DB::table('investments')->where('business_id','=',$business->id)->where('agreement','=','accept')->max('amount_to_invest');
     //find the lowest rate offer from investors
     //$lowest_rate_offer = DB::table('investments')->where('business_id','=',$business->id)->where('agreement','=','accept')->min('target_return_rate');
     //find the highest rate offer from investors
     //$highest_rate_offer = DB::table('investments')->where('business_id','=',$business->id)->where('agreement','=','accept')->max('target_return_rate');
     $investment = Investment::where('business_id', '=', $business->id)->where('agreement', '=', 'accept')->get();
     return view('business/payment_list_business_issuer_detail', compact('business', 'no_of_investor', 'investment'));
 }