Parse Json content in model in Laravel

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



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3xPnwEI
via IFTTT

تعليقات

المشاركات الشائعة من هذه المدونة

How to Create Treeview with Bootstrap and jQuery

Api routes not found when hosted laravel application on server

How to Add Images to Dropdown List using jQuery