123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119 |
- <?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"){
- $proposal =StudentProposal::find($req->id);
- $proposal->proposal_status =$req->value;
- $proposal->proposal_status_date =now();
- $proposal->feedback_msg =NULL;
- $proposal->feedback_reason =NULL;
- $proposal->update();
- if($req->value){
- $user_data = User::find($proposal->student_id);
- $user_data->freez_profile =2; // 2 = [In Review,Pause,Interested,Terminate]
- $user_data->update();
- }
- // Status wise email send
- $teacher =User::find($proposal->teacher_id);
- $student =User::find($proposal->student_id);
- $data['teacher'] = $teacher->first_name.' '.$teacher->last_name;
- $data['student'] = $student->first_name.' '.$student->last_name;
- $data['receive_email']=$student->email;
- $from = 'asraful@revinr.com';
- $user_mail = $student->email;
- //-----Hold----
- if($proposal->proposal_status == 4){
- $data['doc_requirement_list']=Requirement::where('std_proposal_id',$proposal->id)->get();
-
- Mail::send('email.hold_status_email',$data, function ($message) use ($user_mail,$from) {
- $message->from($from);
- $message->to($user_mail)->subject('Request for additional Documents and Information');
- });
-
- if(!empty($student)) {
-
- \Notification::send($student, new \App\Notifications\ProposalStatusNotification($proposal,"Hold",$teacher));
- }
- }
- //-----Interested----
- if($proposal->proposal_status == 5){
- Mail::send('email.interested_status_email',$data, function ($message) use ($user_mail,$from) {
- $message->from($from);
- $message->to($user_mail)->subject('Expression of Interest in Supervising Your Research Application');
- });
- if(!empty($student)) {
- \Notification::send($student, new \App\Notifications\ProposalStatusNotification($proposal,"Interested",$teacher));
- }
- }
- //-----Terminate----
- if($proposal->proposal_status == 7){
-
- Mail::send('email.terminate_status_email',$data, function ($message) use ($user_mail,$from) {
- $message->from($from);
- $message->to($user_mail)->subject('Your doctoral application has been terminated.');
- });
- if(!empty($student)) {
- \Notification::send($student, new \App\Notifications\ProposalStatusNotification($proposal,"Terminate",$teacher));
- }
- }
-
- return response(
- ['msg'=>'Saved 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 =0;
- }else{
- $data->is_available =1;
- }
- $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'=>'You have already received an invitation. Please login to your account to submit'],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_data->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_data->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_data->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"){
- $new_rules=[
- 'others_department'=>'required',
- ];
- $validator=\Validator::make($req->all(),$new_rules, [
- 'first_name'=>'required',
- 'last_name'=>'required',
- 'email'=>'required',
- 'university'=>'required',
- 'others_department.required'=>'Department field is required.',
- 'website'=>'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',
- 'destination'=>'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->nationality =$req->destination;
- $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.']);
- }
- }
- }
|