This commit is contained in:
Daniel Camargo 2014-02-12 10:10:40 -02:00
parent 95773955dc
commit 132c9f19d9

View File

@ -25,10 +25,13 @@ class Crunchbutton_Restaurant_Payment_Type extends Cana_Table {
function byRestaurant( $id_restaurant ){
if( $id_restaurant ){
$payment = Crunchbutton_User_Payment_Type::q( 'SELECT * FROM restaurant_payment_type WHERE id_restaurant = ' . $id_restaurant . ' LIMIT 1' );
if( !$payment->count() ){
return new Crunchbutton_Restaurant_Payment_Type();
} else{
if( $payment->id_restaurant_payment_type ){
return Crunchbutton_Restaurant_Payment_Type::o( $payment->id_restaurant_payment_type );
} else{
$payment = new Crunchbutton_Restaurant_Payment_Type();
$payment->id_restaurant = $id_restaurant;
$payment->save();
return $payment;
}
}
return false;