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

Upgrade to PHP 8.2, Laravel 10, and Backpack 6 #157

Merged
merged 22 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
15 changes: 15 additions & 0 deletions .docker/mysql/db-init/create_testing_db.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash
set -eo pipefail
shopt -s nullglob

if [[ ! -v DB_DATABASE_TEST ]]; then
echo '$DB_DATABASE_TEST is not defined, skipping testing db creation'
else

source /usr/local/bin/docker-entrypoint.sh

docker_process_sql --database=mysql <<EOSQL
CREATE DATABASE IF NOT EXISTS ${DB_DATABASE_TEST};
GRANT ALL ON ${DB_DATABASE_TEST}.* TO '${MYSQL_USER:-ccdb}'@'%';
EOSQL
fi
5 changes: 0 additions & 5 deletions .docker/mysql/db-init/init_testing.sql

This file was deleted.

3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

# needed for backpack pro version
COMPOSER_AUTH='{ "http-basic": { "backpackforlaravel.com": { "username": "changeme", "password": "changeme" } } }'

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
Expand Down
103 changes: 0 additions & 103 deletions .github/workflows/docker-publish.yml

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ configstore/update-notifier-npm.json
psysh/psysh_history
.docker/mysql/data
.docker/mysql/db-init/*.sql.gz
.docker/mysql/db-init/init-testing.sql

# things that php tools may add when HOME=/srv/app
.cache
Expand Down
43 changes: 0 additions & 43 deletions Dockerfile

This file was deleted.

8 changes: 7 additions & 1 deletion app/Actions/SurveyDataExport.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,16 @@ public function handle($class, $limit = null)
{
$responses = $class::with('volunteer')->get();
$rows = $this->getRows($responses);


$filepath = storage_path('app/reports/'.Str::snake(preg_replace('/\\\/', '', $class)).'_'.Carbon::now()->format('Y-m-d').'.csv');

$fh = fopen($filepath, 'w');

if (count($rows) == 0) {
fputcsv($fh, ['No followup survey data to export.']);
return $filepath;
}

fputcsv($fh, array_keys($rows[0]));
foreach ($rows as $idx => $row) {
if ($limit && $idx+1 > $limit) {
Expand Down
4 changes: 1 addition & 3 deletions app/Attestation.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,14 @@ class Attestation extends Model
'signed_at',
'data',
];
protected $dates = [
'signed_at',
];

protected $dispatchesEvents = [
'created' => AttestationCreated::class,
];

protected $casts = [
'data' => 'array',
'signed_at' => 'datetime',
];

public static function boot()
Expand Down
6 changes: 3 additions & 3 deletions app/Campaign.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ class Campaign extends Model
'ends_at',
'display_order'
];
protected $dates = [
'starts_at',
'ends_at',
protected $casts = [
'starts_at' => 'datetime',
'ends_at' => 'datetime',
];

protected static function boot()
Expand Down
40 changes: 23 additions & 17 deletions app/DbMailLog/Listeners/StoreMailInDatabase.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,13 @@
namespace App\DbMailLog\Listeners;

use App\DbMailLog\DbMailLogProvider;
use Illuminate\Mail\Mailables\Address;
use Illuminate\Mail\Events\MessageSent;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;

class StoreMailInDatabase
{
/**
* Create the event listener.
*
* @return void
*/
public function __construct()
{
//
}

