Esempio n. 1
0
 /**
  * Generates a list of the last $limit audits made to any objects of the class it is being called from.
  *
  * @param int $limit
  * @param string $order
  * @return mixed
  */
 public static function classAuditHistory($limit = 100, $order = 'desc')
 {
     return \AlexVergara\Auditable\Audit::where('auditable_type', get_called_class())->orderBy('updated_at', $order)->limit($limit)->get();
 }
Esempio n. 2
0
 /**
  * Called after record successfully created
  */
 public function postCreate()
 {
     // Check if we should store creations in our audit history
     if ((!isset($this->auditCreationsEnabled) || $this->auditCreationsEnabled) && (!isset($this->auditEnabled) || $this->auditEnabled)) {
         $audits[] = array('type' => 'CREATE', 'entity' => $this->getTable(), 'entity_id' => $this->getKey(), 'user_id' => $this->getUserId(), 'created_at' => new \DateTime(), 'updated_at' => new \DateTime());
         $audit = new Audit();
         \DB::table($audit->getTable())->insert($audits);
     }
 }