Skip to content

Commit

Permalink
Update dependencies (#5)
Browse files Browse the repository at this point in the history
* Update JS/Sass deps

* Update PHP deps

* Add FTP and Dropbox filesystem driver
  • Loading branch information
arxeiss authored Aug 3, 2022
1 parent 661ffd1 commit 15aabf2
Show file tree
Hide file tree
Showing 119 changed files with 7,445 additions and 14,482 deletions.
35 changes: 25 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# Czechitas DA Testing App

Aplikace využívá PHP framework [Laravel](https://laravel.com/docs/8.x/), [Bootstrap 4](https://getbootstrap.com/docs/4.6/getting-started/introduction/), [Webpack 5](https://webpack.js.org/).
Aplikace využívá PHP framework [Laravel](https://laravel.com/docs/), [Bootstrap 4](https://getbootstrap.com/docs/4.6/getting-started/introduction/), [Webpack 5](https://webpack.js.org/).

## Dokumentace:

- Systém a jeho komponenty jsou popsány ve [Wiki](https://github.com/czechitas/da-test-webapp/wiki)

## Prerekvizity:

- PHP 7.3+
- PHP 8.1+, rozšíření PDO, a GD nebo Imagick
- Composer 2 https://getcomposer.org/download/
- MySQL - netestováno s jinou DB, ale možná bude fungovat
- NodeJS 14+ - pro build assetů (JS/CSS)
- npm
- NodeJS 16+ - pro build assetů (JS/CSS)
- npm 8.2+

## Instalace

Expand Down Expand Up @@ -47,7 +47,10 @@ Deploy do služby Heroku a pak už jen profitovat z výsledku 🎉🎉

1. Vytvořit fork pro Váš běh digitální akademie
1. Vytvořit účet na herokuapp.com
1. Vytvořit si účet na AWS - je potřeba S3 Bucket nastavit.
1. Vyřešit úložiště, Heroku při restartu smaže všechna data viz https://devcenter.heroku.com/articles/active-storage-on-heroku. Možnosti jsou:
1. Vytvořit si účet na AWS - je potřeba S3 Bucket nastavit
1. Připravit si FTP, nutný přístup přes URL k uloženým datům - pomalejší než AWS
1. Založit si Dropbox - nejpomalejší řešení, spíše nouzovka
1. Vytvořit novou aplikaci na heroku
1. Deployment method - Nastavit GitHub, Váš nový fork
1. Enable Automatic deploys, pokud chcete, aby se Vám aplikace automaticky updatovala s novými commity
Expand All @@ -60,17 +63,29 @@ Deploy do služby Heroku a pak už jen profitovat z výsledku 🎉🎉
2. heroku/php
1. Naconfiguruj VARS
* `APP_KEY` ^^ viz .env
* `AWS_ACCESS_KEY_ID` - access key k S3
* `AWS_BUCKET` - jmeno AWS bucketu
* `AWS_DEFAULT_REGION` - region, kde je umisten S3 bucket
* `AWS_SECRET_ACCESS_KEY` - secret key
* `AWS_URL` - url s3 bucketu
* `DB_DATABASE` - použij db name z `CLEARDB_DATABASE_URL`
* `DB_HOST` - použij host z `CLEARDB_DATABASE_URL`
* `DB_PASSWORD` - použij pass z `CLEARDB_DATABASE_URL`
* `DB_PORT` - 3306
* `DB_USERNAME` - použij username z `CLEARDB_DATABASE_URL`
1. Vars pro **AWS S3** úložiště
* `FILESYSTEM_DRIVER` - `s3`
* `AWS_ACCESS_KEY_ID` - access key k S3
* `AWS_BUCKET` - jmeno AWS bucketu
* `AWS_DEFAULT_REGION` - region, kde je umisten S3 bucket
* `AWS_SECRET_ACCESS_KEY` - secret key
* `AWS_URL` - url s3 bucketu
1. Vars pro **FTP** úložiště
* `FILESYSTEM_DRIVER` - `ftp`
* `FTP_HOST` - host pro připojení
* `FTP_USERNAME` - přístupové jméno k FTP
* `FTP_PASSWORD` - přístupové heslo k FTP
* `FTP_URL` - URL pro přístup k datům na FTP
* `FTP_PORT` - *nepovinné*, defaultně 21
* `FTP_ROOT` - *nepovinné*, pokud po připojení je potřeba změnit složku k ukládání
1. Vars pro **Dropbox** úložiště, **Pomalé, nouzovka!**
* `FILESYSTEM_DRIVER` - `dropbox`
* `DROPBOX_AUTH_TOKEN` - token pro připojení, lze získat při vytvoření aplikace přes https://www.dropbox.com/developers/apps

V tomto bodu jste ready-to-deploy. V záložce Deploy stačí v sekci Manual deploy stisknout tlačítko a tradá.

Expand Down
4 changes: 2 additions & 2 deletions app/Console/Commands/BackupDatabase.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ public function handle()
'mysql:host=%s;port=%s;dbname=%s',
\config('database.connections.mysql.host'),
\config('database.connections.mysql.port'),
\config('database.connections.mysql.database')
\config('database.connections.mysql.database'),
),
\config('database.connections.mysql.username'),
\config('database.connections.mysql.password'),
[
'no-data' => ['password_resets'],
]
],
);

$tmpDisk = Storage::disk('local');
Expand Down
4 changes: 2 additions & 2 deletions app/Http/Contracts/RedirectBack.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ interface RedirectBack
*/
public function redirectBack(
Request $request,
$parameters,
int|string|BaseModel|array $parameters,
string $defaultBackRoute,
array $extraParams = []
array $extraParams = [],
): RedirectResponse;

/**
Expand Down
6 changes: 2 additions & 4 deletions app/Http/Controllers/Admin/CategoryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@

class CategoryController extends Controller
{
/** @var BreadcrumbService */
private $breadcrumbService;
private BreadcrumbService $breadcrumbService;

/** @var CategoryService */
private $categoryService;
private CategoryService $categoryService;

public function __construct(BreadcrumbService $breadcrumbService, CategoryService $categoryService)
{
Expand Down
14 changes: 6 additions & 8 deletions app/Http/Controllers/Admin/ExportController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,14 @@

class ExportController extends Controller
{
/** @var ExcelExportService */
private $exportService;
private ExcelExportService $exportService;

/** @var TermService */
private $termService;
private TermService $termService;

public function __construct(
ExcelExportService $exportService,
BreadcrumbService $breadcrumbService,
TermService $termService
TermService $termService,
) {
$this->exportService = $exportService;
$breadcrumbService->addLevel('admin.exports.index', \trans('exports.title'));
Expand Down Expand Up @@ -78,8 +76,8 @@ public function fullTerm(Request $request): void
$this->validateTermRequest($request, 'full_term');
$this->exportService->fullTermExport(
$this->termService->findTermOrFail(
(int)$request->input('full_term.term_id')
)
(int)$request->input('full_term.term_id'),
),
)->sendToBrowser('Termín.xlsx');
}

Expand All @@ -90,7 +88,7 @@ public function overUnderPaid(Request $request): void
$this->validateDateRequest($request, 'over_under_paid');
$this->exportService->exportOverUnderPaid(
\getCarbon($request->input('over_under_paid.start')),
\getCarbon($request->input('over_under_paid.end'))
\getCarbon($request->input('over_under_paid.end')),
)->sendToBrowser('Přeplatky a nedoplatky.xlsx');
}
}
6 changes: 2 additions & 4 deletions app/Http/Controllers/Admin/NewsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@

