File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change 33namespace Anorgan \LaravelCache ;
44
55use Illuminate \Database \Eloquent \Model ;
6+ use Illuminate \Database \Eloquent \Relations \Pivot ;
67use Illuminate \Support \Collection ;
78
89/**
@@ -18,6 +19,12 @@ class TagFinder
1819 public function find ($ models )
1920 {
2021 if ($ models instanceof Model) {
22+
23+ // Ignore Pivot models
24+ if ($ models instanceof Pivot) {
25+ return [];
26+ }
27+
2128 $ models = collect ([$ models ]);
2229 }
2330
@@ -45,13 +52,21 @@ private function getTagsFromCollection(Collection $collection)
4552 */
4653 private function getTags (Model $ model )
4754 {
55+ if ($ model instanceof Pivot) {
56+ // Ignore Pivot models
57+ return [];
58+ }
59+
4860 $ tags = [
4961 $ this ->createTag ($ model ),
5062 ];
5163
5264 foreach ($ model ->getRelations () as $ relation ) {
5365 if ($ relation instanceof Collection) {
5466 $ tags = array_merge ($ tags , $ this ->getTagsFromCollection ($ relation ));
67+ } elseif ($ relation instanceof Pivot) {
68+ // Ignore Pivot models
69+ $ tags = [];
5570 } elseif ($ relation instanceof Model) {
5671 $ tags = array_merge ($ tags , $ this ->getTags ($ relation ));
5772 }
You can’t perform that action at this time.
0 commit comments