예제 #1
0
파일: Version.php 프로젝트: sidis405/ibi
 /**
  * Diff the attributes of this version model against another version.
  * If no version is provided, it will be diffed against the current version.
  *
  * @param Version|null $againstVersion
  * @return array
  */
 public function diff(Version $againstVersion = null)
 {
     $model = $this->getModel();
     $diff = $againstVersion ? $againstVersion->getModel() : $this->versionable()->withTrashed()->first()->currentVersion()->getModel();
     $diffArray = array_diff_assoc($diff->getAttributes(), $model->getAttributes());
     if (isset($diffArray[$model->getCreatedAtColumn()])) {
         unset($diffArray[$model->getCreatedAtColumn()]);
     }
     if (isset($diffArray[$model->getUpdatedAtColumn()])) {
         unset($diffArray[$model->getUpdatedAtColumn()]);
     }
     if (method_exists($model, 'getDeletedAtColumn') && isset($diffArray[$model->getDeletedAtColumn()])) {
         unset($diffArray[$model->getDeletedAtColumn()]);
     }
     return $diffArray;
 }
예제 #2
0
 function __construct()
 {
     parent::__construct();
     $utenti_in_attesa = User::with('roles', 'profile.provincia_albo_rel', 'profile.specializzazione_rel')->whereHas('roles', function ($q) {
         $q->where('name', '=', 'Medico')->orWhere('name', '=', 'Farmacista');
     })->where('active', 0)->orderBy('first_name')->get();
     $modifiche_in_attesa = Version::with('user')->where('hide', 0)->where('active', 0)->where('seen', 0)->latest()->get();
     // dd($modifiche_in_attesa->toArray());
     view()->share('lista_utenti_in_attesa', $utenti_in_attesa);
     view()->share('count_utenti_in_attesa', count($utenti_in_attesa));
     view()->share('lista_modifiche_in_attesa', $modifiche_in_attesa);
     view()->share('count_modifiche_in_attesa', count($modifiche_in_attesa));
 }
예제 #3
0
 /**
  * Save a new version.
  * @return void
  */
 protected function versionablePostSave()
 {
     /**
      * We'll save new versions on updating and first creation
      */
     if ($this->versioningEnabled === true && $this->updating && $this->isValidForVersioning() || $this->versioningEnabled === true && !$this->updating) {
         // Save a new version
         $version = new Version();
         $version->versionable_id = $this->getKey();
         $version->versionable_type = get_class($this);
         $version->user_id = $this->getAuthUserId();
         $version->model_data = serialize($this->getAttributes());
         if (!empty($this->reason)) {
             $version->reason = $this->reason;
         }
         $version->save();
     }
 }
예제 #4
0
 public function getAll()
 {
     return Version::with('baseContenutoTranslation.contenuto.pagina', 'user')->where('hide', 0)->latest()->get();
 }