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


PHP Owner::find方法代码示例

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


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

示例1: postTestAuthorize

 public function postTestAuthorize()
 {
     if (!array_key_exists('X_ALLOW_TEST_AUTH', $_SERVER) || $_SERVER['X_ALLOW_TEST_AUTH'] != 'true') {
         return;
     }
     $data = ['eduPersonPrincipalName' => Input::get('eduPersonPrincipalName'), 'eduPersonScopedAffiliation' => Input::get('eduPersonScopedAffiliation'), 'sn' => Input::get('sn'), 'givenName' => Input::get('givenName'), 'mail' => Input::get('mail')];
     $user = (object) $data;
     $userId = Input::get('eduPersonPrincipalName');
     $owner = Owner::find($userId);
     if (!$owner) {
         $owner = new Owner();
         $owner->id = $userId;
     }
     $owner->data = json_encode($user);
     $owner->save();
     $params = Session::get('authorize-params');
     $params['user_id'] = $user->eduPersonPrincipalName;
     if (Input::get('approve') !== null) {
         $code = AuthorizationServer::newAuthorizeRequest('user', $params['user_id'], $params);
         Session::forget('authorize-params');
         return Redirect::to(AuthorizationServer::makeRedirectWithCode($code, $params));
     }
     if (Input::get('deny') !== null) {
         Session::forget('authorize-params');
         $url = AuthorizationServer::makeRedirectWithError($params);
         return new \Illuminate\Http\RedirectResponse((string) $url, 302, array());
     }
 }
开发者ID:ebollens,项目名称:shib-oauth2-bridge,代码行数:28,代码来源:OAuth2Controller.php

示例2: it_checks_if_owner_is_same_with_given

 /** @test */
 function it_checks_if_owner_is_same_with_given()
 {
     $john = Owner::find(1);
     $jane = Owner::find(2);
     $ownable = $this->getOwnable();
     $this->assertFalse($ownable->isOwnedBy($john));
     $ownable->associateOwner($john);
     $this->assertTrue($ownable->isOwnedBy($john));
     $this->assertFalse($ownable->isOwnedBy($jane));
 }
开发者ID:kenarkose,项目名称:ownable,代码行数:11,代码来源:OwnableTest.php

示例3: it_changes_owner

 /** @test */
 public function it_changes_owner()
 {
     $ownable = $this->getOwnable();
     $john = Owner::find(1);
     $jane = Owner::find(2);
     $this->assertNull($ownable->getOwner());
     $ownable->changeOwnerTo($john);
     $this->assertEquals($ownable->getOwner(), $john);
     $ownable->changeOwnerTo($jane);
     $this->assertEquals($ownable->getOwner(), $jane);
 }
开发者ID:tshafer,项目名称:laravel-ownable,代码行数:12,代码来源:OwnableTest.php

示例4: create_manual_request

 public function create_manual_request()
 {
     $latitude = Input::get('latitude');
     $longitude = Input::get('longitude');
     $d_latitude = Input::get('d_latitude');
     $d_longitude = Input::get('d_longitude');
     $type = Input::get('type');
     $provider = Input::get('provider');
     $user_id = Session::get('user_id');
     $time = date("Y-m-d H:i:s");
     $provider_details = Walker::where('id', '=', $provider)->first();
     $user = Owner::where('id', '=', $user_id)->first();
     $request = new Requests();
     $request->owner_id = $user_id;
     $request->request_start_time = $time;
     $request->confirmed_walker = $provider;
     if ($d_longitude != '' && $d_latitude != '') {
         $request->D_latitude = $d_latitude;
         $request->D_longitude = $d_longitude;
     }
     $request->current_walker = $provider;
     $request->status = 1;
     $request->save();
     $reqid = $request->id;
     $request_service = new RequestServices();
     $request_service->type = $type;
     $request_service->request_id = $request->id;
     $request_service->save();
     $owner = Owner::find($user_id);
     $owner->latitude = $latitude;
     $owner->longitude = $longitude;
     $owner->save();
     $walkerlocation = new WalkLocation();
     $walkerlocation->request_id = $request->id;
     $walkerlocation->distance = 0.0;
     $walkerlocation->latitude = $latitude;
     $walkerlocation->longitude = $longitude;
     $walkerlocation->save();
     if ($request->save()) {
         $current_request = Requests::where('id', '=', $reqid)->first();
         return Redirect::to('/user/request-trip');
     }
 }
