PageRenderTime 37ms CodeModel.GetById 9ms RepoModel.GetById 0ms app.codeStats 0ms

/database/factories/ModelFactory.php

https://gitlab.com/macitsimsek/fastsubtitle
PHP | 110 lines | 90 code | 10 blank | 10 comment | 0 complexity | 6147e42166ea5d9003c5699d917fb342 MD5 | raw file
  1. <?php
  2. /*
  3. |--------------------------------------------------------------------------
  4. | Model Factories
  5. |--------------------------------------------------------------------------
  6. |
  7. | Here you may define all of your model factories. Model factories give
  8. | you a convenient way to create models for testing and seeding your
  9. | database. Just tell the factory how a default model should look.
  10. |
  11. */
  12. use App\Functions;
  13. use Carbon\Carbon;
  14. $factory->define(App\User::class, function (Faker\Generator $faker) {
  15. return [
  16. 'username' => str_replace('.','',$faker->unique()->userName),
  17. 'memberType' => $faker->randomElement(['normalMember','translatorMember','controllerMember','admin']),
  18. 'position' => $faker->randomElement(['newTranslator','goodTranslator','bestTranslator','excellentTranslator']),
  19. 'profilePicture' => rand(1,4).'.jpg',
  20. 'translateCount' => rand(1,100),
  21. 'password' => md5('123456'),
  22. 'email' => $faker->unique()->email,
  23. 'ipAdress' => $faker->ipv4,
  24. 'approved' => 1
  25. ];
  26. });
  27. $factory->define(App\VideoProperty::class, function (Faker\Generator $faker) {
  28. return [
  29. 'type' => $faker->randomElement(['serie','movie','anime']),
  30. 'name' => $faker->unique()->name,
  31. 'turkishName' => $faker->unique()->text(20),
  32. 'kind' => $faker->firstName.', '.$faker->firstName.' ,'.$faker->firstName,
  33. 'imdbPoint' => rand(7,10),
  34. 'duration' => rand(80,150),
  35. 'country' => $faker->country,
  36. 'dateVision' => $faker->date(),
  37. 'abstract' => $faker->text(800),
  38. 'trailer' => $faker->randomElement(['https://www.youtube.com/embed/m5Jmh9JKnyQ','https://www.youtube.com/embed/RxK48ixsq-A']),
  39. 'picture' => Functions::downloadPicture($faker->imageUrl(175,250),$faker->unique()->name,'videoImages'),
  40. 'vote' => rand(5,10),
  41. 'view' => rand(1000,10000)
  42. ];
  43. });
  44. $factory->define(App\People::class, function (Faker\Generator $faker) {
  45. return [
  46. 'personName' => $faker->unique()->name,
  47. 'personPicture' => Functions::downloadPicture($faker->imageUrl(175,250),$faker->unique()->name,'peopleImages'),
  48. 'content' => $faker->text(500)
  49. ];
  50. });
  51. $factory->define(App\VideoPeople::class, function (Faker\Generator $faker) {
  52. $rol=$faker->randomElement(['actor','director']);
  53. return [
  54. 'videoID' => rand(1,10),
  55. 'personID' => rand(1,20),
  56. 'job' => $rol,
  57. 'rol' => ($rol)=='actor' ? $faker->name:''
  58. ];
  59. });
  60. $factory->define(App\Subtitle::class, function (Faker\Generator $faker) {
  61. $type = $faker->randomElement(['serie','movie']);
  62. return [
  63. 'uploaderID' => rand(1,10),
  64. 'translatingSrtPath' => 'example.srt',
  65. 'translatedSrtPath' => '',
  66. 'lastUpdaterID' => rand(1,10),
  67. 'requestCount' => rand(10,200),
  68. 'progress' => rand(0,99),
  69. 'fromLanguage' => $faker->randomElement(['turkish','english','french','spanish','italian','german']),
  70. 'toLanguage' => $faker->randomElement(['turkish','english','french','spanish','italian','german']),
  71. 'videoID' => rand(1,10),
  72. 'season' => $type== 'movie'? rand(1,10) : null,
  73. 'part' => $type== 'movie'? rand(1,20) : null,
  74. 'partTrailer' => null
  75. ];
  76. });
  77. $factory->define(App\SubtitleRequester::class, function (Faker\Generator $faker) {
  78. return [
  79. 'subtitleID' => rand(1,400),
  80. 'userID' => rand(1,10)
  81. ];
  82. });
  83. $factory->define(App\SubtitleSupport::class, function (Faker\Generator $faker) {
  84. return [
  85. 'fromLanguage' => $faker->randomElement(['turkish','english','german']),
  86. 'toLanguage' => $faker->randomElement(['turkish','english','german']),
  87. 'sentence' => $faker->unique()->sentence,
  88. 'mean' => $faker->unique()->sentence,
  89. 'createTime' => Carbon::now()
  90. ];
  91. });
  92. $factory->define(App\VideoComment::class, function (Faker\Generator $faker) {
  93. return [
  94. 'videoID' => rand(1,12),
  95. 'commenterID' => rand(1,10),
  96. 'comment' => $faker->unique()->sentence,
  97. 'like' => rand(1,20),
  98. 'unlike' => rand(1,4)
  99. ];
  100. });