hasOne('App\Models\TravelProgramCountry', 'country_id', 'id'); } public function feedback_page() { return $this->belongsTo('App\Models\Page', 'feedback_page_id', 'id'); } public function travel_nationality_requirements() { return $this->hasMany('App\Models\TravelNationalityRequirement', 'travel_country_id', 'id'); } public function getNationalityRequirement($travel_nationality_id){ $model = TravelNationalityRequirement::where('travel_country_id', $this->id)->where('travel_nationality_id', $travel_nationality_id)->first(); if($model){ return $model->text; } return ""; } public function setNationalityRequirement($travel_nationality_id, $text){ $model = TravelNationalityRequirement::where('travel_country_id', $this->id)->where('travel_nationality_id', $travel_nationality_id)->first(); if($model){ $model->text = $text; $model->save(); }else{ $data = [ 'travel_country_id' => $this->id, 'travel_nationality_id' => $travel_nationality_id, 'text' => $text, ]; TravelNationalityRequirement::create($data); } return ""; } }