/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $companies = \DB::table('companies')->lists('store_name', 'id'); $channels = \DB::table('marketing_channels')->lists('channel_name', 'id'); $suppliers = \DB::table('suppliers')->lists('supplier_name', 'id'); $supplier_id = \Request::get('supplier_id'); $marketing_channel_id = \Request::get('marketing_channel_id'); $company_id = \Request::get('company_id'); $from = \Request::get('from') . ' 00:00:00'; $to = \Request::get('to') . ' 23:59:59'; if ($supplier_id && $marketing_channel_id && $company_id) { $supplier_branches = \App\Supplier::find($supplier_id)->supplierBranches; foreach ($supplier_branches as $supplier_branch) { $branch_ids[] = $supplier_branch->id; } $allFiscalDocuments = FiscalDocument::whereBetween('created_at', [$from, $to])->WhereIn('supplier_branch_id', $branch_ids)->Where('company_id', $company_id)->orderBy('id', 'desc')->paginate(5); $allCost = Cost::whereBetween('created_at', [$from, $to])->Where('supplier_id', $supplier_id)->Where('marketing_channel_id', $marketing_channel_id)->Where('company_id', $company_id)->orderBy('id', 'desc')->get(); } else { $allFiscalDocuments = FiscalDocument::orderBy('id', 'desc')->paginate(5); $allCost = Cost::orderBy('id', 'desc')->paginate(5); } return view('cost.join', ['fiscalDocuments' => $allFiscalDocuments, 'companies' => $companies, 'suppliers' => $suppliers, 'channels' => $channels, 'costs' => $allCost]); }
public function getFiscalDocument($id) { return FiscalDocument::where('id', $id)->orderBy('created_at', 'desc')->get(); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy(Request $request, FiscalDocument $fiscalDocument) { $fiscalDocument->delete(); return redirect('/fiscalDocument'); }