php - Use IF statement on Eloquent -
there way use if statement on eloquent?
i have 1 table called 'invoices' ..
invoices(invoiceid,debt,status)
status represents if invoice payed or not, , debt debt on invoice. i'm asking if there quick way update status in such way when make payment..
if invoice.debt = 0 invoice.status = 0 else invoice.status = 1
i'm using laravel 5.3. thank you!
it seems you're going in right way,
you can as:
$invoice = invoice::find(1); $status = ($invoice->debt == 0) ? 0 : 1; $invoice->status = $status; $invoice->save();
hope helps!
Comments
Post a Comment