Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. $query = $this->model->customerWithCentralBillingChildren($customer);
  2.  
  3. dd($query);
  4.  
  5. public function scopeCustomerWithCentralBillingChildren($query, Customer $customer)
  6. {
  7. $accdes = [CUT] // doesn't matter
  8.  
  9. return $query->whereIn('accde', $accdes);
  10. }
  11.  
  12. class SyncActive implements Scope
  13. {
  14. /**
  15. * Apply the scope to a given Eloquent query builder.
  16. *
  17. * @param IlluminateDatabaseEloquentBuilder $builder
  18. * @param IlluminateDatabaseEloquentModel $model
  19. * @return void
  20. */
  21. public function apply(Builder $builder, Model $model)
  22. {
  23. $builder->where('sync_active', '=', true);
  24. }
  25. }
  26.  
  27. Builder {#858 ▼
  28. #query: Builder {#859 ▶}
  29. #model: Transaction {#676 ▶}
  30. #eagerLoad: []
  31. #localMacros: []
  32. #onDelete: null
  33. #passthru: array:13 [▶]
  34. #scopes: array:1 [▼
  35. "AppScopesSyncActive" => SyncActive {#677} <---- global scope OK
  36. ]
  37. #removedScopes: []
  38. }
  39.  
  40. dd($query->toSql());
  41.  
  42. "select * from `sync_transactions` where `accde` in (?, ?, ?, ?, ?, ?) and `sync_active` = ?"
  43.  
  44. where `accde` in (?, ?, ?, ?, ?, ?)
  45.  
  46. `sync_active` = ?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement