<?php

namespace App\Observers;

use App\Batch;
use Illuminate\Support\Facades\Auth;
use Illuminate\Database\Eloquent\SoftDeletes;

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

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

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

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

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

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

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

    /**
     * Handle the Batch "deleting" event.
     *
     * @param  \App\Batch  $Batch
     * @return void
     */
    public function deleting(Batch $Batch)
    {
        $id = Auth::id();

       
        $Batch->deleted_by=$id;   
    }
}
