File tree 2 files changed +15
-6
lines changed
2 files changed +15
-6
lines changed Original file line number Diff line number Diff line change 1
1
<?php namespace Conner \Tagging \Model ;
2
2
3
- use Conner \Tagging \Util ;
4
- use Illuminate \Database \Eloquent \Model as Eloquent ;
5
3
use Conner \Tagging \Contracts \TaggingUtility ;
4
+ use Illuminate \Database \Eloquent \Model as Eloquent ;
6
5
7
6
/**
8
7
* Copyright (C) 2014 Robert Conner
@@ -62,8 +61,8 @@ public function scopeSuggested($query)
62
61
}
63
62
64
63
/**
65
- * Set the name of the tag : $tag->name = 'myname';
66
- *
64
+ * Set the name of the tag : $tag->name = 'myname';
65
+ *
67
66
* @param string $value
68
67
*/
69
68
public function setNameAttribute ($ value )
@@ -77,7 +76,7 @@ public function setNameAttribute($value)
77
76
/**
78
77
* Look at the tags table and delete any tags that are no londer in use by any taggable database rows.
79
78
* Does not delete tags where 'suggest'value is true
80
- *
79
+ *
81
80
* @return int
82
81
*/
83
82
public static function deleteUnused ()
Original file line number Diff line number Diff line change 1
1
<?php namespace Conner \Tagging \Model ;
2
2
3
+ use Conner \Tagging \Contracts \TaggingUtility ;
3
4
use Illuminate \Database \Eloquent \Model as Eloquent ;
4
5
5
6
/**
@@ -11,6 +12,15 @@ class Tagged extends Eloquent
11
12
public $ timestamps = false ;
12
13
protected $ fillable = ['tag_name ' , 'tag_slug ' ];
13
14
15
+ public function __construct (array $ attributes = array ())
16
+ {
17
+ parent ::__construct ($ attributes );
18
+
19
+ if (function_exists ('app ' )) {
20
+ $ this ->taggingUtility = app (TaggingUtility::class);
21
+ }
22
+ }
23
+
14
24
/**
15
25
* Morph to the tag
16
26
*
@@ -28,7 +38,7 @@ public function taggable()
28
38
*/
29
39
public function tag ()
30
40
{
31
- $ model = Util:: tagModelString ();
41
+ $ model = $ this -> taggingUtility -> tagModelString ();
32
42
return $ this ->belongsTo ($ model , 'tag_slug ' , 'slug ' );
33
43
}
34
44
You can’t perform that action at this time.
0 commit comments