first commit, after modifying client section
This commit is contained in:
48
app/Models/Client.php
Executable file
48
app/Models/Client.php
Executable file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Models;
|
||||
class Client extends Model
|
||||
{
|
||||
protected $guarded = array('id');
|
||||
public $table = "clients";
|
||||
protected $appends = ['client_services'];
|
||||
|
||||
public function country_info(){
|
||||
return $this->hasOne('App\Models\Country', 'alpha_2_code', 'country');
|
||||
}
|
||||
public function payment_type_info(){
|
||||
return $this->hasOne('App\Models\PaymentType', 'id', 'pay_mode');
|
||||
}
|
||||
|
||||
public function service_info(){
|
||||
#return $this->hasMany('App\Comment', 'foreign_key', 'local_key');
|
||||
return $this->hasMany('App\Models\ClientCategory', 'client_id', 'id');
|
||||
}
|
||||
public function report_info(){
|
||||
return $this->hasMany('App\Models\MeetingReport', 'client', 'id');
|
||||
}
|
||||
public function auth_user_info(){
|
||||
return $this->hasOne('App\Models\Account', 'id', 'auth_user_id');
|
||||
}
|
||||
public function created_by_info(){
|
||||
return $this->hasOne('App\Models\Account', 'id', 'created_by');
|
||||
}
|
||||
public function modified_by_info(){
|
||||
return $this->hasOne('App\Models\Account', 'id', 'last_modified_by');
|
||||
}
|
||||
|
||||
|
||||
public function getClientServicesAttribute(){
|
||||
$services = $this->service_info;
|
||||
$service_name_arr = [];
|
||||
foreach ($services as $value) {
|
||||
$service_name = Models\Service::find($value['category_id']);
|
||||
$service_name_arr[] = $service_name->name;
|
||||
}
|
||||
return $service_name_arr;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user