Import.php 785 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Database\Eloquent\Factories\HasFactory;
  4. use Illuminate\Database\Eloquent\Model;
  5. class Import extends Model
  6. {
  7. use HasFactory;
  8. const DEFAULT_SORT_BY = 'created_at';
  9. const STATUS_PENDING = 'pending';
  10. const STATUS_COMPLETED = 'completed';
  11. const STATUS_FAILED = 'failed';
  12. protected $fillable = [
  13. 'type',
  14. 'year',
  15. 'filename',
  16. 'status',
  17. 'result',
  18. 'user_id',
  19. 'file_path',
  20. 'original_filename',
  21. ];
  22. public function log(string $message, string $level = 'INFO'): string
  23. {
  24. $d = date('Y-m-d H:i:s', strtotime('now'));
  25. $string = "$d\t$level:\t$message\n";
  26. $this->result = $this->result . $string;
  27. return $string;
  28. }
  29. }