<?php

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

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

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

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

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

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

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

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

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