Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

theihasan/geezap

97 stars
2 code files
View theihasan/geezap on GitHub

app/Observers/JobListingObserver.php

Open in GitHub
use App\Models\JobListing;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Str;
 
class JobListingObserver
{
public function creating(JobListing $jobListing): void
{
$jobListing->uuid = Str::uuid();
$jobListing->slug = Str::slug($jobListing->job_title.'-'.time());
}
 
public function created(JobListing $jobListing): void
{
$this->clearCache();
}
 
public function updated(JobListing $jobListing): void
{
$this->clearCache();
}
 
public function deleted(JobListing $jobListing): void
{
$this->clearCache();
}
 
protected function clearCache(): void
{
Cache::forget('jobs_page_*');
Cache::forget('mostViewedJobs');
Cache::forget('lastWeekAddedJobsCount');
 
Cache::forget('job_*');
Cache::forget('related_jobs_*');
 
Cache::forget('latestJobs');
Cache::forget('jobCategories');
Cache::forget('todayAddedJobsCount');
Cache::forget('jobCategoriesJobsCount');
Cache::forget('jobCategoriesCount');
Cache::forget('jobCategoriesAll');
}
}

app/Models/JobListing.php

Open in GitHub
use App\Observers\JobListingObserver;
use Illuminate\Database\Eloquent\Attributes\ObservedBy;
 
#[ObservedBy([JobListingObserver::class])]
class JobListing extends Model
{
// ...
}

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.