Skip to content
This repository has been archived by the owner on Jun 29, 2021. It is now read-only.

Commit

Permalink
feat(Links): add title to links
Browse files Browse the repository at this point in the history
  • Loading branch information
José Postiga committed Sep 19, 2020
1 parent df8c985 commit b7bc72a
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 0 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ All notable changes to `laravel-portugal/api` will be documented in this file

- N/A

## 1.0.4 - 2020-09-19

### Added

- Title to links

## 1.0.3 - 2020-09-19

### Changed
Expand Down
2 changes: 2 additions & 0 deletions domains/Links/Controllers/LinksStoreController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public function __invoke(Request $request): Response
{
$this->validate($request, [
'link' => ['required', 'string'],
'title' => ['required', 'string'],
'description' => ['required', 'string'],
'author_name' => ['required', 'string'],
'author_email' => ['required', 'email'],
Expand All @@ -30,6 +31,7 @@ public function __invoke(Request $request): Response

$link = $this->links->create([
'link' => $request->input('link'),
'title' => $request->input('title'),
'description' => $request->input('description'),
'author_name' => $request->input('author_name'),
'author_email' => $request->input('author_email'),
Expand Down
1 change: 1 addition & 0 deletions domains/Links/Database/Factories/LinkFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public function definition(): array
{
return [
'link' => $this->faker->url,
'title' => $this->faker->title,
'description' => $this->faker->paragraph,
'cover_image' => 'cover_images/' . UploadedFile::fake()->image('cover_image')->getFilename(),
'author_name' => $this->faker->name,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class AddTitleColumnToLinksTable extends Migration
{
public function up(): void
{
Schema::table('links', function (Blueprint $table) {
$table->string('title')->nullable()->index();
});
}
}
1 change: 1 addition & 0 deletions domains/Links/Models/Link.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class Link extends Model

protected $fillable = [
'link',
'title',
'description',
'author_name',
'author_email',
Expand Down
1 change: 1 addition & 0 deletions domains/Links/Resources/LinkResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public function toArray($request): array
return [
'id' => $this->id,
'link' => $this->link,
'title' => $this->title,
'description' => $this->description,
'author_name' => $this->author_name,
'author_email' => $this->author_email,
Expand Down
1 change: 1 addition & 0 deletions domains/Links/Tests/Feature/LinksIndexTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public function it_lists_resources(): void
[
'id',
'link',
'title',
'description',
'cover_image',
'author_name',
Expand Down
3 changes: 3 additions & 0 deletions domains/Links/Tests/Feature/LinksStoreTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public function it_stores_resources(): void

$payload = [
'link' => $this->faker->url,
'title' => $this->faker->title,
'description' => $this->faker->paragraph,
'author_name' => $this->faker->name,
'author_email' => $this->faker->safeEmail,
Expand All @@ -51,6 +52,7 @@ public function it_stores_resources(): void

$this->seeInDatabase('links', [
'link' => $payload['link'],
'title' => $payload['title'],
'description' => $payload['description'],
'author_name' => $payload['author_name'],
'author_email' => $payload['author_email'],
Expand All @@ -74,6 +76,7 @@ public function it_fails_to_store_resources_on_validation_errors(): void
$this->post('/links')
->seeJsonStructure([
'link',
'title',
'description',
'author_name',
'author_email',
Expand Down
1 change: 1 addition & 0 deletions domains/Links/Tests/Unit/LinkModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ protected function setUp(): void
public function it_contains_required_properties(): void
{
self::assertIsString($this->model->link);
self::assertIsString($this->model->title);
self::assertIsString($this->model->description);
self::assertIsString($this->model->cover_image);
self::assertIsString($this->model->author_name);
Expand Down

0 comments on commit b7bc72a

Please sign in to comment.