Skip to content

Commit 4fe974e

Browse files
committed
Laravel 6 & 7 support
1 parent 24970a6 commit 4fe974e

6 files changed

Lines changed: 406 additions & 377 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ composer.phar
33
composer.lock
44
.DS_Store
55
build
6+
.phpunit.result.cache

composer.json

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,22 @@
22
"name": "trexology/taxonomy",
33
"description": "Create and manage a heirarchical taxonomy of terms within different vocabularies",
44
"license": "MIT",
5-
"keywords": ["taxonomy","laravel"],
5+
"keywords": [
6+
"taxonomy",
7+
"laravel"
8+
],
69
"authors": [
710
{
811
"name": "Trex Lim",
912
"email": "trexlim@gmail.com"
1013
}
1114
],
1215
"require": {
13-
"php": ">=5.4",
14-
"illuminate/support": "~5.0"
16+
"php": "^7.2",
17+
"illuminate/support": "^5.0|^6.0|^7.0"
1518
},
1619
"require-dev": {
17-
"mockery/mockery": "0.9.*",
20+
"mockery/mockery": "^1.3.1",
1821
"codeclimate/php-test-reporter": "dev-master"
1922
},
2023
"autoload": {
@@ -32,4 +35,4 @@
3235
}
3336
}
3437
}
35-
}
38+
}

src/Models/Term.php

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,37 @@
1-
<?php namespace Trexology\Taxonomy\Models;
1+
<?php
22

3-
class Term extends \Eloquent {
3+
namespace Trexology\Taxonomy\Models;
44

5-
protected $guarded =[
6-
'id',
7-
'created_at',
8-
'updated_at'
9-
];
5+
class Term extends \Eloquent
6+
{
7+
protected $guarded = [
8+
'id',
9+
'created_at',
10+
'updated_at',
11+
];
1012

11-
public static $rules = [
12-
'name' => 'required'
13-
];
13+
public static $rules = [
14+
'name' => 'required',
15+
];
1416

15-
public function termRelation() {
16-
return $this->morphMany('Trexology\Taxonomy\Models\TermRelation', 'relationable');
17-
}
17+
public function termRelation()
18+
{
19+
return $this->morphMany('Trexology\Taxonomy\Models\TermRelation', 'relationable');
20+
}
1821

19-
public function vocabulary() {
20-
return $this->belongsTo('Trexology\Taxonomy\Models\Vocabulary');
21-
}
22+
public function vocabulary()
23+
{
24+
return $this->belongsTo('Trexology\Taxonomy\Models\Vocabulary');
25+
}
2226

23-
public function childrens() {
24-
return $this->hasMany('Trexology\Taxonomy\Models\Term', 'parent', 'id')
25-
->orderBy('weight', 'ASC');
26-
}
27+
public function childrens()
28+
{
29+
return $this->hasMany('Trexology\Taxonomy\Models\Term', 'parent', 'id')
30+
->orderBy('weight', 'ASC');
31+
}
2732

28-
public function parentTerm() {
29-
return $this->hasOne('Trexology\Taxonomy\Models\Term', 'id', 'parent');
30-
}
33+
public function parentTerm()
34+
{
35+
return $this->hasOne('Trexology\Taxonomy\Models\Term', 'id', 'parent');
36+
}
3137
}

src/Models/TermRelation.php

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
1-
<?php namespace Trexology\Taxonomy\Models;
1+
<?php
22

3-
class TermRelation extends \Eloquent {
3+
namespace Trexology\Taxonomy\Models;
44

5-
protected $fillable = [
6-
'term_id',
7-
'vocabulary_id',
8-
];
5+
class TermRelation extends \Eloquent
6+
{
7+
protected $fillable = [
8+
'term_id',
9+
'vocabulary_id',
10+
];
911

10-
protected $table = 'term_relations';
12+
protected $table = 'term_relations';
1113

12-
public function relationable() {
13-
return $this->morphTo();
14-
}
15-
16-
public function term() {
17-
return $this->belongsTo('Trexology\Taxonomy\Models\Term');
18-
}
14+
public function relationable()
15+
{
16+
return $this->morphTo();
17+
}
1918

19+
public function term()
20+
{
21+
return $this->belongsTo('Trexology\Taxonomy\Models\Term');
22+
}
2023
}

src/Models/Vocabulary.php

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,26 @@
1-
<?php namespace Trexology\Taxonomy\Models;
1+
<?php
22

3-
class Vocabulary extends \Eloquent {
3+
namespace Trexology\Taxonomy\Models;
44

5-
protected $fillable = [
6-
'name',
7-
];
5+
class Vocabulary extends \Eloquent
6+
{
7+
protected $fillable = [
8+
'name',
9+
];
810

9-
protected $table = 'vocabularies';
11+
protected $table = 'vocabularies';
1012

11-
public $rules = [
12-
'name' => 'required'
13-
];
13+
public $rules = [
14+
'name' => 'required',
15+
];
1416

15-
public function terms() {
16-
return $this->HasMany('Trexology\Taxonomy\Models\Term');
17-
}
18-
19-
public function relations() {
20-
return $this->HasMany('Trexology\Taxonomy\Models\TermRelation');
21-
}
17+
public function terms()
18+
{
19+
return $this->HasMany('Trexology\Taxonomy\Models\Term');
20+
}
2221

22+
public function relations()
23+
{
24+
return $this->HasMany('Trexology\Taxonomy\Models\TermRelation');
25+
}
2326
}

0 commit comments

Comments
 (0)