小编rob*_*pin的帖子

当npm i imagemin说自己没有安装?WARN img-loader@3.0.0需要一个imagemin @^5.0.0的对等,但没有安装

npm -v 6.4.1 nvm --version 0.33.11

当我安装laravel-echo(在ubuntu16.04中)

npm i --save socket.io-client
Run Code Online (Sandbox Code Playgroud)

我收到了错误警告

npm WARN ajv-keywords@3.2.0 requires a peer of ajv@^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN img-loader@3.0.0 requires a peer of imagemin@^5.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

+ socket.io-client@2.1.1
added 26 packages from 21 contributors and audited …
Run Code Online (Sandbox Code Playgroud)

laravel imagemin npm-install ubuntu-16.04 laravel-echo

5
推荐指数
1
解决办法
1602
查看次数

如何计算 laravel 刀片上的 +-*/%?

@foreach ($searchalls as $searchall)
    @php
      $i=1
    @endphp
     {{$i }} ={{$loop->iteration}}%3
     @if($i == 1 )
      <div class="row clearfix">
       @endif 
        <div class="col-md-4 column">
                <h2>
                {{$search_all->id }}Heading
                </h2><p>once OK.
                </p>
                <p>
                     <a class="btn" href="#">View details »</a>
                </p>
       </div>
Run Code Online (Sandbox Code Playgroud)

我在刀片上得到的结果是

1 =1%3
1 =2%3
1 =3%3
1 =4%3
Run Code Online (Sandbox Code Playgroud)

不能得到数字余数?

我该如何解决这个问题?

reminders laravel laravel-blade

3
推荐指数
1
解决办法
8851
查看次数

A.* 不在 Laravel 查询生成器上带有左连接的 GROUP BY 中

   $search_alls=
    DB::table('a16s as A')
    ->select('A.id')
    // ->select('A.*')
    ->addSelect(DB::raw('SUM(CASE WHEN B.approve = 1 ELSE 0 END) as Yshow'))
    ->leftjoin('a16s_likes as B', function($join) {
        $join->on('A.id', '=', 'B.p_id');
        })
    ->groupBy('A.id')
    ->get();
Run Code Online (Sandbox Code Playgroud)

当我使用上面的 select('A.id') 时效果很好。

但是当我使用 select('A.*') 选择所有 A 列时,出现错误

SQLSTATE[42000]: Syntax error or access violation: 1055 'employee.A.name' isn't in GROUP BY 
Run Code Online (Sandbox Code Playgroud)

PS:employee是我的数据库名称A表上的列是

id name ....
1  john
2  mary
3  susan
Run Code Online (Sandbox Code Playgroud)

如何通过 leftjoin 选择所有列?A.id 列与 B.p_id 列是一对多关系。

mysql group-by left-join laravel laravel-query-builder

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

{closure}()必须是laravel工厂种子上的Faker \ Generator \ Generator的实例

当我使用php artisan db:seed时出现错误?在UserFactory.php第27行中:

Type error: Argument 1 passed to
Illuminate\Database\Eloquent\Factory::{closure}() must be an instance
of Faker\Generator\Generator, instance of Faker\Generator given
Run Code Online (Sandbox Code Playgroud)

Userfactory.php 使用Faker \ Generator作为Faker;

(这是第27行)

$factory->define(App\Models\Admin::class, function (Faker\Generator $faker) {
    static $password;

        return [
            'name' => $faker->name,
            'email' => $faker->safeEmail,
            'password' => $password ?: $password = bcrypt('secret'),
            'remember_token' => str_random(10),
        ];
    });
Run Code Online (Sandbox Code Playgroud)

AdminsTableSeeder.php

public function run()
{
    factory('App\Models\Admin',3)->create([
        'password' => bcrypt('123456')
        ]);
}
Run Code Online (Sandbox Code Playgroud)

DatabaseSeeder.php

public function run()
{
    // $this->call(UsersTableSeeder::class);
    $this->call(AdminsTableSeeder::class);
}
Run Code Online (Sandbox Code Playgroud)

我不知道怎么回事。

factory laravel laravel-seeding

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