<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;


/**
 * App\Models\Import
 *
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Import newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Import newQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Import query()
 * @mixin \Eloquent
 */
class Import extends Model
{
    public static $start;
    public static $max_time;



    public static $rules = [
        'file' => 'required|mimes:xls,xlsx'
    ];

    public static $messages = [
        'file.mimes' => 'Datei ist kein Excel Format',
        'file.required' => 'Excel is required'
    ];

    protected static $row = [];

    public static function setRow($row){

        //  self::checkTime();
        self::$row[] = $row;
    }


    public static function checkTime(){

        if(round((microtime(true) - self::$start), 2) > 29){
            echo 'Total execution time in seconds: ' . round((microtime(true) - self::$start), 2);
            die();
            return true;
        }
        return false;
    }

    public static function countRows(){
        return count(self::$row);
    }


    public static function break(){
        echo count(self::$row)."<br>";
        echo 'Total execution time in seconds: ' . round((microtime(true) - self::$start), 2);
        die();

    }




}
