32 lines
752 B
PHP
32 lines
752 B
PHP
<?php
|
|
|
|
namespace App\Providers;
|
|
|
|
use Illuminate\Support\Facades\Auth;
|
|
use Illuminate\Support\Facades\View;
|
|
use Illuminate\Support\ServiceProvider;
|
|
|
|
class AppServiceProvider extends ServiceProvider
|
|
{
|
|
public function register(): void
|
|
{
|
|
//
|
|
}
|
|
|
|
public function boot(): void
|
|
{
|
|
View::composer('components.job-card', function ($view) {
|
|
static $bookmarkedIds = null;
|
|
|
|
if ($bookmarkedIds === null) {
|
|
$bookmarkedIds = Auth::check()
|
|
? Auth::user()->savedJobs()->pluck('job_id')->flip()
|
|
: collect();
|
|
}
|
|
|
|
$job = $view->getData()['job'];
|
|
$view->with('bookmarked', $bookmarkedIds->has($job->id));
|
|
});
|
|
}
|
|
}
|