1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- <?php
- namespace App\Repositories\Models\Base;
- use App\Repositories\Enums\ModelStatusEnum;
- use App\Repositories\Models\Model;
- class SourceMatters extends Model
- {
- /**
- * @var string
- */
- protected $table = 'base_source_matters';
- protected $guarded = [];
- protected $casts = [
- 'similar_name' => 'array'
- ];
- /**
- * The attributes excluded from the model's JSON form.
- *
- * @var array
- */
- protected $hidden = [];
- /**
- * 获取名称
- * @return array
- */
- public static function getNames()
- {
- $sourceMatters = self::query()->where('status', ModelStatusEnum::OK)->get();
- $data = [];
- foreach ($sourceMatters as $sourceMatter) {
- $da = $sourceMatter->similar_name;
- if (!is_array($da)) $da = [];
- $da[] = $sourceMatter->name;
- $data[] = [
- 'id' => $sourceMatter->id,
- 'names' => $da,
- ];
- }
- return $data;
- }
- }
|