Exemplo n.º 1
0
 /**
  * Remove the specified resources from storage.
  *
  * @param Request $request
  * @return \Illuminate\Http\Response
  */
 public function bulkDestroy(Request $request)
 {
     $this->authorize('EDIT_NODES');
     $ids = json_decode($request->input('_bulkSelected', '[]'));
     Node::whereIn('id', $ids)->whereLocked(0)->delete();
     $this->notify('nodes.destroyed', 'deleted_nodes');
     return redirect()->back();
 }
Exemplo n.º 2
0
 /**
  * Returns nodes by ids
  *
  * @param array|string $ids
  * @param bool $published
  * @return Collection
  */
 public function getNodesByIds($ids, $published = true)
 {
     if (empty($ids)) {
         return null;
     }
     if (is_string($ids)) {
         $ids = json_decode($ids, true);
     }
     if (is_array($ids) && !empty($ids)) {
         $placeholders = implode(',', array_fill(0, count($ids), '?'));
         $nodes = Node::whereIn('id', $ids)->orderByRaw('field(id,' . $placeholders . ')', $ids);
         if ($published) {
             $nodes->published();
         }
         $nodes = $nodes->get();
         return count($nodes) > 0 ? $nodes : null;
     }
     return null;
 }