Some sample models that show how to access FluxBB data through simple Eloquent magic.
Post::recent()->get();
Post::recent(20)->get();
<?php | |
class Group extends Eloquent | |
{ | |
protected $table = 'groups'; | |
public function users() | |
{ | |
return $this->hasMany('User', 'group_id'); | |
} | |
} |
<?php | |
class Post extends Eloquent | |
{ | |
protected $table = 'posts'; | |
public function topic() | |
{ | |
return $this->belongsTo('Topic', 'topic_id'); | |
} | |
public function scopeRecent($query, $limit = 10) | |
{ | |
return $query->orderBy('posted', 'DESC')->take($limit); | |
} | |
} |
<?php | |
class Topic extends Eloquent | |
{ | |
protected $table = 'topics'; | |
public function posts() | |
{ | |
return $this->hasMany('Post', 'topic_id'); | |
} | |
public function firstPost() | |
{ | |
return $this->belongsTo('Post', 'first_post_id'); | |
} | |
public function lastPost() | |
{ | |
return $this->belongsTo('Post', 'last_post_id'); | |
} | |
} |
<?php | |
class User extends Eloquent | |
{ | |
protected $table = 'users'; | |
public function group() | |
{ | |
return $this->belongsTo('Group', 'group_id'); | |
} | |
} |