<?php

namespace App\Observers;
use Illuminate\Support\Facades\Auth;
use App\Faculty;
use Illuminate\Database\Eloquent\SoftDeletes;

class FacultyObserver
{
    use SoftDeletes;
    /**
     * Handle the faculty "created" event.
     *
     * @param  \App\Faculty  $faculty
     * @return void
     */
    public function created(Faculty $faculty)
    {
        //
    }

    /**
     * Handle the faculty "updated" event.
     *
     * @param  \App\Faculty  $faculty
     * @return void
     */
    public function updated(Faculty $faculty)
    {
        //
    }

    /**
     * Handle the faculty "deleted" event.
     *
     * @param  \App\Faculty  $faculty
     * @return void
     */
    public function deleted(Faculty $faculty)
    {
        $id = Auth::id();
        error_log("Deleted".$id);
       
        $faculty->deleted_by=$id;   
    }

    /**
     * Handle the faculty "restored" event.
     *
     * @param  \App\Faculty  $faculty
     * @return void
     */
    public function restored(Faculty $faculty)
    {
        //
    }

    /**
     * Handle the faculty "force deleted" event.
     *
     * @param  \App\Faculty  $faculty
     * @return void
     */
    public function forceDeleted(Faculty $faculty)
    {
        //
    }

    /**
     * Handle the Faculty "creating" event.
     *
     * @param  \App\Faculty  $Faculty
     * @return void
     */
    public function creating(Faculty $faculty)
    {
      
        $id = Auth::id();
        $faculty->created_by=$id;
        $faculty->updated_by=$id;   
    }

    /**
     * Handle the Faculty "updating" event.
     *
     * @param  \App\Faculty  $Faculty
     * @return void
     */
    public function updating(Faculty $faculty)
    {
      
        $id = Auth::id();
        $faculty->updated_by=$id;   
    }

    /**
     * Handle the Faculty "deleting" event.
     *
     * @param  \App\Faculty  $Faculty
     * @return void
     */
    public function deleting(Faculty $faculty)
    {
        $id = Auth::id();
        error_log("Deleting".$id);
       
        $faculty->deleted_by=$id;   
    }
}
