/** * Display a listing of the resource. * * @return Response */ public function index() { $user = Auth::user(); $firmName = $user->firm->organisation_name; $countOfOrders = Order::where('user_id', Auth::user()->id)->count(); $countOfDocuments = Document::where('user_id', Auth::user()->id)->count(); return view('cabinet.index', ['p' => 'cabinet', 'userId' => $user->id, 'firmName' => $firmName, 'countOfOrders' => $countOfOrders, 'countOfDocuments' => $countOfDocuments]); }
public function showDocs() { $docs = Document::where('user_id', Auth::user()->id)->get(); $docsByTypesArr = []; foreach ($docs as $q => $doc) { $shortFileName = explode(DIRECTORY_SEPARATOR, $doc->file_name); $shortFileName = end($shortFileName); $tempFileName = explode('_', $shortFileName); $tempFileName = explode('.', end($tempFileName)); $fileDate = date('d.m.Y', $tempFileName[0]); $typeOfDoc = Order::getDocTypeName($doc->type, true); if (!$doc->service_order_id && !$doc->order_id) { $docId = null; } else { $docId = $doc->service_order_id ? $doc->service_order_id : $doc->order_id; } $extension = end($tempFileName); //$shownFileName = $typeOfDoc.' №'.$docId.'.'.$tempFileName[1]; $temp = $docId ? ' №' . $docId : ' по оказанию услуг'; $shownFileName = $typeOfDoc . $temp . '.' . $extension; $docsByTypesArr[$typeOfDoc][] = ['shortFileName' => $shortFileName, 'shownFileName' => $shownFileName, 'extension' => $extension, 'fileDate' => $fileDate, 'orderNumber' => $doc->order_id ? $doc->order_id : $doc->service_order_id, 'tempNumber' => $temp]; } return view('documents.showDocs', ['p' => 'cabinet', 'documentsByTypes' => $docsByTypesArr]); }
public function showSpecificOrder($orderId, $userId, $orderType) { if (Auth::user()->id == (int) $userId) { if ($orderType == Order::DOCUMENT_FOR_SPARE_PART) { $order = Order::with('products_in_order.stantion', 'status')->where('id', $orderId)->first(); $documents = Document::where('user_id', Auth::user()->id)->where('order_id', $orderId)->get(); return view('orders.showSpecificOrder', ['p' => 'cabinet', 'order' => $order, 'documents' => $documents]); } else { $order = ServiceOrder::with('service_status')->where('id', $orderId)->first(); $documents = Document::where('user_id', Auth::user()->id)->where('service_order_id', $orderId)->get(); return view('orders.showServiceSpecificOrder', ['p' => 'cabinet', 'order' => $order, 'documents' => $documents]); } } else { return redirect('fatal_error')->with('alert-danger', 'Произошла ошибка в работе сайта. Мы уже исправляем эту проблему. Попробуйте через некоторое время.'); } }
/** * return all organization documents * @param $orgId * @return mixed */ public function getDocuments($orgId) { return $this->document->where('org_id', $orgId)->where('filename', '<>', 'NULL')->get(); }