Created
March 17, 2014 14:11
-
-
Save jgrossi/9599844 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Payment extends Eloquent | |
{ | |
const PAID = 1; | |
const PENDIND = 2; | |
public function entry() | |
{ | |
return $this->belongsTo('Entry', 'entry_id'); | |
} | |
// ... | |
} | |
class Entry extends Eloquent | |
{ | |
public function payments($status = null) | |
{ | |
$relation = $this->hasMany('Payment', 'entry_id'); | |
if ($status !== null) { | |
$relation->where('status', $status); | |
} | |
return $relation; | |
} | |
} | |
// Controller | |
$entries = Entry::payments(Payment::PAID)->get(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Pode criar metodos especificos também: tipo "pagamentosPagos":