Repository navigation
Back end
The back-end of the WPL application is built upon Laravel. The current version can be seen in the composer.json file.
The application tries to adhere to nearly all Laravel practices, with several exceptions. These are listed below.
Even though Facades provide an easy way to use dependencies in classes, the prefered method of getting dependencies is through dependency injection (often in the constructor). Dependency injection makes testing easier and allows us to see quickly which dependencies are used in a class.
Currently most of the application uses controllers like the Laravel documentation describes them. However, new controllers should be single action controllers. If a single resource requires multiple controller files they should be in grouped in a directory. Documentation on how to use them can be found here.
No detailed rules for this. If you add properties to a model/table, don't forget to add them to the properties declarations in the PHP doc above the class declaration. For example:
/**
* @property bool $disabled
*/This helps the IDE to auto-complete code and helps visually to determine whether or not a property really exists.
Translations can be added and modified manually by editing the right lang files in resources/lang/*.
Another approach is to use the Laravel Translation Manager package, available in dev environment at localhost/translations.
Instructions on how to use it can be found at its github page.
React/JS translations are stored in resources/lang/*/react.php. These are compiled to the public/messages.js file with php artisan lang:js.
So don't forget to compile whenever you add new translations that are used in React/JS.
Laravel has three ways to use translations:
- Lang::get('namespace.key')
- trans('namespace.key')
- __('namespace.key') or __('string to translate')
with the latter using .json files first. We only use the __('') function as it will check both json and normal translations files, removing the need to decide which helper to use.
By default users are authenticated through the normal Laravel methods. Additionally, a Canvas integration exists. This is only usable on the live platform.
Users are authorized to perform certain actions. By default users have the user_level of 0. This means the user is a student. If the user_level is 1 then the user is also considered a teacher. With a user_level of 2 the user also has admin rights.