从我的控制器
use App\Jobs\MonthlyReport;
public function store(Request $request)
{
$report = new Report;
...
$report->save();
$this->dispatch(new MonthlyReport($report));
return $report;
}
月报.php
use App\Report;
private $rep;
public function __construct(Report $report)
{
$this->rep = $report;
}
public function handle()
{
dd($this->rep);
}
它给出404,没有其他错误。但是如果我没有传递$report
变量,那么它就可以工作。触发404而不是错误的问题应该是什么?dd();
注意:在另一个项目中使用相同的逻辑并且它正在工作,但不是在这里
我的网页.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>