Browse Source

University Add

Shah Rakibur Rahaman 1 year ago
parent
commit
5ca9ef4c84

+ 2 - 2
app/Http/Controllers/Admin/AdminController.php

@@ -48,7 +48,7 @@ class AdminController extends Controller
             )->get();
 
           
-        $study_destinations = MarketCountry::where( 
+        $market_countries = MarketCountry::where( 
                 'status', 1
             )->select(
                 'market_countries.*', \DB::raw('(SELECT name FROM countries WHERE market_countries.country_id = countries.id ) as sort')
@@ -59,7 +59,7 @@ class AdminController extends Controller
           'register_teachers_list'=>$register_teachers_list , 
           'active_teachers_list'=>$active_teachers_list, 
           'register_student_list'=>$register_student_list , 
-          'study_destinations'=>$study_destinations  
+          'market_countries'=>$market_countries  
         ];
         return view('admin.admin_profile',$data);
     }

+ 41 - 0
app/Http/Controllers/Admin/SubContentController.php

@@ -0,0 +1,41 @@
+<?php
+
+namespace App\Http\Controllers\Admin;
+
+use App\Http\Controllers\Controller;
+use Illuminate\Http\Request;
+use \App\Helpers\PageSL;
+use App\Models\University;
+use App\Models\MarketCountry;
+use Auth;
+
+class SubContentController extends Controller
+{
+    public function get(Request $req, $name){
+
+		$user=Auth::guard('admin')->user();
+		$carbon=new \Carbon\Carbon;
+
+		$data=[
+			'user'=>$user,
+			'carbon'=>$carbon,
+			'name'=>$name
+		];
+
+		if($name=="load_market_countries"){
+			$data['market_countries'] = MarketCountry::where( 
+                'status', 1
+            )->select(
+                'market_countries.*', \DB::raw('(SELECT name FROM countries WHERE market_countries.country_id = countries.id ) as sort')
+            )->orderBy('sort')->get();
+			
+		}elseif($name=='country_wise_university'){ 
+
+			$data['universities'] =University::orderBy('name','ASC')->get(); 
+		 
+		}else $name='default'; 
+		//$data['page_sl']=new PageSL($data['chapter_details']); 
+		return view("admin.sub_contents.{$name}", $data);
+
+	}
+}

+ 49 - 2
app/Http/Controllers/AjaxController.php

@@ -6,6 +6,8 @@ use Illuminate\Http\Request;
 use \App\Helpers\PageSL; 
 use App\User;
 use App\Models\MarketCountry;
+use App\Models\University;
+use App\Models\Department;
 use Session;
 use Mail;
 use Auth;
