本文整理汇总了PHP中App\Http\Controllers\Log::debug方法的典型用法代码示例。如果您正苦于以下问题:PHP Log::debug方法的具体用法?PHP Log::debug怎么用?PHP Log::debug使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类App\Http\Controllers\Log
的用法示例。
在下文中一共展示了Log::debug方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: within
/**
*
*/
public function within(Request $request)
{
$start = microtime(true);
if (str_contains($request->path(), 'mongo')) {
$collection = $this->model->within($request->json('geometry.coordinates'));
$elapsed = microtime(true) - $start;
} else {
$geometry = \geoPHP::load($request->input('geometry'), 'wkt');
$collection = $this->model->within($geometry->asText('wkt'));
$elapsed = microtime(true) - $start;
}
$logMessage = 'ms to get %s data: %f in %s';
\Log::debug(sprintf($logMessage, str_contains($request->path(), 'mongo') ? 'Mongo' : 'PostGIS', $elapsed, 'within()'));
return Response::json(['points' => $collection, 'area' => 0]);
}
示例2: response
/**
* @param string $in
* @param bool $success
* @param int $code
* @param array $extraHeaders
*
* @return mixed
*/
public function response($in = "", $code = 200, $extraHeaders = [])
{
$meta = ['RequestTimestamp' => (string) round($_SERVER["REQUEST_TIME_FLOAT"], 4), 'Duration' => (string) $this->executiontime(), 'ResponseTimestamp' => (string) round(microtime(true), 4)];
$output = ['Success' => true, 'Meta' => $meta, 'Payload' => $in];
$outp = json_encode($output, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
$in = json_encode($output, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
if (config('app.debug') === true) {
\Log::debug("Output: \r\n" . $outp);
}
trim($outp);
$response = new Response($output, $code);
$response->header('Content-Type', 'application/json; charset=UTF-8');
$response->header('Access-Control-Allow-Origin', '*');
if (is_array($extraHeaders) && count($extraHeaders) > 0) {
foreach ($extraHeaders as $key => $value) {
$response->header($key, $value);
}
}
return $response;
}
示例3: store
/**
* Store a newly created resource in storage.
*
* @return \Illuminate\Http\Response
*/
public function store(HandleVisitRequest $request)
{
// Make sure this is a valid stage
$stage = Stage::where('id', '=', $request->stage);
if ($stage->count() > 0) {
$stage = $stage->first();
} else {
return response()->json(['status' => 'failure', 'message' => sprintf('Stage with ID %s does not exist', $request->stage)], 422);
}
// Make sure the destination is valid.
if ($request->destination !== "__checkout__") {
$destination = Stage::where('id', '=', $request->destination);
if ($destination->count() == 0) {
return response()->json(['status' => 'failure', 'message' => sprintf('Destination stage [ID: %s] does not exist', $request->destination)]);
}
}
// Check if the visit has been created yet
$visit;
if (is_null($request->visit) || strlen($request->visit) == 0) {
// Create a new visit
$visit = new Visit();
$visit->patients = array_keys($request->patients);
$visit->stage = $request->stage;
$saved = $visit->save();
if (!$saved) {
return response()->json(['status' => 'failure', 'message' => 'Failed to save new visit record.'], 422);
}
} else {
// Check if the visit exists
$visit = Visit::where('id', '=', $request->visit);
if ($visit->count() > 0) {
$visit = $visit->first();
} else {
return response()->json(['status' => 'failure', 'message' => sprintf('Visit with ID %s does not exist.', $request->visit)]);
}
}
$errors = [];
// Loop through patients, add a new row to the respective Stage for each patient
foreach ($request->patients as $patientID => $patientData) {
// Setup data array
$data = array();
// Make sure all the values in the patientData array are valid stage columns
foreach ($patientData as $key => $value) {
if (array_key_exists($key, $stage->fields)) {
// Check if we should mutate the data (i.e. multiselect)
switch ($stage->fields[$key]["type"]) {
case "file":
case "pharmacy":
case "multiselect":
// Value is an array, convert to string
$data[$key] = json_encode($value);
break;
default:
$data[$key] = $value;
break;
}
} else {
\Log::debug(sprintf('Attemped to update stage [%s], column [%s], but this column is not valid', $stage->id, $key));
}
}
// Make sure this patient record exists
$patient = Patient::where('id', '=', $patientID);
// If the patient exists...
if ($patient->count() > 0) {
// Grab patient record
$patient = $patient->first();
// Update patient record as necessary
if ($stage->root) {
// All data is relative to Patient record
$data['concrete'] = true;
$data['current_visit'] = $visit->id;
// Add this visit ID to patient all-time visits array
// (we're at the root stage so this hasnt been done yet)
$thisPatientVisits = $patient->visits;
$thisPatientVisits[] = $visit->id;
$data['visits'] = $thisPatientVisits;
\Log::debug("Updating patient record at root stage with data:");
\Log::debug($data);
// Update patient record.
$patient->update($data);
} else {
// Set visit_id and patient_id for reference in this stage
$data["visit_id"] = $visit->id;
$data["patient_id"] = $patientID;
// Insert data into this stage's table
DB::table($stage->tableName)->insert($data);
}
// If the destination is checkout, remove "current visit" from patient
if ($request->destination == "__checkout__") {
\Log::debug("Destination for patient " . $patient->id . " in visit " . $visit->id . " is " . $request->destination);
$patient->current_visit = null;
$patient->save();
}
} else {
$error = sprintf("Could not locate patient record [id: %s]", $patientID);
//.........这里部分代码省略.........
示例4: resources
/**
* Handles interaction with file resources
*
* @return \Illuminate\Http\Response
*/
public function resources(Request $request, $method)
{
switch ($method) {
case 'upload':
$i = 0;
$files = array();
$message = array();
while ($request->has('file-' . $i)) {
$key = time() . "-" . mt_rand();
$inputName = 'file-' . $i;
$files[$key] = $request->input($inputName);
$i++;
}
foreach ($files as $fileKey => $fileData) {
$splitTypeAndBase64 = explode(";", $fileData);
\Log::debug($splitTypeAndBase64);
$dataType = explode(":", $splitTypeAndBase64[0]);
$splitType = explode("/", $dataType[1]);
$base64 = explode(",", $splitTypeAndBase64[1]);
$base64 = $base64[1];
$resource = new Resource();
$resource->type = $dataType[1];
$resource->base64 = $base64;
$resource->save();
$message[$resource->id] = array("type" => $resource->type, "data" => $splitType[0] == "image" ? $this->constructBase64File($resource) : null);
}
return response()->json(["status" => "success", "message" => $message]);
break;
case "fetch":
if ($request->has('id')) {
$resource = Resource::where('id', $request->id);
if ($resource->count() > 0) {
$resource = $resource->first(["id", "type", "base64"]);
return response()->json(["status" => "success", "type" => $resource->type, "base64" => $this->constructBase64File($resource)]);
}
} else {
return response()->json(["status" => "failure", "message" => "Missing ID parameter."]);
}
break;
default:
return response()->json(["status" => "failure", "message" => "Unknown method"]);
break;
}
}
示例5: leave
/**
* Allow user to leave team
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/
public function leave()
{
$user = \Auth::user()->with(['team', 'team.members'])->first();
$team_id = $user->team->id;
// Remove user's team
$user->team_id = null;
$user->save();
\Log::debug("User removed from team {$team_id}");
// Clean up team if no more users
if (count($user->team->members) - 1 == 0) {
Team::destroy($team_id);
\Log::info("Team {$team_id} deleted.");
}
return redirect('/');
}
示例6: update
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
*
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
$this->validate($request, ['name' => 'required|min:3', 'category_id' => 'required']);
$venue = Venue::where('id', $id)->first();
\DB::transaction(function () use($request, $venue) {
$venue->name = $request->get('name');
$venue->category_id = $request->get('category_id');
$venue->city = $request->get('city');
$venue->latitude = $request->get('latitude');
$venue->longitude = $request->get('longitude');
$venue->address = $request->get('address');
$venue->country = $request->get('country');
$venue->zip = $request->get('zip');
$venue->number = $request->get('number');
$venue->email = $request->get('email');
$venue->website = $request->get('website');
if ($request->hasFile('logo') && $request->file('logo')->isValid()) {
$venueLogo = $request->file('appIcon');
$uri = config('services.uploads')['venues-logos'];
$path = public_path() . $uri;
$this->createFolderIfNotExists($path);
$destinationPath = $path;
$fileName = "i" . $venue->id . "." . $venueLogo->getClientOriginalExtension();
$venueLogo->move($destinationPath, $fileName);
\Log::debug(sprintf("New icon image has been uploaded to %s, under the name %s", $destinationPath, $fileName));
$venue->logo = $uri . $fileName;
// I might not use it, since I can predict what the name is going to be! id.xx
}
$venue->save();
});
session()->flash('message', ['success', 'Successfully Updated!']);
return redirect(action('VenueController@index'));
}