/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { $document = new Document($request->all()); $document->office_id = $request->oficina; $document->save(); Flash::success("Se ha registrado " . $document->asunto . " de forma exitosa!"); return redirect()->route('document.index'); }
/** * Save an entry * * @return Response */ public function save(Request $request) { $this->validate($request, ['title' => 'required|max:255', 'description' => 'required']); if (Storage::move('.tmp/' . $request->filename, 'files/' . $request->filename)) { $document = new Document(); $document->title = $request->title; $document->description = $request->description; $document->course = $request->course; $document->professor = $request->professor; $document->filename = $request->filename; $document->approved = false; $document->save(); } return 'f**k'; }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { $this->validate($request, ['file' => 'required']); $file = $request->file('file'); if ($file->isValid()) { $name = $file->getClientOriginalName(); $key = 'documents/' . $name; Storage::disk('s3')->put($key, file_get_contents($file)); $document = new Document(); $document->name = $name; $document->file = $key; $document->save(); $document->requestPreview(); } return redirect('documents'); }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { if (!$request->hasFile('document')) { /** @todo Error handling */ throw new RuntimeException('No document :('); } $file = $request->file('document'); $filename = $file->getClientOriginalName(); $data = $file->openFile()->fread($file->getSize()); $document = new Document(); $document->data = $data; $document->filename = $filename; $document->mime_type = $file->getMimeType(); $document->title = $request->input('title', $filename); $document->save(); return redirect()->route('documents.index')->with('message', 'Document created successfully.'); }
public function input2(Request $request) { $Sheet = $request->input('Document_ID'); //Проверяем документ на ведомость $document = DB::connection('sqlsrv')->table('Documents')->selectRaw('DocumentType_Code,Document_ID')->where('Document_ID', $Sheet)->where('DocumentType_Code', 170)->get(); if ($document->isEmpty()) { $Point_ID = $request->input('point_id'); $Reading_Value = $request->input('Reading_Value'); $PReading_Value = $request->input('PReading_Value'); $Action_Date = $request->input('Action_Date'); $MeterReading_ID = $request->input('MeterReading_ID'); $ReadingType_Code = $request->input('ReadingType_Code'); if (Input::has("MeterReading_ID0")) { $MeterReading_ID = $request->input('MeterReading_ID0'); $Reading_Value = $request->input('Reading_Value0'); $PReading_Value = $request->input('PReading_Value0'); $Document_ID = $request->input('Document_ID0'); $ReadingType_Code = $request->input('ReadingType_Code0'); DB::connection('sqlsrv')->table('MeterReadings')->where('MeterReading_ID', $MeterReading_ID)->update(['Reading_Value' => $Reading_Value, 'Reading_Difference_Value' => $Reading_Value - $PReading_Value, 'Daily_Difference_Value' => ($Reading_Value - $PReading_Value) / 30]); $MeterReadings = DB::connection('sqlsrv')->table('MeterReadings')->where('MeterReading_ID', $MeterReading_ID)->first(); $PointActions = DB::connection('sqlsrv')->table('PointActions')->where('Meter_ID', $MeterReadings->Meter_ID)->where('Document_ID', $Document_ID)->where('PointAction_ID', $MeterReadings->PointAction_ID)->first(); DB::connection('sqlsrv')->table('PointConsumptions')->where('PointAction_ID', $PointActions->PointAction_ID)->where('Point_ID', $PointActions->Point_ID)->where('Deal_ID', $PointActions->Deal_ID)->where('Document_ID', $PointActions->Document_ID)->update(['PointConsumption_Value' => $Reading_Value - $PReading_Value]); $PointConsumptions = DB::connection('sqlsrv')->table('PointConsumptions')->where('PointAction_ID', $PointActions->PointAction_ID)->where('Point_ID', $PointActions->Point_ID)->where('Deal_ID', $PointActions->Deal_ID)->where('Document_ID', $PointActions->Document_ID)->first(); $PointConsumptionItems = DB::connection('sqlsrv')->table('PointConsumptionItems')->where('PointConsumption_ID', $PointConsumptions->PointConsumption_ID)->first(); DB::connection('sqlsrv')->table('PointConsumptionItems')->where('PointConsumption_ID', $PointConsumptions->PointConsumption_ID)->update(['PointConsumptionItem_Value' => $Reading_Value - $PReading_Value, 'DailyConsumption_Value' => ($Reading_Value - $PReading_Value) / $PointConsumptionItems->Days_Count]); DB::connection('sqlsrv')->table('PointConsumptionStatuses')->where('PointConsumption_ID', $PointConsumptions->PointConsumption_ID)->update(['PointConsumption_Value' => $Reading_Value - $PReading_Value]); DB::connection('sqlsrv')->table('MeterConsumptions')->where('PointConsumptionItem_ID', $PointConsumptionItems->PointConsumptionItem_ID)->update(['MeterConsumption_Value' => $Reading_Value - $PReading_Value]); DB::connection('sqlsrv')->table('PointConsumptionItemLines')->where('PointConsumptionItem_ID', $PointConsumptionItems->PointConsumptionItem_ID)->where('ReadingType_Code', $ReadingType_Code)->update(['PointConsumptionItemLine_Value' => $Reading_Value - $PReading_Value, 'DailyPointConsumptionItemLine_Value' => ($Reading_Value - $PReading_Value) / $PointConsumptionItems->Days_Count]); } Session::flash('msg', 'Успешно обновлено'); $ConsumptionSheet_ID = Session::get('ConsumptionSheet_ID'); $results = DB::connection('sqlsrv')->table('ConsumptionSheets')->join('MeteringRoutePoints', 'MeteringRoutePoints.Document_ID', '=', 'ConsumptionSheets.MeteringRoute_ID')->join('DealPoints', 'DealPoints.Point_ID', '=', 'MeteringRoutePoints.Point_ID')->join('Deals', 'Deals.Deal_ID', '=', 'DealPoints.Deal_ID')->join('PointAssets', 'PointAssets.Point_ID', '=', 'MeteringRoutePoints.Point_ID')->join('Assets', 'Assets.Asset_ID', '=', 'PointAssets.Asset_ID')->select('ConsumptionSheet_ID', 'MeteringRoutePoints.Point_ID', 'MeteringRoutePoints.Document_ID', 'Deals.Deal_ID', 'Deal_Num', 'Subject_Name', 'Address_Name', 'Serial_Number')->where('ConsumptionSheets.ConsumptionSheet_ID', $ConsumptionSheet_ID)->get(); return View::make('admin.legal.list', compact('results')); } $id = Document::insertGetId(['Document_Num' => 'б/н', 'Document_Date' => '2016-09-30', 'DocumentType_Code' => '108', 'Comments' => '{"Deal_ID":' . $Sheet . ',"Deal_Num":' . $Sheet . ',"Is_Deal_Num_Incomplete":false,"Subject_Name":"","Supplier_Name":"","SupplierServices_Names":"","ReadingsReadBy":"Supplier","Person":"Каниболоцкий С. В.","Person_ID":6865254,"Action_Date":"30.09.2016","BaseDocumentType_Code":1,"CorrectionPeriodId":" ","calculationMethod":0,"calculationMethodDate":null,"pStatusCode":1,"p_DealType_Code":["2"],"p_Deal_ID":"","p_Deal_Num":"","p_Subject_Name":"","Is_Include_Agreements":true,"Is_Include_Accounts":false,"p_Substation_IDs":"","p_Substation_Names":"","p_ConsumptionGroup_Code":"","p_BranchGroup_IDs":"","p_BranchGroup_Names":"","p_District_Codes":"","p_District_Names":"","p_Department_IDs":"","p_Department_Names":"","p_Supplier_IDs":"","p_Supplier_Names":"Все","p_Point_ID":"","p_Point_Name":""}', 'Date_Fix' => '2016-09-30', 'User_ID' => 167, 'Date_Create' => date('Y-m-d H:i'), 'Period_ID' => 92, 'Status_ID' => 2565, 'Status_User_ID' => '167', 'Status_Date' => date('Y-m-d H:i')]); $id = new Document(); $id->Document_Num = 'б/н'; $id->Document_Date = '2016-09-30'; $id->DocumentType_Code = '108'; $id->save(); echo $id->id; }