本文整理汇总了PHP中Requests::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Requests::save方法的具体用法?PHP Requests::save怎么用?PHP Requests::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Requests
的用法示例。
在下文中一共展示了Requests::save方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model = new Requests();
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['Requests'])) {
$model->attributes = $_POST['Requests'];
if ($model->save()) {
$this->redirect(array('view', 'id' => $model->id));
}
}
$this->render('create', array('model' => $model));
}
示例2: DoCreate
public function DoCreate()
{
$requestData = Input::all();
$validationRules = array('name' => 'required', 'location' => 'required', 'skills' => 'required');
$validator = Validator::make($requestData, $validationRules);
if ($validator->fails()) {
return Redirect::action('RequestController@ShowCreate')->withErrors($validator);
} else {
$request = new Requests();
$request->name = Input::get('name');
$request->request_location = Input::get('location');
$request->service_category = "General";
$request->skills_required = Input::get('skills');
$request->creator_user_id = 1;
$request->save();
return Redirect::action('RequestController@ShowCreate')->with('message', 'Request submitted to database!');
}
}
示例3: postFormRequest
public function postFormRequest()
{
$all = Input::all();
$rules = array('name' => 'required|min:2|max:255', 'text' => 'required|min:5', 'email' => 'required|email');
$validator = Validator::make($all, $rules);
if ($validator->fails()) {
return Redirect::to('/#contact')->withErrors($validator)->withInput()->with('message_error', 'Ошибка, пожалуйста заполните форму');
}
$post = new Requests();
$post->name = $all['name'];
$post->phone = $all['phone'];
$post->email = $all['email'];
$post->text = $all['text'];
$post->save();
$mail = Setting::where('name', 'email')->first()->value;
$messages = '<b>Пользователь: </b>' . $all['name'] . '<br>';
$messages .= '<b>Сообщение: </b>' . $all['text'] . '<br>';
$messages .= '<b>Контактные данные: </b>' . '<br>';
$messages .= '<i>Телефон: </i>' . $all['phone'] . '<br>';
$messages .= '<i>Емайл: </i>' . $all['email'] . '<br>';
Mail::send('emails.message', array('messages' => $messages), function ($message) use($mail) {
$message->to($mail)->subject('Заказ каталога');
});
return Redirect::to('/#formRequest')->with('message_sent', 'Ваше сообщение отправлено, с вами свяжутся наши сотрудники.');
}
示例4: saveUserRequestTrip
public function saveUserRequestTrip()
{
$latitude = Input::get('latitude');
$longitude = Input::get('longitude');
$type = Input::get('type');
$owner_id = Session::get('user_id');
$owner_data = Owner::find($owner_id);
$settings = Settings::where('key', 'default_search_radius')->first();
$distance = $settings->value;
$query = "SELECT walker.id, 1.609344 * 3956 * acos( cos( radians('{$latitude}') ) * cos( radians(latitude) ) * cos( radians(longitude) - radians('{$longitude}') ) + sin( radians('{$latitude}') ) * sin( radians(latitude) ) ) as distance from walker where is_available = 1 and is_active = 1 and is_approved = 1 and type = {$type} and (1.609344 * 3956 * acos( cos( radians('{$latitude}') ) * cos( radians(latitude) ) * cos( radians(longitude) - radians('{$longitude}') ) + sin( radians('{$latitude}') ) * sin( radians(latitude) ) ) ) <= {$distance} 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();
$request = new Requests();
$request->owner_id = $owner_id;
$request->type = $type;
$request->request_start_time = date("Y-m-d H:i:s");
$request->save();
$i = 0;
$first_walker_id = 0;
foreach ($walkers as $walker) {
$request_meta = new RequestMeta();
$request_meta->request_id = $request->id;
$request_meta->walker_id = $walker->id;
if ($i == 0) {
$first_walker_id = $walker->id;
$i++;
}
$request_meta->save();
}
$req = Requests::find($request->id);
$req->current_walker = $first_walker_id;
$req->confirmed_walker = 0;
$req->save();
$settings = Settings::where('key', 'provider_timeout')->first();
$time_left = $settings->value;
$message = "Your Request is successful. Please wait while we are finding a nearest cab driver for you.";
$type = "success";
return Redirect::to('/user/request-trip')->with('message', $message)->with('type', $type);
/*
// Send Notification
$walker = Walker::find($first_walker_id);
if($walker){
$msg_array = array();
$msg_array['unique_id'] = 1;
$msg_array['request_id'] = $request->id;
$msg_array['time_left_to_respond'] = $time_left;
$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 = "New Request";
$message = json_encode($msg_array);
send_notifications($first_walker_id,"walker",$title,$message);
}
// Send SMS
$settings = Settings::where('key','sms_request_created')->first();
$pattern = $settings->value;
$pattern = str_replace('%user%', $owner_data->first_name." ".$owner_data->last_name, $pattern);
$pattern = str_replace('%id%', $request->id, $pattern);
$pattern = str_replace('%user_mobile%', $owner_data->phone, $pattern);
sms_notification(1,'admin',$pattern);
// send email
$settings = Settings::where('key','email_new_request')->first();
$pattern = $settings->value;
$pattern = str_replace('%id%', $request->id, $pattern);
$pattern = str_replace('%url%', web_url()."/admin/request/map/".$request->id, $pattern);
$subject = "New Request Created";
email_notification(1,'admin',$pattern,$subject); */
}
示例5: 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');
}
}
示例6: create_request
public function create_request()
{
$token = Input::get('token');
$owner_id = Input::get('id');
$latitude = Input::get('latitude');
$longitude = Input::get('longitude');
$type = Input::get('type');
$validator = Validator::make(array('token' => $token, 'owner_id' => $owner_id, 'latitude' => $latitude, 'longitude' => $longitude), array('token' => 'required', 'owner_id' => 'required|integer', 'latitude' => 'required', 'longitude' => '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 (!$type) {
// choose default type
$provider_type = ProviderType::where('is_default', 1)->first();
if (!$provider_type) {
$type = 0;
} else {
$type = $provider_type->id;
}
}
$settings = Settings::where('key', 'default_search_radius')->first();
$distance = $settings->value;
$query = "SELECT walker.id, 1.609344 * 3956 * acos( cos( radians('{$latitude}') ) * cos( radians(latitude) ) * cos( radians(longitude) - radians('{$longitude}') ) + sin( radians('{$latitude}') ) * sin( radians(latitude) ) ) as distance from walker where is_available = 1 and is_active = 1 and is_approved = 1 and type = {$type} and (1.609344 * 3956 * acos( cos( radians('{$latitude}') ) * cos( radians(latitude) ) * cos( radians(longitude) - radians('{$longitude}') ) + sin( radians('{$latitude}') ) * sin( radians(latitude) ) ) ) <= {$distance} 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();
$request = new Requests();
$request->owner_id = $owner_id;
$request->type = $type;
$request->request_start_time = date("Y-m-d H:i:s");
$request->save();
$i = 0;
$first_walker_id = 0;
foreach ($walkers as $walker) {
$request_meta = new RequestMeta();
$request_meta->request_id = $request->id;
$request_meta->walker_id = $walker->id;
if ($i == 0) {
$first_walker_id = $walker->id;
$i++;
}
$request_meta->save();
}
$req = Requests::find($request->id);
$req->current_walker = $first_walker_id;
$req->save();
$settings = Settings::where('key', 'provider_timeout')->first();
$time_left = $settings->value;
// Send Notification
$walker = Walker::find($first_walker_id);
if ($walker) {
$msg_array = array();
$msg_array['unique_id'] = 1;
$msg_array['request_id'] = $request->id;
$msg_array['time_left_to_respond'] = $time_left;
$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 = "New Request";
$message = $msg_array;
/* don't do json_encode in above line because if */
send_notifications($first_walker_id, "walker", $title, $message);
}
// Send SMS
$settings = Settings::where('key', 'sms_request_created')->first();
$pattern = $settings->value;
$pattern = str_replace('%user%', $owner_data->first_name . " " . $owner_data->last_name, $pattern);
$pattern = str_replace('%id%', $request->id, $pattern);
$pattern = str_replace('%user_mobile%', $owner_data->phone, $pattern);
sms_notification(1, 'admin', $pattern);
// send email
$settings = Settings::where('key', 'email_new_request')->first();
$pattern = $settings->value;
//.........这里部分代码省略.........
示例7: create_request_later
public function create_request_later()
{
$token = Input::get('token');
$owner_id = Input::get('id');
$latitude = Input::get('latitude');
$longitude = Input::get('longitude');
$date_time = Input::get('datetime');
// dd(date('Y-m-d h:i:s', strtotime("$date_time + 2 hours")));
$validator = Validator::make(array('token' => $token, 'owner_id' => $owner_id, 'latitude' => $latitude, 'longitude' => $longitude, 'datetime' => $date_time), array('token' => 'required', 'owner_id' => 'required|integer', 'latitude' => 'required', 'longitude' => 'required', 'datetime' => '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 ($owner_data->debt > 0) {
$response_array = array('success' => false, 'error' => "You are already in \${$owner->debt} debt", 'error_code' => 417);
$response_code = 200;
$response = Response::json($response_array, $response_code);
return $response;
}
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));
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 == '') {
/* $driver = Keywords::where('id', 1)->first();
$response_array = array('success' => false, 'error' => 'No ' . $driver->keyword . ' found matching the service type.', 'error_code' => 405); */
$response_array = array('success' => false, 'error' => 'No ' . Config::get('app.generic_keywords.Provider') . ' found matching the service type.', 'error_code' => 405);
$response_code = 200;
return Response::json($response_array, $response_code);
}
$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;
}
$query1 = "SELECT walker.id, 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.id IN({$typestring});";
$ssstrings = DB::select(DB::raw($query1));
foreach ($ssstrings as $ssstrin) {
$ssstri[] = $ssstrin->id;
}
$ssstring = implode(",", $ssstri);
$datewant = new DateTime($date_time);
$datetime = $datewant->format('Y-m-d H:i:s');
$dategiven = $datewant->sub(new DateInterval('P0Y0M0DT1H59M59S'))->format('Y-m-d H:i:s');
$end_time = $datewant->add(new DateInterval('P0Y0M0DT1H59M59S'))->format('Y-m-d H:i:s');
/* $setting = Settings::where('key', 'allow_calendar')->first();
if ($setting->value == 1)
$pvquery = "SELECT distinct provider_id from provider_availability where start <= '" . $datetime . "' and end >= '" . $datetime . "' and provider_id IN($ssstring) and provider_id NOT IN(SELECT confirmed_walker FROM request where request_start_time>='" . $dategiven . "' and request_start_time<='" . $end_time . "');";
else */
$pvquery = "SELECT id from walker where id IN({$ssstring}) and id NOT IN(SELECT confirmed_walker FROM request where request_start_time>='" . $dategiven . "' and request_start_time<='" . $end_time . "');";
$pvques = DB::select(DB::raw($pvquery));
// dd($pvques);
$ssstr = array();
foreach ($pvques as $ssstn) {
$ssstr[] = $ssstn->provider_id;
}
$pvque = implode(",", $ssstr);
$walkers = array();
if ($pvque) {
$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, 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.id IN({$typestring}) and id IN({$pvque}) 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();
$request = new Requests();
//.........这里部分代码省略.........
示例8: 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) {
//.........这里部分代码省略.........
示例9: createRequest
private function createRequest($user_id, $doc_id, $comment)
{
$params = array('user_id' => $user_id, 'doc_id' => $doc_id, 'comment' => $comment, 'state' => 'WAIT', 'state_time' => date("Y-m-d H:i:s"));
$model = new Requests();
$model->attributes = $params;
if ($model->save()) {
return true;
}
return false;
}