小编Ton*_*y S的帖子

在 Laravel 中分页之前获取所有结果 id

这是我的代码:

$prestations = Prestation::with([
        'service' => function($query) {
            $query->select(['id','name']);
        },
        'facility' => function($query) {
            $query->select(['id','name']);
        },
        'conciergeries.network' => function($query) {
            $query->select(['id','name']);
        }
    ])
    ->whereHas('service', function ($query) use ($sService) {
        $query->where('name', 'regexp', "/$sService/i");
    })
    ->whereHas('facility', function ($query) use ($sPartner) {
        $query->where('name', 'regexp', "/$sPartner/i");
    })
    ->whereHas('conciergeries.network', function ($query) use ($sSubsidiary) {
        $query->where('name', 'regexp', "/$sSubsidiary/i");
    })
    ->options([
        'collation' => [
            'locale' => 'en_US',
            'strength' => 1
        ]
    ])
    ->where('name', 'regexp', "/$search/i")
    ->orderBy($orderBy, $orderDirection)
    ->paginate(25);
Run Code Online (Sandbox Code Playgroud)

当我尝试获取所有 id 时:

$arrIds = [];

foreach ($prestations as …
Run Code Online (Sandbox Code Playgroud)

php pagination laravel eloquent

4
推荐指数
1
解决办法
1153
查看次数

VueJS 在 v-model 中反转值

这是我的代码:

<input
   v-model="comb.inactive"
   type="checkbox"
   @click="setInactive(comb.id_base_product_combination)"
>
Run Code Online (Sandbox Code Playgroud)

我需要在 v 模型上应用comb.inactive 的反转。

这是我尝试过的:

<input
    v-model="comb.inactive == 1 ? 0 : 1"
    type="checkbox"
    @click="setInactive(comb.id_base_product_combination)"
>



<input
    v-model="comb.inactive == 1 ? false : true"
    type="checkbox"
    @click="setInactive(comb.id_base_product_combination)"
>
Run Code Online (Sandbox Code Playgroud)

你还有其他想法吗?

javascript boolean vue.js v-model

2
推荐指数
1
解决办法
4354
查看次数

我怎样才能更短地编写这个 JavaScript 三元?

这是我的三元:

mode === 'edition' ? (this.editionMode = true, this.creationMode = false) : (this.creationMode = true, this.editionMode = false)
Run Code Online (Sandbox Code Playgroud)

我认为这是多余的,我可以用更好的方式编写这个三元吗?谢谢 !

javascript ternary vue.js

0
推荐指数
1
解决办法
68
查看次数

标签 统计

javascript ×2

vue.js ×2

boolean ×1

eloquent ×1

laravel ×1

pagination ×1

php ×1

ternary ×1

v-model ×1