Skip to content

Commit ed48617

Browse files
committed
app: replaced Eloquent with Model for several model classes
This was done as part of getting Hardik's changes for #615 in master. Eloquent and Model are essentially the same thing so that shouldn't change much. More detail is at: https://laracasts.com/discuss/channels/eloquent/models-vs-classes A few other changes were made in the models such as using hasMany in 1-N relationships. The belongsToMany is mainly for M-N relationships.
1 parent 2105e59 commit ed48617

16 files changed

Lines changed: 35 additions & 34 deletions

app/app/Country.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
class Country extends Model
1212
{
1313
protected $table = 'country';
14-
protected $fillable = ["name"
15-
];
14+
protected $fillable = ["name"];
1615
public $timestamps = false;
1716
}

app/app/DataSource.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
namespace App;
44

5-
use Eloquent;
5+
use Illuminate\Database\Eloquent\Model;
66

7-
class DataSource extends Eloquent
7+
class DataSource extends Model
88
{
99
protected $fillable = [
1010
'name', 'description',
@@ -18,6 +18,6 @@ class DataSource extends Eloquent
1818
*/
1919
public function locations()
2020
{
21-
return $this->belongsToMany('App\Location');
21+
return $this->hasMany(Location::class, 'data_source_id');
2222
}
2323
}

app/app/Image.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
namespace App;
44

5-
use Eloquent;
5+
use Illuminate\Database\Eloquent\Model;
66
use Webpatser\Uuid\Uuid;
77

8-
class Image extends Eloquent
8+
class Image extends Model
99
{
1010
protected $fillable = [
1111
'id', 'location_id', 'raw_data',

app/app/Location.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,23 @@
22

33
namespace App;
44

5-
use Eloquent;
5+
use Illuminate\Database\Eloquent\Model;
66
use DB;
77
use Webpatser\Uuid\Uuid;
88

9-
class Location extends Eloquent
9+
class Location extends Model
1010
{
1111
protected $fillable = [
1212
'name', 'phone_number', 'longitude', 'latitude', 'owner_user_id',
1313
'data_source_id', 'universal_rating', 'creator_user_id', 'ratings_cache'
1414
];
15+
1516
public $timestamps = false;
1617

1718
protected $casts = [
1819
'ratings_cache' => 'array'
1920
];
21+
2022
protected $table = 'location';
2123
/**
2224
* Indicates if the IDs are auto-incrementing.
@@ -57,7 +59,7 @@ public function personalizedRatings()
5759

5860
public function comments()
5961
{
60-
return $this->hasMany('App\ReviewComment');
62+
return $this->hasMany(ReviewComment::class);
6163
}
6264

6365
public function locationGroup()

app/app/LocationGroup.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
namespace App;
44

5-
use Eloquent;
5+
use Illuminate\Database\Eloquent\Model;
66

7-
class LocationGroup extends Eloquent
7+
class LocationGroup extends Model
88
{
99
protected $fillable = [
1010
'name',

app/app/LocationLocationTag.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
namespace App;
44

5-
use Eloquent;
5+
use Illuminate\Database\Eloquent\Model;
66
use Webpatser\Uuid\Uuid;
77

8-
class LocationLocationTag extends Eloquent
8+
class LocationLocationTag extends Model
99
{
1010
protected $fillable = [
1111
'location_id', 'location_tag_id',

app/app/LocationTag.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
namespace App;
44

5-
use Eloquent;
5+
use Illuminate\Database\Eloquent\Model;
66

7-
class LocationTag extends Eloquent
7+
class LocationTag extends Model
88
{
99
protected $fillable = [
1010
'name', 'description',

app/app/Question.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
namespace App;
44

5-
use Eloquent;
5+
use Illuminate\Database\Eloquent\Model;
66
use DB;
77
use App\Location;
88

9-
class Question extends Eloquent
9+
class Question extends Model
1010
{
1111
protected $fillable = [
1212
'question_html',

app/app/QuestionCategory.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
namespace App;
44

5-
use Eloquent;
5+
use Illuminate\Database\Eloquent\Model;
66

7-
class QuestionCategory extends Eloquent
7+
class QuestionCategory extends Model
88
{
99
protected $fillable = [
1010
'id', 'name',

app/app/Region.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
namespace App;
44

5-
use Eloquent;
5+
use Illuminate\Database\Eloquent\Model;
66
use DB;
77

8-
class Region extends Eloquent
8+
class Region extends Model
99
{
1010
protected $fillable = [
1111
'name', 'country_id',

0 commit comments

Comments
 (0)