我正在使用Laravel 5并收到以下异常:
PDOException(1044)SQLSTATE [HY000] [1044]用户'@'localhost'对数据库'forge'的访问被拒绝
我的数据库配置文件是:
<?php
return [
/*
|--------------------------------------------------------------------------
| PDO Fetch Style
|--------------------------------------------------------------------------
|
| By default, database results will be returned as instances of the PHP
| stdClass object; however, you may desire to retrieve records in an
| array format for simplicity. Here you can tweak the fetch style.
|
*/
'fetch' => PDO::FETCH_CLASS,
/*
|--------------------------------------------------------------------------
| Default Database Connection Name
|--------------------------------------------------------------------------
|
| Here you may specify which of the database connections below you …Run Code Online (Sandbox Code Playgroud) 我有这个问题。当我点击添加到购物车按钮时出现错误:
解析错误:语法错误、意外的 '__construct' (T_STRING)、期望函数 (T_FUNCTION) 或 const (T_CONST)
我是 Laravel 的新手,我真的不知道我必须做什么,
这是我在“添加到购物车”按钮上的代码:
<a href="{{route('get.addToCart',[$product->id])}}" class="cart-btn">Add to cart</a>
Run Code Online (Sandbox Code Playgroud)
这是我的路线:
Route::get('add-to-cart/{id}', 'WebController@addToCart')->name('get.addToCart');
Run Code Online (Sandbox Code Playgroud)
我在网络控制器中有这个:
public function addToCart(Request $request, $id){
$product = Product::find($id);
$oldCart = Session::has('cart') ? Session::get('cart') : null;
$cart = new Cart($oldCart);
$cart->add($product,$product->id);
$request->session()->put('cart',$cart);
dd($request->session()->get('cart'));
return redirect()->route(get.product);
}
Run Code Online (Sandbox Code Playgroud)
这是我的cart.php
<?php
namespace App;
class Cart{
public $items=null;
public __construct($oldCart){
if($oldCart){
this->$items=$oldCart->items;
}
}
public function add($item,$id){
$storedItem= ['name'=>$item];
if(this-> $items)
{
if(array_key_exists($id, this->$items)){
$storedItem=this->$items[$id];
}
}
this->$items[$id]=$storedItem;
}
}
Run Code Online (Sandbox Code Playgroud) 我正在使用 python 3.5(32 位)、win10-64 位、OpenOPC,并且我已经下载了 pywin32 构建 64 位。我已经运行了以下 python 代码:
import OpenOPC
import time
opc=OpenOPC.client()
opc.connect('Matrikon.OPC.Simulation.1')
tags =['Random.Int4','Random.Real4']
while True:
try:
value = opc.read(tags,group='Group0',update=1)
print (value)
except OpenOPC.TimeoutError:
print ("TimeoutError occured")
time.sleep(5)
Run Code Online (Sandbox Code Playgroud)
但我总是收到此错误消息:
回溯(最近一次调用):文件“C:\Program Files (x86)\Python35-32\lib\multiprocessing\queues.py”,第 241 行,在 _feed obj = ForkingPickler.dumps(obj) 文件“C:\ Program Files (x86)\Python35-32\lib\multiprocessing\reduction.py", line 50, in dumps cls(buf, protocol).dump(obj) _pickle.PicklingError: Can't pickle : attribute lookup datetime on pywintypes failed .
我有一个列表,其中的字段是通过 import xlxs 动态获取的。我已经生成了一个数组列表。当只有 xlxs 文件有 1 条记录时插入工作但在获取多行时不起作用。
当有超过 1 个数组时,它会显示:
SQLSTATE[21S01]:插入值列表与列列表不匹配:1136 列计数与第 2 行的值计数不匹配
然后是sql代码
我的数组列表如下:
Array(
[0] => Array
(
[name] => Md. XXXX
[email] => abc@gmail.com
[mobile_no] => 1751017812
[password] => $2y$10$vgmdsjT64aXHQcPA6vh8LuWfdWWA/NCtC8NLYTl8yyQ/wtXdcSNHy
[user_type_id] => 1
[designation] => Sr. Software Engineer
[market_code] => mirpurA203
[product_code] => Seclo201
[territori_code] => T352
[region_code] => Mirpur334
[division_code] => Dhaka31
)
[1] => Array
(
[name] => Md. XX
[email] => def@gmail.com
[mobile_no] => 1761017812
[password] => $2y$10$52CtpkGrKfriInOmnz.guOrIvnCJyxgYRbfEkDl6nFkPD2UYcvhiO
[user_type_id] => 2
[designation] …Run Code Online (Sandbox Code Playgroud) 我正在尝试从Laravel Vue组件中的API获取数据。我在控制台中收到此错误:
TypeError:无法设置未定义的属性“大陆”
我想念什么?
这是我的代码:
<script>
export default {
mounted() {
console.log('Component mounted.');
},
created(){
this.loadData();
},
data() {
return {
continents: [],
}
},
methods: {
loadData: function() {
axios.get('/api/continents')
.then(function (response) {
// handle success
console.log(response.data);
this.continents = response.data;
})
.catch(function (error) {
// handle error
console.log(error);
})
.then(function () {
// always executed
});
},
},
}
</script>
Run Code Online (Sandbox Code Playgroud) 我在 Laravel 中使用 Vue。当我在 vue 代码中进行更改时,这些更改在我运行以下命令之前不会出现:
npm run production
Run Code Online (Sandbox Code Playgroud)
我想在没有这个命令的情况下使用 vue 或者至少一次就足够了
我想以编程方式从我的存储桶中删除文件,但它没有发生
我有下面的代码
$s3 = \Storage::disk('s3');
$existingImagePath = $studentPortfolios[$i]->portfolio_link; // this returns the path of the file stored in the db
$s3->delete($existingImagePath);
Run Code Online (Sandbox Code Playgroud)
但这并不是从存储桶中删除文件
当我从本地设置运行它时,我必须暂时为每个人向存储桶写入对象权限。
请注意:- 我可以上传文件,但删除不起作用
对此的任何建议都会非常有帮助。
我的计算机具有正确的 SSH 配置,尝试克隆存储库时出现此错误:
我运行此命令来克隆存储库
git clone ssh://git-codecommit.us-west-2.amazonaws.com/v1/repos/NewsFeed-library library1
Run Code Online (Sandbox Code Playgroud)
它给了我一个错误:
克隆到“library1”...
远程:计数对象:510,完成。
远程关闭到 git-codecommit.us-west-2.amazonaws.com 的连接
主持人。致命:远端意外挂断 致命:提前EOF
致命:索引包失败
如何解决此错误以及为什么会出现此错误?
编辑:我已经尝试过但没有成功:
#Windows
set GIT_TRACE_PACKET=1
set GIT_TRACE=1
set GIT_CURL_VERBOSE=1
Run Code Online (Sandbox Code Playgroud)
和
git config --global ssh.postBuffer 524288000
Run Code Online (Sandbox Code Playgroud) 我已经从git克隆了repo,并制作了composer install。
然后,我正在启动服务器,但是每次出现500服务器错误。
另外,我尝试使用创建一个新项目,composer create-project --prefer-dist laravel/laravel blog
并且该项目运行良好。
在我的错误日志中,我收到了如下错误:
production.ERROR:未指定应用程序加密密钥。{“ exception”:“ [对象](RuntimeException(code:0):未指定应用程序加密密钥。位于C:\ OSPanel \ domains \ contact-fw-domanskyi \ vendor \ laravel \ framework \ src \ Illuminate \ Encryption \ EncryptionServiceProvider.php:44)[stacktrace]
我试图在 Amazon elasticBeanstalk 上上传这个实例,但它似乎不起作用。
我曾尝试使用 ssh 访问文件无济于事。
我做了php artisan config:cache和composer dump-autoload上传之前。
任何帮助表示赞赏。
laravel ×8
php ×3
laravel-5 ×2
vue.js ×2
amazon-ec2 ×1
amazon-s3 ×1
eloquent ×1
git ×1
laravel-5.7 ×1
python-3.5 ×1
ssh-keys ×1