Exemplo n.º 1
0
 /**
  * Get the checked out records of this user
  * @method getCheckedOutRecords
  * @return [type]               [description]
  */
 public function getCheckedOutRecords($class = null)
 {
     $locks = RecordLock::ofUser($this->id)->ofType($class);
     $collection = new Collection();
     foreach ($locks->get() as $lock) {
         $model_class = $lock->lockable_type;
         $id = $lock->lockable_id;
         $model = $model_class::find($id);
         if (!!$model) {
             $collection->push($model);
         }
     }
     return $collection;
 }
Exemplo n.º 2
0
 /**
  * Get all checked out records
  *  not by the current user
  * @method getCheckedOutRecords
  * @return [type]               [description]
  */
 public function getCheckedOutRecords($model)
 {
     $class = "App\\{$model}";
     $id = Auth::id();
     return response()->json(RecordLock::with(['user.person'])->ofType($class)->notOfUser($id)->get());
     //->where('user_id','!=',$id);
 }
Exemplo n.º 3
0
 /**
  * Checkout this model to the specified id
  * @method checkoutToId
  * @param  [type]       $id [description]
  * @return [type]           [description]
  */
 public function checkoutToId($id)
 {
     RecordLock::create(['lockable_id' => $this->id, 'lockable_type' => get_class($this), 'user_id' => $id]);
     return $this;
 }