В моем ReportController.php
моя функция получает Request $request
, как показано ниже:
class ReportController extends Controller{
public function store(Request $request)
{
\Log::info("Request content:");
\Log::info($request);
error_log("request:");
error_log($request);
$insertID = Report::create([
'action' => $request->action,
'reportID' => $request->reportID,
'incidentDate' => $request->incidentDate,
'who' => $request->who,
'location' => $request->location,
'description' => $request->details,
'submittedByName' => $request->submittedByName,
'submittedByMobile' => $request->submittedByMobile,
'submittedByEmail' => $request->submittedByEmail,
'attachments' => $attachments,
'attachmentCount' => $attachmentCount,
'request' => $request
])->id;
}
}
Как ни странно, значение $request
изменяется в зависимости от того, где я их сохраняю / храню.Например, в моем файле журнала, где я веду журнал, используя \Log::info($request)
, он отображает что-то вроде:
[2019-05-28 17:35:27] local.INFO: array (
'action' => 'TellUsMore',
'reportID' => 'b19xr211gcbvc',
'incidentDate' => '2019-05-29',
'location' => 'ggg',
'description' => 'gg',
'suggestion' => 'sdfsdf',
'files' =>
array (
0 =>
Illuminate\Http\UploadedFile::__set_state(array(
'test' => false,
'originalName' => 'reports (1).xlsx',
'mimeType' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
'error' => 0,
'hashName' => NULL,
)),
1 =>
Illuminate\Http\UploadedFile::__set_state(array(
'test' => false,
'originalName' => 'love your parents - we\'re so busy growing up, we often forget that they\'re growing old.jpg',
'mimeType' => 'image/jpeg',
'error' => 0,
'hashName' => NULL,
)),
),
)
, но в моем error_log($request)
, который выводит значение в консоль, он отображает
[Wed May 29 01:35:27 2019] POST /api/report/store HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate
Cache-Control: no-cache
Connection: keep-alive
Content-Length: 25172
Content-Type: multipart/form-data; boundary=--------------------------416520203821764707296428
Host: localhost:8000
Postman-Token: 76adb08d-631e-4f10-9a5f-60bc8d015aed
User-Agent: PostmanRuntime/7.6.0
То же самое, когда я хранил значение $request
в базе данных.Я хотел сохранить значение $request
, которое отображается как в моем файле журнала laravel, но вместо этого он сохранил значение $request
как то, что отображается в моей консоли.
Что я здесь упустил?