Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. <?php
  2.  
  3. public function filenameFormatter($entityType, $entityId, $mimeType)
  4. {
  5. $timestamp = Carbon::now()->format('YmdHis');
  6.  
  7. // Extract MIME Type
  8. $explodedMimeType = explode('/', $mimeType);
  9. $type = $explodedMimeType[0];
  10. $subType = $explodedMimeType[1];
  11.  
  12. return "{$timestamp}_{$entityType}_{$entityId}_{$type}.{$subType}";
  13. }
  14.  
  15. public function filenameFormatterTest()
  16. {
  17. $newFilename = $this->filenameFormatter('post', '1234', 'image/png');
  18. echo $newFilename;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement