0

单击生成订单时,我创建了一个 PDF 对象。我想(在显示所有订单的结果后)删除表中的所有订单。我在路线上试过这个,但它不起作用?

//used to reset the orders in database
Route::filter('reset', function()
{
//once rendered the report remove all of the orders from db
DB::query("DELETE FROM orders");
});

报告的get请求如下:

Route::get('report', array('as' => 'report', 'after' => 'reset','uses' => 'admin@report'));

我将如何执行此操作,因为显然脚本在创建 PDF 之前就退出了。

4

2 回答 2

1

尝试

DB::table('orders')->delete();
于 2013-06-03T16:55:38.807 回答
0

我决定在输出 PDF 之后放置它,而不是使用路由过滤器,应该多考虑一下。

        $html2pdf = new HTML2PDF('P','A4','en');

        //set it to full page
        $html2pdf->pdf->SetDisplayMode('fullpage');

        //write the html from the view 'report' and attach the $data array
        $html2pdf->WriteHTML(View::make('documents.report', $data));

        //output the pdf so the user can view
        $html2pdf->Output('orders.pdf');

        //delete all the orders
        DB::table('orders')->delete();

现在,它会在每次请求 pdf 后删除所有订单

于 2013-06-03T18:03:33.927 回答