In usersubscription model
class UserSubscription extends Ardent {
use SoftDeletingTrait;
protected $softDelete = true;
protected $dates = ['deleted_at'];
public static $rules = array(
'user_id' => 'required|numeric',
'order_id' => 'numeric',
'product_id' => 'numeric',
'currency' => 'required',
'shipping_amount' => 'required|numeric',
'net_amount' => 'required|numeric',
'pst_amount' => 'required|numeric',
'gst_amount' => 'required|numeric',
'discount_amount' => 'numeric',
'total_amount' => 'required|numeric',
'start_date' => 'required|date',
'next_date' => 'required|date',
'last_date' => 'date',
'end_date' => 'date',
'completed_orders' => '',
'repeat_unit_type' => '',
'repeat_every_x_units' => 'numeric',
'is_active' => 'required|in:0,1',
'number_of_attempts' => 'numeric',
'last_error_text' => '',
'cancellation_reason_id'=> '',
'custom_cancellation_reason'=> '',
);
{
return $this->belongsTo('CancellationReason', 'cancellation_reason_id');
}
//END OF Usersubscription model
// BEGIN OF CANCELLATION REASON MODEL
class CancellationReason extends Eloquent {
use SoftDeletingTrait;
protected $softDelete = true;
protected $dates = ['deleted_at'];
public static $rules = array(
'reason' => 'required',
'has_custom_text' => '',
);
protected $fillable = array(
'reason',
'has_custom_text',
);
public function userSubscriptions()
{
return $this->hasMany('UserSubscription');
}
/**
* Model bootstrap
*/
public static function boot()
{
// make the parent (Eloquent) boot method run
parent::boot();
}
}
@if($subscription->cancellationReason)
{{$subscription->cancellationReason->reason}}
@endif
No comments:
Post a Comment