/**
* Handle the event.
*
Expand All @@ -28,15 +19,30 @@ public function __construct()
public function handle(MessageSent $event)
{
$email = DbMailLogProvider::getEmailInstance([
'from' => $event->message->getFrom(),
'sender' => $event->message->getSender(),
'reply_to' => $event->message->getReplyTo(),
'to' => $event->message->getTo(),
'cc' => $event->message->getCc(),
'bcc' => $event->message->getBcc(),
'from' => $this->addressesToHash($event->message->getFrom()),
'sender' => $this->addressesToHash([$event->message->getSender()]),
'reply_to' => $this->addressesToHash($event->message->getReplyTo()),
'to' => $this->addressesToHash($event->message->getTo()),
'cc' => $this->addressesToHash($event->message->getCc()),
'bcc' => $this->addressesToHash($event->message->getBcc()),
'subject' => $event->message->getSubject(),
'body' => $event->message->getBody(),
'body' => $event->message->getTextBody(),
]);
$email->save();
}

private function addressesToHash(Array|Address $addresses): array|null
{
$hash = [];
$presentAddresses = array_filter($addresses);
array_walk($presentAddresses, function ($address) use (&$hash) {
$hash[$address->getAddress()] = $address->getName();
});

if (count($hash) == 0) {
return null;
}

return $hash;
}
}
8 changes: 3 additions & 5 deletions app/Http/Controllers/Admin/CurationGroupCrudController.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ public function setup()

$this->crud->modifyField('curation_activity_id', [
'label' => 'Curation Activity',
'type' => 'select',
'entity' => 'curationActivity',
'type' => 'select2',
'name' => 'curation_activity_id',
'attribute' => 'name',
'model' => CurationActivity::class,
Expand All @@ -63,12 +62,11 @@ public function setup()
]);

$this->crud->modifyField('working_group_id', [
'label' => 'Working Group',
'type' => 'select2',
'name' => 'working_group_id',
'entity' => 'workingGroup',
'attribute' => 'name',
'label' => 'Working Group',
'model' => WorkingGroup::class,
'attribute' => 'name',
]);

$this->crud->with('curationActivity');
Expand Down
8 changes: 3 additions & 5 deletions app/Http/Controllers/Admin/CustomSurveyCrudController.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,21 +95,19 @@ protected function setupCreateOperation()
* - CRUD::field('price')->type('number');
* - CRUD::addField(['name' => 'price', 'type' => 'number']));
*/
CRUD::modifyField('curation_group_id', [
$this->crud->modifyField('curation_group_id', [
'type' => 'select2',
'label' => 'Curation Group',
'name' => 'curation_group_id',
'model' => CurationGroup::class,
'attribute' => 'name',
'entity' => 'curationGroup'
]);
CRUD::modifyField('volunteer_type_id', [
$this->crud->modifyField('volunteer_type_id', [
'type' => 'select2',
'name' => 'volunteer_type_id',
'model' => VolunteerType::class,
'entity' => 'volunteerType',
'attribute' => 'name',
'relation_type' => 'belongsTo'
'lable' => 'Volunteer Type'
]);
}

Expand Down
4 changes: 0 additions & 4 deletions app/Http/Controllers/Admin/FaqCrudController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use App\Faq;
use App\Http\Requests\FaqRequest as StoreRequest;
// VALIDATION: change the requests to match your own file names if you need form validation
use App\Http\Requests\FaqRequest as UpdateRequest;
use Backpack\CRUD\app\Http\Controllers\CrudController;
use Backpack\CRUD\app\Http\Controllers\Operations\ReorderOperation;
Expand Down Expand Up @@ -63,9 +62,6 @@ public function setup()

$this->crud->modifyField('answer', [
'type' => 'ckeditor',
'options' => [
'removePlugins' => 'image,maximize,oembed',
],
]);

$this->crud->removeColumn('screenshots');
Expand Down
6 changes: 2 additions & 4 deletions app/Http/Controllers/Admin/UserCrudController.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ function ($value) {
'label' => 'Roles',
'type' => 'select2_multiple',
'name' => 'roles',
'entity' => 'roles',
'attribute' => 'name',
'model' => Role::class,
'pivot' => true,
Expand All @@ -102,7 +101,6 @@ function ($value) {
'label' => 'Additonal Permissions',
'type' => 'select2_multiple',
'name' => 'permissions',
'entity' => 'Permissions',
'attribute' => 'name',
'model' => Permission::class,
'pivot' => true,
Expand Down Expand Up @@ -176,11 +174,11 @@ function ($value) {

protected function setupCreateOperation()
{
$this->crud->setValidation(StoreRequest::class);
// $this->crud->setValidation(StoreRequest::class);
}

protected function setupUpdateOperation()
{
$this->crud->setValidation(UpdateRequest::class);
// $this->crud->setValidation(UpdateRequest::class);
}
}
Loading