当前位置: 首页>>代码示例>>PHP>>正文


PHP Dog::find方法代码示例

本文整理汇总了PHP中Dog::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Dog::find方法的具体用法?PHP Dog::find怎么用?PHP Dog::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Dog的用法示例。


在下文中一共展示了Dog::find方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: providerRequestPing

 public function providerRequestPing()
 {
     $walker_id = Session::get('walker_id');
     $time = date("Y-m-d H:i:s");
     $query = "SELECT id,owner_id,TIMESTAMPDIFF(SECOND,request_start_time, '{$time}') as diff from request where is_cancelled = 0 and status = 0 and current_walker={$walker_id} and TIMESTAMPDIFF(SECOND,request_start_time, '{$time}') <= 600 limit 1";
     $requests = DB::select(DB::raw($query));
     $request_data = array();
     foreach ($requests as $request) {
         $request_data['success'] = "true";
         $request_data['request_id'] = $request->id;
         $request_data['time_left_to_respond'] = 600 - $request->diff;
         $owner = Owner::find($request->owner_id);
         $request_data['owner'] = array();
         $request_data['owner']['name'] = $owner->first_name . " " . $owner->last_name;
         $request_data['owner']['picture'] = $owner->picture;
         $request_data['owner']['phone'] = $owner->phone;
         $request_data['owner']['address'] = $owner->address;
         $request_data['owner']['latitude'] = $owner->latitude;
         $request_data['owner']['longitude'] = $owner->longitude;
         $request_data['owner']['rating'] = DB::table('review_dog')->where('owner_id', '=', $owner->id)->avg('rating') ?: 0;
         $request_data['owner']['num_rating'] = DB::table('review_dog')->where('owner_id', '=', $owner->id)->count();
         $request_data['dog'] = array();
         if ($dog = Dog::find($owner->dog_id)) {
             $request_data['dog']['name'] = $dog->name;
             $request_data['dog']['age'] = $dog->age;
             $request_data['dog']['breed'] = $dog->breed;
             $request_data['dog']['likes'] = $dog->likes;
             $request_data['dog']['picture'] = $dog->image_url;
         }
     }
     $response_code = 200;
     $response = Response::json($request_data, $response_code);
     return $response;
 }
开发者ID:netGALAXYStudios,项目名称:ourmovingapp,代码行数:34,代码来源:WebProviderController.php

示例2: userTripCancel

 public function userTripCancel()
 {
     $request_id = Request::segment(4);
     $owner_id = Session::get('user_id');
     $request = Requests::find($request_id);
     if ($request->owner_id == $owner_id) {
         Requests::where('id', $request_id)->update(array('is_cancelled' => 1));
         RequestMeta::where('request_id', $request_id)->update(array('is_cancelled' => 1));
         if ($request->confirmed_walker) {
             $walker = Walker::find($request->confirmed_walker);
             $walker->is_available = 1;
             $walker->save();
         }
         if ($request->current_walker) {
             $msg_array = array();
             $msg_array['request_id'] = $request_id;
             $msg_array['unique_id'] = 2;
             $owner = Owner::find($owner_id);
             $request_data = array();
             $request_data['owner'] = array();
             $request_data['owner']['name'] = $owner->first_name . " " . $owner->last_name;
             $request_data['owner']['picture'] = $owner->picture;
             $request_data['owner']['phone'] = $owner->phone;
             $request_data['owner']['address'] = $owner->address;
             $request_data['owner']['latitude'] = $owner->latitude;
             $request_data['owner']['longitude'] = $owner->longitude;
             $request_data['owner']['rating'] = DB::table('review_dog')->where('owner_id', '=', $owner->id)->avg('rating') ?: 0;
             $request_data['owner']['num_rating'] = DB::table('review_dog')->where('owner_id', '=', $owner->id)->count();
             $request_data['dog'] = array();
             if ($dog = Dog::find($owner->dog_id)) {
                 $request_data['dog']['name'] = $dog->name;
                 $request_data['dog']['age'] = $dog->age;
                 $request_data['dog']['breed'] = $dog->breed;
                 $request_data['dog']['likes'] = $dog->likes;
                 $request_data['dog']['picture'] = $dog->image_url;
             }
             $msg_array['request_data'] = $request_data;
             $title = "Request Cancelled";
             $message = $msg_array;
             send_notifications($request->current_walker, "walker", $title, $message);
         }
     }
     // Redirect
     $message = "Your Request is Cancelled.";
     $type = "success";
     return Redirect::to('/user/trips')->with('message', $message)->with('type', $type);
 }
开发者ID:netGALAXYStudios,项目名称:ourmovingapp,代码行数:47,代码来源:WebUserController.php

