2018-04-15 23:56:48 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Providers;
|
|
|
|
|
2025-01-04 06:28:57 +00:00
|
|
|
use App\Avatar;
|
|
|
|
use App\Follower;
|
|
|
|
use App\HashtagFollow;
|
|
|
|
use App\Like;
|
|
|
|
use App\ModLog;
|
|
|
|
use App\Notification;
|
|
|
|
use App\Observers\AvatarObserver;
|
|
|
|
use App\Observers\FollowerObserver;
|
|
|
|
use App\Observers\HashtagFollowObserver;
|
|
|
|
use App\Observers\LikeObserver;
|
|
|
|
use App\Observers\ModLogObserver;
|
|
|
|
use App\Observers\NotificationObserver;
|
|
|
|
use App\Observers\ProfileObserver;
|
|
|
|
use App\Observers\StatusHashtagObserver;
|
|
|
|
use App\Observers\StatusObserver;
|
|
|
|
use App\Observers\UserFilterObserver;
|
|
|
|
use App\Observers\UserObserver;
|
|
|
|
use App\Profile;
|
2025-01-04 07:52:24 +00:00
|
|
|
use App\Services\AccountService;
|
2025-01-04 06:28:57 +00:00
|
|
|
use App\Status;
|
|
|
|
use App\StatusHashtag;
|
|
|
|
use App\User;
|
|
|
|
use App\UserFilter;
|
|
|
|
use Auth;
|
|
|
|
use Horizon;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
2020-12-13 21:15:30 +00:00
|
|
|
use Illuminate\Pagination\Paginator;
|
2025-01-04 06:28:57 +00:00
|
|
|
use Illuminate\Support\Facades\Gate;
|
|
|
|
use Illuminate\Support\Facades\Schema;
|
2022-11-08 01:41:25 +00:00
|
|
|
use Illuminate\Support\Facades\Validator;
|
2025-01-04 06:28:57 +00:00
|
|
|
use Illuminate\Support\ServiceProvider;
|
2025-01-04 07:52:24 +00:00
|
|
|
use Laravel\Pulse\Facades\Pulse;
|
2025-01-04 06:28:57 +00:00
|
|
|
use URL;
|
2018-04-15 23:56:48 +00:00
|
|
|
|
|
|
|
class AppServiceProvider extends ServiceProvider
|
|
|
|
{
|
2025-01-04 06:28:57 +00:00
|
|
|
/**
|
|
|
|
* Bootstrap any application services.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function boot()
|
|
|
|
{
|
|
|
|
if (config('instance.force_https_urls', true)) {
|
|
|
|
URL::forceScheme('https');
|
|
|
|
}
|
2022-12-02 03:59:57 +00:00
|
|
|
|
2025-01-04 06:28:57 +00:00
|
|
|
Schema::defaultStringLength(191);
|
|
|
|
Paginator::useBootstrap();
|
|
|
|
Avatar::observe(AvatarObserver::class);
|
|
|
|
Follower::observe(FollowerObserver::class);
|
|
|
|
HashtagFollow::observe(HashtagFollowObserver::class);
|
|
|
|
Like::observe(LikeObserver::class);
|
|
|
|
Notification::observe(NotificationObserver::class);
|
|
|
|
ModLog::observe(ModLogObserver::class);
|
|
|
|
Profile::observe(ProfileObserver::class);
|
|
|
|
StatusHashtag::observe(StatusHashtagObserver::class);
|
|
|
|
User::observe(UserObserver::class);
|
2022-09-13 03:26:54 +00:00
|
|
|
Status::observe(StatusObserver::class);
|
2025-01-04 06:28:57 +00:00
|
|
|
UserFilter::observe(UserFilterObserver::class);
|
|
|
|
Horizon::auth(function ($request) {
|
|
|
|
return Auth::check() && $request->user()->is_admin;
|
|
|
|
});
|
|
|
|
Validator::includeUnvalidatedArrayKeys();
|
|
|
|
|
|
|
|
Gate::define('viewPulse', function (User $user) {
|
|
|
|
return $user->is_admin === 1;
|
|
|
|
});
|
2024-07-31 04:25:48 +00:00
|
|
|
|
2025-01-04 07:52:24 +00:00
|
|
|
Pulse::user(function ($user) {
|
|
|
|
$acct = AccountService::get($user->profile_id, true);
|
|
|
|
|
|
|
|
return $acct ? [
|
|
|
|
'name' => $acct['username'],
|
|
|
|
'extra' => $user->email,
|
|
|
|
'avatar' => $acct['avatar'],
|
|
|
|
] : [
|
|
|
|
'name' => $user->username,
|
|
|
|
'extra' => 'DELETED',
|
|
|
|
'avatar' => '/storage/avatars/default.jpg',
|
|
|
|
];
|
|
|
|
});
|
|
|
|
|
2025-01-04 06:28:57 +00:00
|
|
|
// Model::preventLazyLoading(true);
|
|
|
|
}
|
2018-06-01 23:39:45 +00:00
|
|
|
|
2025-01-04 06:28:57 +00:00
|
|
|
/**
|
|
|
|
* Register any application services.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function register()
|
|
|
|
{
|
|
|
|
//
|
|
|
|
}
|
2018-04-15 23:56:48 +00:00
|
|
|
}
|