/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index(Request $request) { $search = \Request::get('search'); //<-- we use global request to get the param of URI $companies = \DB::table('companies')->lists('store_name', 'id'); $status = \DB::table('fiscal_document_statuses')->lists('status_name', 'id'); if ($search) { $allFiscalDocuments = FiscalDocument::whereRaw('date(created_at) = ?', [$search])->orderBy('id', 'desc')->paginate(5); } else { $allFiscalDocuments = FiscalDocument::orderBy('id', 'desc')->paginate(5); } return view('fiscalDocument.index', ['fiscalDocuments' => $allFiscalDocuments, 'companies' => $companies]); }
/** * 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]); }
/** * Get all of the tasks for a given user. * * @param User $user * @return Collection */ public function allFiscalDocuments() { return FiscalDocument::orderBy('created_at', 'desc')->get(); }