Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Laravel to v. 9 (Warning: requires PHP > 8.0.2) #461

Open
wants to merge 18 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ DB_PASSWORD=mariadb
BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync
QUEUE_CONNECTION=sync

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_DRIVER=smtp
MAIL_MAILER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
Expand Down
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ package-lock.json
.env-prod
.env-local
.env.testing
.env.backup
.env.production

# Composer specific files
composer.phar
Expand All @@ -39,13 +41,18 @@ config/bd_users.initial.php
config/bergfest_users.initial.php

# IDE related files
.idea/
_ide_helper.php
_ide_helper_models.php
.phpstorm.meta.php
/.fleet
/.idea
/.vscode

# Misc
/storage/*.key
.DS_Store
Thumbs.db
Homestead.json
Homestead.yaml

.phpunit.*
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Club management software built on top of Laravel 8
## Club management software built on top of Laravel 9

## About
**Lara** is a planning tool that combines a calendar with personnel scheduling, developed for [Ilmenauer Studentenclub e.V.](http://www.il-sc.de)
Expand All @@ -18,7 +18,7 @@ If you want to contribute, please read this short overview first: [Contributing]
Code published under [GNU GPL v.3](https://github.com/ILSCeV/Lara/blob/master/LICENSE).

Lara VedSt is based on:
- [Laravel 8](http://laravel.com)
- [Laravel 9](http://laravel.com)
- [Bootswatch](http://bootswatch.com)
- [Google Material Color implementation](https://github.com/danlevan/google-material-color)
- [JQuery](http://jquery.com)
Expand Down
8 changes: 5 additions & 3 deletions app/BaseSoftDelete.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ abstract class BaseSoftDelete extends Model
use SoftDeletes;

/**
* The attributes that should be mutated to dates.
* The attributes that should be cast.
*
* @var array
* @var array<string, string>
*/
protected $dates = ['deleted_at'];
protected $casts = [
'deleted_at' => 'datetime',
];
}
9 changes: 7 additions & 2 deletions app/ClubEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,13 @@ class ClubEvent extends Model
'canceled'
];

protected $dates = [
'unlock_date',
/**
* The attributes that should be cast.
*
* @var array<string, string>
*/
protected $casts = [
'unlock_date' => 'datetime',
];


Expand Down
15 changes: 7 additions & 8 deletions app/Console/Commands/LDAPsync.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Lara\Console\Commands;

use Config;
use Illuminate\Console\Command;
use Lara\LdapPlatform;
use Lara\Person;
Expand Down Expand Up @@ -67,7 +66,7 @@ public function handle()

// CONNECTING TO LDAP SERVER

$ldapConn = ldap_connect(Config::get('bcLDAP.server'), Config::get('bcLDAP.port'));
$ldapConn = ldap_connect(config('bcLDAP.server'), config('bcLDAP.port'));

// Set some ldap options for talking to AD
// LDAP_OPT_PROTOCOL_VERSION: LDAP protocol version
Expand All @@ -77,8 +76,8 @@ public function handle()

// Bind as a domain admin
$ldap_bind = ldap_bind($ldapConn,
Config::get('bcLDAP.admin-username'),
Config::get('bcLDAP.admin-password'));
config('bcLDAP.admin-username'),
config('bcLDAP.admin-password'));
$allowedSection = (new Section())->whereIn('title', ['bc-Club', 'bc-Café'])->get();

// STARTING THE UPDATE
Expand All @@ -100,8 +99,8 @@ public function handle()

// Search for a bc-Club user with the uid number entered
$search = ldap_search($ldapConn,
Config::get('bcLDAP.bc-club-ou').
Config::get('bcLDAP.base-dn'),
config('bcLDAP.bc-club-ou').
config('bcLDAP.base-dn'),
'(uid='.$person->prsn_ldap_id.')');

$info = ldap_get_entries($ldapConn, $search);
Expand All @@ -113,8 +112,8 @@ public function handle()

// Search for a Café-user with the uid number entered
$search = ldap_search($ldapConn,
Config::get('bcLDAP.bc-cafe-ou').
Config::get('bcLDAP.base-dn'),
config('bcLDAP.bc-cafe-ou').
config('bcLDAP.base-dn'),
'(uid='.$person->prsn_ldap_id.')');

