<?php

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

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

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

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

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

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

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

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

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