Exemplo n.º 1
0
 public static function boot()
 {
     parent::boot();
     ShortLink::creating(function ($model) {
         $model->hash = self::makeHash($model->url);
     });
 }
Exemplo n.º 2
0
 public function handleShortcode($hash)
 {
     $shortLink = ShortLink::whereHash($hash)->first();
     if (isset($shortLink->url)) {
         $shortLink->increment('visits');
         return redirect($shortLink->url);
     }
     return redirect()->back('/');
 }