mardi 28 mai 2019

$request returns different values depending on where I dump it

In my ReportController.php, my function receives Request $request, as below:

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;
    }
}

Strangely enough, the value of $request changes depending on where I dump/store them. For example, in my log file where I log using \Log::info($request), it displays something like:

[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,
    )),
  ),
)  

but in my error_log($request) which dumps the value in console, it displays

[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

It's the same when I stored the $request value inside database. I meant to store the $request value that's being displayed as in my laravel log file, but instead it saved the value of $request as what's being displayed in my console.

What did I miss here?



from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/2W72mD4
via IFTTT

Aucun commentaire:

Enregistrer un commentaire