小编z0m*_*ale的帖子

Laravel echo服务器无法在生产服务器中运行

我有socket.io作为一个广播员与laravel回声的问题.

我试过了什么:

php artisan cache:clear
php artisan config:clear
Run Code Online (Sandbox Code Playgroud)

我可以看到用户在日志中连接:

0|Socket-Connection  | [11:17:00 AM] - ********** joined channel: test-channel
0|Socket-Connection  | [11:17:01 AM] - ********** authenticated for: private-user.1
0|Socket-Connection  | [11:17:01 AM] - ********** joined channel: private-user.1
Run Code Online (Sandbox Code Playgroud)

我的队列正在运行,正在正确记录所有事件.

我可以在redis控制台中完美地看到redis我的事件和数据库通知.

但是没有广播事件,我没有在laravel-echo-server控制台中看到它们.一切都在我的本地主机上工作,但不是在制作中我失去了理智.

这是我的laravel echo JS:

if (typeof io !== 'undefined') {
    console.log(window.location.origin);
    window.Echo = new Echo({
        broadcaster: 'socket.io',
        host: window.location.origin + ':6001',
        auth: {
            headers: {
                Authorization: 'Bearer ' + bearerToken,
            },
        }
    });
    window.Echo.private('user.' + user_id).notification((notification) => {
        console.log(notification);
    });
}
Run Code Online (Sandbox Code Playgroud)

在我的用户模型上,我定义了这个: …

php redis socket.io laravel laravel-echo

10
推荐指数
1
解决办法
1980
查看次数

如何在子文件夹PHP中呈现视图

我是MVC的新手,刚开始练习它.我正在创建一个中小型企业网站,并且不想使用任何大型框架,所以我发现了这个,到目前为止它工作得很好.我似乎唯一不理解的是如何在子文件夹中呈现视图.

我有3种药物需要显示信息,它们的结构如下:

views
--medicines
----medicine1
------info.php
------forms
--------male.php
--------female.php
Run Code Online (Sandbox Code Playgroud)

这是药物控制器:

<?php

class MedicinesController extends Controller
{
    /**
     * Construct this object by extending the basic Controller class
     */
    public function __construct()
    {
        parent::__construct();

        Auth::checkAuthentication();
    }

    /**
     * Handles what happens when user moves to URL/medicines/index
     **/
    public function index()
    {
        $this->View->render('medicines/index');
    }

    /**
     * Handles what happens when user moves to URL/medicines/medicine1
     **/
    public function medicine1()
    {
        $this->View->render('medicines/medicine/info', array(
            'files' => FilesModel::getMedicineFiles())
        );
    }

    /**
     * Handles what …
Run Code Online (Sandbox Code Playgroud)

php

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

条纹订阅结束日期和时间

我开始使用条带付款并设置我的测试环境.一切正常,直到订阅即将结束.就像在Stripe的主页上所说的教程一样,你应该将订阅结束日期保存在我正在做的数据库中.

因此,假设用户已取消或其订阅已结束.他正试图再次登录,并提示再次注册订阅的消息.我在这里获取日期并重新订阅用户:

//create subscription
$customer = \Stripe\Subscription::create(array(
    "customer" => $customer_id,
    "plan" => "test"
));

//get curent end period
$end_date = $customer->current_period_end;
//getting something like this 1472625732
$next_payment_date = date('Y-m-d',$end_date);
Run Code Online (Sandbox Code Playgroud)

从条纹响应中获取日期.然后我将它转换为我可以在mysql中使用的时间戳,然后我插入它.一切正常,但我认为我的订阅过早取消.

条纹我看到这个:

现时阶段:

2016/08/30 to 2016/08/31
Run Code Online (Sandbox Code Playgroud)

在我的数据库中,我看到2016-08-31 00:00:00,它在午夜取消了订阅,但条纹说订阅仍然有效.

在我的登录脚本中,我在数据库中检查该日期,它表示我的订阅未激活,这是不正确的.

这是我的问题,我该如何防止这种行为?订阅结束时是否有任何方法可以获得时间,或者是否有条带设置的默认时间?

stripe-payments

5
推荐指数
1
解决办法
831
查看次数

Laravel 方法通知不存在

如果新表单插入到数据库中,我试图通知用户,但我收到此错误:

BadMethodCallException in Macroable.php line 74: Method notify does not exist.
Run Code Online (Sandbox Code Playgroud)

这是通知类

<?php

namespace App\Notifications\Admin;

use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;

use App\Models\Admin\Forms\Prescriptions;

class PrescriptionNotification extends Notification
{
    use Queueable;

    public $Prescription;

    /**
     * Create a new notification instance.
     *
     * @return void
     */
    public function __construct(Prescriptions $Prescription)
    {
        $this->Prescriptions = $Prescription;
    }