示例3: cancel_request

 public function cancel_request()
 {
     $request_id = Input::get('request_id');
     $token = Input::get('token');
     $owner_id = Input::get('id');
     $validator = Validator::make(array('request_id' => $request_id, 'token' => $token, 'owner_id' => $owner_id), array('request_id' => 'required|integer', 'token' => 'required', 'owner_id' => 'required|integer'));
     if ($validator->fails()) {
         $error_messages = $validator->messages()->all();
         $response_array = array('success' => false, 'error' => 'Invalid Input', 'error_code' => 401, 'error_messages' => $error_messages);
         $response_code = 200;
     } else {
         $is_admin = $this->isAdmin($token);
         if ($owner_data = $this->getOwnerData($owner_id, $token, $is_admin)) {
             // check for token validity
             if (is_token_active($owner_data->token_expiry) || $is_admin) {
                 // Do necessary operations
                 if ($request = Requests::find($request_id)) {
                     if ($request->owner_id == $owner_data->id) {
                         Requests::where('id', $request_id)->update(array('is_cancelled' => 1));
                         RequestMeta::where('request_id', $request_id)->update(array('is_cancelled' => 1));
                         if ($request->confirmed_walker) {
                             $walker = Walker::find($request->confirmed_walker);
                             $walker->is_available = 1;
                             $walker->save();
                         }
                         if ($request->current_walker) {
                             $msg_array = array();
                             $msg_array['request_id'] = $request_id;
                             $msg_array['unique_id'] = 2;
                             $owner = Owner::find($owner_id);
                             $request_data = array();
                             $request_data['owner'] = array();
                             $request_data['owner']['name'] = $owner->first_name . " " . $owner->last_name;
                             $request_data['owner']['picture'] = $owner->picture;
                             $request_data['owner']['phone'] = $owner->phone;
                             $request_data['owner']['address'] = $owner->address;
                             $request_data['owner']['latitude'] = $owner->latitude;
                             $request_data['owner']['longitude'] = $owner->longitude;
                             $request_data['owner']['rating'] = DB::table('review_dog')->where('owner_id', '=', $owner->id)->avg('rating') ?: 0;
                             $request_data['owner']['num_rating'] = DB::table('review_dog')->where('owner_id', '=', $owner->id)->count();
                             $request_data['dog'] = array();
                             if ($dog = Dog::find($owner->dog_id)) {
                                 $request_data['dog']['name'] = $dog->name;
                                 $request_data['dog']['age'] = $dog->age;
                                 $request_data['dog']['breed'] = $dog->breed;
                                 $request_data['dog']['likes'] = $dog->likes;
                                 $request_data['dog']['picture'] = $dog->image_url;
                             }
                             $msg_array['request_data'] = $request_data;
                             $title = "Request Cancelled";
                             $message = $msg_array;
                             send_notifications($request->current_walker, "walker", $title, $message);
                         }
                         $response_array = array('success' => true);
                         $response_code = 200;
                     } else {
                         $response_array = array('success' => false, 'error' => 'Request ID doesnot matches with Owner ID', 'error_code' => 407);
                         $response_code = 200;
                     }
                 } else {
                     $response_array = array('success' => false, 'error' => 'Request ID Not Found', 'error_code' => 408);
                     $response_code = 200;
                 }
             } else {
                 $response_array = array('success' => false, 'error' => 'Token Expired', 'error_code' => 405);
                 $response_code = 200;
             }
         } else {
             if ($is_admin) {
                 $response_array = array('success' => false, 'error' => 'Owner ID not Found', 'error_code' => 410);
             } else {
                 $response_array = array('success' => false, 'error' => 'Not a valid token', 'error_code' => 406);
             }
             $response_code = 200;
         }
     }
     $response = Response::json($response_array, $response_code);
     return $response;
 }
开发者ID:netGALAXYStudios,项目名称:ourmovingapp,代码行数:79,代码来源:DogController.php

