Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
austinkregel committed Jun 4, 2024
1 parent f21f90f commit 39bbf53
Show file tree
Hide file tree
Showing 31 changed files with 470 additions and 61 deletions.
5 changes: 3 additions & 2 deletions app/Console/Commands/BulkScoutImport.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<?php

declare(strict_types=1);

namespace App\Console\Commands;

use App\Services\Code;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Artisan;
use Laravel\Scout\Searchable;
use Spatie\Activitylog\Traits\LogsActivity;

class BulkScoutImport extends Command
{
Expand All @@ -19,7 +20,7 @@ public function handle()
$searchableModels = Code::instancesOf(Searchable::class)
->getClasses();

foreach($searchableModels as $model) {
foreach ($searchableModels as $model) {
Artisan::call('scout:import', [
'model' => $model,
]);
Expand Down
6 changes: 5 additions & 1 deletion app/Console/Commands/Initialize.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace App\Console\Commands;

use App\Models\Credential;
Expand All @@ -13,10 +15,12 @@ class Initialize extends Command
protected $signature = 'app:initialize';

protected $description = 'Initialize the application';

public function handle()
{
if (Credential::where('type', Credential::TYPE_SSH)->exists()) {
$this->info('SSH key already exists');

return;
}

Expand Down Expand Up @@ -47,7 +51,7 @@ public function handle()
'pub_key_file' => $publicKeyFile,
'private_key' => $privateKey,
'private_key_file' => $privateKeyFile,
'pass_key' => !empty($passKey) ? encrypt($passKey) : '',
'pass_key' => ! empty($passKey) ? encrypt($passKey) : '',
],
]);
}
Expand Down
3 changes: 2 additions & 1 deletion app/Http/Controllers/Spork/BankingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ public function __invoke()
{
$accounts = request()->user()
->accounts()
->with('credential')->get();
->with('credential')
->get();

return Inertia::render('Banking/Index', [
'title' => 'Banking ',
Expand Down
12 changes: 7 additions & 5 deletions app/Http/Controllers/Spork/BatchJobController.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace App\Http\Controllers\Spork;

use App\Http\Controllers\Controller;
Expand All @@ -24,12 +26,12 @@ public function index()
->whereIn('uuid', json_decode($batch->failed_job_ids, true))
->orderByDesc('failed_at')
->get()
->map(function ($job) {
$job->parsed_exception = (new Stacktrace)->parse($job->exception);
$job->payload = json_decode($job->payload, true);
->map(function ($job) {
$job->parsed_exception = (new Stacktrace)->parse($job->exception);
$job->payload = json_decode($job->payload, true);

return $job;
});
return $job;
});
$batch->failed_at = $batch->jobs->max('failed_at');

return $batch;
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Spork/DashboardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

use App\Http\Controllers\Controller;
use App\Models\JobBatch;
use App\Models\Person;
use App\Models\User;
use Illuminate\Support\Arr;
use Illuminate\Support\Collection;
Expand All @@ -27,6 +26,7 @@ public function __invoke()
->selectRaw('max(failed_at)')
->whereIn('id', $batchJob->failed_job_ids)
->value('failed_at');

return $batchJob;
}, $batchJobs->items()))
);
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Spork/DevelopmentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class DevelopmentController
public function index()
{
return Inertia::render('Development/Index', [
// 'instances' => LaravelProgrammingStyle::instancesOf(CustomAction::class),
// 'instances' => LaravelProgrammingStyle::instancesOf(CustomAction::class),
]);
}
}
2 changes: 1 addition & 1 deletion app/Http/Controllers/Spork/LogicController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class LogicController
public function __invoke()
{
return Inertia::render('Logic/Index', [
'container_bindings' => \App\Services\Programming\LaravelProgrammingStyle::findContainerBindings(),
// 'container_bindings' => \App\Services\Programming\LaravelProgrammingStyle::findContainerBindings(),
'events' => \App\Services\Programming\LaravelProgrammingStyle::findLogicalEvents(),
'listeners' => \App\Services\Programming\LaravelProgrammingStyle::findLogicalListeners(),
]);
Expand Down
2 changes: 1 addition & 1 deletion app/Models/Article.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
class Article extends Model implements Crud
{
use HasFactory;
use Searchable;
use LogsActivity;
use ScopeQSearch;
use ScopeRelativeSearch;
use Searchable;

public $fillable = [
'uuid',
Expand Down
2 changes: 1 addition & 1 deletion app/Models/Credential.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public function getPrivateKey(): string

public function getPasskey(): string
{
return empty($this->settings['pass_key'] ?? '') ? '': decrypt($this->settings['pass_key'] ?? '');
return empty($this->settings['pass_key'] ?? '') ? '' : decrypt($this->settings['pass_key'] ?? '');
}

public function getActivitylogOptions(): LogOptions
Expand Down
3 changes: 2 additions & 1 deletion app/Models/Domain.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ class Domain extends Model implements Crud, ModelQuery, Taggable
use HasFactory;
use HasProjectResource;
use HasTags;
use Searchable;
use LogsActivity;
use ScopeQSearch;
use ScopeRelativeSearch;
use Searchable;

public $fillable = ['name', 'verification_key', 'cloudflare_id', 'domain_id', 'registered_at'];

Expand All @@ -43,6 +43,7 @@ class Domain extends Model implements Crud, ModelQuery, Taggable
'updating' => DomainUpdating::class,
'updated' => DomainUpdated::class,
];

// add a global scope to prevent the querying of expired domains
protected static function booted()
{
Expand Down
2 changes: 1 addition & 1 deletion app/Models/DomainRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ class DomainRecord extends Model implements Crud, ModelQuery
{
use HasFactory;
use LogsActivity;
use Searchable;
use ScopeQSearch;
use ScopeRelativeSearch;
use Searchable;

protected $fillable = [
'name',
Expand Down
3 changes: 1 addition & 2 deletions app/Models/Finance/Account.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
class Account extends Model implements Crud
{
use HasFactory;
use Searchable;
use LogsActivity;
use ScopeQSearch;
use ScopeRelativeSearch;
use Searchable;

protected $fillable = [
'account_id',
Expand Down Expand Up @@ -61,7 +61,6 @@ public function transactions(): HasMany
return $this->hasMany(Transaction::class);
}


public function getActivitylogOptions(): LogOptions
{
return LogOptions::defaults()
Expand Down
2 changes: 1 addition & 1 deletion app/Models/Finance/Transaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
class Transaction extends Model implements Crud, ModelQuery, Taggable
{
use HasFactory;
use Searchable;
use HasTags;
use ScopeQSearch;
use ScopeRelativeSearch;
use Searchable;

public $fillable = [
'name',
Expand Down
2 changes: 1 addition & 1 deletion app/Models/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
/** @mixin \Eloquent */
class Message extends Model implements Taggable
{
use Searchable;
use HasFactory, HasJsonRelationships, HasTags;
use Searchable;

public $fillable = [
'from_person',
Expand Down
2 changes: 1 addition & 1 deletion app/Models/Person.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
class Person extends Model implements Crud, ModelQuery
{
use HasFactory;
use Searchable;
use ScopeRelativeSearch;
use Searchable;

public $guarded = [];

Expand Down
2 changes: 0 additions & 2 deletions app/Models/Project.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,12 @@
use App\Events\Models\Project\ProjectUpdating;
use App\Models\Traits\ScopeQSearch;
use App\Models\Traits\ScopeRelativeSearch;
use App\Services\SshKeyGeneratorService;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\MorphMany;
use Illuminate\Database\Eloquent\Relations\MorphToMany;
use Illuminate\Support\Str;
use Spatie\Activitylog\LogOptions;
use Spatie\Activitylog\Traits\LogsActivity;
use Spatie\Tags\HasTags;
Expand Down
2 changes: 1 addition & 1 deletion app/Models/Research.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ class Research extends Model implements Crud
{
use HasFactory;
use LogsActivity;
use Searchable;
use ScopeQSearch;
use ScopeRelativeSearch;
use Searchable;

public $fillable = ['topic', 'notes', 'sources'];

Expand Down
5 changes: 3 additions & 2 deletions app/Models/ShortCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

//use Laravel\Scout\Searchable;

class ShortCode extends Model implements Crud
{
// use Searchable;
// use Searchable;
use HasFactory;
use ScopeRelativeSearch;
use ScopeQSearch;
use ScopeRelativeSearch;

public $fillable = [
'short_code',
Expand Down
2 changes: 1 addition & 1 deletion app/Models/Thread.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@

class Thread extends Model implements Crud
{
use Searchable;
use HasFactory;
use ScopeQSearch;
use ScopeRelativeSearch;
use Searchable;

public $casts = ['settings' => 'json', 'origin_server_ts' => 'datetime'];

Expand Down
3 changes: 1 addition & 2 deletions app/Models/Traits/ScopeRelativeSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ public function scopeRelative(Builder $query, string $string): void
$query->where('user_id', auth()->id());
});
} elseif (method_exists($this, 'credential')) {

$query->whereHas('credential', function (Builder $query) {
$query->where('user_id', auth()->id());
});
Expand All @@ -48,7 +47,7 @@ public function scopeRelative(Builder $query, string $string): void
$query->whereHas('projects.team', function (Builder $query) {
$query->where('user_id', auth()->id());
});
}else {
} else {
abort(400, 'No user relation found for model');
}
}
Expand Down
4 changes: 3 additions & 1 deletion app/Providers/TelescopeServiceProvider.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace App\Providers;

use Illuminate\Support\Facades\Gate;
Expand All @@ -14,7 +16,7 @@ class TelescopeServiceProvider extends TelescopeApplicationServiceProvider
*/
public function register(): void
{
Telescope::night();
Telescope::night();

$this->hideSensitiveRequestDetails();

Expand Down
1 change: 1 addition & 0 deletions app/Services/News/Feeds/AtomFeed.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public function getData(): array
$feedItem->url = $post['link']['@attributes']['href'];
} else {
info('no link', ['context' => $post]);

return $feedItem;
}

Expand Down
4 changes: 1 addition & 3 deletions app/Services/SshKeyGeneratorService.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@

namespace App\Services;

use Exception;
use phpseclib3\Crypt\EC;
use phpseclib3\Crypt\RSA;

class SshKeyGeneratorService
{
Expand All @@ -18,7 +16,7 @@ public static function generate(
) {

$key = EC::createKey('ed25519');
if (!empty($passKey)) {
if (! empty($passKey)) {
$key->withPassword($passKey);
}

Expand Down
4 changes: 2 additions & 2 deletions app/Services/SshService.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,15 @@ public function run(Script $script, string $directory = ''): array
unlink($localFilePath);
try {
// Run a command that will probably write to stderr (unless you have a folder named /hom)
$stream_out = ssh2_exec($this->connection, 'bash ' . escapeshellcmd($file). ' 2>&1');
$stream_out = ssh2_exec($this->connection, 'bash '.escapeshellcmd($file).' 2>&1');
stream_set_blocking($stream_out, true);

$stream_error = ssh2_fetch_stream($stream_out, SSH2_STREAM_STDERR);
ssh2_exec($this->connection, "rm $file -f");
} catch (\Throwable $e) {
return [
'stdout' => '',
'stderr' => $e->getMessage() . "\n" . $e->getTraceAsString(),
'stderr' => $e->getMessage()."\n".$e->getTraceAsString(),
];
}

Expand Down
3 changes: 2 additions & 1 deletion bootstrap/providers.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@

return [
App\Providers\AppServiceProvider::class,
App\Providers\HorizonServiceProvider::class,
App\Providers\FortifyServiceProvider::class,
App\Providers\HorizonServiceProvider::class,
App\Providers\JetstreamServiceProvider::class,
App\Providers\OperationServiceProvider::class,
App\Providers\TelescopeServiceProvider::class,
];
Loading

0 comments on commit 39bbf53

Please sign in to comment.