35 lines
1.0 KiB
PHP
35 lines
1.0 KiB
PHP
<?php
|
|||
|
|
return [
|
||
|
|
'sample_one' => [
|
||
|
|
'model' => \App\MyModel::class,
|
||
|
|
'cols' => "name,code",
|
||
|
|
'select' => ['id as value', 'name as label']
|
||
|
|
],
|
||
|
|
'sample_two' => [
|
||
|
|
'fn' => function ($query) {
|
||
|
|
return \App\DB\MyModel::whereHas('cls', function ($q) {
|
||
|
|
return $q->where('term_id', 2)->where('teacher_id', 1);
|
||
|
|
})
|
||
|
|
->select(['id as value', 'title as label'])
|
||
|
|
->where('title', 'LIKE', '%' . $query . '%')
|
||
|
|
->orWhere('code', 'LIKE', '%' . $query . '%')
|
||
|
|
->get()
|
||
|
|
->toArray();
|
||
|
|
},
|
||
|
|
],
|
||
|
|
'sample_three' => [
|
||
|
|
'model' => \App\DB\MyModel::class,
|
||
|
|
'cols' => "title",
|
||
|
|
'where' => [['sts', '>', '0']],
|
||
|
|
'select' => ['id as value', 'title as label']
|
||
|
|
],
|
||
|
|
'sample_four' => [
|
||
|
|
'model' => \App\DB\MyModel::class,
|
||
|
|
'cols' => "title",
|
||
|
|
'where' => [['w', 'course_level']],
|
||
|
|
'select' => ['id as value', 'title as label']
|
||
|
|
]
|
||
|
|
];
|
||
|
|
|
||
|
|
|