示例4: alternative_walkers_xml

 public function alternative_walkers_xml()
 {
     $id = Request::segment(4);
     $walk = Walk::find($id);
     $schedule = Schedules::find($walk->schedule_id);
     $dog = Dog::find($walk->dog_id);
     $owner = Owner::find($dog->owner_id);
     $current_walker = Walker::find($walk->walker_id);
     $latitude = $owner->latitude;
     $longitude = $owner->longitude;
     $distance = 5;
     // Get Latitude
     $schedule_meta = ScheduleMeta::where('schedule_id', '=', $schedule->id)->orderBy('started_on', 'DESC')->get();
     $flag = 0;
     $date = "0000-00-00";
     $days = array();
     foreach ($schedule_meta as $meta) {
         if ($flag == 0) {
             $date = $meta->started_on;
             $flag++;
         }
         array_push($days, $meta->day);
     }
     $start_time = date('H:i:s', strtotime($schedule->start_time) - 60 * 60);
     $end_time = date('H:i:s', strtotime($schedule->end_time) + 60 * 60);
     $days_str = implode(',', $days);
     $settings = Settings::where('key', 'default_distance_unit')->first();
     $unit = $settings->value;
     if ($unit == 0) {
         $multiply = 1.609344;
     } elseif ($unit == 1) {
         $multiply = 1;
     }
     $query = "SELECT walker.id,walker.bio,walker.first_name,walker.last_name,walker.phone,walker.latitude,walker.longitude from walker where id NOT IN ( SELECT distinct schedules.walker_id FROM `schedule_meta` left join schedules on schedule_meta.schedule_id = schedules.id where schedules.is_confirmed\t != 0 and schedule_meta.day IN ({$days_str}) and schedule_meta.ends_on >= '{$date}' and schedule_meta.started_on <= '{$date}' and ((schedules.start_time > '{$start_time}' and schedules.start_time < '{$end_time}') OR ( schedules.end_time > '{$start_time}' and schedules.end_time < '{$end_time}' )) ) and " . "ROUND((" . $multiply . " * 3956 * acos( cos( radians('{$latitude}') ) * " . "cos( radians(latitude) ) * " . "cos( radians(longitude) - radians('{$longitude}') ) + " . "sin( radians('{$latitude}') ) * " . "sin( radians(latitude) ) ) ) ,8) <= {$distance} ";
     $walkers = DB::select(DB::raw($query));
     $response = "";
     $response .= '<markers>';
     foreach ($walkers as $walker) {
         $response .= '<marker ';
         $response .= 'name="' . $walker->first_name . " " . $walker->last_name . '" ';
         $response .= 'client_name="' . $walker->first_name . " " . $walker->last_name . '" ';
         $response .= 'contact="' . $walker->phone . '" ';
         $response .= 'amount="' . 0 . '" ';
         $response .= 'lat="' . $walker->latitude . '" ';
         $response .= 'lng="' . $walker->longitude . '" ';
         $response .= 'id="' . $walker->id . '" ';
         $response .= 'type="client" ';
         $response .= '/>';
     }
     // Add Current walker
     if ($current_walker) {
         $response .= '<marker ';
         $response .= 'name="' . $current_walker->first_name . " " . $current_walker->last_name . '" ';
         $response .= 'client_name="' . $current_walker->first_name . " " . $current_walker->last_name . '" ';
         $response .= 'contact="' . $current_walker->phone . '" ';
         $response .= 'amount="' . 0 . '" ';
         $response .= 'lat="' . $current_walker->latitude . '" ';
         $response .= 'lng="' . $current_walker->longitude . '" ';
         $response .= 'id="' . $current_walker->id . '" ';
         $response .= 'type="driver" ';
         $response .= '/>';
     }
     // Add Owner
     $response .= '<marker ';
     $response .= 'name="' . $owner->first_name . " " . $owner->last_name . '" ';
     $response .= 'client_name="' . $owner->first_name . " " . $owner->last_name . '" ';
     $response .= 'contact="' . $owner->phone . '" ';
     $response .= 'amount="' . 0 . '" ';
     $response .= 'lat="' . $owner->latitude . '" ';
     $response .= 'lng="' . $owner->longitude . '" ';
     $response .= 'id="' . $owner->id . '" ';
     $response .= 'type="client_pay_done" ';
     $response .= '/>';
     // Add Busy Walkers
     $walkers = DB::table('request')->where('walk.is_started', 1)->where('walk.is_completed', 0)->join('walker', 'walk.walker_id', '=', 'walker.id')->select('walker.id', 'walker.phone', 'walker.first_name', 'walker.last_name', 'walker.latitude', 'walker.longitude')->distinct()->get();
     foreach ($walkers as $walker) {
         $response .= '<marker ';
         $response .= 'name="' . $walker->first_name . " " . $walker->last_name . '" ';
         $response .= 'client_name="' . $walker->first_name . " " . $walker->last_name . '" ';
         $response .= 'contact="' . $walker->phone . '" ';
         $response .= 'amount="' . 0 . '" ';
         $response .= 'lat="' . $walker->latitude . '" ';
         $response .= 'lng="' . $walker->longitude . '" ';
         $response .= 'id="' . $owner->id . '" ';
         $response .= 'type="client_no_pay" ';
         $response .= '/>';
     }
     $response .= '</markers>';
     $content = View::make('walkers_xml')->with('response', $response);
     return Response::make($content, '200')->header('Content-Type', 'text/xml');
 }
开发者ID:felipemarques8,项目名称:goentregas,代码行数:91,代码来源:AdminController.php

