<?php

namespace App\Actions;
use Illuminate\Support\Facades\Auth;
use App\Models\Settings\Establishment;

class Ets {

    
    /**
     * get establishment ID
     * @return int
     */
    public function etsID() : int
    {   
        // Get user connected
        $user = Auth::user();
        $etsID = !empty($user->establishment_id) ? (int)$user->establishment_id : 0;

        //  Return ets id
        $data = Establishment::where('active', 1)
        ->where('establishmenttype_id', $etsID)
        ->where('deleted_at', null)
        ->first();

        return (!empty($data->establishmenttype_id)) ? $data->establishmenttype_id : 0;
    }


}










