Remove unused validation rule, and remove note tagging code, its now in the references observer
This commit is contained in:
parent
aa7e5b259c
commit
14cba19903
1 changed files with 2 additions and 31 deletions
|
@ -2,10 +2,9 @@
|
||||||
|
|
||||||
namespace App\Providers;
|
namespace App\Providers;
|
||||||
|
|
||||||
use App\Tag;
|
|
||||||
use App\Note;
|
use App\Note;
|
||||||
use Validator;
|
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use App\Observers\NoteObserver;
|
||||||
use Laravel\Dusk\DuskServiceProvider;
|
use Laravel\Dusk\DuskServiceProvider;
|
||||||
use Illuminate\Support\ServiceProvider;
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
|
||||||
|
@ -18,35 +17,7 @@ class AppServiceProvider extends ServiceProvider
|
||||||
*/
|
*/
|
||||||
public function boot()
|
public function boot()
|
||||||
{
|
{
|
||||||
// Validate photos for a maximum filesize
|
Note::observe(NoteObserver::class);
|
||||||
Validator::extend('photosize', function ($attribute, $value, $parameters, $validator) {
|
|
||||||
if ($value[0] !== null) {
|
|
||||||
foreach ($value as $file) {
|
|
||||||
if ($file->getSize() > 5000000) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
|
|
||||||
//Add tags for notes
|
|
||||||
Note::created(function ($note) {
|
|
||||||
$tagsToAdd = [];
|
|
||||||
preg_match_all('/#([^\s<>]+)\b/', $note->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) {
|
|
||||||
$note->tags()->attach($tagsToAdd);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Request AS macro
|
// Request AS macro
|
||||||
Request::macro('wantsActivityStream', function () {
|
Request::macro('wantsActivityStream', function () {
|
||||||
|
|
Loading…
Add table
Reference in a new issue