$info = ldap_get_entries($ldapConn, $search);
Expand Down
3 changes: 1 addition & 2 deletions app/Http/Controllers/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

namespace Lara\Http\Controllers;

use Redirect;
use View;

use Lara\Utilities;
Expand All @@ -20,7 +19,7 @@ class AdminController extends Controller
function startUpdateProcess(){
/** if you are no admin, you will be redirected back */
if(!Utilities::requirePermission('admin')){
return Redirect::back($status = 403);
return back($status = 403);
}
return View::make('update');
}
Expand Down
7 changes: 3 additions & 4 deletions app/Http/Controllers/Auth/PasswordChangeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
use Lara\User;
use Lara\Utilities;
use Lara\utilities\LdapUtility;
use Redirect;
use Request;
use Validator;
use View;
Expand All @@ -29,7 +28,7 @@ public function changePassword()
// Get old password and check that it matches the one stored in the DB
$validator = $this->validator($request->all());
if ($validator->fails()) {
return Redirect::back()->withErrors($validator)->withInput();
return back()->withErrors($validator)->withInput();
}
$oldPassword = $request->input('old-password');

Expand All @@ -39,7 +38,7 @@ public function changePassword()

if (!$isPasswordCorrect) {
Utilities::error(trans('auth.passwordDoesNotMatch'));
return Redirect::back();
return back();
}

$newPassword = $request->input('password');
Expand All @@ -56,7 +55,7 @@ public function changePassword()
*/
Utilities::success(trans('auth.passwordChanged'));

return Redirect::to('/');
return redirect('/');
}

public function validator($data)
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Auth/RegisterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public function register(Request $request)

$this->authorize('create', User::class);

