public function testBelongsToRelation() { $this->initDB(); $this->assertEquals(Evidence::find($this->evidenceId), Event::find($this->eventId)->evidence); }
/** * Downloads the evidence for this ticket as EML * * @param Ticket $ticket Ticket Model * @param integer $evidenceId * @return \Illuminate\Http\Response */ public function downloadEvidence(Ticket $ticket, $evidenceId) { $evidence = Evidence::find($evidenceId); if (!$evidence) { return Redirect::route('admin.tickets.show', $ticket->id)->with('message', 'The evidence is no longer available for this event.'); } if (is_file($evidence->filename)) { $evidenceData = file_get_contents($evidence->filename); $outputFilename = "ticket_{$ticket->id}_evidence_{$evidenceId}.eml"; return response($evidenceData, 200)->header('Content-Type', 'message/rfc822')->header('Content-Transfer-Encoding', 'Binary')->header('Content-Disposition', 'attachment; filename="' . $outputFilename . '"'); } else { return Redirect::route('admin.tickets.show', $ticket->id)->with('message', 'ERROR: The file was not available on the filesystem.'); } }
/** * Testing the events() method on the model. */ public function testHasManyEvents() { $this->initDB(); $this->assertTrue(Evidence::find($this->evidenceId)->events->contains(Event::find($this->eventId)->id)); }