我在 Mac OS X Big Sur 上通过 Sail 在 Docker 上运行了一个 Laravel 环境。我在 docker-compose.yml 文件中添加了 phpmyadmin,一切正常,但是当我尝试将数据导入数据库时,我得到:
Warning: POST Content-Length of 68109047 bytes exceeds the limit of 2097152 bytes in Unknown on line 0
Run Code Online (Sandbox Code Playgroud)
我将 docker 配置文件发布到我的 Laravel 项目并重新启动 docker。这是我的 docker-composer.yml:
version: '3'
services:
laravel.test:
build:
context: ./docker/8.1
dockerfile: Dockerfile
args:
WWWGROUP: '${WWWGROUP}'
image: sail-8.1/app
extra_hosts:
- 'host.docker.internal:host-gateway'
ports:
- '${APP_PORT:-80}:80'
environment:
WWWUSER: '${WWWUSER}'
LARAVEL_SAIL: 1
XDEBUG_MODE: '${SAIL_XDEBUG_MODE:-off}'
XDEBUG_CONFIG: '${SAIL_XDEBUG_CONFIG:-client_host=host.docker.internal}'
volumes:
- '.:/var/www/html'
networks:
- sail
depends_on:
- mysql
mysql:
image: …Run Code Online (Sandbox Code Playgroud) 我正在学习 vuex 并取得了一些进展,但我遇到了一些问题。我有一个包含许多模块的商店的 vue 组件。我有设备的地方。用户选择一个位置,我将它存储在我的 vuex 状态中的位置模块中。
我正在尝试从设备模块访问该位置以仅加载所选位置的设备。
文档说这应该有效:
actions: {
incrementIfOddOnRootSum ({ state, commit, rootState }) {
if ((state.count + rootState.count) % 2 === 1) {
commit('increment')
}
}
Run Code Online (Sandbox Code Playgroud)
当我在我的模块中尝试这个时:
GET_EQUIPMENTS : async (context,payload, rootState) => {
alert(JSON.stringify(rootState.location, null, 4));
}
Run Code Online (Sandbox Code Playgroud)
我收到错误 rootState 未定义。
如果我提醒上下文,我可以看到 rootGetters
{
"getters": {},
"state": {
"equipments": [],
"equipment": null
},
"rootGetters": {
"locations/LOCATIONS":[
{
"id": 1,
"name": "West Pico",
}
}
}
Run Code Online (Sandbox Code Playgroud)
但是我不知道如何访问位置/位置,我可以通过访问 context.rootGetters 来访问 rootGetters。
有什么建议吗?
我有一个登录用户,这里的代码有效:
@if( Auth::check() )
Logged in as: {{ Auth::user()->firstname }} {{ Auth::user()->lastname }}
@endif
Run Code Online (Sandbox Code Playgroud)
我正在使用zizaco /委托,而且一切正常.我已经创建了角色和权限,并为我的用户提供了具有管理权限的admin角色.
那么为什么这不起作用:
$user = Auth::user();
print_r($user->hasRole('admin'));
Run Code Online (Sandbox Code Playgroud)
如果我print_r $ user我可以看到Auth用户已加载,但hasRole无效.我现在只是在刀片模板中对此进行了测试,但是在Controller中尝试了相同的结果.我的错误是:
BadMethodCallException in Builder.php line 1992:
Call to undefined method Illuminate\Database\Query\Builder::hasRole()
Run Code Online (Sandbox Code Playgroud)
我的用户模型:
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Zizaco\Entrust\Traits\EntrustUserTrait;
class User extends Model {
use EntrustUserTrait;
protected $table = 'users';
public $timestamps = true;
use SoftDeletes;
protected $dates = ['deleted_at'];
}
Run Code Online (Sandbox Code Playgroud)
UPDATE
当我以这种方式查看用户时,我意识到hasRole适用于我(返回App\Models\User Object):
$user = \App\Models\User::find( \Auth::user()->id );
Run Code Online (Sandbox Code Playgroud)
但不是当我以这种方式找到用户时(返回App\User Object):
$user = \Auth::user();
Run Code Online (Sandbox Code Playgroud)
我宁愿认为它会以另一种方式工作,当我拉起App\User时我可以访问hasRole但不一定在我搜索用户时.我认为hasRole可以从Auth :: …
我可以像这样生成一个基本链接:
This is an [example link](http://example.com/).
Run Code Online (Sandbox Code Playgroud)
我可以生成一个带有动态链接的按钮,如下所示:
@component('mail::button', ['url' => \URL::to('/subscriptions/'.$recipient->id.'/'.$recipient->email.'?action=subscribe')])
Sign Me Up
@endcomponent
Run Code Online (Sandbox Code Playgroud)
但是如何生成动态链接,而不是按钮?
我试过:
[Safe Unsubscribe]( url('/subscriptions/'.$recipient->id.'/'.$recipient->email.'?action=unsubscribe') )
Run Code Online (Sandbox Code Playgroud)
和
[Safe Unsubscribe]( \URL::to('/subscriptions/'.$recipient->id.'/'.$recipient->email.'?action=unsubscribe') )
Run Code Online (Sandbox Code Playgroud)
但这些输出以字面的方式:
url('/subscriptions/'.%24recipient-%3Eid.'/'.%24recipient-%3Eemail.'?action=subscribe%27)
Run Code Online (Sandbox Code Playgroud) 我有两个由透视表和belongsToMany关系连接的Laravel 5模型.如下所示,我有订单,商品和数据透视表item_order.
订购:
public function items() {
return $this -> belongsToMany('App\Item', 'item_order', 'order_id', 'item_id') -> withPivot('id','quantity');
}
Run Code Online (Sandbox Code Playgroud)
项目:
public function orders() {
return $this -> belongsToMany('App\Order', 'item_order', 'item_id', 'order_id') -> withPivot('id','quantity');
}
Run Code Online (Sandbox Code Playgroud)
循环时
$orders->items as $item
Run Code Online (Sandbox Code Playgroud)
我似乎无法访问额外字段'数量'.如果我
dd($item)
Run Code Online (Sandbox Code Playgroud)
我明白了:
Item {#310 ?
#table: "items"
+timestamps: true
#dates: array:1 [?]
#connection: null
#primaryKey: "id"
#perPage: 15
+incrementing: true
#attributes: array:11 [?
"id" => 1
"created_at" => "2015-03-23 21:30:19"
"updated_at" => "2015-03-25 15:37:23"
"deleted_at" => null
"name" => "Medium Lift Sling"
"description" …Run Code Online (Sandbox Code Playgroud) 我能够获取 q 文件来上传单个图像,并且我的 Laravel API 可以完美地处理它。当然,我需要一次上传多个文件,所以我尝试切换到 q-uploader,当我记录响应时,文件显示为 [object File]。
我还尝试在 FileController 中使用 $request->file('attachment') 但它返回 null。
<q-uploader
:factory="uploadFactory"
label="Upload Images/Files"
color="primary"
multiple
/>
Run Code Online (Sandbox Code Playgroud)
然后在我的 FileController.php 中:
public function upload(Request $request) {
\Log::info($request);
}
Run Code Online (Sandbox Code Playgroud)
返回:
array (
'attachment' => '[object File]',
'fileable_type' => 'App\\Task',
'fileable_id' => '27375',
'vessel_id' => '1',
)
Run Code Online (Sandbox Code Playgroud)
我厂上传:
uploadFactory (file) {
let data = new FormData()
data.append('attachment', file)
data.append('fileable_type', 'App\\Task')
data.append('fileable_id', this.task.id)
data.append('vessel_id', this.vessel.id)
return new Promise((resolve, reject) => {
this.$axios.post('/api/file/upload', data, { headers: { 'Content-Type': 'multipart/form-data' } …Run Code Online (Sandbox Code Playgroud) laravel quasar laravel-filesystem quasar-framework laravel-5.8
网站不可用 您尝试访问的网站不可用,因为它使用安全服务来防止未经授权的访问和在线攻击。
Cloudways KB 中没有信息 - 广泛的搜索没有返回任何信息,所以我在这里为其他人添加了这个。
laravel ×5
laravel-5 ×2
cloudways ×1
docker ×1
hosting ×1
html-email ×1
laravel-5.7 ×1
laravel-5.8 ×1
laravel-8 ×1
laravel-sail ×1
markdown ×1
model ×1
nginx ×1
phpmyadmin ×1
pivot-table ×1
quasar ×1
vue.js ×1
vuejs2 ×1
vuex ×1
vuex-modules ×1