Skip to content

Commit

Permalink
WIP: upgraded to work with Laravel 10x
Browse files Browse the repository at this point in the history
  • Loading branch information
roncodes committed Jan 30, 2024
1 parent b1a6b5f commit aa15268
Show file tree
Hide file tree
Showing 20 changed files with 338 additions and 187 deletions.
30 changes: 15 additions & 15 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,36 +19,36 @@
],
"require": {
"php": "^7.4|^8.0",
"fleetbase/laravel-mysql-spatial": "^1.0.1",
"illuminate/broadcasting": "^9.0|^10.0",
"illuminate/contracts": "^9.0|^10.0",
"illuminate/database": "^9.0|^10.0",
"illuminate/http": "^9.0|^10.0",
"illuminate/notifications": "^9.0|^10.0",
"illuminate/routing": "^9.0|^10.0",
"illuminate/support": "^9.0|^10.0",
"aloha/twilio": "^5.0",
"aws/aws-sdk-php-laravel": "^3.7",
"giggsey/libphonenumber-for-php": "^8.13",
"grimzy/laravel-mysql-spatial": "^5.0",
"guzzlehttp/guzzle": "^7.4",
"hammerstone/fast-paginate": "^1.0",
"illuminate/broadcasting": "^7.0|^8.0|^9.0",
"illuminate/contracts": "^7.0|^8.0|^9.0",
"illuminate/database": "^7.0|^8.0|^9.0",
"illuminate/http": "^7.0|^8.0|^9.0",
"illuminate/notifications": "^7.0|^8.0|^9.0",
"illuminate/routing": "^7.0|^8.0|^9.0",
"illuminate/support": "^7.0|^8.0|^9.0",
"jdorn/sql-formatter": "^1.2",
"laravel/sanctum": "^2.15",
"laravel/sanctum": "^3.2",
"maatwebsite/excel": "^3.1",
"phpoffice/phpspreadsheet": "^1.28",
"phrity/websocket": "^1.7",
"pragmarx/countries": "^0.8.2",
"sentry/sentry-laravel": "*",
"spatie/laravel-activitylog": "^3.17",
"spatie/laravel-permission": "^5.5",
"spatie/laravel-responsecache": "^6.6",
"spatie/laravel-sluggable": "^2.6",
"vinkla/hashids": "^9.1",
"spatie/laravel-activitylog": "^4.7",
"spatie/laravel-permission": "^6.3",
"spatie/laravel-responsecache": "^7.4",
"spatie/laravel-sluggable": "^3.5",
"sqids/sqids": "^0.4.1",
"xantios/mimey": "^2.2.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.34.1",
"nunomaduro/collision": "^5.11.0|^6.4.0",
"nunomaduro/collision": "^7.0",
"pestphp/pest": "^1.22.6",
"phpstan/phpstan": "^1.10.38",
"symfony/var-dumper": "^5.4.29"
Expand Down
4 changes: 2 additions & 2 deletions migrations/2023_09_04_091906_create_failed_jobs_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateFailedJobsTable extends Migration
return new class extends Migration
{
/**
* Run the migrations.
Expand Down Expand Up @@ -33,4 +33,4 @@ public function down()
{
Schema::dropIfExists('failed_jobs');
}
}
};
4 changes: 2 additions & 2 deletions migrations/2023_10_18_080950_create_notifications_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateNotificationsTable extends Migration
return new class extends Migration
{
/**
* Run the migrations.
Expand Down Expand Up @@ -32,4 +32,4 @@ public function down()
{
Schema::dropIfExists('notifications');
}
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('personal_access_tokens', function (Blueprint $table) {
$table->timestamp('expires_at')->nullable()->after('last_used_at');
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('personal_access_tokens', function (Blueprint $table) {
$table->dropColumn('expires_at');
});
}
};
32 changes: 0 additions & 32 deletions src/Mail/TestEmail.php

This file was deleted.

39 changes: 39 additions & 0 deletions src/Mail/TestMail.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

namespace Fleetbase\Mail;

use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Queue\SerializesModels;

class TestMail extends Mailable
{
use Queueable;
use SerializesModels;

/**
* Get the message content definition.
*
* @return \Illuminate\Mail\Mailables\Envelope
*/
public function envelope(): Envelope
{
return new Envelope(
subject: '🎉 Your Fleetbase Mail Configuration Works!',
);
}

/**
* Get the message content definition.
*
* @return \Illuminate\Mail\Mailables\Content
*/
public function content(): Content
{
return new Content(
text: 'Hello! This is a test email from Fleetbase to confirm that your mail configuration works.',
);
}
}
73 changes: 73 additions & 0 deletions src/Mail/VerificationMail.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?php

namespace Fleetbase\Mail;

use Fleetbase\Models\VerificationCode;
use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Queue\SerializesModels;
// use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Bus\Queueable;

class VerificationMail extends Mailable
{
use Queueable;
use SerializesModels;

/**
* The verification code to email.
*
* @var \Fleetbase\Models\VerificationCode
*/
private VerificationCode $verificationCode;

/**
* Custom content to render if supplied.
*
* @var string|null
*/
private ?string $content;

/**
* Create a new message instance.
*
* @return void
*/
public function __construct(VerificationCode $verificationCode, ?string $content = null)
{
$this->verificationCode = $verificationCode;
$this->content = $content;
}

/**
* Get the message content definition.
*
* @return \Illuminate\Mail\Mailables\Envelope
*/
public function envelope(): Envelope
{
return new Envelope(
subject: $this->verificationCode->code . ' is your ' . config('app.name') . ' verification code',
);
}

/**
* Get the message content definition.
*
* @return \Illuminate\Mail\Mailables\Content
*/
public function content(): Content
{
return new Content(
html: 'fleetbase::mail.verification',
with: [
'appName' => config('app.name'),
'currentHour' => now()->hour,
'user' => $this->verificationCode->subject,
'code' => $this->verificationCode->code,
'content' => $this->content
]
);
}
}
90 changes: 0 additions & 90 deletions src/Mail/VerifyEmail.php

This file was deleted.

20 changes: 17 additions & 3 deletions src/Models/ApiCredential.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Hash;
use Spatie\Activitylog\Traits\LogsActivity;
use Spatie\Activitylog\LogOptions;
use Spatie\Permission\Traits\HasPermissions;
use Vinkla\Hashids\Facades\Hashids;

class ApiCredential extends Model
{
use HasUuid;
Expand Down Expand Up @@ -100,6 +99,20 @@ class ApiCredential extends Model
*/
public static array $skipTables = ['vehicles_data', 'permissions', 'roles', 'role_has_permissions', 'model_has_permissions', 'model_has_roles', 'model_has_policies'];

/**
* Get the activity log options for the model.
*
* @return \Spatie\Activitylog\LogOptions
*/
public function getActivitylogOptions(): LogOptions
{
return LogOptions::defaults()
->logOnly([
'name'
])
->logOnlyDirty();
}

/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
Expand Down Expand Up @@ -174,7 +187,8 @@ public function setExpiresAtAttribute($expiresAt)
*/
public static function generateKeys($encode, $testKey = false)
{
$key = Hashids::encode($encode);
$sqids = new \Sqids\Sqids();
$key = $sqids->encode([$encode]);
$hash = Hash::make($key);

return [
Expand Down
Loading

0 comments on commit aa15268

Please sign in to comment.