Bank.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: tandunzhao
  5. * Date: 2017/12/6
  6. * Time: 下午7:03
  7. */
  8. namespace App\Modules\Finance\Models;
  9. use Illuminate\Database\Eloquent\Model;
  10. class Bank extends Model
  11. {
  12. protected $table = 'banks';
  13. protected $fillable = ['name','code', 'source', 'is_show'];
  14. /**
  15. * @param $id
  16. * @return mixed
  17. */
  18. public static function getBankSingle($id) {
  19. return self::find($id);
  20. }
  21. /**
  22. * @param $name
  23. * @param $source
  24. * @return mixed
  25. */
  26. public static function getBankSingleByNameSource($name, $source) {
  27. $search_object = self::where('name', $name)->where('source', $source);
  28. return $search_object->first();
  29. }
  30. /**
  31. * 获取银行列表
  32. * @param string $source
  33. * @return mixed
  34. */
  35. public static function getBankList($source = '') {
  36. $search_object = self::orderBy('id','asc')->where('is_show', 1);
  37. if($source) {
  38. $search_object->where('source', $source);
  39. }
  40. return $search_object->get();
  41. }
  42. }