    /**
     * Get the notification's delivery channels.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function via($notifiable)
    {
        return ['database'];
    }

    /**
     * …
Run Code Online (Sandbox Code Playgroud)

php laravel

4
推荐指数
1
解决办法
6912
查看次数

text()不会附加到同一行的第二个<span>

jQuery text()函数不会option从选择字段追加到span.我有两个select相同的字段div.它们是不同的,包含动态创建的数字.

function myFunction(selector) {
    var i;
    for (i = 1; i <= 999; i++) {
      var text = '00' + i;
      selector.options[i - 1] = new Option(text.substr(text.length - 3, 3));
    }
  }
  //usage:
myFunction(document.getElementById("patient_code"));

$('#patsiendikoodi_label #patient_code ').change(function(i, text) {
  var $this = $(this);
  $this.prev().find('.patsiendikoodi_label_nr').text($(this).find('option:selected').text());
}).change();



function patsient(selector) {
    var i;
    for (i = 1; i <= 99; i++) {
      var text = '0' + i;
      selector.options[i - 1] = new …
Run Code Online (Sandbox Code Playgroud)

html javascript jquery

3
推荐指数
1
解决办法
148
查看次数

如何更新MYSQL中的特定行

我有一个表,我存储用户上传的文件.可以有5种不同的文件类型:个人资料图片,cpr文件,学位文件,视频文件,背景检查文件.

表结构是这样的:

file_id, user_id, file_type, file_size, file_name, file_new_name, file_path, file_cat, date_created
Run Code Online (Sandbox Code Playgroud)

我的问题:

  1. 这种结构有效还是我应该创建5个不同的表?
  2. 如果我想更新,让我们说用户个人资料图片行,那么最好的方法是什么呢?---我提出了一个可能不是最好的解决方案 - 我更新了行file_cat = "profile_picture" and user_id=:user_id.这会给系统带来很大的负担吗?
  3. 首先,当用户注册时,他没有任何文件.我应该insert into ... VALUES ... on duplicate key update在表单中使用隐藏值吗?

先感谢您.

php mysql

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

Laravel 自定义授权失败时的错误页面

当我的编辑请求授权失败时,我试图在 laravel 中显示自定义 403 文件。

我尝试过forbiddenResponse(),但事实证明它已经被淘汰了。

然后我尝试了failedauthorization(),但这也没有重定向并允许我进行编辑。

这是我的请求文件

public function authorize()
{
  $job_posting_id = $this->route('id');

  $job_posting = Job_postings::where('id', $job_posting_id)->where('user_id', user()->id)->exists();

  if($job_posting){
    return true;
  }

  return false;
}

public function failedAuthorization()
{

  return redirect('errors.dashboard.parent.403');
}
Run Code Online (Sandbox Code Playgroud)

我有一个名为“错误”的文件夹,其中有仪表板文件夹和错误文件所在的父文件夹。

如果授权失败,如何重定向到该页面?

laravel

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

Laravel URL过期

我正在创建一个保姆预订系统。预订后24小时,我将向父母用户发送电子邮件以查看保姆。我想向父用户发送一个URL,以便他单击该URL时可以查看保姆。除URL之外,其他所有内容均有效。该网址必须在24小时内过期。我知道我必须在url中传递令牌,但是我该如何进行数据库设计呢?以及如何根据令牌使URL过期?

任何意见,将不胜感激

laravel

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