hasMany('App\Entities\Projects\Project'); } /** * Customer morph many payments. * * @return \Illuminate\Database\Eloquent\Relations\MorphMany */ public function payments() { return $this->morphMany('App\Entities\Payments\Payment', 'partner'); } /** * Customer has many subscriptions. * * @return \Illuminate\Database\Eloquent\Relations\HasMany */ public function subscriptions() { return $this->hasMany('App\Entities\Subscriptions\Subscription'); } /** * Customer has many invoices through their projects. * * @return \Illuminate\Database\Eloquent\Relations\HasManyThrough */ public function invoices() { return $this->hasManyThrough('App\Entities\Invoices\Invoice', 'App\Entities\Projects\Project'); } /** * Get customer name in html link format. * * @return \Illuminate\Support\HtmlString */ public function nameLink() { return link_to_route('customers.show', $this->name, [$this->id], [ 'title' => trans( 'app.show_detail_title', ['name' => $this->name, 'type' => trans('customer.customer')] ), ]); } /** * Get customr status attribute. * * @return string */ public function getStatusAttribute() { return $this->is_active == 1 ? trans('app.active') : trans('app.in_active'); } /** * Get customr status label attribute. * * @return string */ public function getStatusLabelAttribute() { $color = $this->is_active == 1 ? ' style="background-color: #337ab7"' : ''; return ''.$this->status.''; } }