@@ -22,6 +22,9 @@ |
||
| 22 | 22 | return $this->getUrlResourceResponse($url); |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | + /** |
|
| 26 | + * @return Url |
|
| 27 | + */ |
|
| 25 | 28 | protected function findUrlByUri($uri) |
| 26 | 29 | { |
| 27 | 30 | try { |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | /** |
| 50 | 50 | * Saves the URI and related URL object for the model. |
| 51 | 51 | * |
| 52 | - * @return Luminark\Url\Interfaces\HasUrlInterface URL resource object |
|
| 52 | + * @return HasUrlTrait URL resource object |
|
| 53 | 53 | */ |
| 54 | 54 | public function saveUri($uri = null) |
| 55 | 55 | { |
@@ -119,6 +119,7 @@ discard block |
||
| 119 | 119 | * Validates the URL value and makes sure it is unique. Override this |
| 120 | 120 | * method if custom validation is needed. |
| 121 | 121 | * |
| 122 | + * @param string $uri |
|
| 122 | 123 | * @return boolean URI validity status |
| 123 | 124 | */ |
| 124 | 125 | protected function validateUri($uri) |
@@ -12,7 +12,7 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | public function up() |
| 14 | 14 | { |
| 15 | - Schema::create('urls', function (Blueprint $table) { |
|
| 15 | + Schema::create('urls', function(Blueprint $table) { |
|
| 16 | 16 | $table->string('uri')->primary(); |
| 17 | 17 | $table->string('redirects_to')->nullable()->index(); |
| 18 | 18 | // Nullable morphs_to resource |
@@ -10,19 +10,19 @@ |
||
| 10 | 10 | public function boot() |
| 11 | 11 | { |
| 12 | 12 | $this->publishes([ |
| 13 | - __DIR__ . '/../database/migrations/' => database_path('migrations') |
|
| 13 | + __DIR__.'/../database/migrations/' => database_path('migrations') |
|
| 14 | 14 | ], 'migrations'); |
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | public function register() |
| 18 | 18 | { |
| 19 | - $this->app['events']->listen('eloquent.saved*', function ($model) { |
|
| 19 | + $this->app['events']->listen('eloquent.saved*', function($model) { |
|
| 20 | 20 | if ($model instanceof HasUrlInterface) { |
| 21 | 21 | $model->saveUri(); |
| 22 | 22 | } |
| 23 | 23 | }); |
| 24 | 24 | |
| 25 | - $this->app['events']->listen('eloquent.deleted*', function ($model) { |
|
| 25 | + $this->app['events']->listen('eloquent.deleted*', function($model) { |
|
| 26 | 26 | if ($model instanceof HasUrlInterface && $model->url) { |
| 27 | 27 | $model->url->delete(); |
| 28 | 28 | } |
@@ -21,12 +21,12 @@ discard block |
||
| 21 | 21 | protected static function boot() |
| 22 | 22 | { |
| 23 | 23 | parent::boot(); |
| 24 | - static::creating(function (Url $url) { |
|
| 24 | + static::creating(function(Url $url) { |
|
| 25 | 25 | $url->created_at = Carbon::now(); |
| 26 | 26 | }); |
| 27 | - static::deleting(function (Url $url) { |
|
| 27 | + static::deleting(function(Url $url) { |
|
| 28 | 28 | if ($url->redirectedToBy) { |
| 29 | - $url->redirectedToBy->each(function (Url $url) { |
|
| 29 | + $url->redirectedToBy->each(function(Url $url) { |
|
| 30 | 30 | $url->delete(); |
| 31 | 31 | }); |
| 32 | 32 | } |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | |
| 62 | 62 | public function getUrlAttribute() |
| 63 | 63 | { |
| 64 | - return '/' . $this->uri; |
|
| 64 | + return '/'.$this->uri; |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | public function __toString() |