Skip to content

Commit

Permalink
Merge branch 'laravel-7' of github.com:rtconner/laravel-tagging into …
Browse files Browse the repository at this point in the history
…laravel-7
  • Loading branch information
rtconner committed Apr 28, 2020
2 parents 522e3c0 + fa13edb commit 84c18be
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 4 deletions.
7 changes: 5 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,8 @@
]
}
},
"minimum-stability": "dev"
}
"minimum-stability": "dev",
"scripts": {
"test": "./vendor/bin/phpunit tests"
}
}
23 changes: 23 additions & 0 deletions migrations/2020_03_13_083515_add_description_to_tags_table.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

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

class AddDescriptionToTagsTable extends Migration {

public function up()
{
Schema::table('tagging_tags', function ($table) {
$table->text('description')->nullable();
});

}


public function down()
{
Schema::table('tagging_tags', function ($table) {
$table->dropColumn('description');
});
}
}
3 changes: 2 additions & 1 deletion src/Model/Tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@
* @property integer count
* @property integer tag_group_id
* @property TagGroup group
* @property string description
* @method static suggested()
* @method static inGroup(string $group)
*/
class Tag extends Model
{
protected $table = 'tagging_tags';
public $timestamps = false;
public $fillable = ['name'];
public $fillable = ['name', 'description'];

/**
* @param array $attributes
Expand Down
17 changes: 16 additions & 1 deletion tests/TagBaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,19 @@ public function test_saving_a_tag()
$this->assertEquals('Foobar', $tag->name);
$this->assertEquals('foobar', $tag->slug);
}
}

public function test_it_can_have_a_description()
{
$description = 'Fooobar test description';
$tag = new Tag([
'name' => 'foobar',
'description' => $description
]);

$tag->save();

$this->assertEquals('Foobar', $tag->name);
$this->assertEquals('foobar', $tag->slug);
$this->assertEquals($description, $tag->description);
}
}

0 comments on commit 84c18be

Please sign in to comment.