Example #1
0
 protected function findUrlByUri($uri)
 {
     try {
         $url = Url::findOrFail($uri);
     } catch (ModelNotFoundException $e) {
         throw new NotFoundHttpException(null, $e);
     }
     return $url;
 }
Example #2
0
 public function testResourceUrlDelete()
 {
     $resource = Resource::create(['title' => 'Test Deleting', 'uri' => 'test/deleting-1']);
     $resource->uri = 'test/deleting-2';
     $resource->save();
     $resource->uri = 'test/deleting-3';
     $resource->save();
     $resource->delete();
     $url3 = Url::find('test/deleting-3');
     $this->assertNull($url3, 'Url has not been properly deleted.');
     $url2 = Url::find('test/deleting-2');
     $this->assertNull($url2, 'Old Url has not been properly deleted.');
     $url1 = Url::find('test/deleting-1');
     $this->assertNull($url1, 'Old Url has not been properly deleted.');
 }
Example #3
0
 /**
  * Modifies the $originalUrl to redirect to $newUrl.
  * 
  * @param Url $originalUrl The URL that will be redirecting
  * @param Url $newUrl The URL that will be redirected to
  */
 protected function redirectUrl(Url $originalUrl, Url $newUrl)
 {
     $newUrl->redirectsTo()->dissociate();
     $newUrl->save();
     $originalUrl->redirectsTo()->associate($newUrl);
     $originalUrl->save();
 }