CustomerPackage.php 690 B

12345678910111213141516171819202122232425
  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Database\Eloquent\Model;
  4. use App;
  5. class CustomerPackage extends Model
  6. {
  7. public function getTranslation($field = '', $lang = false){
  8. $lang = $lang == false ? App::getLocale() : $lang;
  9. $brand_translation = $this->hasMany(CustomerPackageTranslation::class)->where('lang', $lang)->first();
  10. return $brand_translation != null ? $brand_translation->$field : $this->$field;
  11. }
  12. public function customer_package_translations(){
  13. return $this->hasMany(CustomerPackageTranslation::class);
  14. }
  15. public function customer_package_payments()
  16. {
  17. return $this->hasMany(CustomerPackagePayment::class);
  18. }
  19. }