2023_01_27_171019_create_visits_table.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. use Illuminate\Database\Migrations\Migration;
  3. use Illuminate\Database\Schema\Blueprint;
  4. use Illuminate\Support\Facades\Schema;
  5. class CreateVisitsTable extends Migration
  6. {
  7. /**
  8. * Run the migrations.
  9. *
  10. * @return void
  11. */
  12. public function up()
  13. {
  14. Schema::create(config('visitor.table_name'), function (Blueprint $table) {
  15. $table->bigIncrements('id');
  16. $table->string('method')->nullable();
  17. $table->mediumText('request')->nullable();
  18. $table->mediumText('url')->nullable();
  19. $table->mediumText('referer')->nullable();
  20. $table->text('languages')->nullable();
  21. $table->text('useragent')->nullable();
  22. $table->text('headers')->nullable();
  23. $table->text('device')->nullable();
  24. $table->text('platform')->nullable();
  25. $table->text('browser')->nullable();
  26. $table->ipAddress('ip')->nullable();
  27. $table->nullableMorphs('visitable'); // object model
  28. $table->nullableMorphs('visitor'); // subject model
  29. $table->timestamps();
  30. });
  31. }
  32. /**
  33. * Reverse the migrations.
  34. *
  35. * @return void
  36. */
  37. public function down()
  38. {
  39. Schema::dropIfExists(config('visitor.table_name'));
  40. }
  41. }