問題タブ [laravel-eloquent]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
php - App\Repositories\FavoriteRepository::delete() の不足している引数 1 を解決するには? (ララベル5.3)
私のサービスは次のようなものです:
私のリポジトリは次のようなものです:
エラーが存在します:
App\Repositories\FavoriteRepository::delete() の引数 1 がありません。C:\xampp\htdocs\mysystem\app\Repositories\FavoriteRepository.php の 45 行目で呼び出され、定義されています。
手伝って頂けますか?
アップデート
EloquentRepository の削除機能は次のようになります。
laravel - クエリリポジトリで読み取れない状態はなぜですか?
ここからリポジトリのチュートリアルを取得します:
https://github.com/rinvex/repository
そして、次のようなコードを作成してみます:
クエリをデバッグすると、結果は次のようになります。
配列:3 [▼</p>
"query" => "select * from
favorites
limit 1"「バインディング」=> []
「時間」 => 1.28
]
見た目、条件はありません
なぜそれが起こったのですか?
mysql - Laravel Eloquent Query - count() の制限
テーブルに 50 を超える行があるかどうかを知る必要があります。したがって、生のクエリは次のようになります。
SELECT COUNT(id) FROM (SELECT id FROM table WHERE {conditions} LIMIT 50)
しかし、雄弁でこれを行うのに問題があります。これは私がこれまでに試したことです....
card::where( ... )->limit(50)->count("id");
...しかし、これは機能しません。制限のサブクエリを作成しないため、制限が役に立たなくなります。
制限されたサブクエリを実行しないと、クエリに最大で 10 倍の時間がかかります。必要なほどスケーラブルではないのではないかと心配しています。
php - Laravel 5.2 Using raw query when defining self-referencing model relationship?
When calling CollegeMajor::with('majors')->get()
, I would like to apply the following raw sql query:
TRIM(TRAILING SUBSTRING_INDEX(parent_id, ':', -1) FROM parent_id)
to the parent_id
column. The values in parent_id are stored as 1:1234, 1:3121, 1:1332
etc... and so therefore I'd like to strip everything after the colon. The primary key for CollegeMajor is id and those values are integers like 1
. I get the error below because Laravel believes the raw query is the name of the column. How do I tell Laravel to apply that sql query to project_id
column when executing the relationship?
CollegeMajor.php
Error
college_majors table
How to make it return?
php - モデルの未定義のプロパティ
ユーザーモデル:
ロールIDの代わりにロールの名前を表示したくありません。
しかし、それは言います:
User.php 行 38 の ErrorException: 未定義のプロパティ: App\User::$role
ロール テーブルにはIDと名前が含まれています
users テーブルにはrole_idが含まれています
編集:
試しreturn $this->role()->name;
てみると、次のようになります。
User.php 行 38 の ErrorException: 未定義のプロパティ: Illuminate\Database\Eloquent\Relations\BelongsTo::$name
しかし、私は役割を確認し、それは機能します...