예제 #1
0
 /**
  * @desc show list of terms per year
  * @param Year $year int to load terms
  * @param Department $department fro breadcrumbs
  **/
 public function index(Year $year, Department $department, Faculty $faculty)
 {
     $year->load('terms');
     $terms = Term::where('year_id', $year->id)->select('academystructure_terms.*')->selectRaw('COUNT(sh.id) as total_students')->leftJoin('academystructure_departments as acadep', 'acadep.term_id', '=', 'academystructure_terms.id')->Leftjoin('student_histories as sh', 'sh.academystructure_department_id', '=', 'acadep.id')->groupBy('academystructure_terms.id')->get();
     $breadcrumbs = $faculty->breadcrumbs()->where('ay.id', '=', $year->id)->first();
     return view('academystructure::terms.index', compact('terms', 'year', 'breadcrumbs'));
 }
예제 #2
0
 /**
  * @desc show list of terms per year
  * @param Year $year int to load terms 
  * @param Department $department fro breadcrumbs
  **/
 public function index(Year $year, Department $department, Faculty $faculty)
 {
     $year->load('terms');
     $terms = $year->terms;
     $breadcrumbs = $faculty->breadcrumbs()->where('ay.id', '=', $year->id)->first();
     //dd($breadcrumbs);
     return view('academystructure::terms.index', compact('terms', 'year', 'breadcrumbs'));
 }
예제 #3
0
 /**
  * @desc show list of department and its parent sequence and subject per year
  * @param Term $term int to load terms 
  * @param Department $department to load parent_deparment_sequence	
  * @param Department $department to load list of subject append them to its department object
  * @param Faculty $faculty for breadcrumbs
  **/
 public function index(Term $term, Department $department, Faculty $faculty, Subject $subject)
 {
     $departments = $department->menu()->with('parent_department')->where('term_id', '=', $term->id)->get();
     $subjects = $subject->all();
     foreach ($departments as &$department) {
         $department->subjects = $subjects->filter(function ($subject) use($department) {
             return in_array($subject->id, json_decode($department->subject_ids, TRUE));
         });
     }
     $breadcrumbs = $faculty->breadcrumbs()->where('at.id', '=', $term->id)->first();
     return view('academystructure::departments.index', compact('departments', 'term', 'breadcrumbs'));
 }
예제 #4
0
 /**
  * @desc show list of department and its parent sequence and subject per year
  * @param Term $term int to load terms
  * @param Department $department to load parent_deparment_sequence
  * @param Department $department to load list of subject append them to its department object
  * @param Faculty $faculty for breadcrumbs
  **/
 public function index(Term $term, Department $department, Faculty $faculty, Subject $subject)
 {
     $departments = $department->menu()->selectRaw('COUNT(sh.id) as total_students')->Leftjoin('student_histories as sh', 'sh.academystructure_department_id', '=', 'academystructure_departments.id')->with('parent_department')->where('term_id', '=', $term->id)->groupBy('sid')->get();
     $subjects = $subject->all();
     foreach ($departments as &$department) {
         $department->subjects = $subjects->filter(function ($subject) use($department) {
             $subject_ids = json_decode($department->subject_ids, TRUE);
             return is_array($subject_ids) and in_array($subject->id, $subject_ids);
         });
     }
     $breadcrumbs = $faculty->breadcrumbs()->where('at.id', '=', $term->id)->first()->toArray();
     return view('academystructure::departments.index', compact('departments', 'term', 'breadcrumbs'));
 }
