Skip to content

Commit

Permalink
default academic year cache enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
hrshadhin committed Jul 20, 2020
1 parent 4823fc0 commit c757f37
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 13 deletions.
2 changes: 1 addition & 1 deletion app/Http/Controllers/Backend/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ public function institute(Request $request)
Cache::forget('studentCount');
Cache::forget('student_count_by_class');
Cache::forget('student_count_by_section');
Cache::forget('default_academic_year');
Cache::put('default_academic_year', $request->get('academic_year', 0));

//now notify the admins about this record
$msg = "Institute settings updated by ".auth()->user()->name;
Expand Down
1 change: 1 addition & 0 deletions app/Http/Controllers/Backend/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public function authenticate(Request $request)
session(['user_role_id' => auth()->user()->role->role_id]);

$appSettings = AppHelper::getAppSettings(null, true);
Cache::put('default_academic_year', AppHelper::getAcademicYear());

$msgType = "success";
$msg = "Welcome to admin panel.";
Expand Down
14 changes: 4 additions & 10 deletions app/Http/Helpers/AppHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,10 @@ public static function getInstituteCategory()
public static function getAcademicYear()
{
$settings = AppHelper::getAppSettings(null, true);
return isset($settings['academic_year']) ? intval($settings['academic_year']) : 0;
if(AppHelper::getInstituteCategory() != 'college') {
return isset($settings['academic_year']) ? intval($settings['academic_year']) : 0;
}
return 0;
}

public static function getUserSessionHash()
Expand Down Expand Up @@ -854,15 +857,6 @@ public static function checkLeaveBalance($leaveType, $requestLeaveDay, $employee
return [$holidayBalance, $message];
}

public static function get_default_ac_year(){
if (AppHelper::getInstituteCategory() == "school" && Schema::hasTable('app_metas'))
{
return AppHelper::getAcademicYear();
}

return 0;
}

public static function check_dev_route_access($code) {
if ($code !== '007') {
dd("Wrong code!");
Expand Down
4 changes: 2 additions & 2 deletions app/Providers/ComposerServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace App\Providers;

use App\Http\Helpers\AppHelper;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\View;
use Illuminate\Support\ServiceProvider;

Expand Down Expand Up @@ -45,7 +45,7 @@ public function boot()
'App\Http\ViewComposers\ReportMasterComposer'
);

\view()->share('default_academic_year', AppHelper::get_default_ac_year());
\view()->share('default_academic_year', Cache::get('default_academic_year', 0));
}

/**
Expand Down

0 comments on commit c757f37

Please sign in to comment.