Import.php 710 B

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