12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088 |
- <?php
- namespace App\Http\Controllers;
- use Illuminate\Http\Request;
- use \App\Helpers\PageSL;
- use App\User;
- use App\Models\MarketCountry;
- use App\Models\University;
- use App\Models\Department;
- use App\Models\ReferUser;
- use App\Models\ResearchInterest;
- use App\Models\Requirement;
- use App\Models\Publication;
- use App\StudentProposal;
- use App\Proposal;
- use App\Institution;
- use App\Score;
- use App\Workexperience;
- use Carbon\Carbon;
- use Session;
- use Mail;
- use Auth;
- use Hash;
- use Illuminate\Support\Str;
- class AjaxController extends Controller
- {
- public function get($name, Request $req)
- {
- if($name=='available_ref_no_search') {
- }elseif(empty($name)){
- return response([
- 'msg'=>'Invalid request please insert correct value!.'
- ], 403);
- }
- }
- public function post($name, Request $req)
- {
- if($name =='teacher_change_password') {
- $validator=\Validator::make($req->all(), [
- 'old_password'=>'required',
- 'new_password_confirmation'=>'required',
- 'new_password'=>[
- 'required',
- 'confirmed',
- 'min:8',
- //'regex:/[a-z]/',
- //'regex:/[A-Z]/',
- //'regex:/[0-9]/',
- //'regex:/[@$!%*#?&]/',
- ]
- ]);
- // [
- // 'regex' => 'The :attribute must contain at least one lowercase, uppercase, digit and special character.'
- // ]);
- if($validator->fails()){
- $errors=$validator->errors()->all();
- return response(['msg'=>$errors[0]], 422);
- }
- $user=auth_user('teacher');
- if(\Illuminate\Support\Facades\Hash::check($req->old_password, $user->password)) {
- $user->password=bcrypt($req->new_password);
- $user->update();
- return ['msg'=>'Your login password updated successfully!. Please use your new password for next time login.'];
- }else{
- return response(
- ['msg'=>'Sorry!, old password does not match with login credential.'],
- 403
- );
- }
- }elseif($name=="teacher_user_status_change"){
- $user=auth_user('teacher');
- $teacher =User::find($req->id);
- $teacher->apply_status =$req->status;
- $teacher->update();
- $data['name'] = $teacher->first_name.' '.$teacher->last_name;
- $data['receive_email']=$teacher->email;
- $user_mail = $teacher->email;
- $from = 'asraful@revinr.com';
- if($teacher->apply_status==1){
- Mail::send('email.approve_teacher_email',$data, function ($message) use ($user_mail,$from) {
- $message->from($from);
- $message->to($user_mail)->subject('Account Activation Confirmation');
- });
- }
- return response(
- ['msg'=>'Successfully saved.']
- );
- }elseif($name=="set_country"){
- $user =Auth::guard('admin')->user();
- if($req->checked == 'true'){
- $mc = new MarketCountry;
- $mc->country_id = $req->id;
- $mc->status = 1;
- $mc->added_by = $user->id;
- $mc->save();
- return response(
- ['msg'=>'Added Successfully.']
- );
- }else{
- MarketCountry::where('country_id', $req->id)->delete();
- return response(
- ['msg'=>'Removed Successfully.']
- );
- }
- }elseif($name=="add_country_wise_uni"){
- $user =Auth::guard('admin')->user();
- $validator=\Validator::make($req->all(), [
- 'country_id'=>'required',
- 'university_name'=>'required',
- 'university_website'=>'required',
- ]);
- if($validator->fails()){
- $errors=$validator->errors()->all();
- return response(['msg'=>$errors[0]], 422);
- }
- $data =new University;
- $data->country_id =$req->country_id;
- $data->name =$req->university_name;
- $data->web_address =$req->university_website;
- $data->save();
- return response(
- ['msg'=>'Saved Successfully.']
- );
- }elseif($name=="add_department"){
- $user =Auth::guard('admin')->user();
- $validator=\Validator::make($req->all(), [
- 'dapartment'=>'required',
- ]);
- if($validator->fails()){
- $errors=$validator->errors()->all();
- return response(['msg'=>$errors[0]], 422);
- }
- $data =new Department;
- $data->name =$req->dapartment;
- $data->status =1;
- $data->save();
- return response(
- ['msg'=>'Department saved successfully.']
- );
- }elseif($name=="update_profile"){
- $validator=\Validator::make($req->all(), [
- 'first_name'=>'required',
- 'last_name'=>'required',
- 'university_id'=>'required',
- 'department'=>'required',
- 'designation'=>'required',
- ]);
- if($validator->fails()){
- $errors=$validator->errors()->all();
- return response(['msg'=>$errors[0]], 422);
- }
- $data = User::find($req->id);
- $data->first_name =$req->first_name;
- $data->last_name =$req->last_name;
- $data->university_id =$req->university_id;
- $data->university_name =NULL;
- $data->department =$req->department;
- $data->others_department =NULL;
- $data->designation =$req->designation;
- $data->update();
- return response(
- ['msg'=>'Saved successfully.']
- );
- }elseif($name=="save_student_refer_friend"){
- $user =Auth::user();
- $validator=\Validator::make($req->all(), [
- 'name'=>'required',
- 'email'=>'required|email|max:255'
- ]);
- if($validator->fails()){
- $errors=$validator->errors()->all();
- return response(['msg'=>$errors[0]], 422);
- }
- $std_proposal =StudentProposal::where(
- 'student_id',$user->id
- )->where(
- 'proposal_submit_status',1
- )->first();
- if(empty($std_proposal)){
- return response(
- ['msg'=>'Sorry! you have to submit a proposal first.'],403
- );
- }
- $user_data = new User;
- $user_data->first_name = $req->name;
- $user_data->email =$req->email;
- $user_data->invitation_date =now();
- $user_data->user_type =1;
- $user_data->register_type =6; // 6= student refer a friend for a application proposal
- $user_data->created_by =$user->id;
- $user_data->save();
- $refer =new ReferUser;
- $refer->name =$req->name;
- $refer->email =$req->email;
- $refer->refer_by =$user->id;
- $refer->teacher_id =$std_proposal->teacher_id;
- $refer->save();
- if($refer->save()){
- $data['name'] = $refer->name;
- $data['teacher_id'] = $refer->teacher_id;
- $data['student_id'] = $user_data->id;
- $data['std_email'] = $refer->email;
- $data['applicant_name'] = $user->first_name.' '.$user->last_name;
- $data['receive_email']=$refer->email;
- $user_mail = $refer->email;
- $from = 'asraful@revinr.com';
- Mail::send('email.refer_a_friend_email',$data, function ($message) use ($user_mail,$from) {
- $message->from($from);
- $message->to($user_mail)->subject('Recommendation - Research Admission Platform for Finding a Research Superviso.');
- });
- }
- return response(
- ['msg'=>'Saved successfully.']
- );
- }elseif($name=="research_interest"){
- $validator=\Validator::make($req->all(), [
- 'research'=>'required',
- ]);
- if($validator->fails()){
- $errors=$validator->errors()->all();
- return response(['msg'=>$errors[0]], 422);
- }
- $data = new ResearchInterest;
- $data->teacher_id =$req->id;
- $data->research =$req->research;
- $data->save();
- return response(
- ['msg'=>'Saved successfully.']
- );
- }elseif($name=="edit_university_save"){
- $user=Auth::guard('admin')->user();
- $validator=\Validator::make($req->all(), [
- 'country_id'=>'required',
- 'university_name'=>'required',
- 'university_website'=>'required',
- ]);
- if($validator->fails()){
- $errors=$validator->errors()->all();
- return response(['msg'=>$errors[0]], 422);
- }
- $data =University::find($req->edit_id);
- $data->country_id =$req->country_id;
- $data->name =$req->university_name;
- $data->web_address =$req->university_website;
- $data->update();
- return response([
- 'msg'=>'Update Successfully.'
- ]);
- }elseif($name=="delete_university_info"){
- $user=Auth::guard('admin')->user();
- $data =University::find($req->delete_id);
- $data->delete();
- return response([
- 'msg'=>'Successfully Deleted'
- ]);
- }elseif($name=="delete_department_info"){
- $user=Auth::guard('admin')->user();
- $data =Department::find($req->delete_id);
- $data->delete();
- return response([
- 'msg'=>'Successfully Deleted'
- ]);
- }elseif($name=="edit_department_save"){
- $user=Auth::guard('admin')->user();
- $validator=\Validator::make($req->all(), [
- 'department'=>'required',
- ]);
- if($validator->fails()){
- $errors=$validator->errors()->all();
- return response(['msg'=>$errors[0]], 422);
- }
- $data =Department::find($req->edit_id);
- $data->name =$req->department;
- $data->update();
- return response([
- 'msg'=>'Successfully updated.'
- ]);
- }elseif($name=="concept_status_update"){
- $data =StudentProposal::find($req->id);
- $data->concept =$req->value;
- $data->update();
- return response(
- ['msg'=>'Updated successfully.']
- );
- }elseif($name=="proposal_status_update"){
- $data =StudentProposal::find($req->id);
- $data->proposal_status =$req->value;
- $data->proposal_status_date =now();
- $data->feedback_msg =NULL;
- $data->update();
- if($req->value){
- $user_data = User::find($data->student_id);
- $user_data->freez_profile =2; // 2 = [In Review,Pause,Interested]
- $user_data->update();
- }
- return response(
- ['msg'=>'Updated successfully.']
- );
- }elseif($name=="proposal_feedback_update"){
- $validator=\Validator::make($req->all(), [
- 'message'=>'required',
- ]);
- if($validator->fails()){
- $errors=$validator->errors()->all();
- return response(['msg'=>$errors[0]], 422);
- }
- $data =StudentProposal::find($req->id);
- $data->proposal_status =$req->proposal_status;
- $data->feedback_msg =$req->message;
- $data->proposal_status_date =now();
- $data->update();
- if($req->proposal_status ==3){ // 3= rejected
- $user_rejected = User::find($data->student_id);
- $user_rejected->freez_profile =0;
- $user_rejected->update();
- }
- return response(
- ['msg'=>'Updated successfully.']
- );
- }elseif($name=="accept_status_update"){
- $data =StudentProposal::find($req->id);
- $data->accepted_status =1;
- $data->accepted_date =now();
- $data->update();
- $user_accepted = User::find($data->student_id);
- $user_accepted->freez_profile =0;
- $user_accepted->update();
- return response([
- 'msg'=>'Updated successfully.'
- ]);
- }elseif($name=="proposal_quality_rate_star_update"){
- $data =StudentProposal::find($req->id);
- $data->proposal_quality =$req->value;
- $data->update();
- return response([
- 'msg'=>'Updated successfully.'
- ]);
- }elseif($name=="teacher_is_available"){
- $user =Auth::guard('teacher')->user();
- $data =User::find($user->id);
- if($req->checked =="true"){
- $data->is_available =1;
- }else{
- $data->is_available =0;
- }
- $data->update();
- return response(
- ['msg'=>"Updated Successfully."]
- );
- }elseif($name=="student_q_form"){
- $validator=\Validator::make($req->all(), [
- 'name'=>'required',
- 'email'=>'required|email|max:255'
- ]);
- if($validator->fails()){
- $errors=$validator->errors()->all();
- return response(['msg'=>$errors[0]], 422);
- }
- $user =User::where('email',$req->email)->where('user_type',1)->first();
- if($user){
- $is_student_proposal_exists =StudentProposal::where(
- 'teacher_id',$req->id
- )->where(
- 'student_id',$user->id
- )->whereIn(
- 'proposal_status',[1,2,3,4] // 1 =New; 2 =In Review; 3=Push; 4=Hold;
- )->exists();
- if($is_student_proposal_exists){
- return response(
- ['msg'=>'Already pending a proposal'],403
- );
- }else{
- $student_proposal =new StudentProposal;
- $student_proposal->student_id =$user->id;
- $student_proposal->teacher_id =$req->id;
- $student_proposal->draft_status =1;
- $student_proposal->save();
- $refer =new ReferUser;
- $refer->name =$req->name;
- $refer->email =$req->email;
- $refer->refer_by =$user->id;
- $refer->teacher_id =$req->id;
- $refer->q_form_status =1;
- $refer->save();
- }
- }else{
- $user_data =new User;
- $user_data->first_name =$req->name;
- $user_data->email =$req->email;
- $user_data->user_type =1;
- $user_data->status =0;
- $user_data->register_type =3; // 1=invitation ; 2= landing/wishlish; 3 =q_form ; 4=student_wishlist
- $user_data->invitation_date =now();
- $user_data->wishlist_teacher_id =$req->id;
- $user_data->save();
- $student_proposal =new StudentProposal;
- $student_proposal->student_id =$user->id;
- $student_proposal->teacher_id =$req->id;
- $student_proposal->draft_status =1;
- $student_proposal->save();
- $refer =new ReferUser;
- $refer->name =$req->name;
- $refer->email =$req->email;
- $refer->refer_by =$user->id;
- $refer->teacher_id =$req->id;
- $refer->q_form_status =1;
- $refer->save();
- if($refer->save()){
- $teacher = User::find($refer->teacher_id);
- if($teacher->others_department){
- $department =$teacher->others_department;
- }else{
- $department = cn($teacher,'department_name.name','');
- }
- if($teacher->university_name){
- $university =$teacher->university_name;
- }else{
- $university = cn($teacher,'university.name','');
- }
- $data['name'] = $refer->name;
- $data['student_id'] = $user->id;
- $data['teacher'] = $teacher->first_name.' '.$teacher->last_name;
- $data['arn'] = $teacher->ref_no;
- $data['designation'] = $teacher->designation;
- $data['department'] = $department;
- $data['university'] = $university;
- $data['email'] =$refer->email;
- $data['receive_email']=$refer->email;
- $user_mail = $refer->email;
- $from = 'asraful@revinr.com';
- Mail::send('email.q_form_email',$data, function ($message) use ($user_mail,$from) {
- $message->from($from);
- $message->to($user_mail)->subject('Invitation to submit your doctoral application');
- });
- }
- }
- return response(
- ['msg'=>'Saved successfully.']
- );
- }elseif($name=="q_apply_wishlist_registration_save"){
- $validator=\Validator::make($req->all(), [
- 'first_name'=>'required',
- 'last_name'=>'required',
- 'dob'=>'required',
- 'gender'=>'required',
- 'nationality'=>'required',
- 'email'=>'required',
- 'password_confirmation'=>'required',
- 'password'=>[
- 'required',
- 'confirmed',
- 'min:8',
- ]
- ]);
- if($validator->fails()){
- $errors=$validator->errors()->all();
- return response(['msg'=>$errors[0]], 422);
- }
- $token =Str::random(64);
- $user_check = User::where(
- 'id',$req->id
- )->where(
- 'sign_up',1
- )->first();
- if($user_check){
- // return redirect()->to("/login")->with('success','You are already registered. Please login here.');
- return response(
- ['msg'=>'You are already registered.','action'=>'redirect']
- );
- }
- $user_data = User::find($req->id);
- $user_data->first_name =$req->first_name;
- $user_data->last_name =$req->last_name;
- $user_data->first_name =$req->first_name;
- $user_data->nationality =$req->nationality;
- $user_data->dob =\Carbon\Carbon::parse($req->dob)->format('Y-m-d');
- $user_data->gender =$req->gender;
- $user_data->password =Hash::make($req->password);
- $user_data->status =0;
- $user_data->sign_up =1;
- $user_data->registered_date =now();
- //$user_data->email_verification=1;
- $user_data->remember_token=$token;
- //$user_data->email_verified_at=now();
- $user_data->update();
- $data['name'] = $user_data->first_name .' '.$user_data->last_name;
- $data['token']=$token;
- $data['receive_email']=$user_data->email;
- $user_mail = $user_data->email;
- $from = 'asraful@revinr.com';
- Mail::send('email.q_apply_wishlist_registration_email',$data, function ($message) use ($user_mail,$from) {
- $message->from($from);
- $message->to($user_mail)->subject('Thank You for joining us!');
- });
- return response(
- ['msg'=>'Successfully saved. Please check your email for verify.']
- );
- }elseif($name=="invitation_register_save"){
- $validator=\Validator::make($req->all(), [
- 'first_name'=>'required',
- 'last_name'=>'required',
- 'email'=>'required',
- 'university'=>'required',
- 'others_department'=>'required',
- 'designation'=>'required',
- 'password_confirmation'=>'required',
- 'password'=>[
- 'required',
- 'confirmed',
- 'min:8',
- ]
- ]);
- if($validator->fails()){
- $errors=$validator->errors()->all();
- return response(['msg'=>$errors[0]], 422);
- }
- $isExists = User::where(
- 'id',$req->id
- )->where(
- 'user_type',2
- )->where(
- 'sign_up',1
- )->first();
- if($isExists){
- return response(
- ['msg'=>'You are already registered.','action'=>'redirect']
- );
- }else{
- $user_data = User::find($req->id);
- $user_data->first_name =$req->first_name;
- $user_data->last_name =$req->last_name;
- $user_data->university_name =$req->university;
- $user_data->ref_no = name_initials($req->first_name,$req->last_name).''.teacherRefNoGenerate();
- //$user_data->department =$req->department;
- $user_data->others_department =$req->others_department;
- $user_data->designation =$req->designation;
- $user_data->uni_website =$req->website;
- $user_data->password =Hash::make($req->password);
- $user_data->status =1;
- $user_data->sign_up = 1; // 1=signup
- $user_data->user_type = 2;
- $user_data->registered_date = now();
- $user_data->update();
- if($user_data->update()){
- $data['name'] = $user_data->first_name .' '.$user_data->last_name;
- $data['receive_email']=$user_data->email;
- $user_mail = $user_data->email;
- $from = 'asraful@revinr.com';
- Mail::send('email.register_teacher_email',$data, function ($message) use ($user_mail,$from) {
- $message->from($from);
- $message->to($user_mail)->subject('We’re excited to have you as a member of our community');
- });
- }
- }
- return response(
- ['msg'=>'Registration successfully saved.']
- );
- }elseif($name=="delete_doc_required"){
- $requirements=Requirement::find($req->delete_id);
- $requirements->delete();
- return response([
- 'msg'=>'Deleted Successfully.'
- ]);
- }elseif($name=="document_required_upload_save"){
- $rules=[
- 'id'=>'required',
- 'document_file' => 'required',
- ];
- $validator=\Validator::make($req->all(), $rules);
- if($validator->fails()){
- $errors=$validator->errors()->all();
- return response(['msg'=>$errors[0]], 422);
- }
- $data=Requirement::find($req->id);
- $std_ref = StudentProposal::find($data->std_proposal_id);
- if($req->document_file){
- $destinationPath = public_path('/uploads/required_doc');
- $file = $req->document_file;
- $ext = $file->getClientOriginalExtension();
- $fileName = 'document_file_'.$std_ref->student_apply_ref.'.'.$ext;
- if(file_exists($destinationPath.'/'.$fileName)){
- @unlink($destinationPath.'/'.$fileName);
- }
- $file->move($destinationPath, $fileName);
- $data->document_file = $fileName;
- }
- $data->update();
- return response([
- 'msg'=>'Successfully uploaded.'
- ]);
- }elseif($name=="update_proposal"){
- $user=auth_user();
- $validator=\Validator::make($req->all(), [
- 'title'=>'required',
- 'methology'=>'required',
- 'department'=>'required',
- ]);
- if($validator->fails()){
- $errors=$validator->errors()->all();
- return response(['msg'=>$errors[0]], 422);
- }
- $data =Proposal::find($req->edit_id);
- $data->title =$req->title;
- $data->methology= $req->methology;
- $data->department= $req->department;
- $data->status= $req->status;
- if($req->documentfile){
- $destinationPath = public_path('/uploads/proposal');
- $file = $req->documentfile;
- $ext = $file->getClientOriginalExtension();
- $fileName = time().'documentfile_'.'.'.$ext;
- if(file_exists($destinationPath.'/'.$fileName)){
- @unlink($destinationPath.'/'.$fileName);
- }
- $file->move($destinationPath, $fileName);
- $data->document_file = $fileName;
- }
- $data->update();
- return response([
- 'msg'=>'Successfully updated.'
- ]);
- }elseif($name=="edit_register_teacher_save"){
- $validator=\Validator::make($req->all(), [
- 'first_name'=>'required',
- 'last_name'=>'required',
- 'university'=>'required',
- 'department'=>'required',
- 'designation'=>'required',
- ]);
- if($validator->fails()){
- $errors=$validator->errors()->all();
- return response(['msg'=>$errors[0]], 422);
- }
- $user_data = User::find($req->edit_id);
- $user_data->first_name =$req->first_name;
- $user_data->last_name =$req->last_name;
- $user_data->university_id =$req->university;
- $user_data->university_name = NULL;
- $user_data->department =$req->department;
- $user_data->others_department = NULL;
- $user_data->designation =$req->designation;
- $user_data->uni_website =$req->uni_website;
- $user_data->update();
- return response(
- ['msg'=>'Successfully updated.']
- );
- }elseif($name=="landing_invitation_email_send"){
- $user_data =User::find($req->id);
- $user_data->invitation_date =now();
- $user_data->update();
- if($user_data->update()){
- $data['name'] = $user_data->first_name .' '.$user_data->last_name;
- $data['receive_email']=$user_data->email;
- $user_mail = $user_data->email;
- $data['teacher_id'] = $user_data->id;
- $data['email'] = $user_data->email;
- $from = 'asraful@revinr.com';
- Mail::send('email.invitation_to_supervisor_email',$data, function ($message) use ($user_mail,$from) {
- $message->from($from);
- $message->to($user_mail)->subject('Manage Doctoral Applicants with Ease - You’re invited!');
- });
- }
- return response(
- ['msg'=>'Invitation sent successfully.']
- );
- }elseif($name=="delete_research_info"){
- $user=Auth::guard('teacher')->user();
- $data =ResearchInterest::find($req->delete_id);
- $data->delete();
- return response([
- 'msg'=>'Successfully Deleted'
- ]);
- }elseif($name=="edit_research_save"){
- $user=Auth::guard('teacher')->user();
- $validator=\Validator::make($req->all(), [
- 'research'=>'required',
- ]);
- if($validator->fails()){
- $errors=$validator->errors()->all();
- return response(['msg'=>$errors[0]], 422);
- }
- $data =ResearchInterest::find($req->edit_id);
- $data->research =$req->research;
- $data->update();
- return response([
- 'msg'=>'Successfully updated.'
- ]);
- }elseif($name=="add_proposal_publication"){
- $student=Auth::user();
- $validator=\Validator::make($req->all(), [
- 'publication'=>'required',
- 'status'=>'required',
- ]);
- if($validator->fails()){
- $errors=$validator->errors()->all();
- return response(['msg'=>$errors[0]], 422);
- }
- $data =new Publication;
- $data->student_id =$student->id;
- $data->publication =$req->publication;
- $data->status =$req->status;
- $data->save();
- return response([
- 'msg'=>'Successfully saved.'
- ]);
- }elseif($name=="update_publication"){
- $student=Auth::user();
- $validator=\Validator::make($req->all(), [
- 'publication'=>'required',
- 'status'=>'required',
- ]);
- if($validator->fails()){
- $errors=$validator->errors()->all();
- return response(['msg'=>$errors[0]], 422);
- }
- $data =Publication::find($req->edit_id);
- $data->student_id = $student->id;
- $data->publication = $req->publication;
- $data->status = $req->status;
- $data->update();
- return response([
- 'msg'=>'Successfully updated.'
- ]);
- }elseif($name=="delete_publication_info"){
- $data =Publication::find($req->delete_id);
- $data->delete();
- return response([
- 'msg'=>'Successfully deleted.'
- ]);
- }elseif($name=="is_attended_conference_status"){
- $data =User::find($req->uid);
- if($req->checked =='yes'){
- $data->is_attended_conference =1; // 1=yes
- }else{
- $data->is_attended_conference =2; // 2=no
- }
- $data->update();
- return response([
- 'msg'=>'Successfully saved.'
- ]);
- }elseif($name=="work_experience_status_update"){
- $data =User::find($req->uid);
- if($req->value =='yes'){
- $data->is_work_experience =1; // 1=yes
- }else{
- $data->is_work_experience =2; // 2=no
- }
- $data->update();
- return response([
- 'msg'=>'Successfully saved.'
- ]);
- }elseif($name=="publication_status_update"){
- $data =User::find($req->uid);
- if($req->value =='yes'){
- $data->is_publication =1; // 1=yes
- }else{
- $data->is_publication =2; // 2=no
- }
- $data->update();
- return response([
- 'msg'=>'Successfully saved.'
- ]);
- }elseif($name=="education_status_update"){
- $data =User::find($req->uid);
- if($req->value =='yes'){
- $data->is_education =1; // 1=yes
- }else{
- $data->is_education =2; // 2=no
- }
- $data->update();
- return response([
- 'msg'=>'Successfully saved.'
- ]);
- }elseif($name=="update_education_history"){
- $student=Auth::user();
- $validator=\Validator::make($req->all(), [
- 'academiclevel'=>'required',
- 'subject'=>'required',
- 'institution'=>'required',
- 'passingyear'=>'required',
- 'result'=>'required',
- ]);
- if($validator->fails()){
- $errors=$validator->errors()->all();
- return response(['msg'=>$errors[0]], 422);
- }
- $institution= Institution::find($req->edit_id);
- $institution->student_id= $student->id;
- $institution->academic_level= $req->academiclevel;
- $institution->subject= $req->subject;
- $institution->institution= $req->institution;
- $institution->passing_year= $req->passingyear;
- $institution->result= $req->result;
- $institution->update();
- return response([
- 'msg'=>'Successfully updated.'
- ]);
- }elseif($name=="delete_education_info"){
- $data =Institution::find($req->delete_id);
- $data->delete();
- return response([
- 'msg'=>'Successfully deleted.'
- ]);
- }elseif($name=="update_english_languge_proficiency"){
- $student=Auth::user();
- $validator=\Validator::make($req->all(), [
- 'testdate'=>'required',
- 'expirationdate'=>'required',
- 'testname'=>'required',
- 'overallscore'=>'required',
- 'listening'=>'required',
- 'speaking'=>'required',
- 'writing'=>'required',
- 'reading'=>'required',
- ]);
- if($validator->fails()){
- $errors=$validator->errors()->all();
- return response(['msg'=>$errors[0]], 422);
- }
- $score= Score::find($req->edit_id);
- $score->student_id= $student->id;
- $score->test_date= Carbon::parse($req->testdate)->format('Y-m-d');
- $score->expiration_date= Carbon::parse($req->expirationdate)->format('Y-m-d');
- $score->test_name= $req->testname;
- $score->overall_score= $req->overallscore;
- $score->listening= $req->listening;
- $score->writing= $req->speaking;
- $score->reading= $req->writing;
- $score->speaking= $req->reading;
- $score->update();
- return response([
- 'msg'=>'Successfully updated.'
- ]);
- }elseif($name=="delete_score_info"){
- $data =Score::find($req->delete_id);
- $data->delete();
- return response([
- 'msg'=>'Successfully deleted.'
- ]);
- }elseif($name=="update_work_experience"){
- $student=Auth::user();
- $validator=\Validator::make($req->all(), [
- 'companyname'=>'required',
- 'designation'=>'required',
- 'startdate'=>'required',
- 'enddate'=>'required',
- ]);
- if($validator->fails()){
- $errors=$validator->errors()->all();
- return response(['msg'=>$errors[0]], 422);
- }
- $work_experience= Workexperience::find($req->edit_id);
- $work_experience->student_id= $student->id;
- $work_experience->company_name= $req->companyname;
- $work_experience->designation= $req->designation;
- if($req->currently_working=='on'){
- $work_experience->currently_working=1;
- }else{
- $work_experience->currently_working=0;
- }
- $work_experience->start_date= date($req->startdate.'-'.$req->startmonth.'-01');
- $work_experience->end_date= date($req->enddate.'-'.$req->endmonth.'-01');
- $work_experience->update();
- return response([
- 'msg'=>'Successfully updated.'
- ]);
- }elseif($name=="delete_work_experience_info"){
- $data =Workexperience::find($req->delete_id);
- $data->delete();
- return response([
- 'msg'=>'Successfully deleted.'
- ]);
- }elseif($name=="test_score_status_update"){
- $data =User::find($req->uid);
- if($req->value =='yes'){
- $data->is_test_score =1; // 1=yes
- }else{
- $data->is_test_score =2; // 2=no
- }
- $data->update();
- return response([
- 'msg'=>'Successfully saved.'
- ]);
- }elseif($name=="all_publication_delete"){
- Publication::where('student_id',$req->uid)->delete();
- return response([
- 'msg'=>'Successfully delete.'
- ]);
- }elseif($name=="all_education_history_delete"){
- Institution::where('student_id',$req->uid)->delete();
- return response([
- 'msg'=>'Successfully delete.'
- ]);
- }elseif($name=="all_work_experience_delete"){
- Workexperience::where('student_id',$req->uid)->delete();
- return response([
- 'msg'=>'Successfully delete.'
- ]);
- }elseif($name=="all_test_score_delete"){
- Score::where('student_id',$req->uid)->delete();
- return response([
- 'msg'=>'Successfully delete.'
- ]);
- }elseif($name=="update_feedback_msg"){
- $data =StudentProposal::find($req->edit_id);
- $data->feedback_msg =$req->feedback_msg;
- $data->update();
- return response(['msg'=>'Updated successfully.']);
- }elseif($name=="delete_student_feedback_msg"){
- $data =StudentProposal::find($req->delete_id);
- $data->feedback_msg =NULL;
- $data->update();
- return response(['msg'=>'Deleted successfully.']);
- }
- }
- }
|