class NewsController extends Controller
{
/** @var NewsService */
private $newsService;
private NewsService $newsService;

/** @var BreadcrumbService */
private $breadcrumbService;
private BreadcrumbService $breadcrumbService;

public function __construct(NewsService $newsService, BreadcrumbService $breadcrumbService)
{
Expand Down
24 changes: 8 additions & 16 deletions app/Http/Controllers/Admin/OrderController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
use CzechitasApp\Modules\AjaxDataTables\TableColumns;
use CzechitasApp\Services\BreadcrumbService;
use CzechitasApp\Services\Models\OrderService;
use CzechitasApp\Services\Models\UserService;
use Illuminate\Http\Request;
use Illuminate\View\View;
use Prologue\Alerts\Facades\Alert;
Expand All @@ -25,18 +24,11 @@ class OrderController extends NoAdminOrderController implements RedirectBackCont
{
use RedirectBack;

/** @var UserService */
private $userService;

public function __construct(
BreadcrumbService $breadcrumbService,
OrderService $orderService,
UserService $userService
) {
public function __construct(BreadcrumbService $breadcrumbService, OrderService $orderService)
{
parent::__construct($breadcrumbService, $orderService);

$breadcrumbService->addLevel('admin.orders.index', \trans('orders.breadcrumbs.index'));
$this->userService = $userService;
}

/**
Expand All @@ -59,9 +51,7 @@ public function getTableColumns(): TableColumns
->addColumn((new Column('flag'))->search(null))
->addColumn((new Column('flag', null, 'flag_icon'))
->onlyExtra()
->printCallback(static function (Order $order) {
return \config('czechitas.flags.' . ($order->flag ?: 'default'));
}))
->printCallback(static fn (Order $order) => \config('czechitas.flags.' . ($order->flag ?: 'default'))))
->addColumn((new Column('client')))
->addColumn((new Column('contact_name')))
->addColumn((new Column('signature_date'))->search(null)->printCallback(static function (Order $model) {
Expand All @@ -71,9 +61,11 @@ public function getTableColumns(): TableColumns

return null;
}))
->addColumn((new Column('type'))->search(null)->printCallback(static function (Order $model) {
return \trans('orders.type.short.' . $model->type);
}))
->addColumn(
(new Column('type'))->search(null)->printCallback(
static fn (Order $model) => \trans('orders.type.short.' . $model->type)
),
)
->addColumn((new Column('contact_tel'))->notInTable())
->addColumn((new Column('contact_mail'))->notInTable())
->addColumn((new Column('ico'))->notInData()->noOrder()) // search only
Expand Down
51 changes: 24 additions & 27 deletions app/Http/Controllers/Admin/StudentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,16 @@ class StudentController extends Controller implements RedirectBackContract
{
use RedirectBack;

/** @var StudentService */
private $studentService;
private StudentService $studentService;

/** @var BreadcrumbService */
private $breadcrumbService;
private BreadcrumbService $breadcrumbService;

/** @var TermService */
private $termService;
private TermService $termService;

public function __construct(
StudentService $studentService,
BreadcrumbService $breadcrumbService,
TermService $termService
TermService $termService,
) {
$this->studentService = $studentService;
$this->breadcrumbService = $breadcrumbService;
Expand Down Expand Up @@ -76,31 +73,31 @@ public function getTableColumns(): TableColumns
/** @var Builder<Student> $query */
$query->withPaymentSum();
})
->addColumn((new Column('surname', null, 'name'))->printCallback(static function (Student $student) {
return "{$student->surname} {$student->forename}";
})->orderCallback(static function (Builder $query, $dir): void {
/** @var Builder<Student> $query */
$query->orderBy('surname', $dir)->orderBy('forename', $dir);
}))
->addColumn(
(new Column('surname', null, 'name'))->printCallback(
static fn (Student $student) => "{$student->surname} {$student->forename}",
)->orderCallback(
static function (Builder $query, $dir): void {
/** @var Builder<Student> $query */
$query->orderBy('surname', $dir)->orderBy('forename', $dir);
},
),
)
->addColumn((new Column('forename'))->noOrder()->notInTable())
->addColumn((new Column('term.term_range'))->search(null))
->addColumn((new Column('term_id'))->onlyExtra())
->addColumn((new Column('payment'))
->search(null)
->printCallback(static function (Student $student, $value) {
return \trans('students.payments.' . $value ?? 'none');
}))
->printCallback(
static fn (Student $student, $value) => \trans('students.payments.' . ($value ?? 'none'))
))
->addColumn((new Column('price_to_pay'))
->noDB()
->printCallback(static function (Student $student, $price) {
return \formatPrice($price);
}))
->printCallback(static fn (Student $student, $price) => \formatPrice($price)))
->addColumn((new Column('rowClass'))
->noDB()
->onlyExtra()
->printCallback(static function (Student $student) {
return \studentListClass($student);
}))
->printCallback(static fn (Student $student) => \studentListClass($student)))
->addColumn((new Column('parent_name'))->notInData()->noOrder()) // Do search
->addColumn((new Column('birthday'))->notInData()->dateSearch('%d.%m.%Y')->noOrder())
->addColumn((new Column('birthday'))->notInData()->dateSearch('%e.%c.%Y')->noOrder())
Expand Down Expand Up @@ -226,9 +223,9 @@ public function logout(AdminLogoutStudentRequest $request, Student $student): Re
$this->studentService->setContext($student)->updateLogout($request->getData());
Alert::success(
\trans(
'students.logout.flash_' . ($student->logged_out == null ? 'isnot' : $student->logged_out),
['name' => $student->name]
)
'students.logout.flash_' . ($student->logged_out ?? 'isnot'),
['name' => $student->name],
),
)->flash();

return \redirect()->route('admin.students.show', $student);
Expand All @@ -241,8 +238,8 @@ public function cancel(AdminCanceledStudentRequest $request, Student $student):
Alert::success(
\trans(
'students.cancel.flash_' . ($student->canceled ? 'is' : 'isnot'),
['name' => $student->name]
)
['name' => $student->name],
),
)->flash();

return \redirect()->route('admin.students.show', $student);
Expand Down
Loading

0 comments on commit 15aabf2

Please sign in to comment.