saved jobs
This commit is contained in:
@@ -2,23 +2,30 @@
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\View;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Register any application services.
|
||||
*/
|
||||
public function register(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*/
|
||||
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));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user