@@ -22,7 +24,7 @@ class AjaxController extends Controller
 
 	public function post($name, Request $req)
 	{
-        $user =Auth::guard('admin')->user();
+       
 		if($name =='teacher_change_password') {  
 
 			$validator=\Validator::make($req->all(), [
@@ -85,7 +87,7 @@ class AjaxController extends Controller
             );
 
         }elseif($name=="set_country"){
-          
+            $user =Auth::guard('admin')->user();
             if($req->checked == 'true'){
                 $mc = new MarketCountry; 
                 $mc->country_id = $req->id;
@@ -102,6 +104,51 @@ class AjaxController extends Controller
                     ['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();
+            info($req->all());
+
+            $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->save();
+
+            return response(
+                ['msg'=>'Department saved successfully.']
+            ); 
+             
         }  
 	}
 }

+ 15 - 0
app/Models/University.php

@@ -0,0 +1,15 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Model;
+
+class University extends Model
+{
+    protected $guarded=['id']; 
+
+    public function country(){
+        return $this->belongsTo('App\Country','country_id','id');
+    } 
+     
+}

+ 123 - 29
resources/views/admin/admin_profile.blade.php

@@ -784,8 +784,8 @@ tbody, td, tfoot, th, thead, tr {
                                                 <h6 style="padding: 13px 10px 0px; margin-bottom: 0px;">Department</h6>
                                                 <div>
                                                     <div class="form-icon position-relative p-2" style="display: flex;">
-                                                        <input type="text" class="form-control" placeholder="" name="" required="">
-                                                        <button class="btn btn2" style="margin-left: -3.4rem; border-radius: 0px 6px 6px 0px">Add</button>
+                                                        <input type="text" class="form-control" placeholder="" name="dapartment" id="dapartment" required="">
+                                                        <button class="btn btn2 add_department" style="margin-left: -3.4rem; border-radius: 0px 6px 6px 0px">Add</button>
                                                     </div>
                                                 </div>
                                                 <div class="left mb-2">
@@ -833,7 +833,8 @@ tbody, td, tfoot, th, thead, tr {
                                 <div class="col-md-8 rounded ms-4">
                                     <div class="card p-2 rounded border-0 mb-4">
                                         <div class="destination_boxes">
-                                            @foreach($study_destinations as $i => $row)
+                                            <div id="load_market_countries"></div>
+                                            @foreach($market_countries as $i => $row)
                                             <div class="box country" data-id="{{$row->country->id}}" id="country_{{$row->country->id}}">
                                                 <div class="flag_country">
                                                     <img src="{{ asset('/assets/img/flags/4x3').'/'.strtolower($row->country->iso_3166_2).'.svg' }}" alt="">
@@ -860,13 +861,18 @@ tbody, td, tfoot, th, thead, tr {
                                             <div class="col-md-12 mb-3">
                                                 <div id="demo15" class="collapse mt-2">
                                                     <div class="panel-body" style="padding:10px; background-color: #4b4c6824; border: 1px solid #e9e5e5; border-radius: 5px;">
-                                                        <form method="POST" action="">
+                                                      
                                                             <div class="row">
                                                                 <div class="col-md-4">
                                                                     <div class="mb-2">
                                                                         <label class="form-label config">Destination</label>
-                                                                        <div class="form-icon position-relative">
-                                                                            <input type="text" class="form-control" placeholder="Destination" name="destination" required="" style="font-size: 13px;">
+                                                                        <div class="form-icon position-relative"> 
+                                                                            <select name="country_id" id="country_id" class="form-control" required="" style="font-size: 13px;">
+                                                                                <option value="" selected disabled>Select</option>
+                                                                                @foreach($market_countries as $row)
+                                                                                    <option value="{{$row->country_id}}">{{ cn($row, 'country.name','')}}</option>
+                                                                                @endforeach
+                                                                            </select>
                                                                         </div>
                                                                     </div>
                                                                 </div>
@@ -874,7 +880,7 @@ tbody, td, tfoot, th, thead, tr {
                                                                     <div class="mb-2">
                                                                         <label class="form-label config">University Name</label>
                                                                         <div class="form-icon position-relative">
-                                                                            <input type="text" class="form-control" placeholder="University Name" name="university_name" required="" style="font-size: 13px;">
+                                                                            <input type="text" class="form-control" placeholder="University Name" id="university_name" name="university_name" required="" style="font-size: 13px;">
                                                                         </div>
                                                                     </div>
                                                                 </div>
@@ -882,7 +888,7 @@ tbody, td, tfoot, th, thead, tr {
                                                                     <div class="mb-2">
                                                                         <label class="form-label config">University Website</label>
                                                                         <div class="form-icon position-relative">
-                                                                            <input type="text" class="form-control" placeholder="University Website" name="university_website" required="" style="font-size: 13px;">
+                                                                            <input type="text" class="form-control" placeholder="University Website" id="university_website" name="university_website" required="" style="font-size: 13px;">
                                                                         </div>
                                                                     </div>
                                                                 </div>
@@ -890,33 +896,17 @@ tbody, td, tfoot, th, thead, tr {
                                                             <div class="row">
                                                                 <div class="col-md-12">
                                                                     <div class="text-end">
-                                                                        <button class="btn btn2">Save</button>                                                                                                                
+                                                                        <button class="btn btn2" id="submit_uni">Save</button>                                                                                                                
                                                                     </div>
                                                                 </div> 
                                                             </div>  
-                                                        </form>
                                                     </div>
                                                 </div> 
                                             </div>    
                                         </div>
-                                        <table class="table table-bordered list_table">
-                                            <thead>
-                                                <tr>
-                                                    <th>Sl</th>
-                                                    <th>Designation</th>
-                                                    <th>University Name</i></th>
-                                                    <th>University website</i></th>
-                                                </tr>
-                                            </thead>
-                                            <tbody style="border-style: dashed;">
-                                                <tr> 
-                                                    <td style="font-size: 11px;">1</td>
-                                                    <td style="font-size: 11px;">1</td>
-                                                    <td style="font-size: 11px;">1</td>
-                                                    <td style="font-size: 11px;">1</td>
-                                                </tr>
-                                            </tbody>
-                                        </table> 
+                                        {{-- Load country wise university --}}
+                                        <div id="country_wise_university"></div>
+                                        
                                     </div>
                                 </div>
                             </div>
@@ -961,6 +951,49 @@ tbody, td, tfoot, th, thead, tr {
 
     @include('web.layouts.modal')
     <script>
+        function fetch_sub_content(selector, url, args=null){
+
+            var config={
+            spinner: true
+            }
+
+            if(typeof args=='object'){
+            config=Object.assign(config, args);
+            }
+
+            if(config.spinner){
+
+            $(selector).waitMe({
+                effect: 'facebook',
+                text: 'Please! Wait ...'
+            });
+
+            }
+
+            $(selector).load(url, null, function(){
+            $(selector).waitMe('hide');
+            if(typeof args=='function') args();
+            });
+
+        }
+
+        function wait_me(selector, config=null){
+
+            if(config){
+
+                selector.waitMe(config);
+
+            }else{ 
+
+                selector.waitMe({
+                    effect: 'facebook',
+                    //color: '#000',
+                    text: 'Please! Wait ...'
+                }); 
+            } 
+        }
+ 
+
         function pop_up_msg(msg='No message specified', type='success', callback=null){ 
             new Noty({
             theme:'sunset',
@@ -985,7 +1018,8 @@ tbody, td, tfoot, th, thead, tr {
 
         }
 
-        $(function(){
+        $(function(){ 
+
             $('.status_change').on('click', function(e){  
                 var self =$(this); 
                 var id =$(this).data('id');
@@ -1025,6 +1059,66 @@ tbody, td, tfoot, th, thead, tr {
                     } 
                 }); 
             });
+
+
+            fetch_sub_content(
+                '#country_wise_university',
+                "{{ route('admin.sub-content', ['name'=>'country_wise_university']) }}"
+            );
+
+
+
+            $('#submit_uni').on('click', function(){ 
+                var country_id =$('#country_id option:selected').val();  
+                var university_name =$('#university_name').val();
+                var university_website =$('#university_website').val();
+
+                var form_data={
+                    _token: "{{ csrf_token() }}", 
+                    country_id: country_id,
+                    university_name: university_name,
+                    university_website: university_website,
+                }
+
+                $.post("{{ route('ajax-post', ['name'=>'add_country_wise_uni']) }}", form_data, function(res){ 
+                    pop_up_msg(res.msg);
+
+                    fetch_sub_content(
+                        '#country_wise_university',
+                        "{{ route('admin.sub-content', ['name'=>'country_wise_university']) }}"
+                    );
+
+                }).fail(function(err){
+
+                    pop_up_msg(err_msg(err), 'error');
+
+                }); 
+            });
+
+
+            $('.add_department').on('click', function(){  
+
+                var dapartment =$('#dapartment').val(); 
+                
+                var form_data={
+                    _token: "{{ csrf_token() }}", 
+                    dapartment: dapartment, 
+                }
+
+                $.post("{{ route('ajax-post', ['name'=>'add_department']) }}", form_data, function(res){ 
+                    pop_up_msg(res.msg);
+
+                    fetch_sub_content(
+                        '#load_department',
+                        "{{ route('admin.sub-content', ['name'=>'load_department']) }}"
+                    );
+
+                }).fail(function(err){
+
+                    pop_up_msg(err_msg(err), 'error');
+
+                }); 
+            });
         });
       </script>
 </body>

+ 7 - 0
resources/views/admin/sub_contents/base.blade.php

@@ -0,0 +1,7 @@
+@yield('main')
+
+<script>
+$(function(){
+	$('.tooltips').tooltip();
+});
+</script>

+ 26 - 0
resources/views/admin/sub_contents/country_wise_university.blade.php

@@ -0,0 +1,26 @@
+@extends('admin.sub_contents.base')  
+@section('main') 
+@if(count($universities) > 0)
+<table class="table table-bordered list_table">
+    <thead>
+        <tr>
+            <th>Sl</th>
+            <th>Designation</th>
+            <th>University Name</i></th>
+            <th>University website</i></th>
+        </tr>
+    </thead>
+    <tbody style="border-style: dashed;">
+        @foreach($universities as $key=>$row)
+        <tr> 
+            <td style="font-size: 11px;">{{++$key}}</td>
+            <td style="font-size: 11px;">{{cn($row,'country.name','')}}</td>
+            <td style="font-size: 11px;">{{$row->name}}</td>
+            <td style="font-size: 11px;">{{$row->web_address}}</td>
+        </tr>
+        @endforeach
+    </tbody>
+</table>
+@endif
+ 
+@endsection

+ 1 - 25
resources/views/modal_pages/add_destination.blade.php

@@ -16,31 +16,7 @@
                     <i class="fa fa-search ms-3" style="position: absolute; margin-top: 14px; font-size: 13px;"></i>
                     <input type="text" class="form-control search-box" id="search_add" placeholder="Search" name="" required="" style="padding: 0.4rem 0.9rem 0.4rem 2.5rem !important; background: linear-gradient(to bottom, #FFF 0%,#FFF 55%,#eeedf1 80%,#f5f5f5 100%); font-size: 13px;">
                 </div>  
-                <div class="load_list_add"></div>
-                {{-- <table class="table table-bordered list_table mt-3">
-                    <thead>
-                        <tr>
-                            <th class="text-center" style="width: 13%;">Sl</th>
-                            <th>Country</th>
-                            <th class="text-center"><i class="fa fa-cog"></i></th>
-                        </tr>
-                    </thead>
-                    <tbody style="border-style: dashed;">
-                        <tr> 
-                            <td class="text-center" style="font-size: 11px;">1</td>
-                            <td style="font-size: 11px;">
-                                <img src="{{ asset('web/images/au.svg') }}" alt="" style="height: 20px; border-radius: 50%; width: 20px; margin: 3px;">
-                                Australia
-                            </td>
-                            <td class="text-center" style="font-size: 11px;">
-                                <div class="form-check form-switch" id="">
-                                    <input class="form-check-input" type="checkbox" name="" value="" style="height:18px; width: 30px; position: absolute;">
-                                    <label class="form-check-label" for=""></label>
-                                </div>
-                            </td>  
-                        </tr>
-                    </tbody>
-                </table>  --}}
+                <div class="load_list_add"></div> 
             </div>
         </div> 
     </div>

+ 3 - 0
routes/web.php

@@ -101,6 +101,9 @@ Route::post('admin-logout', [App\Http\Controllers\AdminAuth\LoginController::cla
 Route::group(['middleware' => ['admin']], function() {
     Route::get('/admin/dashboard', [App\Http\Controllers\Admin\AdminController::class,'dashboard']);
     Route::get('/admin/dashboard/load_country_list/{text}', [App\Http\Controllers\Admin\AdminController::class,'load_country_list']);
+    Route::get(
+		'sub-content/{name}', [App\Http\Controllers\Admin\SubContentController::class, 'get']
+	)->name('admin.sub-content');
 });