开发者ID:felipemarques8,项目名称:goentregas,代码行数:43,代码来源:WebProviderController.php

示例5: destroy

 /**
  * Remove the specified resource from storage.
  * DELETE /owners/{id}
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     Owner::find($id)->delete();
     return Redirect::route('admin.owner');
 }
开发者ID:jeremiteki,项目名称:mteja,代码行数:12,代码来源:OwnersController.php

示例6: schedule_request

 public function schedule_request()
 {
     $time = date("Y-m-d H:i:s");
     $query = "SELECT id,owner_id,current_walker,TIMESTAMPDIFF(SECOND,request_start_time, '{$time}') as diff from request where status = 0 and is_cancelled = 0";
     $results = DB::select(DB::raw($query));
     foreach ($results as $result) {
         $settings = Settings::where('key', 'provider_timeout')->first();
         $timeout = $settings->value;
         if ($result->diff >= $timeout) {
             // Archiving Old Walker
             RequestMeta::where('request_id', '=', $result->id)->where('walker_id', '=', $result->current_walker)->update(array('status' => 2));
             $request_meta = RequestMeta::where('request_id', '=', $result->id)->where('status', '=', 0)->orderBy('created_at')->first();
             // update request
             if (isset($request_meta->walker_id)) {
                 // assign new walker
                 Requests::where('id', '=', $result->id)->update(array('current_walker' => $request_meta->walker_id, 'request_start_time' => date("Y-m-d H:i:s")));
                 // Send Notification
                 $walker = Walker::find($request_meta->walker_id);
                 $owner_data = Owner::find($result->owner_id);
                 $msg_array = array();
                 $msg_array['request_id'] = $result->id;
                 $msg_array['id'] = $request_meta->walker_id;
                 if ($walker) {
                     $msg_array['token'] = $walker->token;
                 }
                 $msg_array['client_profile'] = array();
                 $msg_array['client_profile']['name'] = $owner_data->first_name . " " . $owner_data->last_name;
                 $msg_array['client_profile']['picture'] = $owner_data->picture;
                 $msg_array['client_profile']['bio'] = $owner_data->bio;
                 $msg_array['client_profile']['address'] = $owner_data->address;
                 $msg_array['client_profile']['phone'] = $owner_data->phone;
                 $title = "New Request";
                 $message = $msg_array;
                 send_notifications($request_meta->walker_id, "walker", $title, $message);
             } else {
                 // request ended
                 Requests::where('id', '=', $result->id)->update(array('current_walker' => 0, 'status' => 1));
                 $settings = Settings::where('key', 'sms_request_unanswered')->first();
                 $pattern = $settings->value;
                 $pattern = str_replace('%id%', $result->id, $pattern);
                 sms_notification(1, 'admin', $pattern);
                 // send email
                 $settings = Settings::where('key', 'email_request_unanswered')->first();
                 $pattern = $settings->value;
                 $pattern = str_replace('%id%', $result->id, $pattern);
                 $pattern = str_replace('%url%', web_url() . "/admin/request/map/" . $result->id, $pattern);
                 $subject = "New Request Unansweres";
                 email_notification(1, 'admin', $pattern, $subject);
             }
         }
     }
 }
开发者ID:netGALAXYStudios,项目名称:ourmovingapp,代码行数:52,代码来源:DogController.php

示例7: pay_debt

 public function pay_debt()
 {
     $token = Input::get('token');
     $owner_id = Input::get('id');
     $validator = Validator::make(array('token' => $token, 'owner_id' => $owner_id), array('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) {
                 $total = $owner_data->debt;
                 if ($total == 0) {
                     $response_array = array('success' => true);
                     $response_code = 200;
                     $response = Response::json($response_array, $response_code);
                     return $response;
                 }
                 $payment_data = Payment::where('owner_id', $owner_id)->where('is_default', 1)->first();
                 if (!$payment_data) {
                     $payment_data = Payment::where('owner_id', $request->owner_id)->first();
                 }
                 if ($payment_data) {
                     $customer_id = $payment_data->customer_id;
                     if (Config::get('app.default_payment') == 'stripe') {
                         Stripe::setApiKey(Config::get('app.stripe_secret_key'));
                         try {
                             Stripe_Charge::create(array("amount" => $total * 100, "currency" => "usd", "customer" => $customer_id));
                         } catch (Stripe_InvalidRequestError $e) {
                             // Invalid parameters were supplied to Stripe's API
                             $ownr = Owner::find($owner_id);
                             $ownr->debt = $total;
                             $ownr->save();
                             $response_array = array('error' => $e->getMessage());
                             $response_code = 200;
                             $response = Response::json($response_array, $response_code);
                             return $response;
                         }
                         $owner_data->debt = 0;
                         $owner_data->save();
                     } else {
                         $amount = $total;
                         Braintree_Configuration::environment(Config::get('app.braintree_environment'));
                         Braintree_Configuration::merchantId(Config::get('app.braintree_merchant_id'));
                         Braintree_Configuration::publicKey(Config::get('app.braintree_public_key'));
                         Braintree_Configuration::privateKey(Config::get('app.braintree_private_key'));
                         $card_id = $payment_data->card_token;
                         $result = Braintree_Transaction::sale(array('amount' => $amount, 'paymentMethodToken' => $card_id));
                         Log::info('result = ' . print_r($result, true));
                         if ($result->success) {
                             $owner_data->debt = $total;
                         } else {
                             $owner_data->debt = 0;
                         }
                         $owner_data->save();
                     }
                 }
                 $response_array = array('success' => true);
                 $response_code = 200;
             } else {
                 $response_array = array('success' => false, 'error' => 'Token Expired', 'error_code' => 405);
                 $response_code = 200;
             }
         } else {
             if ($is_admin) {
                 /* $var = Keywords::where('id', 2)->first();
                    $response_array = array('success' => false, 'error' => '' . $var->keyword . ' ID not Found', 'error_code' => 410); */
                 $response_array = array('success' => false, 'error' => '' . Config::get('app.generic_keywords.User') . ' 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,代码来源:OwnerController_old.php

示例8: request_walk_completed

 public function request_walk_completed()
 {
     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');
         $walker = Walker::find($walker_id);
         $validator = Validator::make(array('request_id' => $request_id, 'token' => $token, 'walker_id' => $walker_id, 'latitude' => $latitude, 'longitude' => $longitude, 'distance' => $distance, 'time' => $time), array('request_id' => 'required|integer', 'token' => 'required', 'walker_id' => 'required|integer', 'latitude' => 'required', 'longitude' => 'required', 'distance' => 'required', 'time' => '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 ($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) {
                             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;
                                 $distance = convert($distance, $unit);
                                 $pt = ProviderServices::where('provider_id', $walker_id)->get();
                                 foreach ($pt as $key) {
                                     $reqserv = RequestServices::where('request_id', $request_id)->where('type', $key->type)->first();
                                     $base_price = $key->base_price;
                                     $price_per_unit_distance = $key->price_per_unit_distance * $distance;
                                     $price_per_unit_time = $key->price_per_unit_time * $time;
                                     $reqserv->base_price = $base_price;
                                     $reqserv->distance_cost = $price_per_unit_distance;
                                     $reqserv->time_cost = $price_per_unit_time;
                                     $reqserv->total = $base_price + $price_per_unit_distance + $price_per_unit_time;
                                     $reqserv->save();
                                 }
                                 $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;
                                 }
                                 $request->is_completed = 1;
                                 $request->distance = $distance;
                                 $request->time = $time;
                                 $request->total = $total;
                                 // charge client
                                 $ledger = Ledger::where('owner_id', $request->owner_id)->first();
                                 if ($ledger) {
                                     $balance = $ledger->amount_earned - $ledger->amount_spent;
                                     if ($balance > 0) {
                                         if ($total > $balance) {
                                             $ledger_temp = Ledger::find($ledger->id);
                                             $ledger_temp->amount_spent = $ledger_temp->amount_spent + $balance;
                                             $ledger_temp->save();
                                             $total = $total - $balance;
                                         } else {
                                             $ledger_temp = Ledger::find($ledger->id);
                                             $ledger_temp->amount_spent = $ledger_temp->amount_spent + $total;
                                             $ledger_temp->save();
                                             $total = 0;
                                         }
                                     }
                                 }
                                 if ($total == 0) {
                                     $request->is_paid = 1;
                                 } else {
                                     $payment_data = Payment::where('owner_id', $request->owner_id)->first();
                                     if ($payment_data) {
                                         $customer_id = $payment_data->customer_id;
                                         try {
                                             if (Config::get('app.default_payment') == 'stripe') {
                                                 $am = round($total) * 100;
                                                 $sett = Settings::where('key', 'service_fee')->first();
                                                 $serviceFee = $sett->value * 100;
                                                 $amount = $am - $serviceFee;
                                                 Stripe::setApiKey(Config::get('app.stripe_secret_key'));
                                                 Stripe_Charge::create(array("amount" => $am, "currency" => "usd", "customer" => $customer_id));
                                                 if ($walker->merchant_id != NULL) {
                                                     $transfer = Stripe_Transfer::create(array("amount" => $amount, "currency" => "usd", "recipient" => $walker->merchant_id, "statement_descriptor" => "UberFoxX"));
                                                     Log::info('transfer = ' . print_r($transfer, true));
                                                 }
                                                 $request->is_paid = 1;
                                             } else {
                                                 $am = round($total, 2);
                                                 $sett = Settings::where('key', 'service_fee')->first();
                                                 $serviceFee = $sett->value;
                                                 $amount = $am - $serviceFee;
                                                 Braintree_Configuration::environment(Config::get('app.braintree_environment'));
                                                 Braintree_Configuration::merchantId(Config::get('app.braintree_merchant_id'));
                                                 Braintree_Configuration::publicKey(Config::get('app.braintree_public_key'));
                                                 Braintree_Configuration::privateKey(Config::get('app.braintree_private_key'));
                                                 $card_id = $payment_data->card_token;
                                                 if ($walker->merchant_id == NULL) {
//.........这里部分代码省略.........
开发者ID:netGALAXYStudios,项目名称:ourmovingapp,代码行数:101,代码来源:WalkerController.php

示例9: edit

 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $user = Owner::find($id);
     return View::make('pages.edit', compact('user'));
 }
开发者ID:Homeboyzandroid,项目名称:greensport,代码行数:11,代码来源:TeamOwnerContoller.php

示例10: 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

示例11: forgot_password

 public function forgot_password()
 {
     $type = Input::get('type');
     $email = Input::get('email');
     if ($type == 1) {
         // Walker
         $walker_data = Walker::where('email', $email)->first();
         if ($walker_data) {
             $walker = Walker::find($walker_data->id);
             $new_password = time();
             $new_password .= rand();
             $new_password = sha1($new_password);
             $new_password = substr($new_password, 0, 8);
             $walker->password = Hash::make($new_password);
             $walker->save();
             // send email
             $settings = Settings::where('key', 'email_forgot_password')->first();
             $pattern = $settings->value;
             $pattern = str_replace('%password%', $new_password, $pattern);
             $subject = "Your New Password";
             email_notification($walker->id, 'walker', $pattern, $subject);
             $response_array = array();
             $response_array['success'] = true;
             $response_code = 200;
             $response = Response::json($response_array, $response_code);
             return $response;
         } else {
             $response_array = array('success' => false, 'error' => 'This Email is not Registered', 'error_code' => 425);
             $response_code = 200;
             $response = Response::json($response_array, $response_code);
             return $response;
         }
     } else {
         $owner_data = Owner::where('email', $email)->first();
         if ($owner_data) {
             $owner = Owner::find($owner_data->id);
             $new_password = time();
             $new_password .= rand();
             $new_password = sha1($new_password);
             $new_password = substr($new_password, 0, 8);
             $owner->password = Hash::make($new_password);
             $owner->save();
             $settings = Settings::where('key', 'email_forgot_password')->first();
             $pattern = $settings->value;
             $pattern = str_replace('%password%', $new_password, $pattern);
             $subject = "Your New Password";
             email_notification($owner->id, 'owner', $pattern, $subject);
             $response_array = array();
             $response_array['success'] = true;
             $response_code = 200;
             $response = Response::json($response_array, $response_code);
             return $response;
         } else {
             $response_array = array('success' => false, 'error' => 'This Email is not Registered', 'error_code' => 425);
             $response_code = 200;
             $response = Response::json($response_array, $response_code);
             return $response;
         }
     }
 }
开发者ID:netGALAXYStudios,项目名称:ourmovingapp,代码行数:60,代码来源:ApplicationController.php

示例12: forgot_password

 public function forgot_password()
 {
     $type = Input::get('type');
     $email = Input::get('email');
     if ($type == 1) {
         // Walker
         $walker_data = Walker::where('email', $email)->first();
         if ($walker_data) {
             $walker = Walker::find($walker_data->id);
             $new_password = time();
             $new_password .= rand();
             $new_password = sha1($new_password);
             $new_password = substr($new_password, 0, 8);
             $walker->password = Hash::make($new_password);
             $walker->save();
             /* $subject = "Your New Password";
                $email_data = array();
                $email_data['password'] = $new_password;
                send_email($walker->id, 'walker', $email_data, $subject, 'forgotpassword'); */
             $settings = Settings::where('key', 'admin_email_address')->first();
             $admin_email = $settings->value;
             $login_url = web_url() . "/provider/signin";
             $pattern = array('name' => $walker->first_name . " " . $walker->last_name, 'admin_eamil' => $admin_email, 'new_password' => $new_password, 'login_url' => $login_url);
             $subject = "Your New Password";
             email_notification($walker->id, 'walker', $pattern, $subject, 'forgot_password', "imp");
             $response_array = array();
             $response_array['success'] = true;
             $response_code = 200;
             $response = Response::json($response_array, $response_code);
             return $response;
         } else {
             $response_array = array('success' => false, 'error' => 'This Email is not Registered', 'error_code' => 425);
             $response_code = 200;
             $response = Response::json($response_array, $response_code);
             return $response;
         }
     } else {
         $owner_data = Owner::where('email', $email)->first();
         if ($owner_data) {
             $owner = Owner::find($owner_data->id);
             $new_password = time();
             $new_password .= rand();
             $new_password = sha1($new_password);
             $new_password = substr($new_password, 0, 8);
             $owner->password = Hash::make($new_password);
             $owner->save();
             /* $subject = "Your New Password";
                $email_data = array();
                $email_data['password'] = $new_password;
                send_email($owner->id, 'owner', $email_data, $subject, 'forgotpassword'); */
             $settings = Settings::where('key', 'admin_email_address')->first();
             $admin_email = $settings->value;
             $login_url = web_url() . "/user/signin";
             $pattern = array('name' => $owner->first_name . " " . $owner->last_name, 'admin_eamil' => $admin_email, 'new_password' => $new_password, 'login_url' => $login_url);
             $subject = "Your New Password";
             email_notification($owner->id, 'owner', $pattern, $subject, 'forgot_password', "imp");
             $response_array = array();
             $response_array['success'] = true;
             $response_code = 200;
             $response = Response::json($response_array, $response_code);
             return $response;
         } else {
             $response_array = array('success' => false, 'error' => 'This Email is not Registered', 'error_code' => 425);
             $response_code = 200;
             $response = Response::json($response_array, $response_code);
             return $response;
         }
     }
 }
开发者ID:felipemarques8,项目名称:goentregas,代码行数:69,代码来源:ApplicationController.php

示例13: update_profile

 public function update_profile()
 {
     $token = Input::get('token');
     $owner_id = Input::get('id');
     $first_name = Input::get('first_name');
     $last_name = Input::get('last_name');
     $email = Input::get('email');
     $phone = Input::get('phone');
     $password = Input::get('password');
     $picture = Input::file('picture');
     $bio = Input::get('bio');
     $address = Input::get('address');
     $state = Input::get('state');
     $country = Input::get('country');
     $zipcode = Input::get('zipcode');
     $validator = Validator::make(array('token' => $token, 'owner_id' => $owner_id, 'email' => $email, 'picture' => $picture, 'zipcode' => $zipcode), array('token' => 'required', 'owner_id' => 'required|integer', 'email' => 'email', 'picture' => 'mimes:jpeg,bmp,png', 'zipcode' => '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
                 $owner = Owner::find($owner_id);
                 if ($first_name) {
                     $owner->first_name = $first_name;
                 }
                 if ($last_name) {
                     $owner->last_name = $last_name;
                 }
                 if ($email) {
                     $owner->email = $email;
                 }
                 if ($phone) {
                     $owner->phone = $phone;
                 }
                 if ($bio) {
                     $owner->bio = $bio;
                 }
                 if ($address) {
                     $owner->address = $address;
                 }
                 if ($state) {
                     $owner->state = $state;
                 }
                 if ($country) {
                     $owner->country = $country;
                 }
                 if ($zipcode) {
                     $owner->zipcode = $zipcode;
                 }
                 if ($password) {
                     $owner->password = Hash::make($password);
                 }
                 if (Input::hasFile('picture')) {
                     // upload image
                     $file_name = time();
                     $file_name .= rand();
                     $file_name = sha1($file_name);
                     $ext = Input::file('picture')->getClientOriginalExtension();
                     Input::file('picture')->move(public_path() . "/uploads", $file_name . "." . $ext);
                     $local_url = $file_name . "." . $ext;
                     // Upload to S3
                     if (Config::get('app.s3_bucket') != "") {
                         $s3 = App::make('aws')->get('s3');
                         $pic = $s3->putObject(array('Bucket' => Config::get('app.s3_bucket'), 'Key' => $file_name, 'SourceFile' => public_path() . "/uploads/" . $local_url));
                         $s3->putObjectAcl(array('Bucket' => Config::get('app.s3_bucket'), 'Key' => $file_name, 'ACL' => 'public-read'));
                         $s3_url = $s3->getObjectUrl(Config::get('app.s3_bucket'), $file_name);
                     } else {
                         $s3_url = asset_url() . '/uploads/' . $local_url;
                     }
                     $owner->picture = $s3_url;
                 }
                 $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, 'token' => $owner->token);
                 $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,代码行数:95,代码来源:OwnerController.php

示例14: providerTripDetail

 public function providerTripDetail()
 {
     $id = Request::segment(3);
     $walker_id = Session::get('walker_id');
     $request = Requests::find($id);
     if ($request->confirmed_walker == $walker_id) {
         $locations = WalkLocation::where('request_id', $id)->orderBy('id')->get();
         $start = WalkLocation::where('request_id', $id)->orderBy('id')->first();
         $end = WalkLocation::where('request_id', $id)->orderBy('id', 'desc')->first();
         $map = "https://maps-api-ssl.google.com/maps/api/staticmap?size=249x249&style=feature:landscape|visibility:off&style=feature:poi|visibility:off&style=feature:transit|visibility:off&style=feature:road.highway|element:geometry|lightness:39&style=feature:road.local|element:geometry|gamma:1.45&style=feature:road|element:labels|gamma:1.22&style=feature:administrative|visibility:off&style=feature:administrative.locality|visibility:on&style=feature:landscape.natural|visibility:on&scale=2&markers=shadow:false|scale:2|icon:http://d1a3f4spazzrp4.cloudfront.net/receipt-new/marker-start@2x.png|{$start->latitude},{$start->longitude}&markers=shadow:false|scale:2|icon:http://d1a3f4spazzrp4.cloudfront.net/receipt-new/marker-finish@2x.png|{$end->latitude},{$end->longitude}&path=color:0x2dbae4ff|weight:4";
         foreach ($locations as $location) {
             $map .= "|{$location->latitude},{$location->longitude}";
         }
         $start_location = json_decode(file_get_contents("https://maps.googleapis.com/maps/api/geocode/json?latlng={$start->latitude},{$start->longitude}"), TRUE);
         $start_address = $start_location['results'][0]['formatted_address'];
         $end_location = json_decode(file_get_contents("https://maps.googleapis.com/maps/api/geocode/json?latlng={$end->latitude},{$end->longitude}"), TRUE);
         $end_address = $end_location['results'][0]['formatted_address'];
         $owner = Owner::find($request->owner_id);
         $owner_review = DogReview::where('request_id', $id)->first();
         if ($owner_review) {
             $rating = round($owner_review->rating);
         } else {
             $rating = 0;
         }
         return View::make('web.providerTripDetail')->with('title', 'My Trips')->with('request', $request)->with('start_address', $start_address)->with('end_address', $end_address)->with('start', $start)->with('end', $end)->with('map_url', $map)->with('owner', $owner)->with('rating', $rating);
     } else {
         echo "false";
     }
 }
开发者ID:netGALAXYStudios,项目名称:ourmovingapp,代码行数:29,代码来源:WebProviderController.php

示例15: updateUserPassword

 public function updateUserPassword()
 {
     $current_password = Input::get('current_password');
     $new_password = Input::get('new_password');
     $confirm_password = Input::get('confirm_password');
     $owner_id = Session::get('user_id');
     $owner = Owner::find($owner_id);
     if (Hash::check($current_password, $owner->password)) {
         $password = Hash::make($new_password);
         $owner->password = $password;
         $owner->save();
         $message = "Your password is successfully updated";
         $type = "success";
     } else {
         $message = "Please enter your current password correctly";
         $type = "danger";
     }
     return Redirect::to('/user/profile')->with('message', $message)->with('type', $type);
 }
开发者ID:netGALAXYStudios,项目名称:ourmovingapp,代码行数:19,代码来源:WebUserController.php


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