Ticket.php 566 B

1234567891011121314151617181920212223242526272829
  1. <?php
  2. namespace App\Models;
  3. /**
  4. * Ticket Model
  5. */
  6. class Ticket extends Model
  7. {
  8. protected $connection = "default";
  9. protected $table = "ticket";
  10. public function datetime()
  11. {
  12. return date("Y-m-d H:i:s", $this->attributes['datetime']);
  13. }
  14. public function User()
  15. {
  16. $user = User::where("id", $this->attributes['userid'])->first();
  17. if ($user == null) {
  18. Ticket::where('id', '=', $this->attributes['id'])->delete();
  19. return null;
  20. } else {
  21. return $user;
  22. }
  23. }
  24. }