小编Mos*_*ade的帖子

如何将foreach循环中的值存储到数组中?

需要将foreach循环中的值存储到数组中,需要帮助.下面的代码不起作用,只存储最后一个值,尝试$ items.= ...,但这也不是诀窍,任何帮助将不胜感激.

foreach($group_membership as $i => $username) {
    $items = array($username);
}

print_r($items);
Run Code Online (Sandbox Code Playgroud)

php foreach

107
推荐指数
4
解决办法
34万
查看次数

在MySQL中删除列的最后两个字符

我有一个SQL列,其中的条目是字符串.我需要在修剪最后两个字符后显示这些条目,例如,如果条目是199902345应输出的话1999023.

我试着调查TRIM但看起来它只在我们知道最后两个字符是什么时提供修剪.但在我的情况下,我不知道最后两个数字是什么,他们只需要被丢弃.

那么,简而言之,MySQL字符串操作能够修剪字符串的最后两个字符?

我必须补充一点,字符串的长度不固定.它可以是9个字符,11个字符或任何其他.

mysql sql string

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

Laravel 6.0 中未定义命令“ui”

我在 laravel 中开始了一个新项目,但我的作曲家安装了一个新版本的 laravel 6.0.1。

Php artisan make:auth 命令无法工作。

我尝试了很多次但错误无法删除

composer require laravel/ui
Run Code Online (Sandbox Code Playgroud)

安装但是当我使用第二个命令时:

php artisan ui vue --auth
Run Code Online (Sandbox Code Playgroud)

然后系统向我显示此消息:

Command "ui" is not defined.
Using version ^1.0 for laravel/ui
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
PHP Fatal error:  Allowed memory size of 536870912 bytes exhausted (tried to allocate 4096 bytes) in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/DependencyResolver/RuleSetGenerator.php on line 129

Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 4096 bytes) in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/DependencyResolver/RuleSetGenerator.php …
Run Code Online (Sandbox Code Playgroud)

laravel laravel-authentication laravel-6

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

配音不是正在阅读我在文本框中输入的内容

以下是我的代码:

    <form>
        <div class="form-group loginFormGrp">
            <label class="caption">Backup Cloud</label>
            <div class="custSelect loginSelect">
            <label class="caption">Server URL</label>
                <input type="text" aria-label="Server URL" name="serverUrl" class="form-control" placeholder="example.server.com" value="">
            </div>
            <div class="form-group loginFormGrp">
                <label class="caption">Email</label>
                <input type="text" aria-label="Email" name="email" class="form-control" placeholder="user@example.com" value="">
            </div>
            <div class="loginBtnRow">
                <button tabindex="0" type="submit" class="lgBtn btn btn-primary btn-block">Continue</button>
            </div>
        </div>
    </form>
Run Code Online (Sandbox Code Playgroud)

每当画外文突出显示输入文本字段时,它会显示"您当前正在文本字段中,在Web内容中.要在此字段中输入文本,请键入.要退出Web区域,...",当我开始键入时,它什么也没说.并检查其他appilcation或网站,它读取我正在键入的内容.但在我的情况下,它不读.如果有人知道解决方案,请帮忙.

html javascript html5 voiceover electron

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

Laravel允许的内存大小为134217728字节(已尝试分配20480字节)

我对Laravel有问题。重新启动系统后,我的项目将无法运行!

我使用php artisan serv,但控制台中有以下消息:

[Tue Jul  3 14:31:35 2018] PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) in /laravel-projects/blog/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php on line 122


[Tue Jul  3 14:31:35 2018] PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) in /laravel-projects/blog/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php on line 46


[Tue Jul  3 14:31:38 2018] PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) in /laravel-projects/blog/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php on line …
Run Code Online (Sandbox Code Playgroud)

laravel laravel-5

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

Laravel POST调用返回index()函数而不是store()

我正在写laravel中的第一个应用程序,这对于新的laravel开发人员来说是非常好的环境.缩短故事:我通过php artisan命令创建了两个雄辩的模型,并以相同的方式创建了相应的控制器.其中之一是类控制器的内部"成员"的模式,我创建的公共职能,但是当我尝试发布到应该使用存储路线()函数航线实际使用index()函数.

控制器:

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Member;
use Response;

