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

Commit b7bc72a

Browse files
author
José Postiga
committed
feat(Links): add title to links
1 parent df8c985 commit b7bc72a

File tree

9 files changed

+31
-0
lines changed

9 files changed

+31
-0
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ All notable changes to `laravel-portugal/api` will be documented in this file
2828

2929
- N/A
3030

31+
## 1.0.4 - 2020-09-19
32+
33+
### Added
34+
35+
- Title to links
36+
3137
## 1.0.3 - 2020-09-19
3238

3339
### Changed

domains/Links/Controllers/LinksStoreController.php

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public function __invoke(Request $request): Response
2020
{
2121
$this->validate($request, [
2222
'link' => ['required', 'string'],
23+
'title' => ['required', 'string'],
2324
'description' => ['required', 'string'],
2425
'author_name' => ['required', 'string'],
2526
'author_email' => ['required', 'email'],
@@ -30,6 +31,7 @@ public function __invoke(Request $request): Response
3031

3132
$link = $this->links->create([
3233
'link' => $request->input('link'),
34+
'title' => $request->input('title'),
3335
'description' => $request->input('description'),
3436
'author_name' => $request->input('author_name'),
3537
'author_email' => $request->input('author_email'),

domains/Links/Database/Factories/LinkFactory.php

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public function definition(): array
1616
{
1717
return [
1818
'link' => $this->faker->url,
19+
'title' => $this->faker->title,
1920
'description' => $this->faker->paragraph,
2021
'cover_image' => 'cover_images/' . UploadedFile::fake()->image('cover_image')->getFilename(),
2122
'author_name' => $this->faker->name,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
class AddTitleColumnToLinksTable extends Migration
8+
{
9+
public function up(): void
10+
{
11+
Schema::table('links', function (Blueprint $table) {
12+
$table->string('title')->nullable()->index();
13+
});
14+
}
15+
}

domains/Links/Models/Link.php

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class Link extends Model
1414

1515
protected $fillable = [
1616
'link',
17+
'title',
1718
'description',
1819
'author_name',
1920
'author_email',

domains/Links/Resources/LinkResource.php

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public function toArray($request): array
1212
return [
1313
'id' => $this->id,
1414
'link' => $this->link,
15+
'title' => $this->title,
1516
'description' => $this->description,
1617
'author_name' => $this->author_name,
1718
'author_email' => $this->author_email,

domains/Links/Tests/Feature/LinksIndexTest.php

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public function it_lists_resources(): void
2626
[
2727
'id',
2828
'link',
29+
'title',
2930
'description',
3031
'cover_image',
3132
'author_name',

domains/Links/Tests/Feature/LinksStoreTest.php

+3
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public function it_stores_resources(): void
3333

3434
$payload = [
3535
'link' => $this->faker->url,
36+
'title' => $this->faker->title,
3637
'description' => $this->faker->paragraph,
3738
'author_name' => $this->faker->name,
3839
'author_email' => $this->faker->safeEmail,
@@ -51,6 +52,7 @@ public function it_stores_resources(): void
5152

5253
$this->seeInDatabase('links', [
5354
'link' => $payload['link'],
55+
'title' => $payload['title'],
5456
'description' => $payload['description'],
5557
'author_name' => $payload['author_name'],
5658
'author_email' => $payload['author_email'],
@@ -74,6 +76,7 @@ public function it_fails_to_store_resources_on_validation_errors(): void
7476
$this->post('/links')
7577
->seeJsonStructure([
7678
'link',
79+
'title',
7780
'description',
7881
'author_name',
7982
'author_email',

domains/Links/Tests/Unit/LinkModelTest.php

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ protected function setUp(): void
2424
public function it_contains_required_properties(): void
2525
{
2626
self::assertIsString($this->model->link);
27+
self::assertIsString($this->model->title);
2728
self::assertIsString($this->model->description);
2829
self::assertIsString($this->model->cover_image);
2930
self::assertIsString($this->model->author_name);

0 commit comments

Comments
 (0)