Exemple #1
0
 /**
  * Display the specified url.
  *
  * @param Url   $url
  * @return Response
  */
 public function show(Url $url)
 {
     if ($url->isProtected() && \Hash::check(app()->request->password, $url->password)) {
         return $url->destination . PHP_EOL;
     }
     if (!$url->userHasAccess()) {
         return "Not authorized." . PHP_EOL;
     }
     return $url->destination . PHP_EOL;
 }
Exemple #2
0
 public function run()
 {
     $faker = Faker\Factory::create();
     $users = User::lists('id')->all();
     foreach (range(1, 100) as $index) {
         $url = Url::create(['user_id' => $faker->boolean() ? $faker->randomElement($users) : null, 'destination' => $faker->url, 'password' => $faker->boolean() ? 'secret' : null]);
         UrlSlug::create(['url_id' => $url->id, 'slug' => $url]);
     }
 }
Exemple #3
0
 /**
  * Remove the specified url from storage.
  *
  * @param  int  Url $url
  * @return Response
  */
 public function destroy(Url $url)
 {
     $url->delete();
     flash("URL successfully deleted.");
     return redirect()->back();
 }
 /**
  * Handle the creation of a new URL
  *
  * @param  StoreNewUrlCommand $command
  * @return void
  */
 public function handle(StoreNewUrlCommand $command)
 {
     $url = Url::create(['user_id' => $this->auth->user() ? $this->auth->user()->id : null, 'destination' => $command->destination, 'password' => $command->password]);
     UrlSlug::create(['url_id' => $url->id, 'slug' => $url]);
     return $url;
 }