Skip to content

Commit 19331f7

Browse files
authored
Merge pull request #184 from mateusjunges/feature/short-description
Feature: add a short description to the tag
2 parents 833de03 + 188d80f commit 19331f7

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

migrations/2014_01_07_073615_create_tags_table.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ public function up()
1111
$table->increments('id');
1212
$table->string('slug', 125)->index();
1313
$table->string('name', 125);
14+
$table->text('description')->nullable();
1415
$table->boolean('suggest')->default(false);
1516
$table->integer('count')->unsigned()->default(0); // count of how many times this tag was used
1617
$table->integer('tag_group_id')->unsigned()->nullable();

src/Model/Tag.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,15 @@
1515
* @property integer count
1616
* @property integer tag_group_id
1717
* @property TagGroup group
18+
* @property string description
1819
* @method static suggested()
1920
* @method static inGroup(string $group)
2021
*/
2122
class Tag extends Model
2223
{
2324
protected $table = 'tagging_tags';
2425
public $timestamps = false;
25-
public $fillable = ['name'];
26+
public $fillable = ['name', 'description'];
2627

2728
/**
2829
* @param array $attributes

tests/TagBaseTest.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,19 @@ public function test_saving_a_tag()
1515
$this->assertEquals('Foobar', $tag->name);
1616
$this->assertEquals('foobar', $tag->slug);
1717
}
18-
}
18+
19+
public function test_it_can_have_a_description()
20+
{
21+
$description = 'Fooobar test description';
22+
$tag = new Tag([
23+
'name' => 'foobar',
24+
'description' => $description
25+
]);
26+
27+
$tag->save();
28+
29+
$this->assertEquals('Foobar', $tag->name);
30+
$this->assertEquals('foobar', $tag->slug);
31+
$this->assertEquals($description, $tag->description);
32+
}
33+
}

0 commit comments

Comments
 (0)