小编Gam*_*mer的帖子

laravel 5:找不到类'输入'

在我的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)

php laravel laravel-5 laravel-5.1 laravel-5.2

103
推荐指数
7
解决办法
16万
查看次数

laravel updateOrCreate方法

我在我的方法中有以下代码,我通过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)

php forms jquery laravel eloquent

21
推荐指数
3
解决办法
5万
查看次数

Vue.js:在laravel中实现MPA(多页面应用程序)的最佳方式

我一直在四处寻找,但没有得到任何召集.

在laravel中实现Vue MPA架构的最佳方法和实践是什么.

搜索了很多.但没有什么能给你一个清晰的想法.你的回答很有帮助,请简要说明.

回答这一点也很有帮助:

  • 使用laravel作为数据API是一个好主意,并将Vue与laravel分开?
  • 实现SPA和MPA混合的最佳方法.

javascript design-patterns multipage laravel vue.js

18
推荐指数
2
解决办法
1万
查看次数

Laravel:多次插入

我有两个型号,UserTeam 他们之间的关系是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数组中为每个成员创建一条记录.我该怎么做?

php loops laravel eloquent laravel-5.4

17
推荐指数
1
解决办法
1万
查看次数

Laravel:Redis无法建立连接:[tcp://127.0.0.1:6379]

我通过添加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.

php redis laravel

14
推荐指数
3
解决办法
2万
查看次数

laravel 5.4:Laravelcollective/html v5.3.0需要照亮/查看5.3.*

我用Laravelcollective/html v5.3.0laravel 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

php forms laravel laravelcollective

12
推荐指数
1
解决办法
2万
查看次数

禁止或删除python表格警告

我有使用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抑制上述警告。

有什么方法可以消除或抑制以上警告。

python tabula

11
推荐指数
1
解决办法
601
查看次数

Ubuntu 14.04服务器:Apache2问题与phpMyAdmin

我已经安装了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)

php apache ubuntu apache2 server

9
推荐指数
2
解决办法
6760
查看次数

Laravel Echo私人频道与Laravel echo服务器| Redis的

场景:客户可以将客户引荐给另一个客户.每个引用都需要存储在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)

php redis socket.io laravel laravel-echo

8
推荐指数
1
解决办法
654
查看次数

laravel 5.2:获取查询字符串

我有以下网址 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)存储在数据库中.

谢谢.

php laravel

7
推荐指数
3
解决办法
3万
查看次数