-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ability to use a link instead of a page #750
- Loading branch information
Showing
12 changed files
with
206 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
app/Database/migrations/2020_06_09_141153_pages_add_link.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
class PagesAddLink extends Migration | ||
{ | ||
/** | ||
* Add a `link` column and make the body optional. Also add a "new_window" bool | ||
* which determines if we open this link in a new window or not | ||
*/ | ||
public function up() | ||
{ | ||
Schema::table('pages', function (Blueprint $table) { | ||
$table->string('body')->change()->nullable(); | ||
$table->string('link') | ||
->default('') | ||
->nullable() | ||
->after('body'); | ||
|
||
$table->boolean('new_window')->default(false); | ||
}); | ||
} | ||
|
||
/** | ||
* @return void | ||
*/ | ||
public function down() | ||
{ | ||
Schema::table('fares', function (Blueprint $table) { | ||
$table->dropColumn('link'); | ||
$table->dropColumn('new_window'); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
namespace App\Exceptions; | ||
|
||
use App\Models\Page; | ||
|
||
class UnknownPageType extends AbstractHttpException | ||
{ | ||
private $page; | ||
|
||
public function __construct(Page $page) | ||
{ | ||
$this->page = $page; | ||
parent::__construct( | ||
400, | ||
'Unknown page type "'.$page->type.'"' | ||
); | ||
} | ||
|
||
/** | ||
* Return the RFC 7807 error type (without the URL root) | ||
*/ | ||
public function getErrorType(): string | ||
{ | ||
return 'unknown-page-type'; | ||
} | ||
|
||
/** | ||
* Get the detailed error string | ||
*/ | ||
public function getErrorDetails(): string | ||
{ | ||
return $this->getMessage(); | ||
} | ||
|
||
/** | ||
* Return an array with the error details, merged with the RFC7807 response | ||
*/ | ||
public function getErrorMetadata(): array | ||
{ | ||
return [ | ||
'id' => $this->page->id, | ||
'type' => $this->page->type, | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters