. */ namespace App\Observers; use App\Application; use App\Vacancy; use Illuminate\Support\Facades\Log; class VacancyObserver { /** * Handle the vacancy "created" event. * * @param \App\Vacancy $vacancy * @return void */ public function created(Vacancy $vacancy) { // } /** * Handle the vacancy "updated" event. * * @param \App\Vacancy $vacancy * @return void */ public function updated(Vacancy $vacancy) { // } public function deleting(Vacancy $vacancy) { foreach(Application::with('response.vacancy')->get() as $app) { if ($app->response->vacancy->id == $vacancy->id) { $app->delete(); } } } /** * Handle the vacancy "deleted" event. * * @param \App\Vacancy $vacancy * @return void */ public function deleted(Vacancy $vacancy) { } /** * Handle the vacancy "restored" event. * * @param \App\Vacancy $vacancy * @return void */ public function restored(Vacancy $vacancy) { // } /** * Handle the vacancy "force deleted" event. * * @param \App\Vacancy $vacancy * @return void */ public function forceDeleted(Vacancy $vacancy) { // } }