Пример #1
0
 public function run()
 {
     $faker = Faker\Factory::create();
     $users = \DarkShare\Users\User::lists('id')->all();
     foreach (range(1, 100) as $index) {
         $file = File::create(['user_id' => $faker->boolean() ? $faker->randomElement($users) : null, 'title' => $faker->sentence(), 'path' => '/home/vagrant/sites/darkshare/storage/app/testfile.md', 'password' => $faker->boolean() ? 'secret' : null]);
         FileSlug::create(['file_id' => $file->id, 'slug' => $file]);
     }
 }
 /**
  * Handle the command.
  *
  * @param  StoreNewFileCommand $command
  * @return void
  */
 public function handle(StoreNewFileCommand $command)
 {
     $command->path = $this->handleUploadedFile($command->file);
     if (empty($command->title)) {
         $command->title = htmlentities($command->file->getClientOriginalName());
     }
     $file = File::create(['user_id' => $this->auth->user() ? $this->auth->user()->id : null, 'title' => $command->title, 'path' => $command->path, 'password' => $command->password]);
     FileSlug::create(['file_id' => $file->id, 'slug' => $file]);
     return $file;
 }