Don’t use NotePrep for retreiving tags from a note
This commit is contained in:
parent
cac29bbb63
commit
58c060ad27
1 changed files with 7 additions and 5 deletions
|
@ -5,7 +5,6 @@ namespace App\Providers;
|
|||
use App\Tag;
|
||||
use App\Note;
|
||||
use Validator;
|
||||
use Jonnybarnes\IndieWeb\NotePrep;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
|
@ -32,11 +31,14 @@ class AppServiceProvider extends ServiceProvider
|
|||
|
||||
//Add tags for notes
|
||||
Note::created(function ($note) {
|
||||
$noteprep = new NotePrep();
|
||||
$tagsToAdd = [];
|
||||
$tags = $noteprep->getTags($note->note);
|
||||
foreach ($tags as $text) {
|
||||
$tag = Tag::firstOrCreate(['tag' => $text]);
|
||||
preg_match_all('/#([^\s<>]+)\b/', $note, $tags);
|
||||
foreach ($tags[1] as $tag) {
|
||||
$tag = Tag::normalizeTag($tag);
|
||||
}
|
||||
$tags = array_unique($tags[1]);
|
||||
foreach ($tags as $tag) {
|
||||
$tag = Tag::firstOrCreate(['tag' => $tag]);
|
||||
$tagsToAdd[] = $tag->id;
|
||||
}
|
||||
if (count($tagsToAdd > 0)) {
|
||||
|
|
Loading…
Add table
Reference in a new issue