示例5: login

 public function login()
 {
     $login_by = Input::get('login_by');
     $device_token = Input::get('device_token');
     $device_type = Input::get('device_type');
     if (Input::has('email') && Input::has('password')) {
         $email = Input::get('email');
         $password = Input::get('password');
         $validator = Validator::make(array('password' => $password, 'email' => $email, 'device_token' => $device_token, 'device_type' => $device_type, 'login_by' => $login_by), array('password' => 'required', 'email' => 'required|email', 'device_token' => 'required', 'device_type' => 'required|in:android,ios', 'login_by' => 'required|in:manual,facebook,google'));
         if ($validator->fails()) {
             $error_messages = $validator->messages()->all();
             $response_array = array('success' => false, 'error' => 'Invalid Input', 'error_code' => 401, 'error_messages' => $error_messages);
             $response_code = 200;
             Log::error('Validation error during manual login for owner = ' . print_r($error_messages, true));
         } else {
             if ($owner = Owner::where('email', '=', $email)->first()) {
                 if (Hash::check($password, $owner->password)) {
                     if ($login_by !== "manual") {
                         $response_array = array('success' => false, 'error' => 'Login by mismatch', 'error_code' => 417);
                         $response_code = 200;
                     } else {
                         if ($owner->device_type != $device_type) {
                             $owner->device_type = $device_type;
                         }
                         if ($owner->device_token != $device_token) {
                             $owner->device_token = $device_token;
                         }
                         $owner->token = generate_token();
                         $owner->token_expiry = generate_expiry();
                         $owner->save();
                         /* SEND REFERRAL & PROMO INFO */
                         $settings = Settings::where('key', 'referral_code_activation')->first();
                         $referral_code_activation = $settings->value;
                         if ($referral_code_activation) {
                             $referral_code_activation_txt = "referral on";
                         } else {
                             $referral_code_activation_txt = "referral off";
                         }
                         $settings = Settings::where('key', 'promotional_code_activation')->first();
                         $promotional_code_activation = $settings->value;
                         if ($promotional_code_activation) {
                             $promotional_code_activation_txt = "promo on";
                         } else {
                             $promotional_code_activation_txt = "promo off";
                         }
                         /* SEND REFERRAL & PROMO INFO */
                         $code_data = Ledger::where('owner_id', '=', $owner->id)->first();
                         $response_array = array('success' => true, 'id' => $owner->id, 'first_name' => $owner->first_name, 'last_name' => $owner->last_name, 'phone' => $owner->phone, 'email' => $owner->email, 'picture' => $owner->picture, 'bio' => $owner->bio, 'address' => $owner->address, 'state' => $owner->state, 'country' => $owner->country, 'zipcode' => $owner->zipcode, 'login_by' => $owner->login_by, 'social_unique_id' => $owner->social_unique_id, 'device_token' => $owner->device_token, 'device_type' => $owner->device_type, 'timezone' => $owner->timezone, 'token' => $owner->token, 'referral_code' => $code_data->referral_code, 'is_referee' => $owner->is_referee, 'promo_count' => $owner->promo_count, 'is_referral_active' => $referral_code_activation, 'is_referral_active_txt' => $referral_code_activation_txt, 'is_promo_active' => $promotional_code_activation, 'is_promo_active_txt' => $promotional_code_activation_txt);
                         $dog = Dog::find($owner->dog_id);
                         if ($dog !== NULL) {
                             $response_array = array_merge($response_array, array('dog_id' => $dog->id, 'age' => $dog->age, 'name' => $dog->name, 'breed' => $dog->breed, 'likes' => $dog->likes, 'image_url' => $dog->image_url));
                         }
                         $response_code = 200;
                     }
                 } else {
                     $response_array = array('success' => false, 'error' => 'Invalid Username and Password', 'error_code' => 403);
                     $response_code = 200;
                 }
             } else {
                 $response_array = array('success' => false, 'error' => 'Not a Registered User', 'error_code' => 404);
                 $response_code = 200;
             }
         }
     } elseif (Input::has('social_unique_id')) {
         $social_unique_id = Input::get('social_unique_id');
         $socialValidator = Validator::make(array('social_unique_id' => $social_unique_id, 'device_token' => $device_token, 'device_type' => $device_type, 'login_by' => $login_by), array('social_unique_id' => 'required|exists:owner,social_unique_id', 'device_token' => 'required', 'device_type' => 'required|in:android,ios', 'login_by' => 'required|in:manual,facebook,google'));
         if ($socialValidator->fails()) {
             $error_messages = $socialValidator->messages();
             Log::error('Validation error during social login for owner = ' . print_r($error_messages, true));
             $error_messages = $socialValidator->messages()->all();
             $response_array = array('success' => false, 'error' => 'Invalid Input', 'error_code' => 401, 'error_messages' => $error_messages);
             $response_code = 200;
         } else {
             if ($owner = Owner::where('social_unique_id', '=', $social_unique_id)->first()) {
                 if (!in_array($login_by, array('facebook', 'google'))) {
                     $response_array = array('success' => false, 'error' => 'Login by mismatch', 'error_code' => 417);
                     $response_code = 200;
                 } else {
                     if ($owner->device_type != $device_type) {
                         $owner->device_type = $device_type;
                     }
                     if ($owner->device_token != $device_token) {
                         $owner->device_token = $device_token;
                     }
                     $owner->token_expiry = generate_expiry();
                     $owner->save();
                     $response_array = array('success' => true, 'id' => $owner->id, 'first_name' => $owner->first_name, 'last_name' => $owner->last_name, 'phone' => $owner->phone, 'email' => $owner->email, 'picture' => $owner->picture, 'bio' => $owner->bio, 'address' => $owner->address, 'state' => $owner->state, 'country' => $owner->country, 'zipcode' => $owner->zipcode, 'login_by' => $owner->login_by, 'social_unique_id' => $owner->social_unique_id, 'device_token' => $owner->device_token, 'device_type' => $owner->device_type, 'timezone' => $owner->timezone, 'token' => $owner->token, 'is_referee' => $owner->is_referee);
                     $dog = Dog::find($owner->dog_id);
                     if ($dog !== NULL) {
                         $response_array = array_merge($response_array, array('dog_id' => $dog->id, 'age' => $dog->age, 'name' => $dog->name, 'breed' => $dog->breed, 'likes' => $dog->likes, 'image_url' => $dog->image_url));
                     }
                     $response_code = 200;
                 }
             } else {
                 $response_array = array('success' => false, 'error' => 'Not a valid social registration User', 'error_code' => 404);
                 $response_code = 200;
             }
         }
     } else {
         $response_array = array('success' => false, 'error' => 'Invalid input', 'error_code' => 404);
//.........这里部分代码省略.........
开发者ID:felipemarques8,项目名称:goentregas,代码行数:101,代码来源:OwnerController_old.php

示例6: get_request

 public function get_request()
 {
     $request_id = Input::get('request_id');
     $token = Input::get('token');
     $walker_id = Input::get('id');
     $validator = Validator::make(array('request_id' => $request_id, 'token' => $token, 'walker_id' => $walker_id), array('request_id' => 'required|integer', 'token' => 'required', 'walker_id' => 'required|integer'));
     if ($validator->fails()) {
         $error_messages = $validator->messages()->all();
         $response_array = array('success' => false, 'error' => 'Invalid Input', 'error_code' => 401, 'error_messages' => $error_messages);
         $response_code = 200;
     } else {
         $is_admin = $this->isAdmin($token);
         if ($walker_data = $this->getWalkerData($walker_id, $token, $is_admin)) {
             // check for token validity
             if (is_token_active($walker_data->token_expiry) || $is_admin) {
                 // Do necessary operations
                 if ($request = Requests::find($request_id)) {
                     if ($request->confirmed_walker == $walker_id) {
                         $owner = Owner::find($request->owner_id);
                         $request_data = array();
                         $request_data['is_walker_started'] = $request->is_walker_started;
                         $request_data['is_walker_arrived'] = $request->is_walker_arrived;
                         $request_data['is_started'] = $request->is_started;
                         $request_data['is_completed'] = $request->is_completed;
                         $request_data['is_dog_rated'] = $request->is_dog_rated;
                         $request_data['accepted_time'] = $request->request_start_time;
                         if ($request->is_started == 1) {
                             $request_data['start_time'] = DB::table('walk_location')->where('request_id', $request_id)->min('created_at');
                             $settings = Settings::where('key', 'default_distance_unit')->first();
                             $unit = $settings->value;
                             $distance = DB::table('walk_location')->where('request_id', $request_id)->max('distance');
                             $request_data['distance'] = convert($distance, $unit);
                         }
                         if ($request->is_completed == 1) {
                             $request_data['distance'] = $distance;
                             $request_data['end_time'] = DB::table('walk_location')->where('request_id', $request_id)->max('created_at');
                         }
                         $request_data['owner'] = array();
                         $request_data['owner']['name'] = $owner->first_name . " " . $owner->last_name;
                         $request_data['owner']['picture'] = $owner->picture;
                         $request_data['owner']['phone'] = $owner->phone;
                         $request_data['owner']['address'] = $owner->address;
                         $request_data['owner']['latitude'] = $owner->latitude;
                         $request_data['owner']['longitude'] = $owner->longitude;
                         $request_data['owner']['rating'] = DB::table('review_dog')->where('owner_id', '=', $owner->id)->avg('rating') ?: 0;
                         $request_data['owner']['num_rating'] = DB::table('review_dog')->where('owner_id', '=', $owner->id)->count();
                         $request_data['dog'] = array();
                         if ($dog = Dog::find($owner->dog_id)) {
                             $request_data['dog']['name'] = $dog->name;
                             $request_data['dog']['age'] = $dog->age;
                             $request_data['dog']['breed'] = $dog->breed;
                             $request_data['dog']['likes'] = $dog->likes;
                             $request_data['dog']['picture'] = $dog->image_url;
                         }
                         $request_data['bill'] = array();
                         $bill = array();
                         $settings = Settings::where('key', 'default_distance_unit')->first();
                         $unit = $settings->value;
                         if ($request->is_completed == 1) {
                             $bill['distance'] = convert($request->distance, $unit);
                             $bill['time'] = $request->time;
                             $bill['base_price'] = $request->base_price;
                             $bill['distance_cost'] = $request->distance_cost;
                             $bill['time_cost'] = $request->time_cost;
                             $bill['total'] = $request->total;
                             $bill['is_paid'] = $request->is_paid;
                         }
                         $request_data['bill'] = $bill;
                         $response_array = array('success' => true, 'request' => $request_data);
                         $response_code = 200;
                     } else {
                         $response_array = array('success' => false, 'error' => 'Walk ID doesnot matches with Walker ID', 'error_code' => 407);
                         $response_code = 200;
                     }
                 } else {
                     $response_array = array('success' => false, 'error' => 'Walk ID Not Found', 'error_code' => 408);
                     $response_code = 200;
                 }
             } else {
                 $response_array = array('success' => false, 'error' => 'Token Expired', 'error_code' => 405);
                 $response_code = 200;
             }
         } else {
             if ($is_admin) {
                 $response_array = array('success' => false, 'error' => 'Walker ID not Found', 'error_code' => 410);
             } else {
                 $response_array = array('success' => false, 'error' => 'Not a valid token', 'error_code' => 406);
             }
             $response_code = 200;
         }
     }
     $response = Response::json($response_array, $response_code);
     return $response;
 }
开发者ID:netGALAXYStudios,项目名称:ourmovingapp,代码行数:94,代码来源:WalkerController.php

示例7: request_walk_completed_old123

 public function request_walk_completed_old123()
 {
     if (Request::isMethod('post')) {
         $request_id = Input::get('request_id');
         $token = Input::get('token');
         $walker_id = Input::get('id');
         $latitude = Input::get('latitude');
         $longitude = Input::get('longitude');
         $distance = Input::get('distance');
         $time = Input::get('time');
         if (Input::has('bearing')) {
             $angle = Input::get('bearing');
         }
         Log::info('distance input = ' . print_r($distance, true));
         Log::info('time input = ' . print_r($time, true));
         $validator = Validator::make(array('request_id' => $request_id, 'token' => $token, 'walker_id' => $walker_id, 'latitude' => $latitude, 'longitude' => $longitude, 'distance' => $distance), array('request_id' => 'required|integer', 'token' => 'required', 'walker_id' => 'required|integer', 'latitude' => 'required', 'longitude' => 'required', 'distance' => 'required'));
         if ($validator->fails()) {
             $error_messages = $validator->messages()->all();
             $response_array = array('success' => false, 'error' => 'Invalid Input', 'error_code' => 401, 'error_messages' => $error_messages);
             $response_code = 200;
         } else {
             $cash_card_user = "";
             $payment_type = "";
             $walker_payment_remaining = 0;
             $is_admin = $this->isAdmin($token);
             if ($walker_data = $this->getWalkerData($walker_id, $token, $is_admin)) {
                 // check for token validity
                 if (is_token_active($walker_data->token_expiry) || $is_admin) {
                     $providertype = ProviderType::where('id', $walker_data->type)->first();
                     // Do necessary operations
                     if ($request = Requests::find($request_id)) {
                         $time = $request->time;
                         if ($request->confirmed_walker == $walker_id) {
                             if ($request->is_started == 1) {
                                 $settings = Settings::where('key', 'default_charging_method_for_users')->first();
                                 $pricing_type = $settings->value;
                                 $settings = Settings::where('key', 'default_distance_unit')->first();
                                 $unit = $settings->value;
                                 Log::info('distance = ' . print_r($distance, true));
                                 $reqserv = RequestServices::where('request_id', $request_id)->get();
                                 $actual_total = 0;
                                 $price_per_unit_distance = 0;
                                 $price_per_unit_time = 0;
                                 $base_price = 0;
                                 foreach ($reqserv as $rse) {
                                     Log::info('type = ' . print_r($rse->type, true));
                                     $protype = ProviderType::where('id', $rse->type)->first();
                                     $pt = ProviderServices::where('provider_id', $walker_id)->where('type', $rse->type)->first();
                                     if ($pt->base_price == 0) {
                                         /* $setbase_price = Settings::where('key', 'base_price')->first();
                                            $base_price = $setbase_price->value; */
                                         $base_price = $providertype->base_price;
                                         $rse->base_price = $base_price;
                                     } else {
                                         $base_price = $pt->base_price;
                                         $rse->base_price = $base_price;
                                     }
                                     $is_multiple_service = Settings::where('key', 'allow_multiple_service')->first();
                                     if ($is_multiple_service->value == 0) {
                                         if ($pt->price_per_unit_distance == 0) {
                                             /* $setdistance_price = Settings::where('key', 'price_per_unit_distance')->first();
                                                $price_per_unit_distance = $setdistance_price->value * $distance;
                                                $rse->distance_cost = $price_per_unit_distance; */
                                             if ($distance <= $providertype->base_distance) {
                                                 $price_per_unit_distance = 0;
                                             } else {
                                                 $price_per_unit_distance = $providertype->price_per_unit_distance * ($distance - $providertype->base_distance);
                                             }
                                             $rse->distance_cost = $price_per_unit_distance;
                                         } else {
                                             if ($distance <= $providertype->base_distance) {
                                                 $price_per_unit_distance = 0;
                                             } else {
                                                 $price_per_unit_distance = $pt->price_per_unit_distance * ($distance - $providertype->base_distance);
                                             }
                                             $rse->distance_cost = $price_per_unit_distance;
                                         }
                                         if ($pt->price_per_unit_time == 0) {
                                             /* $settime_price = Settings::where('key', 'price_per_unit_time')->first();
                                                $price_per_unit_time = $settime_price->value * $time; */
                                             $price_per_unit_time = $providertype->price_per_unit_time * $time;
                                             $rse->time_cost = $price_per_unit_time;
                                         } else {
                                             $price_per_unit_time = $pt->price_per_unit_time * $time;
                                             $rse->time_cost = $price_per_unit_time;
                                         }
                                     }
                                     Log::info('total price = ' . print_r($base_price + $price_per_unit_distance + $price_per_unit_time, true));
                                     $rse->total = $base_price + $price_per_unit_distance + $price_per_unit_time;
                                     $rse->save();
                                     $actual_total = $actual_total + $base_price + $price_per_unit_distance + $price_per_unit_time;
                                     Log::info('total_price = ' . print_r($actual_total, true));
                                 }
                                 pay_fail:
                                 $rs = RequestServices::where('request_id', $request_id)->get();
                                 $total = 0;
                                 foreach ($rs as $key) {
                                     Log::info('total = ' . print_r($key->total, true));
                                     $total = $total + $key->total;
                                 }
//.........这里部分代码省略.........
开发者ID:felipemarques8,项目名称:goentregas,代码行数:101,代码来源:WalkerController.php

示例8: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $dog = Dog::find($id);
     if (!$dog) {
         Session::flash('errorMessage', "Something went wrong, no dog with id: {$id} found!");
         App::abort(404);
     }
     Dog::find($id)->delete();
     return Redirect::action('DogsController@index');
 }
开发者ID:remington9,项目名称:quanwillbulldogs,代码行数:16,代码来源:DogsController.php

示例9: user_set_destination

 public function user_set_destination()
 {
     $request_id = Input::get('request_id');
     $token = Input::get('token');
     $owner_id = Input::get('id');
     $dest_lat = Input::get('dest_lat');
     $dest_long = Input::get('dest_long');
     $validator = Validator::make(array('request_id' => $request_id, 'token' => $token, 'owner_id' => $owner_id, 'dest_lat' => $dest_lat, 'dest_long' => $dest_long), array('request_id' => 'required|integer', 'token' => 'required', 'owner_id' => 'required|integer', 'dest_lat' => 'required', 'dest_long' => 'required'));
     if ($validator->fails()) {
         $error_messages = $validator->messages()->all();
         $response_array = array('success' => false, 'error' => 'Invalid Input', 'error_code' => 401, 'error_messages' => $error_messages);
         $response_code = 200;
     } else {
         $is_admin = $this->isAdmin($token);
         if ($owner_data = $this->getOwnerData($owner_id, $token, $is_admin)) {
             // check for token validity
             if (is_token_active($owner_data->token_expiry) || $is_admin) {
                 // Do necessary operations
                 if ($request = Requests::find($request_id)) {
                     if ($request->owner_id == $owner_data->id) {
                         Requests::where('id', $request_id)->update(array('D_latitude' => $dest_lat, 'D_longitude' => $dest_long));
                         if ($request->current_walker) {
                             $msg_array = array();
                             $msg_array['request_id'] = $request_id;
                             $msg_array['unique_id'] = 4;
                             $last_destination = Requests::find($request_id);
                             $owner = Owner::find($owner_id);
                             $request_data = array();
                             $request_data['owner'] = array();
                             $request_data['owner']['name'] = $owner->first_name . " " . $owner->last_name;
                             $request_data['owner']['picture'] = $owner->picture;
                             $request_data['owner']['phone'] = $owner->phone;
                             $request_data['owner']['address'] = $owner->address;
                             $request_data['owner']['latitude'] = $owner->latitude;
                             $request_data['owner']['longitude'] = $owner->longitude;
                             $request_data['owner']['dest_latitude'] = $last_destination->D_latitude;
                             $request_data['owner']['dest_longitude'] = $last_destination->D_longitude;
                             $request_data['owner']['rating'] = $owner->rate;
                             $request_data['owner']['num_rating'] = $owner->rate_count;
                             $request_data['dog'] = array();
                             if ($dog = Dog::find($owner->dog_id)) {
                                 $request_data['dog']['name'] = $dog->name;
                                 $request_data['dog']['age'] = $dog->age;
                                 $request_data['dog']['breed'] = $dog->breed;
                                 $request_data['dog']['likes'] = $dog->likes;
                                 $request_data['dog']['picture'] = $dog->image_url;
                             }
                             $msg_array['request_data'] = $request_data;
                             $title = "Set Destination";
                             $message = $msg_array;
                             if ($request->confirmed_walker == $request->current_walker) {
                                 send_notifications($request->confirmed_walker, "walker", $title, $message);
                             }
                         }
                         $response_array = array('success' => true, 'error' => "Destination Set Successfully");
                         $response_code = 200;
                     } else {
                         $response_array = array('success' => false, 'error' => 'Request ID doesnot matches with Owner ID', 'error_code' => 407);
                         $response_code = 200;
                     }
                 } else {
                     $response_array = array('success' => false, 'error' => 'Request ID Not Found', 'error_code' => 408);
                     $response_code = 200;
                 }
             } else {
                 $response_array = array('success' => false, 'error' => 'Token Expired', 'error_code' => 405);
                 $response_code = 200;
             }
         } else {
             if ($is_admin) {
                 $response_array = array('success' => false, 'error' => 'Owner ID not Found', 'error_code' => 410);
             } else {
                 $response_array = array('success' => false, 'error' => 'Not a valid token', 'error_code' => 406);
             }
             $response_code = 200;
         }
     }
     $response = Response::json($response_array, $response_code);
     return $response;
 }
开发者ID:felipemarques8,项目名称:goentregas,代码行数:80,代码来源:DogController.php

示例10: saveUserRequestTrip

 public function saveUserRequestTrip()
 {
     Session::forget('skipReview');
     $latitude = Input::get('latitude');
     $longitude = Input::get('longitude');
     $d_latitude = Input::get('d_latitude');
     $d_longitude = Input::get('d_longitude');
     $type = Input::get('type');
     $owner_id = Session::get('user_id');
     $payment_type = Input::get('payment_type');
     if ($type == "") {
         $message = "Please Select the Service Type";
         $type = "warning";
         return Redirect::route('userrequestTrip')->with('message', $message)->with('type', $type);
     } else {
         if (Input::has('promo_code')) {
             $promo_code = Input::get('promo_code');
             $code_check = PromoCodes::where('coupon_code', $promo_code)->first();
             if ($code_check == NULL) {
                 $message = "Invalid Promo Code";
                 $type = "error";
                 return Redirect::route('userrequestTrip')->with('message', $message)->with('type', $type);
             } else {
                 if ($code_check->state == 1 && date('Y-m-d H:i:s', strtotime($code_check->expiry)) > date('Y-m-d H:i:s')) {
                     $code_id = $code_check->id;
                 } else {
                     $message = "Invalid Promo Code";
                     $type = "error";
                     return Redirect::route('userrequestTrip')->with('message', $message)->with('type', $type);
                 }
             }
         } else {
             $code_id = NULL;
         }
         $owner_data = Owner::find($owner_id);
         $settings = Settings::where('key', 'default_search_radius')->first();
         $distance = $settings->value;
         if (Input::has('type')) {
             $type = Input::get('type');
             if (!$type) {
                 // choose default type
                 $provider_type = ProviderType::where('is_default', 1)->first();
                 if (!$provider_type) {
                     $type = 1;
                 } else {
                     $type = $provider_type->id;
                 }
             }
         }
         $typequery = "SELECT distinct provider_id from walker_services where type IN({$type})";
         $typewalkers = DB::select(DB::raw($typequery));
         /* $var = Keywords::where('id', 1)->first(); */
         if (empty($typewalkers)) {
             /* $message = "No " . $var->keyword . " found matching the service type."; */
             $message = "No " . Config::get('app.generic_keywords.Provider') . " found matching the service type.";
         } else {
             Log::info('typewalkers = ' . print_r($typewalkers, true));
             foreach ($typewalkers as $key) {
                 $types[] = $key->provider_id;
             }
             $typestring = implode(",", $types);
             Log::info('typestring = ' . print_r($typestring, true));
             if ($typestring == '') {
                 /* $message = "No " . $var->keyword . " found matching the service type."; */
                 $message = "No " . Config::get('app.generic_keywords.Provider') . " found matching the service type.";
             }
             $settings = Settings::where('key', 'default_search_radius')->first();
             $distance = $settings->value;
             $settings = Settings::where('key', 'default_distance_unit')->first();
             $unit = $settings->value;
             if ($unit == 0) {
                 $multiply = 1.609344;
             } elseif ($unit == 1) {
                 $multiply = 1;
             }
             $query = "SELECT walker.*, ROUND(" . $multiply . " * 3956 * acos( cos( radians('{$latitude}') ) * cos( radians(latitude) ) * cos( radians(longitude) - radians('{$longitude}') ) + sin( radians('{$latitude}') ) * sin( radians(latitude) ) ) ,8) as distance from walker where is_available = 1 and is_active = 1 and is_approved = 1 and ROUND((" . $multiply . " * 3956 * acos( cos( radians('{$latitude}') ) * cos( radians(latitude) ) * cos( radians(longitude) - radians('{$longitude}') ) + sin( radians('{$latitude}') ) * sin( radians(latitude) ) ) ) ,8) <= {$distance} and walker.deleted_at IS NULL and walker.id IN({$typestring}) order by distance";
             $walkers = DB::select(DB::raw($query));
             $walker_list = array();
             $owner = Owner::find($owner_id);
             $owner->latitude = $latitude;
             $owner->longitude = $longitude;
             $owner->save();
             $user_timezone = $owner->timezone;
             $default_timezone = Config::get('app.timezone');
             $offset = $this->get_timezone_offset($default_timezone, $user_timezone);
             $request = new Requests();
             $request->owner_id = $owner_id;
             if ($d_longitude != '' && $d_latitude != '') {
                 $request->D_latitude = $d_latitude;
                 $request->D_longitude = $d_longitude;
             }
             $request->request_start_time = date("Y-m-d H:i:s", strtotime(date("Y-m-d H:i:s")) + $offset);
             $request->save();
             $request_service = new RequestServices();
             $request_service->type = $type;
             $request_service->request_id = $request->id;
             $request_service->save();
             $i = 0;
             $first_walker_id = 0;
             foreach ($walkers as $walker) {
//.........这里部分代码省略.........
开发者ID:felipemarques8,项目名称:goentregas,代码行数:101,代码来源:WebUserController.php


注:本文中的Dog::find方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。