Skip to content

Commit d40146e

Browse files
committed
Bug fixes and cleanup
1 parent 6a0ed4a commit d40146e

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

src/Model/Tag.php

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
<?php namespace Conner\Tagging\Model;
22

3-
use Conner\Tagging\Util;
4-
use Illuminate\Database\Eloquent\Model as Eloquent;
53
use Conner\Tagging\Contracts\TaggingUtility;
4+
use Illuminate\Database\Eloquent\Model as Eloquent;
65

76
/**
87
* Copyright (C) 2014 Robert Conner
@@ -62,8 +61,8 @@ public function scopeSuggested($query)
6261
}
6362

6463
/**
65-
* Set the name of the tag : $tag->name = 'myname';
66-
*
64+
* Set the name of the tag : $tag->name = 'myname';
65+
*
6766
* @param string $value
6867
*/
6968
public function setNameAttribute($value)
@@ -77,7 +76,7 @@ public function setNameAttribute($value)
7776
/**
7877
* Look at the tags table and delete any tags that are no londer in use by any taggable database rows.
7978
* Does not delete tags where 'suggest'value is true
80-
*
79+
*
8180
* @return int
8281
*/
8382
public static function deleteUnused()

src/Model/Tagged.php

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php namespace Conner\Tagging\Model;
22

3+
use Conner\Tagging\Contracts\TaggingUtility;
34
use Illuminate\Database\Eloquent\Model as Eloquent;
45

56
/**
@@ -11,6 +12,15 @@ class Tagged extends Eloquent
1112
public $timestamps = false;
1213
protected $fillable = ['tag_name', 'tag_slug'];
1314

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+
1424
/**
1525
* Morph to the tag
1626
*
@@ -28,7 +38,7 @@ public function taggable()
2838
*/
2939
public function tag()
3040
{
31-
$model = Util::tagModelString();
41+
$model = $this->taggingUtility->tagModelString();
3242
return $this->belongsTo($model, 'tag_slug', 'slug');
3343
}
3444

0 commit comments

Comments
 (0)