예제 #5
0
 /**
  * Register the service provider.
  *
  * @return void
  */
 public function register()
 {
     //Faculty
     Faculty::created(function ($faculty) {
         UserLog::create(['operation' => 'create', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Academystructure_Faculty', 'reference_id' => $faculty->id]);
     });
     Faculty::updated(function ($faculty) {
         UserLog::create(['operation' => 'update', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Academystructure_Faculty', 'reference_id' => $faculty->id]);
     });
     Faculty::deleted(function ($faculty) {
         UserLog::create(['operation' => 'delete', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Academystructure_Faculty', 'reference_id' => $faculty->id]);
     });
     //Year
     Year::created(function ($year) {
         UserLog::create(['operation' => 'create', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Academystructure_Year', 'reference_id' => $year->id]);
     });
     Year::updated(function ($year) {
         UserLog::create(['operation' => 'update', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Academystructure_Year', 'reference_id' => $year->id]);
     });
     Year::deleted(function ($year) {
         UserLog::create(['operation' => 'delete', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Academystructure_Year', 'reference_id' => $year->id]);
     });
     //Term
     Term::created(function ($term) {
         UserLog::create(['operation' => 'create', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Academystructure_term', 'reference_id' => $term->id]);
     });
     Term::updated(function ($term) {
         UserLog::create(['operation' => 'update', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Academystructure_term', 'reference_id' => $term->id]);
     });
     Term::deleted(function ($term) {
         UserLog::create(['operation' => 'delete', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Academystructure_term', 'reference_id' => $term->id]);
     });
     //Department
     Department::created(function ($department) {
         UserLog::create(['operation' => 'create', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Academystructure_department', 'reference_id' => $department->id]);
     });
     Department::updated(function ($department) {
         UserLog::create(['operation' => 'update', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Academystructure_department', 'reference_id' => $department->id]);
     });
     Department::deleted(function ($department) {
         UserLog::create(['operation' => 'delete', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Academystructure_department', 'reference_id' => $department->id]);
     });
     //Specailty
     Specialty::created(function ($specialty) {
         UserLog::create(['operation' => 'create', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Academystructure_specialty', 'reference_id' => $specialty->id]);
     });
     Specialty::updated(function ($specialty) {
         UserLog::create(['operation' => 'update', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Academystructure_specialty', 'reference_id' => $specialty->id]);
     });
     Specialty::deleted(function ($specialty) {
         UserLog::create(['operation' => 'delete', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Academystructure_specialty', 'reference_id' => $specialty->id]);
     });
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Model::unguard();
     DB::statement('SET FOREIGN_KEY_CHECKS=0;');
     if (Department::count()) {
         return;
     }
     Year::truncate();
     Department::truncate();
     Faculty::truncate();
     Specialty::truncate();
     Term::truncate();
     $specialties = [['name' => 'العلوم الشرعية', 'type' => 'dep', 'code' => 'G'], ['name' => 'الفقه و علومه', 'type' => 'bac', 'code' => 'O'], ['name' => 'الدراسات الاسلامية', 'type' => 'bac', 'code' => 'I']];
     foreach ($specialties as $s) {
         Specialty::create($s);
     }
     $structure = [['name' => 'كلية العلوم الشرعية', 'years' => [['name' => 'السنة الأولى', 'terms' => [['name' => 'الفصل الأول', 'departments' => [['subject_ids' => json_encode([1, 2, 3, 4, 5, 6]), 'spec_id' => 1], ['subject_ids' => json_encode([1, 2, 3, 4, 5, 6]), 'spec_id' => 2], ['subject_ids' => json_encode([1, 2, 3, 4, 5, 6]), 'spec_id' => 3]]], ['name' => 'الفصل الثاني', 'departments' => [['subject_ids' => json_encode([12, 11, 10, 14, 9, 8]), 'spec_id' => 1], ['subject_ids' => json_encode([12, 11, 10, 14, 9, 8]), 'spec_id' => 2], ['subject_ids' => json_encode([12, 11, 10, 14, 9, 8]), 'spec_id' => 3]]]]], ['name' => 'السنة الثانية', 'terms' => [['name' => 'الفصل الثالث', 'departments' => [['subject_ids' => json_encode([15, 16, 17, 18, 19, 20, 21]), 'spec_id' => 1], ['subject_ids' => json_encode([15, 16, 17, 18, 19, 20, 21]), 'spec_id' => 2], ['subject_ids' => json_encode([15, 16, 17, 18, 19, 20, 21]), 'spec_id' => 3]]], ['name' => 'الفصل الرابع', 'departments' => [['subject_ids' => json_encode([22, 23, 24, 29, 26, 27, 29]), 'spec_id' => 1], ['subject_ids' => json_encode([22, 23, 24, 29, 26, 27, 29]), 'spec_id' => 2], ['subject_ids' => json_encode([22, 23, 24, 29, 26, 27, 29]), 'spec_id' => 3]]]]], ['name' => 'السنة الثالثة', 'terms' => [['name' => 'الفصل الخامس', 'departments' => [['subject_ids' => json_encode([31, 32, 33, 34, 30, 35, 36, 39]), 'spec_id' => 2], ['subject_ids' => json_encode([32, 33, 30, 34, 37, 36, 39]), 'spec_id' => 3], ['subject_ids' => json_encode([33, 37]), 'spec_id' => 1]]], ['name' => 'الفصل السادس', 'departments' => [['subject_ids' => json_encode([41, 42, 43, 44, 45, 46, 47, 52]), 'spec_id' => 2], ['subject_ids' => json_encode([31, 50, 46, 47, 48, 49, 51, 52]), 'spec_id' => 3]]]]], ['name' => 'السنة الرابعة', 'terms' => [['name' => 'الفصل السابع', 'departments' => [['subject_ids' => json_encode([53, 54, 55, 56, 57, 58, 59, 77]), 'spec_id' => 2], ['subject_ids' => json_encode([55, 59, 60, 67, 68, 69, 75, 77]), 'spec_id' => 3]]], ['name' => 'الفصل الثامن', 'departments' => [['subject_ids' => json_encode([58, 61, 62, 63, 64, 65, 76, 78]), 'spec_id' => 2], ['subject_ids' => json_encode([58, 66, 70, 71, 72, 73, 74, 78]), 'spec_id' => 3]]]]]]]];
     $last_1_id = null;
     $last_2_id = null;
     $last_3_id = null;
     foreach ($structure as $f) {
         $faculty = Faculty::create(['name' => $f['name']]);
         foreach ($f['years'] as $y) {
             $year = Year::create(['name' => $y['name'], 'faculty_id' => $faculty->id]);
             foreach ($y['terms'] as $t) {
                 $term = Term::create(['year_id' => $year->id, 'name' => $t['name']]);
                 foreach ($t['departments'] as $d) {
                     $department = Department::create(['spec_id' => $d['spec_id'], 'subject_ids' => $d['subject_ids'], 'parent_id' => ${'last_' . $d['spec_id'] . '_id'}, 'term_id' => $term->id]);
                     if ($d['spec_id'] == 1) {
                         $last_1_id = $department->id;
                     } elseif ($d['spec_id'] == 2) {
                         $last_2_id = $department->id;
                     } elseif ($d['spec_id'] == 3) {
                         $last_3_id = $department->id;
                     }
                 }
             }
         }
     }
 }
예제 #7
0
 /**
  * @desc show list of years per faculty
  * @param Faculty $faculty int to load years 
  * @param Department $department fro breadcrumbs
  **/
 public function index(Faculty $faculty, Department $department)
 {
     $faculty->load('years');
     $years = $faculty->years;
     return view('academystructure::years.index', compact('years', 'faculty', 'menu'));
 }
예제 #8
0
 /**
  * @desc Delete Faculty
  * @param Faculty $faculty (get faculty data from provider route model binding $router->model lisner)
  * @delete Function delete faculty
  * @redirct to faculty index
  **/
 public function delete(Faculty $faculty)
 {
     $faculty->delete();
     return redirect()->route('as.faculties.index');
 }
예제 #9
0
 function faculty()
 {
     return \Modules\Academystructure\Entities\Faculty::whereActive(1)->first();
 }