LoadSampleData.php 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <?php
  2. namespace App\Console\Commands;
  3. use Illuminate\Console\Command;
  4. use App\Models\Comment;
  5. use App\Models\Article;
  6. use App\Models\Author;
  7. use App\Models\Book;
  8. class LoadSampleData extends Command
  9. {
  10. /**
  11. * The name and signature of the console command.
  12. *
  13. * @var string
  14. */
  15. protected $signature = 'app:load-sample-data';
  16. /**
  17. * The console command description.
  18. *
  19. * @var string
  20. */
  21. protected $description = 'Command description';
  22. /**
  23. * Execute the console command.
  24. */
  25. public function handle()
  26. {
  27. $article = new Article;
  28. $article->title = "Использование netcat-openbsd в качестве HTTP сервера";
  29. $article->description = "Если нет нормального веб-сервера...";
  30. $article->content = "<p>При необходимости передать файл по HTTP, но отсутствии какого-либо веб-сервера, можно использовать netcat:</p><pre><code>cat <(echo -en \"HTTP/1.0 200 OK\\r\\n\\r\\n\") arch/x86/boot/bzImage | nc -N -l -p 8080</code></pre>";
  31. $article->publish_at = now();
  32. $article->status = Article::STATUS_PUBLISHED;
  33. $article->save();
  34. $article->comments()->create([
  35. "name" => "somebody",
  36. "email" => "a@mail.ru",
  37. "content" => "Ну и дичь",
  38. ]);
  39. $article->comments()->create([
  40. "name" => "bodysome",
  41. "email" => "b@mail.ru",
  42. "content" => "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
  43. ]);
  44. $article = new Article;
  45. $article->title = "Построение спектрограмм при помощи ffmpeg";
  46. $article->description = "Спектрограммы с микрофона в реальном времени";
  47. $article->content = "<p>Под Linux, если есть pipewire (Или вообще везде так можно?), можно сделать так:<p><pre><code>ffplay -f lavfi -i 'amovie=mpv:f=pulse,aderivative,volume=10,showspectrum=color=viridis:s=1024x384' -an</code></pre><p>Просмотреть доступные устройства можно так:</p><pre><code>$ pw-link -o\nMidi-Bridge:Midi Through:(capture_0) Midi Through Port-0\nalsa_output.pci-0000_00_1f.3.analog-stereo:monitor_FL\nalsa_output.pci-0000_00_1f.3.analog-stereo:monitor_FR\nalsa_input.pci-0000_00_1f.3.analog-stereo:capture_FL\nalsa_input.pci-0000_00_1f.3.analog-stereo:capture_FR\nmpv:output_FL\nmpv:output_FR\n</code></pre>";
  48. $article->publish_at = now();
  49. $article->status = Article::STATUS_PUBLISHED;
  50. $article->save();
  51. $article = new Article;
  52. $article->title = "Test article";
  53. $article->description = "Short description";
  54. $article->content = "Test article contents";
  55. $article->publish_at = now();
  56. $article->save();
  57. $author = new Author;
  58. $author->name = "Howard Johnson";
  59. $author->save();
  60. $book = new Book;
  61. $book->name = "High-Speed Digital Design: A Handbook of Black Magic";
  62. $book->isbn = "9780133957242";
  63. $book->year = 1993;
  64. $book->pagecount = 446;
  65. $book->author_id = $author->id;
  66. $book->annotation = "Focuses on a combination of digital and analog circuit theory. Helps engineers who work with digital systems, shorten their product development cycles and fix their latest high-speed design problems. DLC: Digital electronics.";
  67. $book->save();
  68. $author = new Author;
  69. $author->name = "Харкевич А.А.";
  70. $author->save();
  71. $book = new Book;
  72. $book->name = "Основы радиотехники";
  73. $book->isbn = "978-5-9221-0790-7";
  74. $book->year = 2007;
  75. $book->pagecount = 512;
  76. $book->author_id = $author->id;
  77. $book->annotation = "В курс теоретических основ радиотехники вошли: общие вопросы передачи и приема сигналов, исследование прохождения электрических сигналов через внутренние цепи аппаратуры и распространения сигналов по линиям и волноводам, исследование основных радиотехнических процессов. Математический аппарат курса включает решение линейных дифференциальных уравнений с постоянными и переменными коэффициентами и решение нелинейных дифференциальных уравнений. Настоящее издание полностью воспроизводит текст издания 1962 года, которое было допущено Министерством высшего и среднего специального образования СССР в качестве учебного пособия для высших учебных заведений СССР.";
  78. $book->save();
  79. $author = new Author;
  80. $author->name = "Allen Downey";
  81. $author->save();
  82. $book = new Book;
  83. $book->name = "Think DSP";
  84. $book->isbn = "978-1491938454";
  85. $book->year = 2016;
  86. $book->pagecount = 153;
  87. $book->author_id = $author->id;
  88. $book->annotation = "If you understand basic mathematics and know how to program with Python, you're ready to dive into signal processing. While most resources start with theory to teach this complex subject, this practical book introduces techniques by showing you how they're applied in the real world. In the first chapter alone, you'll be able to decompose a sound into its harmonics, modify the harmonics, and generate new sounds.";
  89. $book->save();
  90. $book->comments()->create([
  91. "name" => "somebody",
  92. "email" => "a@mail.ru",
  93. "content" => "Отличная книга!"
  94. ]);
  95. $book = new Book;
  96. $book->name = "Think Stats";
  97. $book->isbn = "978-1491907337";
  98. $book->year = 2014;
  99. $book->pagecount = 264;
  100. $book->author_id = $author->id;
  101. $book->annotation = "If you know how to program, you have the skills to turn data into knowledge, using tools of probability and statistics. This concise introduction shows you how to perform statistical analysis computationally, rather than mathematically, with programs written in Python.";
  102. $book->save();
  103. $author = new Author;
  104. $author->name = "Robert Lucky";
  105. $author->save();
  106. $book = new Book;
  107. $book->name = "Silicon Dreams: Information, Man, and Machine";
  108. $book->isbn = "9780312029609";
  109. $book->year = 1989;
  110. $book->pagecount = 440;
  111. $book->author_id = $author->id;
  112. $book->annotation = "Silicon Dreams is a highly informed discussion of the new information age, from the Executive Director of Research at Bell Labs. Robert Lucky addresses such questions as what information is, how it is generated, captured, stored, and communicated, and goes on to explain information theory, cryptology, speech synthesis and recognition, and much more. Charts, diagrams, photographs.";
  113. $book->save();
  114. }
  115. }