/** * test when audit trai is not found with bad index */ function testFindAuditTrailwithIndexNotFound() { //arange $AuditTrail = new AuditTrail(); //act $result = $AuditTrail->find('100000'); //assert $this->assertNull($result); }
/** * Run the database seeds. * * @return void */ public function run() { DB::table('audit_trails')->delete(); AuditTrail::create(['user' => 'Luke Skywalker', 'browser' => 'chrome', 'ip_address' => '127.0.0.1', 'os' => 'MAC OSX']); }
/** * Display a listing of the resource. * * @return Response */ public function index() { $data = AuditTrail::all(); return response()->json($data, 200, array(), JSON_PRETTY_PRINT); }
/** * This function retrieves AuditTrails * * It receives as inputs Smsr-Id (Mandatory), EID (Mandatory) and AuditTrail identifier (Optional) * It searches in the audittrail model and retrieves the audittrail requested * Smsr-Id, EID and AuditTrail input paramater may include the 'all' wilcard * When Audittrail is omitted, it searches all audit trails in the scope of the SMSSRId and Eid. * The function returns a HTTP response object. It contains the either the result of the search or an eror code. * * @param string $smsrid * @param string $eid * @param string $audittrailid * @return response * */ public function getAuditTrail($SmsrId, $Eid, $AuditTrailId = null) { $AuditTrail = new AuditTrail(); if ($SmsrId == 'all') { if ($Eid == 'all') { if ($AuditTrailId == null) { //return all Audit Trails in base $Result = $AuditTrail->all(); } else { //return Audit Trail with id from all smsr and all eis $Result = $AuditTrail->find($AuditTrailId); } } else { if ($AuditTrailId == null) { //return all Audit Trails with id for a specific EIS on any SMSR $Result = $AuditTrail->where('eid', $Eid)->get(); } else { //return a specific Audit Trail from a specific EIS on any SMSR $Result = $AuditTrail->where('eid', $Eid)->find($AuditTrailId); } } } else { if ($Eid == 'all') { if ($AuditTrailId == null) { //return all Audit Trails in base $Result = $AuditTrail->all(); } else { //return Audit Trail with id from all smsr and all eis $Result = $AuditTrail->find($AuditTrailId); } } else { if ($AuditTrailId == null) { //return all Audit Trails with id for a specific EIS on any SMSR $Result = $AuditTrail->where('eid', $Eid)->get(); } else { //return a specific Audit Trail from a specific EIS on any SMSR $Result = $AuditTrail->where('eid', $Eid)->find($AuditTrailId); } } } return response()->json($Result); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $audits = AuditTrail::orderBy('id', 'desc')->paginate(env('PAGINATION_MAX')); return view('backend.audits.index')->with('audits', $audits); }