SellerPackage.php 742 B

123456789101112131415161718192021222324252627
  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Database\Eloquent\Model;
  4. use App;
  5. class SellerPackage extends Model
  6. {
  7. protected $guarded = [];
  8. public function getTranslation($field = '', $lang = false){
  9. $lang = $lang == false ? App::getLocale() : $lang;
  10. $seller_package_translation = $this->hasMany(SellerPackageTranslation::class)->where('lang', $lang)->first();
  11. return $seller_package_translation != null ? $seller_package_translation->$field : $this->$field;
  12. }
  13. public function seller_package_translations(){
  14. return $this->hasMany(SellerPackageTranslation::class);
  15. }
  16. public function seller_package_payments()
  17. {
  18. return $this->hasMany(SelllerPackagePayment::class);
  19. }
  20. }