LoadSampleData.php 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. namespace App\Console\Commands;
  3. use Illuminate\Console\Command;
  4. use App\Models\Comment;
  5. use App\Models\Article;
  6. class LoadSampleData extends Command
  7. {
  8. /**
  9. * The name and signature of the console command.
  10. *
  11. * @var string
  12. */
  13. protected $signature = 'app:load-sample-data';
  14. /**
  15. * The console command description.
  16. *
  17. * @var string
  18. */
  19. protected $description = 'Command description';
  20. /**
  21. * Execute the console command.
  22. */
  23. public function handle()
  24. {
  25. $article = new Article;
  26. $article->title = "Использование netcat-openbsd в качестве HTTP сервера";
  27. $article->description = "Если нет нормального веб-сервера...";
  28. $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>";
  29. $article->publish_at = now();
  30. $article->status = Article::STATUS_PUBLISHED;
  31. $article->save();
  32. $article->comments()->create([
  33. "name" => "somebody",
  34. "email" => "a@mail.ru",
  35. "content" => "Ну и дичь",
  36. ]);
  37. $article->comments()->create([
  38. "name" => "bodysome",
  39. "email" => "b@mail.ru",
  40. "content" => "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
  41. ]);
  42. $article = new Article;
  43. $article->title = "Построение спектрограмм при помощи ffmpeg";
  44. $article->description = "Спектрограммы с микрофона в реальном времени";
  45. $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>";
  46. $article->publish_at = now();
  47. $article->status = Article::STATUS_PUBLISHED;
  48. $article->save();
  49. $article = new Article;
  50. $article->title = "Test article";
  51. $article->description = "Short description";
  52. $article->content = "Test article contents";
  53. $article->publish_at = now();
  54. $article->save();
  55. }
  56. }