我已经从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]
我需要将数据从控制器传递到partials 文件夹内的头文件。
建议我如何将数据“货币”从控制器传递到头文件。
控制器 :
class HeaderController extends Controller
{
public function rate(){
$currency = Whmcs::GetCurrencies([
]);
return view('partials.header',compact('currency'));
}
}
Run Code Online (Sandbox Code Playgroud)
头文件:
<form name="form">
<select name="currency" class="form-control">
@foreach($currency['currencies']['currency'] as $key=>$value)
@for($key=0;$key<100;$key++)
@endfor
<option value="{{$value['code']}}">{{$v=$value['code']}}</option>
@endforeach
</select>
</form>
Run Code Online (Sandbox Code Playgroud)
路线:
Route::any('/partials.header', 'HeaderController@rate');
Run Code Online (Sandbox Code Playgroud) 我正在制作一个博客,它有一些奇怪的问题.我在帖子模型上使用了注释和帖子模型之间的OneToMany连接(一个帖子可以有很多注释):
public function comments(){
return $this->hasMany('App\Comment');
}
Run Code Online (Sandbox Code Playgroud)
和评论模型:
public function Posts(){
return $this->belongsTo('App\Posts');
}
Run Code Online (Sandbox Code Playgroud)
现在我遇到的问题是show.blade.php,它从控制器的show()方法接收来自控制器的数据,并返回一些关于帖子的数据.
public function show($id)
{
$post = Posts::find($id);
return view('posts.show')->with('post', $post);
}
Run Code Online (Sandbox Code Playgroud)
从刀片模板,我显示与postid相关的帖子相关的评论
<div class="card-body">
<h5 class="card-title"><strong>test comment:</strong></h5>
<p class="card-text">{{$post->comments->body}}</p>
</div>
Run Code Online (Sandbox Code Playgroud)
我试过,$post->comments->body但我得到错误这有什么问题,建议将不胜感激
我是 laravel 的新手并尝试运行迁移,但它显示以下错误:
在 Connection.php 第 664 行中:
SQLSTATE[HY000] [1045] 用户 'root'@'localhost' 的访问被拒绝(使用密码:NO)(SQL:选择 * from information_schema.tables where table_schema = test1 and table_name = migrations)
在 Connector.php 第 67 行:
SQLSTATE[HY000] [1045] 用户 'root'@'localhost' 的访问被拒绝(使用密码:NO)
正如在laravel/algolia网站上写的那样,我一切都正确。
我试图阅读大量有关 Laravel Scout 安装的文档和教程,但仍然找不到解决方案。
我的设置中一切都正确,API 也正确,但仍然出现此错误:
无法连接,请检查您的 Algolia 应用程序 ID。
我为我的空间(属性)创建了一个模型和控制器,该模型和控制器具有数据库结构;space_id,space_address,space_owner,space_price等...
但是,当我访问localhost:8000 / project / space / 1时,出现此错误:
找不到列:1054“ where子句”中的未知列“ spaces.id”(SQL:select * from
spaceswherespaces。id= 3 limit 1)
功能:
public function show($id)
{
$space = Space::find($id);
return view('space.show')->with('space', $space);
}
Run Code Online (Sandbox Code Playgroud)
这是我的模型,如果有帮助:
class Space extends Model
{
protected $table = 'spaces';
public $primarykey = 'space_id';
}
Run Code Online (Sandbox Code Playgroud) 当我email从数据库字段更改为Laravel错误user_email
Illuminate \ Database \ QueryException SQLSTATE [42S22]:找不到列:1054“ where子句”中的未知列“ email”(SQL:select * from
ns_userswhere
Schema::create('ns_users', function (Blueprint $table) {
$table->increments('user_id');
$table->boolean('active')->default(0);/*by default the user is not active*/
$table->integer('role')->default(0);/* role 0 means user and role 1 means admin!! */
$table->string('name');
$table->string('user_email')->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->rememberToken();
$table->timestamps();
});
Run Code Online (Sandbox Code Playgroud)
有人知道我必须更改默认身份验证才能使用user_email字段而不是email吗?
如果数值$mqmtxt大于20,我试图回显特定的消息.
该值位于txt文件中,值为7,因此应显示NO WARN但正在显示WARN.不知道我在这里缺少什么.
<?php
$mqmtxt = file_get_contents("./MQM/mqmcount.txt");
$mqmtxt = preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $mqmtxt);
if ($mqmtxt >= "20"){
$mqmwarning = "WARN";
}else{
$mqmwarning = "NO WARN";
}
?>
<!DOCTYPE html>
<html>
<body>
<div id="dispmqmcount"><?php echo $mqmtxt; ?></div>
<div id="warning"><?php echo $mqmwarning; ?></div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud) 我在 Laravel 中遇到了一个空白页面的问题,我不知道哪里出了问题。
这是我的代码示例:查看maintenance/index.blade.php
<form method="post" action="{{route('maintenance.update_request')}}" enctype="multipart/form-data">
<input type="hidden" name="_method" value="put">
{{ csrf_field() }}
.....
Run Code Online (Sandbox Code Playgroud)
并在控制器MaintenanceController.php中创建自定义方法update_request
public function update_request(Request $request) {
dd($request);
}
Run Code Online (Sandbox Code Playgroud)
然后是web.php(路由)
Route::post('maintenance/update_request', 'MaintenanceController@update_request')->name('maintenance.update_request');
Route::resource('maintenance', 'MaintenanceController');
Run Code Online (Sandbox Code Playgroud)
但是当我单击“提交”按钮时,我得到空白页....public/maintenance/update_request
当我运行此命令时: php artisan make:auth
我收到一个错误:
未定义命令“ make:auth”。
我的命令有问题php artisan make:auth。如何在Laravel中创建登录名