if (Gate::denies('createUserOfSection', $request->get('section'))) {
if (Gate::denies('createUserOfSection', $request->input('section'))) {
Utilities::error('You cannot create a user of another section!');
return redirect($this->redirectPath());
}
Expand Down
68 changes: 37 additions & 31 deletions app/Http/Controllers/ClubEventController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use Auth;
use Cache;
use Carbon\Carbon;
use Config;
use DateInterval;
use DateTime;
use DateTimeZone;
Expand All @@ -24,8 +23,7 @@
use Lara\Template;
use Lara\Utilities;
use Lara\utilities\RoleUtility;
use Redirect;
use Session;

use View;

class ClubEventController extends Controller
Expand Down Expand Up @@ -89,9 +87,9 @@ public function create($year = null, $month = null, $day = null, $templateId = n
$isDateFormatValid = $d && $d->format('Y-m-d') === $dateString;

if (!$isDateFormatValid) {
Session::put('message', trans("messages.invalidDate", compact('day', 'month', 'year')));
Session::put('msgType', 'danger');
return Redirect::to('/');
session()->put('message', trans("messages.invalidDate", compact('day', 'month', 'year')));
session()->put('msgType', 'danger');
return redirect('/');
}

// prepare correct date format to be used in the forms
Expand Down Expand Up @@ -221,9 +219,9 @@ public function store(Request $request)
{
//validate passwords
if ($request->input('password') != $request->input('passwordDouble')) {
Session::put('message', Config::get('messages_de.password-mismatch'));
Session::put('msgType', 'danger');
return Redirect::back()->withInput();
session()->put('message', config('messages_de.password-mismatch'));
session()->put('msgType', 'danger');
return back()->withInput();
}

$newEvent = $this->editClubEvent(null);
Expand All @@ -245,7 +243,7 @@ public function store(Request $request)
}

// show new event
return Redirect::action('ClubEventController@show', [$newEvent->id]);
return redirect()->action([ClubEventController::class, 'show'], [$newEvent->id]);
}

/**
Expand All @@ -265,14 +263,14 @@ public function show(ClubEvent $event)

$user = Auth::user();
if (!$user && $clubEvent->evnt_is_private == 1) {
Session::put('message', Config::get('messages_de.access-denied'));
Session::put('msgType', 'danger');
return Redirect::action(
'MonthController@showMonth',
array(
session()->put('message', config('messages_de.access-denied'));
session()->put('msgType', 'danger');
return redirect()->action(
[MonthController::class, 'showMonth'],
[
'year' => date('Y'),
'month' => date('m')
)
]
);
}

Expand Down Expand Up @@ -451,9 +449,9 @@ public function update(Request $request, ClubEvent $event)
{
//validate passwords
if ($request->input('password') != $request->input('passwordDouble')) {
Session::put('message', Config::get('messages_de.password-mismatch'));
Session::put('msgType', 'danger');
return Redirect::back()->withInput();
session()->put('message', config('messages_de.password-mismatch'));
session()->put('msgType', 'danger');
return back()->withInput();
}

$event = $this->editClubEvent($event);
Expand All @@ -473,7 +471,7 @@ public function update(Request $request, ClubEvent $event)
}

// show event
return Redirect::action('ClubEventController@show', [$event->id]);
return redirect()->action([ClubEventController::class, 'show'], [$id]);
}

/**
Expand All @@ -486,20 +484,28 @@ public function destroy(ClubEvent $event)
{
$date = new DateTime($event->evnt_date_start);


// Check if event exists
if (is_null($event)) {
session()->put('message', config('messages_de.event-doesnt-exist'));
session()->put('msgType', 'danger');
return back();
}

// Check credentials: you can only delete, if you have rights for marketing or management.
$revisions = json_decode($event->getSchedule->entry_revisions, true);
$created_by = $revisions[0]["user id"];

$user = Auth::user();
if (!$user || !$user->isAn(RoleUtility::PRIVILEGE_MARKETING, RoleUtility::PRIVILEGE_CL, RoleUtility::PRIVILEGE_ADMINISTRATOR)) {
Session::put('message', 'Du darfst diese Veranstaltung/Aufgabe nicht einfach löschen! Frage die Clubleitung oder Markleting ;)');
Session::put('msgType', 'danger');
return Redirect::action(
'MonthController@showMonth',
array(
session()->put('message', 'Du darfst diese Veranstaltung/Aufgabe nicht einfach löschen! Frage die Clubleitung oder Markleting ;)');
session()->put('msgType', 'danger');
return redirect()->action(
[MonthController::class, 'showMonth'],
[
'year' => date('Y'),
'month' => date('m')
)
]
);
}

Expand All @@ -512,9 +518,9 @@ public function destroy(ClubEvent $event)
$event->delete();

// show current month afterwards
Session::put('message', Config::get('messages_de.event-delete-ok'));
Session::put('msgType', 'success');
return Redirect::action('MonthController@showMonth', [
session()->put('message', config('messages_de.event-delete-ok'));
session()->put('msgType', 'success');
return redirect()->action([MonthController::class, 'showMonth'], [
'year' => $date->format('Y'),
'month' => $date->format('m')
]);
Expand Down Expand Up @@ -574,14 +580,14 @@ private function editClubEvent(ClubEvent $event = null)

// format: date; validate on filled value
if (!empty(request('beginDate'))) {
$newBeginDate = new DateTime(request('beginDate'), new DateTimeZone(Config::get('app.timezone')));
$newBeginDate = new DateTime(request('beginDate'), new DateTimeZone(config('app.timezone')));
$event->evnt_date_start = $newBeginDate->format('Y-m-d');
} else {
$event->evnt_date_start = date('Y-m-d', mktime(0, 0, 0, 0, 0, 0));;
}

if (!empty(request('endDate'))) {
$newEndDate = new DateTime(request('endDate'), new DateTimeZone(Config::get('app.timezone')));
$newEndDate = new DateTime(request('endDate'), new DateTimeZone(config('app.timezone')));
$event->evnt_date_end = $newEndDate->format('Y-m-d');
} else {
$event->evnt_date_end = date('Y-m-d', mktime(0, 0, 0, 0, 0, 0));;
Expand Down
4 changes: 2 additions & 2 deletions app/Http/Controllers/DateController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Carbon\Carbon;
use Request;
use Redirect;
use View;

use Lara\Http\Requests;
Expand All @@ -25,7 +24,8 @@ class DateController extends Controller {
*/
public function currentDate()
{
return Redirect::action( 'DateController@showDate', ['year' => date("Y"),
return redirect()->action( [DateController::class,'showDate'],
['year' => date("Y"),
'month' => date("m"),
'day' => date("d")] );
}
Expand Down
Loading