public function show($post_id, $revision_id) { $revision = Revision::findOrfail($revision_id); return view('admin::posts.revisions.show', compact('post_id', 'revision')); }
/** * Generates a list of the last $limit revisions made to any objects of the class it is being called from. * * @param int $limit * @param string $order * @return mixed */ public static function classRevisionHistory($limit = 100, $order = 'desc') { return \Venturecraft\Revisionable\Revision::where('revisionable_type', get_called_class())->orderBy('updated_at', $order)->limit($limit)->get(); }
/** * Display the specified revision. * * @param int $id * @return \Dingo\Api\Http\Response */ public function show($id) { $revision = $this->revision->findOrFail($id); return $this->response->item($revision, new RevisionTransformer()); }
/** * Called after record successfully created */ public function postCreate() { // Check if we should store creations in our revision history // Set this value to true in your model if you want to if (empty($this->revisionCreationsEnabled)) { // We should not store creations. return false; } if (!isset($this->revisionEnabled) || $this->revisionEnabled) { $revisions[] = array('revisionable_type' => get_class($this), 'revisionable_id' => $this->getKey(), 'key' => 'created_at', 'old_value' => null, 'new_value' => $this->created_at, 'user_id' => $this->getUserId(), 'created_at' => new \DateTime(), 'updated_at' => new \DateTime()); $revision = new Revision(); \DB::table($revision->getTable())->insert($revisions); } }
/** * Called after a model is successfully saved. * * @return void */ public function postSave() { // check if the model already exists if ((!isset($this->revisionEnabled) || $this->revisionEnabled) && $this->updating) { // if it does, it means we're updating $changes_to_record = $this->changedRevisionableFields(); $revisions = array(); foreach ($changes_to_record as $key => $change) { $revisions[] = array('revisionable_type' => get_class($this), 'revisionable_id' => $this->getKey(), 'key' => $key, 'old_value' => array_get($this->originalData, $key), 'new_value' => $this->updatedData[$key], 'user_id' => $this->getUserId(), 'created_at' => new \DateTime(), 'updated_at' => new \DateTime()); } if (count($revisions) > 0) { $revision = new Revision(); \DB::table($revision->getTable())->insert($revisions); } } }
public function show($post_id, $revision_id) { $revision = Revision::findOrfail($revision_id); return response()->json($revision); }
/** * Insert revisions in database. * * We use the database query builder instead of Eloquent to make insert * queries spanning multiple records more effecient. * * @param array $revisions * * @return void */ protected function dbInsert(array $revisions) { $revision = new Revision(); $table = $revision->getTable(); DB::table($table)->insert($revisions); }
private function storeRevisions($revisions) { if (isset($this->historyLimit) && $this->revisionHistory()->count() >= $this->historyLimit && !$this->isPersistenceModeEnabled()) { $LimitReached = true; } else { $LimitReached = false; } if (isset($this->revisionCleanup)) { $RevisionCleanup = $this->revisionCleanup; } else { $RevisionCleanup = false; } if (count($revisions) > 0) { if ($LimitReached && $RevisionCleanup) { $toDelete = $this->revisionHistory()->orderBy('id', 'asc')->limit(count($revisions))->get(); foreach ($toDelete as $delete) { $delete->delete(); } } $revision = new Revision(); \DB::table($revision->getTable())->insert($revisions); } }
public function index() { $picture_fields = ['scanned_ktp', 'scanned_npwp', 'front_picture', 'left_picture', 'dp_evidence', 'akad_evidence']; $data = ['customer' => Customer::count(), 'unit' => Unit::count(), 'booked_valid' => BookedUnit::where('is_valid', '=', 1)->count(), 'booked_invalid' => BookedUnit::where('is_valid', '=', 0)->count(), 'history' => \Venturecraft\Revisionable\Revision::take(10)->orderBy('created_at', 'desc')->whereNotIn('key', $picture_fields)->get()]; return View::make('admin.index', compact('data')); }