class MemberController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return Response
     */
    public function index()
    {
        $members = Member::all();
        return Response::json([
            'data' => $this->transformCollection($members)
        ], 200);
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return Response
     */
    public function create()
    {
        //
    }

    /**
     * @param Request $request
     * @return mixed
     */
    public function store(Request $request) …
Run Code Online (Sandbox Code Playgroud)

php http-post laravel laravel-routing laravel-5

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

使用迁移重命名 Laravel 中的列

我使用 Laravel 5.6

我想改变author_IDuser_id

我有如下提到的列:

class CreatePostsTable extends Migration{

    public function up()
    {
        Schema::create('posts', function (Blueprint $table) {
            $table->increments('id');
            $table->bigInteger('author_ID');
            $table->bigInteger('category_ID')->nullable();
            $table->longText('post_content');
            $table->text('post_title');
            $table->string('post_slug', 200);
            $table->string('post_type', 20);
            $table->timestamps();
        });
    }

    public function down()
    {
        Schema::dropIfExists('posts');
    }
}
Run Code Online (Sandbox Code Playgroud)

我使用以下链接更改我的列名:

如何使用迁移重命名 Laravel 中的列?

然后创建吹迁移:

php artisan make:migration rename_author_id_in_post_table
Run Code Online (Sandbox Code Playgroud)

重命名迁移文件:

class UpdateUsernameInPostTable extends Migration{

    public function up()
    {
        Schema::create('posts', function (Blueprint $table) {
            $table->renameColumn('author_ID', 'user_id');
        });

    }

    public function down()
    {
        Schema::create('posts', function (Blueprint $table) {
            $table->renameColumn('user_id', 'author_ID');
        });
    } …
Run Code Online (Sandbox Code Playgroud)

migration laravel

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

如何使用 Bootstrap 4 重新排序列?

我在 bootstrap 4 中使用了以下标签。

    <div class="container">
        <div class="row align-items-center">
            <div class="col-md-3">
                <div class="right-user-account" >
                    <a href="#">User Account</a>
                </div>
            </div>

            <div class="col-md-6">
                <img src="images/logo.png">
            </div>

            <div class="col-md-3">
                <div class="left-login" >
                    <a href="#">Login</a>
                </div>
            </div>
        </div>
    </div>
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

我想要全宽的标志

在此处输入图片说明

如何使用重新排序命令?

flexbox twitter-bootstrap bootstrap-4

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

Laravel:无法打开流:成功_身份验证错误

我使用 Laravel 5.6

我运行以下命令:

php artisan make:auth
Run Code Online (Sandbox Code Playgroud)

http://localhost:8000/register 注册后,会遇到如下错误:

 failed to open stream: Success
Run Code Online (Sandbox Code Playgroud)

或者在http://localhost:8000/login 登录后,我会遇到以下错误:

failed to open stream: No such file or directory
Run Code Online (Sandbox Code Playgroud)

谢谢你的帮助

laravel laravel-5

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

如何使用导入excel更新数据库中的数据

如何使用导入excel更新数据库中的数据。我正在使用 laravel 5.7 和 maatwebsite 3.1

\n

这是我的控制器:

\n
public function import()\n{\n   $data = Excel::toArray(new ProdukImport, request()->file('file')); \n   if ($data) {\n       DB::table('produk')\n            ->where('id_produk', $data['id'])\n            ->update($data);\n   }\n}\n
Run Code Online (Sandbox Code Playgroud)\n

这是我的导入类:

\n
<?php\n\n namespace App\\Imports;\n\n use App\\Produk;\n use Maatwebsite\\Excel\\Concerns\\ToModel;\n use Maatwebsite\\Excel\\Concerns\\WithHeadingRow;\n\n\n class ProdukImport implements ToModel, WithHeadingRow\n {\n    /**\n     * @param array $row\n     *\n     * @return \\Illuminate\\Database\\Eloquent\\Model|null\n     */\n    public function model(array $row)\n    {\n       return new Produk([\n          'id_produk' => $row['id'],\n          'nama_produk' => $row['produk'],\n          'harga_jual' => $row['harga']\n       ]);\n     }\n  }\n
Run Code Online (Sandbox Code Playgroud)\n

这个 dd($data) 结果:

\n
array:1 …
Run Code Online (Sandbox Code Playgroud)

php laravel laravel-5 laravel-excel maatwebsite-excel

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

Laravel 日志系统与 Logstash

我有一个 Laravel 应用程序,我想将日志存储到 Logstash 中并在 kibana 中查看它们,我在网上搜索了很多以找到它的解决方案,但我没有找到任何好的来源,是否有任何包可以使用 Laravel登录logstash ??? 顺便说一句,我的 Logstash 和 kibana 运行没有任何问题,我现在只需要一个数据源。这是我正在运行的 elstic 搜索:

    {
name: "5351ced3b7a4",
cluster_name: "elasticsearch",
cluster_uuid: "Ej5TRN8CQyGvemZlT3gAFA",
version: {
number: "7.1.1",
build_flavor: "oss",
build_type: "tar",
build_hash: "7a013de",
build_date: "2019-05-23T14:04:00.380842Z",
build_snapshot: false,
lucene_version: "8.0.0",
minimum_wire_compatibility_version: "6.8.0",
minimum_index_compatibility_version: "6.0.0-beta1"
},
tagline: "You Know, for Search"
}
Run Code Online (Sandbox Code Playgroud)

编辑,因为答案解释了我的做法,现在我在 laravel 的日志中收到此错误:

[2019-08-05 14:16:17] laravel.INFO: Hello logstash!  
Run Code Online (Sandbox Code Playgroud)

编辑:日志配置文件:

<?php

use Monolog\Handler\StreamHandler;
use Monolog\Handler\SyslogUdpHandler;

return [

/*
|--------------------------------------------------------------------------
| Default Log Channel
|--------------------------------------------------------------------------
|
| This option defines the default …
Run Code Online (Sandbox Code Playgroud)

php logging elasticsearch laravel logstash

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

laravel - livewire 整页组件

我使用 Laravel 8。

我在RouteServiceProvider以下位置定义了受保护的命名空间:

protected $namespace = 'App\Http\Controllers';
Run Code Online (Sandbox Code Playgroud)

然后通过以下路线使用 livewire:

Route::get('/xxx' , App\Http\Livewire\Counter::class);
Run Code Online (Sandbox Code Playgroud)

但我有以下错误:

Invalid route action: [App\Http\Controllers\App\Http\Livewire\Counter].
Run Code Online (Sandbox Code Playgroud)

注意:这增加App\Http\Controllers了我的第一个动作!!!如果protected $namespace全部删除就可以了。但我不想删除它。

有没有办法让我同时拥有两者?controller protected namespace(用于控制器命名空间)和一个Route::getfor Full-Page Components?

livewires laravel laravel-livewire laravel-8

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

如何在Laravel 5.6中禁用注册新用户

我使用laravel 5.6

我想为新用户禁用注册,当然登录表单必须可用

我看到以下问题:

/sf/ask/2042834391/
Run Code Online (Sandbox Code Playgroud)

但是我没有找到?? showRegistrationForm()在以下路径上运行:

Auth/RegisterController.php

laravel laravel-5

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