Esempio n. 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;
 }
Esempio n. 3
0
 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router $router
  * @return void
  */
 public function boot(Router $router)
 {
     parent::boot($router);
     $router->bind('snippets', function ($value) {
         return SnippetSlug::where(\DB::raw('BINARY slug'), $value)->firstOrFail()->snippet;
     });
     $router->bind('files', function ($value) {
         return FileSlug::where(\DB::raw('BINARY slug'), $value)->firstOrFail()->file;
     });
     $router->bind('urls', function ($value) {
         return UrlSlug::where(\DB::raw('BINARY slug'), $value)->firstOrFail()->url;
     });
     $router->bind('username', function ($value) {
         return User::where('username', $value)->firstOrFail();
     });
 }