PickupPoint.php 698 B

12345678910111213141516171819202122232425
  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Database\Eloquent\Model;
  4. use App;
  5. class PickupPoint extends Model
  6. {
  7. protected $with = ['pickup_point_translations'];
  8. public function getTranslation($field = '', $lang = false){
  9. $lang = $lang == false ? App::getLocale() : $lang;
  10. $pickup_point_translation = $this->pickup_point_translations->where('lang', $lang)->first();
  11. return $pickup_point_translation != null ? $pickup_point_translation->$field : $this->$field;
  12. }
  13. public function pickup_point_translations(){
  14. return $this->hasMany(PickupPointTranslation::class);
  15. }
  16. public function staff(){
  17. return $this->belongsTo(Staff::class);
  18. }
  19. }