将数据传递到队列作业会得到404-其他错误

问题描述

从我的控制器

use App\Jobs\MonthlyReport;

public function store(Request $request)
{
  $report = new Report;
  ...
  $report->save();
  $this->dispatch(new MonthlyReport($report));
  return $report;
}

MonthlyReport.php

use App\Report;

private $rep;

public function __construct(Report $report)
{
    $this->rep = $report;
}

public function handle()
{
    dd($this->rep);
}

给出404,没有其他错误。但是,如果我没有传递$report变量,那么它将起作用。触发404而不是错误或dd();

的问题应该是什么?

注意:另一个项目中使用了相同的逻辑并且该逻辑正在起作用,但此处不起作用

我的Web.php

Route::resource('report','ReportController');

我的表单(年和月数据来自JQuery)

<form method="POST" action="/report">
@csrf
<div class="form-group">
    <label class="required">Office</label>
    <select class="form-control" id="change_office" required name="office">
        <option value>choose office</option>
        @foreach ($offices as $office)
            <option value="{{ $office->id }}">{{ $office->name }}</option>
        @endforeach
    </select>
</div>

<div class="form-group">
    <label class="required" for="year">Option</label>
    <select id="option" class="form-control" name="option" required>
        <option value="">Choose options</option>
        <option value="Monthly">Monthly</option>
        <option value="Quarterly">Quarterly</option>
        <option value="Yearly">Yearly</option>
        <option value="Custom">Custom</option>
        <option value="Time Base">Entry/Exit Report</option>
    </select>
</div>

<div class="form-group" id="yearly_wrapper" style="display: none;">
    <label class="required" for="year">Year</label>
    <select id="year" class="form-control" name="year">
        <option value="">Choose year</option>
    </select>
</div>

<div class="form-group" id="monthly_wrapper" style="display: none;">
    <label class="required">Select Month</label>
    <select id="monthly" class="form-control" name="monthly">
        <option value="">Select month</option>
    </select>
</div>

<div>
    <button type="submit" class="btn btn-outline-warning btn-round">
        <i class="now-ui-icons ui-1_check"></i> Generate
    </button>
</div>
</form>

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)