37 lines
845 B
PHP
37 lines
845 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use App\Models\Service;
|
|
|
|
class ClientPayment extends Model
|
|
{
|
|
protected $guarded = array('id');
|
|
public $table = "client_finances";
|
|
|
|
public function client_info(){
|
|
return $this->hasOne('App\Models\Client', 'id', 'client_id');
|
|
}
|
|
public function created_by_info(){
|
|
return $this->hasOne('App\Models\Account', 'id', 'auth_user_id');
|
|
}
|
|
// public function services(){
|
|
// return $this->hasMany('App\Models\Service', 'id', 'client_id');
|
|
// }
|
|
protected $casts = [
|
|
'services' => 'array',
|
|
];
|
|
|
|
|
|
|
|
|
|
public function getServiceNamesAttribute()
|
|
{
|
|
if (empty($this->services) || !is_array($this->services)) {
|
|
return collect();
|
|
}
|
|
return Service::whereIn('id', $this->services)->pluck('name');
|
|
}
|
|
}
|