在我的routes.php
档案中,我有:
Route::get('/', function () {
return view('login');
});
Route::get('/index', function(){
return view('index');
});
Route::get('/register', function(){
return view('register');
});
Route::post('/register',function(){
$user = new \App\User;
$user->username = input::get('username');
$user->email = input::get('email');
$user->password = Hash::make(input::get('username'));
$user->designation = input::get('designation');
$user->save();
});
Run Code Online (Sandbox Code Playgroud)
我有一个用户注册表.我也在表格中输入表格输入值routes.php
.
但是当我注册用户时出现错误.错误:
FatalErrorException in routes.php line 61:
Class 'input' not found
Run Code Online (Sandbox Code Playgroud) 我在我的方法中有以下代码,我通过ajax发送到控制器方法:
$newUser = \App\UserInfo::updateOrCreate([
'user_id' => Auth::user()->id,
'about' => $request->get('about'),
'sec_email' => $request->get('sec_email'),
'gender' => $request->get("gender"),
'country' => $request->get('country'),
'dob' => $request->get('dob'),
'address' => $request->get('address'),
'mobile' => $request->get('cell_no')
]);
Run Code Online (Sandbox Code Playgroud)
该dd($request->all())
给我:
array:8 [
"_token" => "fHeEPfTvgMD3FpIBmmc6DmKXFaiuWKZEiOhg6twQ"
"about" => "Some about me."
"sec_email" => "example@gmail.com"
"country" => "Priority highest"
"gender" => "male"
"dob" => "12/12/1990"
"address" => "Some address"
"cell_no" => "234234234"
]
Run Code Online (Sandbox Code Playgroud)
这是完美的.
Jquery代码:
$('#submit-editProfile-form').on('click', function() {
var profileEditForm = $("#edit-user-profile");
var formData = $('#edit-user-profile').serialize();
profileEditForm.on('submit', function(e){
e.preventDefault();
$.ajaxSetup({ …
Run Code Online (Sandbox Code Playgroud) 我一直在四处寻找,但没有得到任何召集.
在laravel中实现Vue MPA架构的最佳方法和实践是什么.
搜索了很多.但没有什么能给你一个清晰的想法.你的回答很有帮助,请简要说明.
回答这一点也很有帮助:
我有两个型号,User
和Team
他们之间的关系是ManyToMany
:
在User
:
public function teamMembers(){
return $this->belongsToMany('App\Team')->withPivot('id');;
}
Run Code Online (Sandbox Code Playgroud)
并在Team
:
public function teamMembers(){
return $this->belongsToMany('App\User')->withPivot('id');;
}
Run Code Online (Sandbox Code Playgroud)
现在我想将用户添加到特定团队.因此数据透视表名称是team_user
.
现在我要插入数据透视表的数据是:
array:4 [?
"_token" => "mlwoAgCQYals1N1s2lNa4U5OTgtMNHh9LUhNGrWh"
"team_id" => "1"
"members_id" => array:3 [?
0 => "2"
1 => "3"
2 => "4"
]
"status" => "1"
]
Run Code Online (Sandbox Code Playgroud)
我在我的控制器中做了什么:
$team_id = $request->get("team_id");
$team = \App\Team::findOrFail($team_id);
foreach ($request->get('members_id') as $key => $value) {
$team->teamMembers()->attach($team);
$team->save();
}
Run Code Online (Sandbox Code Playgroud)
但它只插入一条记录,我的意思team_id
是第一条记录member_id
.我希望它从members_id
数组中为每个成员创建一条记录.我该怎么做?
我通过添加laravel安装了redis "predis/predis":"~1.0"
,
然后为了测试我添加了以下代码:
public function showRedis($id = 1)
{
$user = Redis::get('user:profile:'.$id);
Xdd($user);
}
Run Code Online (Sandbox Code Playgroud)
在app/config/database.php我有:
'redis' => [
'cluster' => false,
'default' => [
'host' => env('REDIS_HOST', 'localhost'),
'password' => env('REDIS_PASSWORD', null),
'port' => env('REDIS_PORT', 6379),
'database' => 0,
],
],
Run Code Online (Sandbox Code Playgroud)
它会引发以下错误: No connection could be made because the target machine actively refused it. [tcp://127.0.0.1:6379]
我virtualhost
用于该项目.用Xampp with windows
.
我用Laravelcollective/html v5.3.0
用laravel 5.3
.现在我正在使用laravel 5.4
.我有正在使用的表格Laravelcollective/html v5.3.0
.
该composer require laravelcollective/html
给我下面的错误:
Installation request for laravelcollective/html ^5.3 -> satisfiable by laravelcollective/html[v5.3.0].
-Conclusion: remove laravel/frameworkv5.4.0
- Conclusion: don't install laravel/framework v5.4.0
Run Code Online (Sandbox Code Playgroud)
什么时候laravel 5.4支持Laravelcollective/html
?
我有使用tabula-py读取pdf的python代码以提取文本,然后通过tabula-py将其更改为表格形式。但这给了我一个警告。
Nov 15, 2017 3:40:23 PM org.apache.pdfbox.pdmodel.font.PDSimpleFont toUnicode
WARNING: No Unicode mapping for .notdef (9) in font Helvetica
Run Code Online (Sandbox Code Playgroud)
此警告是tabula-py,并且Tabula-py用Java编写。因此,我不能简单地使用-W ignore
抑制上述警告。
有什么方法可以消除或抑制以上警告。
我已经安装了Apache 2,它工作正常.我已经安装了PHP 7,一切正常,但是当我安装phpMyAdmin时,Apache 2停止工作.检查Apache 2时,它甚至不会加载默认页面.
当我重新启动Apache 2时,出现以下错误:
root@ip-172-31-30-202:~# service apache2 restart
* Restarting web server apache2 [fail]
* The apache2 configtest failed.
Output of config test was:
Segmentation fault (core dumped)
Action 'configtest' failed.
The Apache error log may have more information.
Run Code Online (Sandbox Code Playgroud)
错误日志包含:
[Mon Jul 18 12:54:10.668017 2016] [mpm_event:notice] [pid 13665:tid 140077033654144] AH00489: Apache/2.4.7 (Ubuntu) configured -- resuming normal operations
[Mon Jul 18 12:54:10.668089 2016] [core:notice] [pid 13665:tid 140077033654144] AH00094: Command line: '/usr/sbin/apache2'
[Mon Jul 18 12:54:23.642421 2016] [mpm_event:notice] [pid …
Run Code Online (Sandbox Code Playgroud) 场景:客户可以将客户引荐给另一个客户.每个引用都需要存储在DB表行中.接收推荐的客户应该看到该活动的通知.
创建新的推荐并发送事件:
$totalRefers = [];
foreach ($array as $to) {
$refer = new ClientReferral;
$refer->user_id = $user_id;
$refer->by = $by;
$refer->to = $to;
$refer->save();
array_push($totalRefers, $refer);
ReferralSent::dispatch($refer); // Here is the Event
}
return response()->json([
'status' => 'Success',
'message' => 'Client referred successfully to selected professionals.',
'data' => $totalRefers
], 200);
Run Code Online (Sandbox Code Playgroud)
事件broadcastOn()
方法:
public function broadcastOn() {
return new PrivateChannel('referral.' . $this->referral->id);
}
Run Code Online (Sandbox Code Playgroud)
这个频道:
Broadcast::channel('referral.{id}', function ($user, $id) {
// let's say it's true for the time being …
Run Code Online (Sandbox Code Playgroud) 我有以下网址
http://project.su/?invitee=95
首先,我想检查输入invitee
网址,如果网址已invitee
获得值.
我试过的(控制器):
if(!empty($request->get('invitee'))){
$user->invitee = $request->get('invitee');
}
Run Code Online (Sandbox Code Playgroud)
以下代码无效.
我想将invitee
结果(id)存储在数据库中.
谢谢.
laravel ×8
php ×8
eloquent ×2
forms ×2
redis ×2
apache ×1
apache2 ×1
javascript ×1
jquery ×1
laravel-5 ×1
laravel-5.1 ×1
laravel-5.2 ×1
laravel-5.4 ×1
laravel-echo ×1
loops ×1
multipage ×1
python ×1
server ×1
socket.io ×1
tabula ×1
ubuntu ×1
vue.js ×1