StudentHomeController.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  1. <?php
  2. namespace App\Http\Controllers;
  3. use Illuminate\Http\Request;
  4. use App\Institution;
  5. use App\Workexperience;
  6. use App\Score;
  7. use App\User;
  8. use App\Proposal;
  9. use App\StudentProposalUpload;
  10. use App\StudentProposal;
  11. use App\AcademicLevel;
  12. use App\Models\Department;
  13. use App\Models\Publication;
  14. use Auth;
  15. use Carbon\Carbon;
  16. class StudentHomeController extends Controller
  17. {
  18. public function __construct()
  19. {
  20. $this->middleware('auth');
  21. }
  22. public function index(){
  23. $user = Auth::user();
  24. $student_proposal =StudentProposal::where(
  25. 'student_id',$user->id
  26. )->where(
  27. 'proposal_submit_status',1
  28. )->orderBy('id','DESC')->get();
  29. return view('application.home',compact('student_proposal'));
  30. }
  31. public function application(){
  32. $user = Auth::user();
  33. $proposal= Proposal::where('student_id',$user->id)->doesntExist();
  34. $publication =User::where('id',$user->id)->where('is_publication',0)->exists();
  35. $worK_exp =User::where('id',$user->id)->where('is_work_experience',0)->exists();
  36. $institution =User::where('id',$user->id)->where('is_education',0)->exists();
  37. $score =User::where('id',$user->id)->where('is_test_score',0)->exists();
  38. $student_proposal =StudentProposal::where('student_id',$user->id)->orderBy('id','DESC')->get();
  39. $data =[
  40. 'proposal'=>$proposal,
  41. 'publication'=>$publication,
  42. 'worK_exp'=>$worK_exp,
  43. 'institution'=>$institution,
  44. 'score'=>$score,
  45. 'student_proposal'=>$student_proposal,
  46. ];
  47. return view('application.application',$data);
  48. }
  49. public function profile()
  50. {
  51. $user = Auth::user();
  52. $publications= Publication::where('student_id',$user->id)->get();
  53. $institution= Institution::where('student_id',Auth::user()->id)->get();
  54. $work_experience= Workexperience::where('student_id',Auth::user()->id)->get();
  55. $score= Score::where('student_id',$user->id)->get();
  56. $proposal= Proposal::where('student_id',$user->id)->orderBy('id','DESC')->get();
  57. $user_info= User::find($user->id);
  58. $academic_level= AcademicLevel::all();
  59. $proposal_files= StudentProposalUpload::where('student_id',$user->id)->get();
  60. $departments = Department::where('status',1)->orderBy('name','ASC')->get();
  61. $is_freez_profile = User::where(
  62. 'id',$user->id
  63. )->where(
  64. 'freez_profile','!=',0
  65. )->exists();
  66. return view('application.profile',compact('publications','is_freez_profile','institution','academic_level','work_experience','score','user_info','proposal','proposal_files','departments'));
  67. }
  68. public function institution_save(Request $request)
  69. {
  70. $student =Auth::user();
  71. $institution= New Institution;
  72. $institution->student_id= Auth::user()->id;
  73. $institution->academic_level= $request->academiclevel;
  74. $institution->subject= $request->subject;
  75. $institution->institution= $request->institution;
  76. $institution->passing_year= $request->passingyear;
  77. //$institution->during= $request->during;
  78. $institution->result= $request->result;
  79. //$institution->start_date= date($request->startdate.'-'.$request->startmonth.'-01');
  80. //$institution->end_date= date($request->enddate.'-'.$request->endmonth.'-30');
  81. $institution->save();
  82. $data = User::find($student->id);
  83. $data->is_education =1;
  84. $data->update();
  85. return redirect()->back()->with('Added successfully.');
  86. }
  87. public function work_save(Request $request)
  88. {
  89. $work_experience= New Workexperience;
  90. $work_experience->student_id= Auth::user()->id;
  91. $work_experience->company_name= $request->companyname;
  92. $work_experience->designation= $request->designation;
  93. $work_experience->currently_working= $request->currentlyworking ? 0 : 1;
  94. $work_experience->start_date= date($request->startdate.'-'.$request->startmonth.'-01');
  95. if($request->enddate && $request->endmonth){
  96. $work_experience->end_date= date($request->enddate.'-'.$request->endmonth.'-01');
  97. }
  98. $work_experience->save();
  99. return redirect()->back()->with('Added successfully.');
  100. }
  101. public function score_save(Request $request)
  102. {
  103. $score= New Score;
  104. $score->student_id= Auth::user()->id;
  105. $score->test_date= Carbon::parse($request->testdate)->format('Y-m-d');
  106. $score->expiration_date= Carbon::parse($request->expirationdate)->format('Y-m-d');
  107. $score->test_name= $request->testname;
  108. $score->overall_score= $request->overallscore;
  109. $score->listening= $request->listening;
  110. $score->writing= $request->speaking;
  111. $score->reading= $request->writing;
  112. $score->speaking= $request->reading;
  113. $score->save();
  114. return redirect()->back()->with('Added successfully.');
  115. }
  116. public function proposal_save(Request $request)
  117. {
  118. $student_id =Auth::user()->id;
  119. $proposal= New Proposal;
  120. $proposal->student_id= $student_id;
  121. $proposal->proposal_ref= proposalRefNoGenerate($student_id);
  122. $proposal->title= $request->title;
  123. $proposal->methology= $request->methology;
  124. $proposal->department= $request->department;
  125. $proposal->status= $request->status;
  126. if($request->documentfile!=''){
  127. $destinationPath = public_path('/uploads/proposal');
  128. $file = $request->documentfile;
  129. $ext = $file->getClientOriginalExtension();
  130. $fileName = time().'documentfile_'.'.'.$ext;
  131. if(file_exists($destinationPath.'/'.$fileName)){
  132. @unlink($destinationPath.'/'.$fileName);
  133. }
  134. $file->move($destinationPath, $fileName);
  135. $proposal->document_file = $fileName;
  136. $proposal->file_type = $ext;
  137. }
  138. $proposal->save();
  139. return redirect()->back()->with('Added successfully.');
  140. }
  141. public function save_as_complete()
  142. {
  143. $user= User::find(Auth::user()->id);
  144. $user->save_as_complete= 1;
  145. $user->save();
  146. return redirect()->back()->with('Added successfully.');
  147. }
  148. public function education_remove($id)
  149. {
  150. $institution= Institution::find($id);
  151. $institution->delete();
  152. }
  153. public function work_remove($id)
  154. {
  155. $work_experience= Workexperience::find($id);
  156. $work_experience->delete();
  157. }
  158. public function score_remove($id)
  159. {
  160. $score= Score::find($id);
  161. $score->delete();
  162. }
  163. public function proposal_remove($id)
  164. {
  165. $proposal= Proposal::find($id);
  166. $proposal->delete();
  167. }
  168. public function institution_update($id,Request $request)
  169. {
  170. $institution= Institution::find($id);
  171. $institution->student_id= Auth::user()->id;
  172. $institution->academic_level= $request->academiclevel;
  173. $institution->subject= $request->subject;
  174. $institution->institution= $request->institution;
  175. $institution->passing_year= $request->passingyear;
  176. $institution->during= $request->during;
  177. $institution->result= $request->result;
  178. $institution->start_date= date($request->startdate.'-'.$request->startmonth.'-01');
  179. $institution->end_date= date($request->enddate.'-'.$request->endmonth.'-30');
  180. $institution->update();
  181. return redirect()->back()->with('Updated successfully.');
  182. }
  183. public function work_update($id,Request $request)
  184. {
  185. $work_experience= Workexperience::find($id);
  186. $work_experience->student_id= Auth::user()->id;
  187. $work_experience->company_name= $request->companyname;
  188. $work_experience->designation= $request->designation;
  189. $work_experience->currently_working= $request->checkbox;
  190. $work_experience->start_date= date($request->startdate.'-'.$request->startmonth.'-01');
  191. $work_experience->end_date= date($request->enddate.'-'.$request->endmonth.'-01');
  192. $work_experience->update();
  193. return redirect()->back()->with('Updated successfully.');
  194. }
  195. public function score_update($id,Request $request)
  196. {
  197. $score= Score::find($id);
  198. $score->student_id= Auth::user()->id;
  199. $score->test_date= Carbon::parse($request->testdate)->format('Y-m-d');
  200. $score->expiration_date= Carbon::parse($request->expirationdate)->format('Y-m-d');
  201. $score->test_name= $request->testname;
  202. $score->overall_score= $request->overallscore;
  203. $score->listening= $request->listening;
  204. $score->writing= $request->speaking;
  205. $score->reading= $request->writing;
  206. $score->speaking= $request->reading;
  207. $score->update();
  208. return redirect()->back()->with('Updated successfully.');
  209. }
  210. public function proposal_update($id,Request $request)
  211. {
  212. $proposal=Proposal::find($id);
  213. $proposal->student_id= Auth::user()->id;
  214. $proposal->title= $request->title;
  215. $proposal->methology= $request->methology;
  216. $proposal->department= $request->department;
  217. $proposal->status= $request->status;
  218. $proposal->update();
  219. return redirect()->back()->with('Added successfully.');
  220. }
  221. // public function proposal_media_upload(Request $request)
  222. // {
  223. // $student_doc=new StudentProposalUpload;
  224. // $student_doc->student_id=Auth::user()->id;
  225. // $student_doc->created_by=Auth::user()->id;
  226. // if($request->documentfile!=''){
  227. // $destinationPath = public_path('/uploads/proposal');
  228. // $file = $request->documentfile;
  229. // $ext = $file->getClientOriginalExtension();
  230. // $fileName = time().'documentfile_'.'.'.$ext;
  231. // if(file_exists($destinationPath.'/'.$fileName)){
  232. // @unlink($destinationPath.'/'.$fileName);
  233. // }
  234. // $file->move($destinationPath, $fileName);
  235. // $student_doc->document_file = $fileName;
  236. // $student_doc->file_type = $ext;
  237. // $student_doc->save();
  238. // return redirect()->back()->with('Added successfully.');
  239. // }
  240. // }
  241. public function change_work_experience($status)
  242. {
  243. $change_work_experience= Auth::user();
  244. $change_work_experience->is_work_experience=$status;
  245. $change_work_experience->update();
  246. }
  247. public function change_test_score($status)
  248. {
  249. $change_test_score= Auth::user();
  250. $change_test_score->is_test_score=$status;
  251. $change_test_score->update();
  252. }
  253. public function ref_search(Request $req){
  254. $data['teacher'] ="";
  255. if($req->teacher_ref_no){
  256. $data['teacher'] =User::where(
  257. 'ref_no',$req->teacher_ref_no
  258. )->where(
  259. 'is_available',1
  260. )->first();
  261. }
  262. return view('ref_search_load',$data);
  263. }
  264. public function logout(){
  265. \Auth::guard()->logout();
  266. request()->session()->invalidate();
  267. return redirect('/applicant/login');
  268. }
  269. }