<?php

namespace App;

use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Facades\Auth;

class Dump
{

    public static $ESIGN = 'esign';

    public static function log($string, $fileName = 'cf-debug'){
        $file_name = storage_path().'/logs/'.$fileName.'-'.date('Y-m-d');

        $file = fopen($file_name, "a");

        if (Auth::check()){
            $user = Auth::user();
            $string['name'] = ucwords($user->name);
            $string['id'] = $user->id;
        }

        $string['date'] = date('Y-m-d H:i:s');

        fputcsv($file, ['payload' => json_encode($string)]);

        fclose($file);

        return $file_name;
    }
}
