I have a payment and Payment history models
Payment History:
class PaymentHistory extends Model
{
public function subscription()
{
return $this->hasOne('App\Models\Payment', 'id','payment_id');
}
}
Payment :
class Payment extends Model
{
public function PaymentHistory(){
return $this->belongsTo('App\Models\PaymentHistory ','id','payment_id');
}
}
I have a json column named as response in Payment History table that i want to return it after decoding json data in model function with each and every row
My query in controller is as follows
$data = User::with('Payment.PaymentHistory')->get();
i was trying to do something like this in payment history model:
public function json_response()
{
return json_decode($json, TRUE);
}
Any help is highly appreciated
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire