public function get_index() { $records = Cars::where('parent_id', '=', (int) $_GET['node'])->get(); $result = '['; foreach ($records as $record) { $result .= '{ text: \'' . $record->text . '\', leaf: ' . ($record->leaf ? 'true' : 'false') . ', id: ' . $record->id . ' },'; } $result .= ']'; return $result; }
public function getCompare() { $brand = e(Input::get('car')); $year = e(Input::get('year')); $model = e(Input::get('model')); $location = e(Input::get('location')); $usage = e(Input::get('usage')); $coverage = e(Input::get('coverage')); $car_id = Cars::where('brand', '=', $brand)->where('year', '=', $year)->where('model', '=', $model)->get()->first()->id; $insurers = Cars::find($car_id)->insurers; $message = "Sending an email with the following:<br/><br/>"; $message .= "Your Car: {$brand}<br/>"; $message .= "Year: {$year}<br/>"; $message .= "Model: {$model}<br/>"; $message .= "Location: {$location}<br/>"; $message .= "Usage: {$usage}<br/>"; $message .= "coverage: {$coverage}<br/><br/>"; $message .= "<table border=1>"; $message .= "<tr>"; $message .= "<th>"; $message .= "Original FMV"; $message .= "</th>"; $message .= "<th>"; $message .= "Computed Qoutes"; $message .= "</th>"; $message .= "<th>"; $message .= "Insurer"; $message .= "</th>"; $message .= "<th>"; $message .= ""; $message .= "</th>"; $message .= "</tr>"; $additional = 0; if ($location === "luzon") { $additional += 0.01; } if ($usage === "private") { $additional += 0.02; } if ($coverage === "yes") { $additional += 0.024; } foreach ($insurers as $insurer) { $message .= "<tr>"; $message .= "<td>"; $message .= number_format($insurer->fmv * 1000000, 2); $message .= "</td>"; $message .= "<td>"; $fmv_computed = $insurer->fmv + $additional; $message .= number_format($fmv_computed * 1000000, 2); $message .= "</td>"; $message .= "<td>"; $message .= $insurer->insurer; $message .= "</td>"; $message .= "<td>"; $message .= "<button>buy now</button>"; $message .= "</td>"; $message .= "</tr>"; } $message .= "</table>"; return $message; }
<?php $records = Cars::where('parent_id', '=', (int) $_GET['node'])->get(); ?> [ <?php foreach ($records as $record) { ?> { text: '<?php echo $record->text; ?> ', leaf: <?php if ($record->leaf) { echo 'true'; } else { echo 'false'; } ?> , id: <?php echo $record->id; ?> }, <?php } ?>
public function requestRevision() { $tripId = Input::get('trip_id'); $carName = Input::get('car'); $clientName = Input::get('client'); $customerName = Input::get('customer_name'); $customerEmail = Input::get('customer_email'); $customerPhone = Input::get('customer_phone'); $departureKm = Input::get('start_km'); $arrivalKm = Input::get('end_km'); $departureDateTime = Input::get('start_time'); $arrivalDateTime = Input::get('end_time'); $departureAddress = Input::get('departure_address'); $arrivalAddress = Input::get('destination_address'); $car = Cars::where('name', '=', substr($carName, 0, 3))->first(); if ($car instanceof Cars) { $carId = $car->id; } else { $carId = ''; } $client = Client::where('name', '=', $clientName)->first(); if ($client instanceof Client) { $clientId = $client->id; } else { $clientId = ''; } try { $myTrip = DailyTrips::find($tripId); $myTrip->edit_req = 1; $myTrip->save(); $myTripRevison = new DailyTripsRevision(); $myTripRevison->trip_id = $tripId; $myTripRevison->user_id = Session::get('user_id'); $myTripRevison->car_id = $carId; $myTripRevison->client_id = $clientId; $myTripRevison->customer_name = $customerName; $myTripRevison->customer_email = $customerEmail; $myTripRevison->customer_phone = $customerPhone; $myTripRevison->departure_km = $departureKm; $myTripRevison->departure_date_time = $departureDateTime; $myTripRevison->arrival_km = $arrivalKm; $myTripRevison->arrival_date_time = $arrivalDateTime; $myTripRevison->departure_address = $departureAddress; $myTripRevison->arrival_address = $arrivalAddress; $myTripRevison->save(); $results = array('success' => true, 'message' => 'revision requested'); } catch (Exception $ex) { \Log::error(__METHOD__ . ' | error :' . print_r($ex, 1)); $results = array('success' => false, 'message' => 'an error occurred'); } return $results; }