private function StoreProposal() { $obj = DB::transaction(function ($connection) { $var = INPUT::all(); $user = Auth::user()->user(); $mod = new Proposal(); $mod1 = new Proposal(); $filename = $user['id'] . '_' . $var['title_g'] . '.'; $filename .= $var['grantProposal']->getClientOriginalExtension(); $var['grantProposal']->move(storage_path('uploads/grant_proposals'), $filename); $mod::create(['field' => $var['fieldName'], 'title' => $var['title_g'], 'team_members' => $var['teamMembers'], 'research_place' => $var['researchPlace'], 'end_date_of_proposal' => $var['duration'], 'proposed_amount' => $var['grantNeeded'], 'description' => $var['propDescription'], 'userid' => $user['id']]); $obj = new \App\proposal_version(); $mod1 = $mod::get()->last(); $obj::create(['version_number' => '1', 'version_path' => $filename, 'proposal_id' => $mod1['id']]); }); }
public function makechanges($id) { $var = INPUT::all(); $obj = new \App\proposal_comment(); $obj1 = new \App\proposal_version(); $mod = \App\Proposal::join('proposal_versions', 'proposals.id', '=', 'proposal_versions.proposal_id')->where('proposals.id', '=', $id)->orderby('proposal_versions.id', 'DESC')->select('proposal_versions.id')->first(); $obj->comments = $var['comments']; $obj->type = 1; $obj->proposal_version_id = $mod->id; $obj->save(); $obj1 = $obj1::find($mod->id); $obj1->research_status = $var['status']; $obj1->save(); /*return $mod->id; if($var['status']) { if($var['status']==0) { $obj1->research_status=0; //$obj1->save(); } if($var['status']==1) { $obj1->research_status=1; // $obj1->save(); } /* if($var['status']==2) { $obj1->research_status=2; $obj1->save(); }*/ /*if($var['status']==3) { $obj1->research_status=3; $obj1->save(); }*/ // $obj1->save(); return $this->allgrants(); //return $var['status']; }
/** * Show the form for editing the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function edit() { $user_id = Auth::user()->id; $data = INPUT::all(); $rules = $this->rules(); $messages = $this->messages(); $validator = Validator::make($data, $rules, $messages); if (!$validator->fails()) { $book = Book::find($data['id']); $book->title = $data['title']; $book->subtitle = $data['subtitle']; $book->publishedDate = $data['publishedDate']; $book->description = $data['description']; $book->pages = $data['pages']; $book->isbn10 = $data['isbn10']; $book->isbn13 = $data['isbn13']; $book->price_day = $data['price_day']; $book->price_bail = $data['price_bail']; $book->price_sale = $data['price_sale']; $book->language = $data['language']; if ($data['publisher'] != $book->id_publisher) { if ($data['publisher'] != '0') { $book->id_publisher = $data['publisher']; } else { $publisher = new Publisher(); $publisher->publisher = $data['newpublisher']; $publisher->save(); $book->id_publisher = $publisher->id; } } if (isset($data['cover'])) { $book->cover = file_get_contents($data['cover']); } $book_id = $book->id; Book_Collection::where('book_id', $book_id)->delete(); Author_Book::where('book_id', $book_id)->delete(); $book_collection = new Book_Collection(); $book_collection->book_id = $book_id; $book_collection->collection_id = $data['collection']; $authors = explode(',', $data['authors']); foreach ($authors as $author) { $tmp = Author::where('name', 'like', $author)->limit(1)->get(); if (count($tmp) > 0) { $author_book = new Author_Book(); $author_book->book_id = $book_id; $author_book->author_id = $tmp[0]->id; $author_book->save(); } else { $newAuthor = new Author(); $newAuthor->name = $author; $newAuthor->save(); $author_id = $newAuthor->id; $author_book = new Author_Book(); $author_book->book_id = $book_id; $author_book->author_id = $author_id; $author_book->save(); } } $book->save(); return redirect('book/edit/' . $book_id . ''); } return back()->withInput($data)->withErrors($validator); }