diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 605bda0..57d7d79 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,46 +1,46 @@ -name: deploy - -on: - push: - tags: - - 'v*' - -concurrency: production_environment - -jobs: - production: - runs-on: ubuntu-latest - environment: Production - - steps: - - uses: actions/checkout@v3 - - # - name: Get composer cache directory - # id: composer-cache - # run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT - - # - name: Cache dependencies - # uses: actions/cache@v3 - # with: - # path: ${{ steps.composer-cache.outputs.dir }} - # key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} - # restore-keys: ${{ runner.os }}-composer- - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - env: - GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} - with: - tools: composer - extensions: bcmath, ctype, fileinfo, json, odbc, mbstring, openssl, pdo, pdo_mysql, pdo_odbc tokenizer, xml, soap, redis, igbinary - php-version: "8.2" - - - name: Install dependencies - run: composer install --no-interaction --no-scripts --prefer-dist - - - - name: Deploy - uses: deployphp/action@v1 - with: - private-key: ${{ secrets.DEPLOY_KEY }} - dep: deploy production +name: deploy + +on: + push: + tags: + - 'v*' + +concurrency: production_environment + +jobs: + production: + runs-on: ubuntu-latest + environment: Production + + steps: + - uses: actions/checkout@v3 + + # - name: Get composer cache directory + # id: composer-cache + # run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT + + # - name: Cache dependencies + # uses: actions/cache@v3 + # with: + # path: ${{ steps.composer-cache.outputs.dir }} + # key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + # restore-keys: ${{ runner.os }}-composer- + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + env: + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} + with: + tools: composer + extensions: bcmath, ctype, fileinfo, json, odbc, mbstring, openssl, pdo, pdo_mysql, pdo_odbc tokenizer, xml, soap, redis, igbinary + php-version: "8.2" + + - name: Install dependencies + run: composer install --no-interaction --no-scripts --prefer-dist + + + - name: Deploy + uses: deployphp/action@v1 + with: + private-key: ${{ secrets.DEPLOY_KEY }} + dep: deploy production diff --git a/app/Http/Controllers/Api/UserController.php b/app/Http/Controllers/Api/UserController.php index 6eb4768..73ac070 100644 --- a/app/Http/Controllers/Api/UserController.php +++ b/app/Http/Controllers/Api/UserController.php @@ -3,36 +3,33 @@ namespace App\Http\Controllers\Api; use App\Http\Controllers\Controller; -use App\Models\User; -use Illuminate\Support\Str; -use Illuminate\Http\Request; use App\Http\Requests\StoreUserRequest; -use Illuminate\Support\Facades\Validator; +use App\Models\User; +use Illuminate\Http\Request; +use Illuminate\Support\Str; +use Throwable; class UserController extends Controller { public function registerUser(StoreUserRequest $request) { + $data = $request->validated(); + $data['password'] = Str::random(8); - $validated = $request->validated(); - $validated['is_admin'] = false; - $validated['password'] = Str::random(8); - $validated['status'] = true; try { - $user = User::create($validated); - }catch (Throwable $exception){ + $user = User::create($data); + } catch (Throwable $exception) { return response() - ->json($exception); + ->json($exception); } - return response() - ->json(['message' => 'Successfully created user ' . $user->firstname]); + ->json(['message' => 'Successfully created user ' . $user->firstname]); } public function getUser(Request $request, User $user) { return response() - ->json(["status" => true]); + ->json(['status' => true]); } } diff --git a/app/Http/Controllers/Api/WebHookController.php b/app/Http/Controllers/Api/WebHookController.php index 1f81d9b..05cf9cd 100644 --- a/app/Http/Controllers/Api/WebHookController.php +++ b/app/Http/Controllers/Api/WebHookController.php @@ -7,11 +7,11 @@ use App\Models\Quote; use Illuminate\Http\Request; use Illuminate\Support\Facades\Http; - class WebHookController extends Controller { public function webHookSend(string $payload) { + // TODO: move this to a helper class so we can reuse code between API and FE $data = ['text' => $payload]; $response = Http::post(config('bot.webhook'), $data); } @@ -19,17 +19,28 @@ class WebHookController extends Controller public function sendQuote(Request $request) { $quote = $request->input('quote'); + if (empty($quote)) { return; } + activity() + ->event('send') + ->log("Manually sent quote: $quote"); + $this->webHookSend($quote); } public function sendRandomQuote() { - $quote = Quote::inRandomOrder()->first()->quote; - $this->webHookSend($quote); + $quote = Quote::inRandomOrder()->first(); + + activity() + ->performedOn($quote) + ->event('send') + ->log("Requested quote: $quote->quote"); + + $this->webHookSend($quote->quote); } public function test() diff --git a/app/Models/Quote.php b/app/Models/Quote.php index ce9fc18..0c0bf07 100644 --- a/app/Models/Quote.php +++ b/app/Models/Quote.php @@ -4,21 +4,50 @@ namespace App\Models; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\SoftDeletes; +use Spatie\Activitylog\LogOptions; +use Spatie\Activitylog\Models\Activity; +use Spatie\Activitylog\Traits\LogsActivity; /** * @mixin IdeHelperQuote */ class Quote extends Model { - use SoftDeletes; + use LogsActivity, SoftDeletes; + + protected $fillable = [ + 'user_id', + 'quote', + ]; public function request(): void { - // Send the notification + // Send the quote // If success, add it to the transactions + + activity() + ->performedOn($this) + ->event('send') + ->log("Requested quote: $this->quote"); } - protected $fillable = [ - 'quote', - ]; + public function tapActivity(Activity $activity, string $eventName) + { + switch ($eventName) { + case 'created': + $activity->description = "Quote created: {$this->quote}"; + return; + case 'deleted': + $activity->description = "Quote deleted: {$this->quote}"; + return; + default; + return; + } + } + + public function getActivityLogOptions(): LogOptions + { + return LogOptions::defaults() + ->logOnly(['quote']); + } } diff --git a/app/Models/RequestedQuote.php b/app/Models/RequestedQuote.php index e1da899..53e29dc 100644 --- a/app/Models/RequestedQuote.php +++ b/app/Models/RequestedQuote.php @@ -4,33 +4,57 @@ namespace App\Models; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\SoftDeletes; +use Spatie\Activitylog\Facades\LogBatch; +use Spatie\Activitylog\LogOptions; +use Spatie\Activitylog\Models\Activity; +use Spatie\Activitylog\Traits\LogsActivity; /** * @mixin IdeHelperRequestedQuote */ class RequestedQuote extends Model { - use SoftDeletes; + use LogsActivity, SoftDeletes; protected $fillable = [ 'quote', - 'user_id', ]; public function approve(): void { - // TODO: we'll probs want to log who approved this quote + LogBatch::startBatch(); + Quote::create([ 'quote' => $this->quote, ]); $this->delete(); + + LogBatch::endBatch(); } public function reject(): void { - // TODO: we'll probs want to log who reject this quote - $this->delete(); } + + public function tapActivity(Activity $activity, string $eventName) + { + switch ($eventName) { + case 'created': + $activity->description = "Quote created: {$this->quote}"; + return; + case 'deleted': + $activity->description = "Quote deleted: {$this->quote}"; + return; + default; + return; + } + } + + public function getActivityLogOptions(): LogOptions + { + return LogOptions::defaults() + ->logOnly(['quote']); + } } diff --git a/app/Models/User.php b/app/Models/User.php index c3f3b03..cdc39e7 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -5,14 +5,26 @@ namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Notifications\Notifiable; -use Laravel\Sanctum\HasApiTokens; +use Spatie\Activitylog\LogOptions; +use Spatie\Activitylog\Models\Activity; +use Spatie\Activitylog\Traits\LogsActivity; /** * @mixin IdeHelperUser */ class User extends Authenticatable { - use HasApiTokens, HasFactory, Notifiable; + use LogsActivity, HasFactory, Notifiable; + + /** + * The model's default values for attributes. + * + * @var array + */ + protected $attributes = [ + 'is_admin' => false, + 'status' => true, + ]; /** * The attributes that are mass assignable. @@ -46,6 +58,33 @@ class User extends Authenticatable * @var array */ protected $casts = [ + 'is_admin' => 'boolean', + 'status' => 'boolean', 'password' => 'hashed', ]; + + public function getFullNameAttribute(): string + { + return "$this->firstname $this->lastname"; + } + + public function tapActivity(Activity $activity, string $eventName) + { + switch ($eventName) { + case 'created': + $activity->description = "User created: {$this->full_name}"; + return; + case 'deleted': + $activity->description = "User deleted: {$this->full_name}"; + return; + default; + return; + } + } + + public function getActivityLogOptions(): LogOptions + { + return LogOptions::defaults() + ->logExcept(['password']); + } } diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index a8daa55..fc7759b 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -3,6 +3,7 @@ namespace App\Providers; use Illuminate\Support\ServiceProvider; +use Spatie\Activitylog\Models\Activity; class AppServiceProvider extends ServiceProvider { @@ -15,6 +16,7 @@ class AppServiceProvider extends ServiceProvider $this->app->register(\Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class); } + // This is so we can access alpine without livewire on the page. \Livewire\Livewire::forceAssetInjection(); } @@ -23,6 +25,8 @@ class AppServiceProvider extends ServiceProvider */ public function boot(): void { - // + Activity::saving(function (Activity $activity) { + $activity->properties = $activity->properties->put('ip', request()->ip()); + }); } } diff --git a/composer.json b/composer.json index 086f945..71fec1b 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,8 @@ "laravel/sanctum": "^3.2", "laravel/tinker": "^2.8", "livewire/livewire": "^3.0", - "livewire/volt": "^1.0" + "livewire/volt": "^1.0", + "spatie/laravel-activitylog": "^4.7" }, "require-dev": { "barryvdh/laravel-ide-helper": "^2.13", diff --git a/composer.lock b/composer.lock index d4ec390..437fd0f 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "6f613b80fde0f91b5425be61accfc51f", + "content-hash": "e30e72a75870b7f76938f6dd2adff20c", "packages": [ { "name": "brick/math", @@ -434,21 +434,21 @@ }, { "name": "fruitcake/php-cors", - "version": "v1.2.0", + "version": "v1.3.0", "source": { "type": "git", "url": "https://github.com/fruitcake/php-cors.git", - "reference": "58571acbaa5f9f462c9c77e911700ac66f446d4e" + "reference": "3d158f36e7875e2f040f37bc0573956240a5a38b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/fruitcake/php-cors/zipball/58571acbaa5f9f462c9c77e911700ac66f446d4e", - "reference": "58571acbaa5f9f462c9c77e911700ac66f446d4e", + "url": "https://api.github.com/repos/fruitcake/php-cors/zipball/3d158f36e7875e2f040f37bc0573956240a5a38b", + "reference": "3d158f36e7875e2f040f37bc0573956240a5a38b", "shasum": "" }, "require": { "php": "^7.4|^8.0", - "symfony/http-foundation": "^4.4|^5.4|^6" + "symfony/http-foundation": "^4.4|^5.4|^6|^7" }, "require-dev": { "phpstan/phpstan": "^1.4", @@ -458,7 +458,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.1-dev" + "dev-master": "1.2-dev" } }, "autoload": { @@ -489,7 +489,7 @@ ], "support": { "issues": "https://github.com/fruitcake/php-cors/issues", - "source": "https://github.com/fruitcake/php-cors/tree/v1.2.0" + "source": "https://github.com/fruitcake/php-cors/tree/v1.3.0" }, "funding": [ { @@ -501,7 +501,7 @@ "type": "github" } ], - "time": "2022-02-20T15:07:15+00:00" + "time": "2023-10-12T05:21:21+00:00" }, { "name": "graham-campbell/result-type", @@ -972,16 +972,16 @@ }, { "name": "laravel/framework", - "version": "v10.26.2", + "version": "v10.28.0", "source": { "type": "git", "url": "https://github.com/laravel/framework.git", - "reference": "6e5440f7c518f26b4495e5d7e4796ec239e26df9" + "reference": "09137f50f715c1efc649788a26092dcb1ec4ab6e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/framework/zipball/6e5440f7c518f26b4495e5d7e4796ec239e26df9", - "reference": "6e5440f7c518f26b4495e5d7e4796ec239e26df9", + "url": "https://api.github.com/repos/laravel/framework/zipball/09137f50f715c1efc649788a26092dcb1ec4ab6e", + "reference": "09137f50f715c1efc649788a26092dcb1ec4ab6e", "shasum": "" }, "require": { @@ -1168,7 +1168,7 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2023-10-03T14:24:20+00:00" + "time": "2023-10-10T13:01:37+00:00" }, { "name": "laravel/prompts", @@ -1818,16 +1818,16 @@ }, { "name": "livewire/livewire", - "version": "v3.0.5", + "version": "v3.0.8", "source": { "type": "git", "url": "https://github.com/livewire/livewire.git", - "reference": "37f11583c61a75d51b2146c2fe38f506ad36014b" + "reference": "6f62019a0e821894f701ca463210c01d7369c929" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/livewire/livewire/zipball/37f11583c61a75d51b2146c2fe38f506ad36014b", - "reference": "37f11583c61a75d51b2146c2fe38f506ad36014b", + "url": "https://api.github.com/repos/livewire/livewire/zipball/6f62019a0e821894f701ca463210c01d7369c929", + "reference": "6f62019a0e821894f701ca463210c01d7369c929", "shasum": "" }, "require": { @@ -1836,15 +1836,15 @@ "illuminate/validation": "^10.0", "league/mime-type-detection": "^1.9", "php": "^8.1", - "symfony/http-kernel": "^5.0|^6.0" + "symfony/http-kernel": "^6.2" }, "require-dev": { "calebporzio/sushi": "^2.1", "laravel/framework": "^10.0", "laravel/prompts": "^0.1.6", "mockery/mockery": "^1.3.1", - "orchestra/testbench": "^7.0|^8.0", - "orchestra/testbench-dusk": "^7.0|^8.0", + "orchestra/testbench": "^8.0", + "orchestra/testbench-dusk": "^8.0", "phpunit/phpunit": "^9.0", "psy/psysh": "@stable" }, @@ -1880,7 +1880,7 @@ "description": "A front-end framework for Laravel.", "support": { "issues": "https://github.com/livewire/livewire/issues", - "source": "https://github.com/livewire/livewire/tree/v3.0.5" + "source": "https://github.com/livewire/livewire/tree/v3.0.8" }, "funding": [ { @@ -1888,7 +1888,7 @@ "type": "github" } ], - "time": "2023-09-16T11:51:32+00:00" + "time": "2023-10-10T20:44:46+00:00" }, { "name": "livewire/volt", @@ -2948,16 +2948,16 @@ }, { "name": "psy/psysh", - "version": "v0.11.21", + "version": "v0.11.22", "source": { "type": "git", "url": "https://github.com/bobthecow/psysh.git", - "reference": "bcb22101107f3bf770523b65630c9d547f60c540" + "reference": "128fa1b608be651999ed9789c95e6e2a31b5802b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/bobthecow/psysh/zipball/bcb22101107f3bf770523b65630c9d547f60c540", - "reference": "bcb22101107f3bf770523b65630c9d547f60c540", + "url": "https://api.github.com/repos/bobthecow/psysh/zipball/128fa1b608be651999ed9789c95e6e2a31b5802b", + "reference": "128fa1b608be651999ed9789c95e6e2a31b5802b", "shasum": "" }, "require": { @@ -2986,7 +2986,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "0.11.x-dev" + "dev-0.11": "0.11.x-dev" }, "bamarni-bin": { "bin-links": false, @@ -3022,9 +3022,9 @@ ], "support": { "issues": "https://github.com/bobthecow/psysh/issues", - "source": "https://github.com/bobthecow/psysh/tree/v0.11.21" + "source": "https://github.com/bobthecow/psysh/tree/v0.11.22" }, - "time": "2023-09-17T21:15:54+00:00" + "time": "2023-10-14T21:56:36+00:00" }, { "name": "ralouphie/getallheaders", @@ -3251,6 +3251,157 @@ ], "time": "2023-04-15T23:01:58+00:00" }, + { + "name": "spatie/laravel-activitylog", + "version": "4.7.3", + "source": { + "type": "git", + "url": "https://github.com/spatie/laravel-activitylog.git", + "reference": "ec65a478a909b8df1b4f0c3c45de2592ca7639e5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/spatie/laravel-activitylog/zipball/ec65a478a909b8df1b4f0c3c45de2592ca7639e5", + "reference": "ec65a478a909b8df1b4f0c3c45de2592ca7639e5", + "shasum": "" + }, + "require": { + "illuminate/config": "^8.0 || ^9.0 || ^10.0", + "illuminate/database": "^8.69 || ^9.27 || ^10.0", + "illuminate/support": "^8.0 || ^9.0 || ^10.0", + "php": "^8.0", + "spatie/laravel-package-tools": "^1.6.3" + }, + "require-dev": { + "ext-json": "*", + "orchestra/testbench": "^6.23 || ^7.0 || ^8.0", + "pestphp/pest": "^1.20" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "Spatie\\Activitylog\\ActivitylogServiceProvider" + ] + } + }, + "autoload": { + "files": [ + "src/helpers.php" + ], + "psr-4": { + "Spatie\\Activitylog\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Freek Van der Herten", + "email": "freek@spatie.be", + "homepage": "https://spatie.be", + "role": "Developer" + }, + { + "name": "Sebastian De Deyne", + "email": "sebastian@spatie.be", + "homepage": "https://spatie.be", + "role": "Developer" + }, + { + "name": "Tom Witkowski", + "email": "dev.gummibeer@gmail.com", + "homepage": "https://gummibeer.de", + "role": "Developer" + } + ], + "description": "A very simple activity logger to monitor the users of your website or application", + "homepage": "https://github.com/spatie/activitylog", + "keywords": [ + "activity", + "laravel", + "log", + "spatie", + "user" + ], + "support": { + "issues": "https://github.com/spatie/laravel-activitylog/issues", + "source": "https://github.com/spatie/laravel-activitylog/tree/4.7.3" + }, + "funding": [ + { + "url": "https://spatie.be/open-source/support-us", + "type": "custom" + }, + { + "url": "https://github.com/spatie", + "type": "github" + } + ], + "time": "2023-01-25T17:04:51+00:00" + }, + { + "name": "spatie/laravel-package-tools", + "version": "1.16.1", + "source": { + "type": "git", + "url": "https://github.com/spatie/laravel-package-tools.git", + "reference": "cc7c991555a37f9fa6b814aa03af73f88026a83d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/spatie/laravel-package-tools/zipball/cc7c991555a37f9fa6b814aa03af73f88026a83d", + "reference": "cc7c991555a37f9fa6b814aa03af73f88026a83d", + "shasum": "" + }, + "require": { + "illuminate/contracts": "^9.28|^10.0", + "php": "^8.0" + }, + "require-dev": { + "mockery/mockery": "^1.5", + "orchestra/testbench": "^7.7|^8.0", + "pestphp/pest": "^1.22", + "phpunit/phpunit": "^9.5.24", + "spatie/pest-plugin-test-time": "^1.1" + }, + "type": "library", + "autoload": { + "psr-4": { + "Spatie\\LaravelPackageTools\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Freek Van der Herten", + "email": "freek@spatie.be", + "role": "Developer" + } + ], + "description": "Tools for creating Laravel packages", + "homepage": "https://github.com/spatie/laravel-package-tools", + "keywords": [ + "laravel-package-tools", + "spatie" + ], + "support": { + "issues": "https://github.com/spatie/laravel-package-tools/issues", + "source": "https://github.com/spatie/laravel-package-tools/tree/1.16.1" + }, + "funding": [ + { + "url": "https://github.com/spatie", + "type": "github" + } + ], + "time": "2023-08-23T09:04:39+00:00" + }, { "name": "symfony/console", "version": "v6.3.4", @@ -5921,16 +6072,16 @@ }, { "name": "brianium/paratest", - "version": "v7.2.9", + "version": "v7.3.0", "source": { "type": "git", "url": "https://github.com/paratestphp/paratest.git", - "reference": "1f9e41c0779be4540654d92a9314016713f5e62c" + "reference": "2951d3f773ea91451c7440f48122287778634b0d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/paratestphp/paratest/zipball/1f9e41c0779be4540654d92a9314016713f5e62c", - "reference": "1f9e41c0779be4540654d92a9314016713f5e62c", + "url": "https://api.github.com/repos/paratestphp/paratest/zipball/2951d3f773ea91451c7440f48122287778634b0d", + "reference": "2951d3f773ea91451c7440f48122287778634b0d", "shasum": "" }, "require": { @@ -5944,22 +6095,22 @@ "phpunit/php-code-coverage": "^10.1.7", "phpunit/php-file-iterator": "^4.1.0", "phpunit/php-timer": "^6.0", - "phpunit/phpunit": "^10.4.0", + "phpunit/phpunit": "^10.4.1", "sebastian/environment": "^6.0.1", - "symfony/console": "^6.3.4", - "symfony/process": "^6.3.4" + "symfony/console": "^6.3.4 || ^7.0.0", + "symfony/process": "^6.3.4 || ^7.0.0" }, "require-dev": { "doctrine/coding-standard": "^12.0.0", "ext-pcov": "*", "ext-posix": "*", - "infection/infection": "^0.27.3", - "phpstan/phpstan": "^1.10.37", + "infection/infection": "^0.27.4", + "phpstan/phpstan": "^1.10.38", "phpstan/phpstan-deprecation-rules": "^1.1.4", - "phpstan/phpstan-phpunit": "^1.3.14", + "phpstan/phpstan-phpunit": "^1.3.15", "phpstan/phpstan-strict-rules": "^1.5.1", "squizlabs/php_codesniffer": "^3.7.2", - "symfony/filesystem": "^6.3.1" + "symfony/filesystem": "^6.3.1 || ^7.0.0" }, "bin": [ "bin/paratest", @@ -6000,7 +6151,7 @@ ], "support": { "issues": "https://github.com/paratestphp/paratest/issues", - "source": "https://github.com/paratestphp/paratest/tree/v7.2.9" + "source": "https://github.com/paratestphp/paratest/tree/v7.3.0" }, "funding": [ { @@ -6012,7 +6163,7 @@ "type": "paypal" } ], - "time": "2023-10-06T07:53:04+00:00" + "time": "2023-10-10T15:11:25+00:00" }, { "name": "composer/class-map-generator", @@ -6089,16 +6240,16 @@ }, { "name": "composer/pcre", - "version": "3.1.0", + "version": "3.1.1", "source": { "type": "git", "url": "https://github.com/composer/pcre.git", - "reference": "4bff79ddd77851fe3cdd11616ed3f92841ba5bd2" + "reference": "00104306927c7a0919b4ced2aaa6782c1e61a3c9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/pcre/zipball/4bff79ddd77851fe3cdd11616ed3f92841ba5bd2", - "reference": "4bff79ddd77851fe3cdd11616ed3f92841ba5bd2", + "url": "https://api.github.com/repos/composer/pcre/zipball/00104306927c7a0919b4ced2aaa6782c1e61a3c9", + "reference": "00104306927c7a0919b4ced2aaa6782c1e61a3c9", "shasum": "" }, "require": { @@ -6140,7 +6291,7 @@ ], "support": { "issues": "https://github.com/composer/pcre/issues", - "source": "https://github.com/composer/pcre/tree/3.1.0" + "source": "https://github.com/composer/pcre/tree/3.1.1" }, "funding": [ { @@ -6156,7 +6307,7 @@ "type": "tidelift" } ], - "time": "2022-11-17T09:50:14+00:00" + "time": "2023-10-11T07:11:09+00:00" }, { "name": "deployer/deployer", @@ -6296,16 +6447,16 @@ }, { "name": "doctrine/dbal", - "version": "3.7.0", + "version": "3.7.1", "source": { "type": "git", "url": "https://github.com/doctrine/dbal.git", - "reference": "00d03067f07482f025d41ab55e4ba0db5eca2cdf" + "reference": "5b7bd66c9ff58c04c5474ab85edce442f8081cb2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/dbal/zipball/00d03067f07482f025d41ab55e4ba0db5eca2cdf", - "reference": "00d03067f07482f025d41ab55e4ba0db5eca2cdf", + "url": "https://api.github.com/repos/doctrine/dbal/zipball/5b7bd66c9ff58c04c5474ab85edce442f8081cb2", + "reference": "5b7bd66c9ff58c04c5474ab85edce442f8081cb2", "shasum": "" }, "require": { @@ -6389,7 +6540,7 @@ ], "support": { "issues": "https://github.com/doctrine/dbal/issues", - "source": "https://github.com/doctrine/dbal/tree/3.7.0" + "source": "https://github.com/doctrine/dbal/tree/3.7.1" }, "funding": [ { @@ -6405,7 +6556,7 @@ "type": "tidelift" } ], - "time": "2023-09-26T20:56:55+00:00" + "time": "2023-10-06T05:06:20+00:00" }, { "name": "doctrine/deprecations", @@ -6857,16 +7008,16 @@ }, { "name": "laravel/breeze", - "version": "v1.24.1", + "version": "v1.25.0", "source": { "type": "git", "url": "https://github.com/laravel/breeze.git", - "reference": "15c8866a19a5469c34748586162a238efa27fa51" + "reference": "d62371252246d45417d077ca8019b6abd679343c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/breeze/zipball/15c8866a19a5469c34748586162a238efa27fa51", - "reference": "15c8866a19a5469c34748586162a238efa27fa51", + "url": "https://api.github.com/repos/laravel/breeze/zipball/d62371252246d45417d077ca8019b6abd679343c", + "reference": "d62371252246d45417d077ca8019b6abd679343c", "shasum": "" }, "require": { @@ -6915,20 +7066,20 @@ "issues": "https://github.com/laravel/breeze/issues", "source": "https://github.com/laravel/breeze" }, - "time": "2023-10-04T01:03:14+00:00" + "time": "2023-10-06T13:24:19+00:00" }, { "name": "laravel/pint", - "version": "v1.13.2", + "version": "v1.13.3", "source": { "type": "git", "url": "https://github.com/laravel/pint.git", - "reference": "bbb13460d7f8c5c0cd9a58109beedd79cd7331ff" + "reference": "93b2d0d49719bc6e444ba21cd4dbbccec935413d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/pint/zipball/bbb13460d7f8c5c0cd9a58109beedd79cd7331ff", - "reference": "bbb13460d7f8c5c0cd9a58109beedd79cd7331ff", + "url": "https://api.github.com/repos/laravel/pint/zipball/93b2d0d49719bc6e444ba21cd4dbbccec935413d", + "reference": "93b2d0d49719bc6e444ba21cd4dbbccec935413d", "shasum": "" }, "require": { @@ -6939,7 +7090,7 @@ "php": "^8.1.0" }, "require-dev": { - "friendsofphp/php-cs-fixer": "^3.26.1", + "friendsofphp/php-cs-fixer": "^3.34.1", "illuminate/view": "^10.23.1", "laravel-zero/framework": "^10.1.2", "mockery/mockery": "^1.6.6", @@ -6981,7 +7132,7 @@ "issues": "https://github.com/laravel/pint/issues", "source": "https://github.com/laravel/pint" }, - "time": "2023-09-19T15:55:02+00:00" + "time": "2023-10-10T15:39:09+00:00" }, { "name": "laravel/sail", @@ -7194,16 +7345,16 @@ }, { "name": "nunomaduro/collision", - "version": "v7.9.0", + "version": "v7.10.0", "source": { "type": "git", "url": "https://github.com/nunomaduro/collision.git", - "reference": "296d0cf9fe462837ac0da8a568b56fc026b132da" + "reference": "49ec67fa7b002712da8526678abd651c09f375b2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nunomaduro/collision/zipball/296d0cf9fe462837ac0da8a568b56fc026b132da", - "reference": "296d0cf9fe462837ac0da8a568b56fc026b132da", + "url": "https://api.github.com/repos/nunomaduro/collision/zipball/49ec67fa7b002712da8526678abd651c09f375b2", + "reference": "49ec67fa7b002712da8526678abd651c09f375b2", "shasum": "" }, "require": { @@ -7212,19 +7363,22 @@ "php": "^8.1.0", "symfony/console": "^6.3.4" }, + "conflict": { + "laravel/framework": ">=11.0.0" + }, "require-dev": { - "brianium/paratest": "^7.2.7", - "laravel/framework": "^10.23.1", - "laravel/pint": "^1.13.1", + "brianium/paratest": "^7.3.0", + "laravel/framework": "^10.28.0", + "laravel/pint": "^1.13.3", "laravel/sail": "^1.25.0", "laravel/sanctum": "^3.3.1", "laravel/tinker": "^2.8.2", "nunomaduro/larastan": "^2.6.4", - "orchestra/testbench-core": "^8.11.0", - "pestphp/pest": "^2.19.1", - "phpunit/phpunit": "^10.3.5", + "orchestra/testbench-core": "^8.13.0", + "pestphp/pest": "^2.23.2", + "phpunit/phpunit": "^10.4.1", "sebastian/environment": "^6.0.1", - "spatie/laravel-ignition": "^2.3.0" + "spatie/laravel-ignition": "^2.3.1" }, "type": "library", "extra": { @@ -7283,33 +7437,33 @@ "type": "patreon" } ], - "time": "2023-09-19T10:45:09+00:00" + "time": "2023-10-11T15:45:01+00:00" }, { "name": "pestphp/pest", - "version": "v2.21.0", + "version": "v2.23.2", "source": { "type": "git", "url": "https://github.com/pestphp/pest.git", - "reference": "2ffafd445d42c8b7b7e1874bde1c29945767a49d" + "reference": "b126e8e6e4afd6562e80c5dafcc2a973f17a09b3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/pestphp/pest/zipball/2ffafd445d42c8b7b7e1874bde1c29945767a49d", - "reference": "2ffafd445d42c8b7b7e1874bde1c29945767a49d", + "url": "https://api.github.com/repos/pestphp/pest/zipball/b126e8e6e4afd6562e80c5dafcc2a973f17a09b3", + "reference": "b126e8e6e4afd6562e80c5dafcc2a973f17a09b3", "shasum": "" }, "require": { - "brianium/paratest": "^7.2.9", - "nunomaduro/collision": "^7.9.0", - "nunomaduro/termwind": "^1.15.1", + "brianium/paratest": "^7.3.0", + "nunomaduro/collision": "^7.9.0|^8.0.0", + "nunomaduro/termwind": "^1.15.1|^2.0.0", "pestphp/pest-plugin": "^2.1.1", - "pestphp/pest-plugin-arch": "^2.3.3", + "pestphp/pest-plugin-arch": "^2.4.0", "php": "^8.1.0", - "phpunit/phpunit": "^10.4.0" + "phpunit/phpunit": "^10.4.1" }, "conflict": { - "phpunit/phpunit": ">10.4.0", + "phpunit/phpunit": ">10.4.1", "sebastian/exporter": "<5.1.0", "webmozart/assert": "<1.11.0" }, @@ -7374,7 +7528,7 @@ ], "support": { "issues": "https://github.com/pestphp/pest/issues", - "source": "https://github.com/pestphp/pest/tree/v2.21.0" + "source": "https://github.com/pestphp/pest/tree/v2.23.2" }, "funding": [ { @@ -7386,7 +7540,7 @@ "type": "github" } ], - "time": "2023-10-06T12:33:39+00:00" + "time": "2023-10-10T15:40:34+00:00" }, { "name": "pestphp/pest-plugin", @@ -7460,26 +7614,26 @@ }, { "name": "pestphp/pest-plugin-arch", - "version": "v2.3.3", + "version": "v2.4.1", "source": { "type": "git", "url": "https://github.com/pestphp/pest-plugin-arch.git", - "reference": "b758990e83f89daba3c45672398579cf8692213f" + "reference": "59698f0a381c5bc4fa2cd5b6ed331067c4501fdb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/pestphp/pest-plugin-arch/zipball/b758990e83f89daba3c45672398579cf8692213f", - "reference": "b758990e83f89daba3c45672398579cf8692213f", + "url": "https://api.github.com/repos/pestphp/pest-plugin-arch/zipball/59698f0a381c5bc4fa2cd5b6ed331067c4501fdb", + "reference": "59698f0a381c5bc4fa2cd5b6ed331067c4501fdb", "shasum": "" }, "require": { - "nunomaduro/collision": "^7.8.1", - "pestphp/pest-plugin": "^2.0.1", + "nunomaduro/collision": "^7.10.0|^8.0.0", + "pestphp/pest-plugin": "^2.1.1", "php": "^8.1", - "ta-tikoma/phpunit-architecture-test": "^0.7.4" + "ta-tikoma/phpunit-architecture-test": "^0.7.5" }, "require-dev": { - "pestphp/pest": "^2.16.0", + "pestphp/pest": "^2.23.2", "pestphp/pest-dev-tools": "^2.16.0" }, "type": "library", @@ -7508,7 +7662,7 @@ "unit" ], "support": { - "source": "https://github.com/pestphp/pest-plugin-arch/tree/v2.3.3" + "source": "https://github.com/pestphp/pest-plugin-arch/tree/v2.4.1" }, "funding": [ { @@ -7520,7 +7674,7 @@ "type": "github" } ], - "time": "2023-08-21T16:06:30+00:00" + "time": "2023-10-12T15:35:38+00:00" }, { "name": "pestphp/pest-plugin-laravel", @@ -8240,16 +8394,16 @@ }, { "name": "phpunit/phpunit", - "version": "10.4.0", + "version": "10.4.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "9784e877e3700de37475545bdbdce8383ff53d25" + "reference": "62bd7af13d282deeb95650077d28ba3600ca321c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/9784e877e3700de37475545bdbdce8383ff53d25", - "reference": "9784e877e3700de37475545bdbdce8383ff53d25", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/62bd7af13d282deeb95650077d28ba3600ca321c", + "reference": "62bd7af13d282deeb95650077d28ba3600ca321c", "shasum": "" }, "require": { @@ -8321,7 +8475,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/10.4.0" + "source": "https://github.com/sebastianbergmann/phpunit/tree/10.4.1" }, "funding": [ { @@ -8337,7 +8491,7 @@ "type": "tidelift" } ], - "time": "2023-10-06T03:41:22+00:00" + "time": "2023-10-08T05:01:11+00:00" }, { "name": "psr/cache", @@ -9520,16 +9674,16 @@ }, { "name": "spatie/laravel-ignition", - "version": "2.3.0", + "version": "2.3.1", "source": { "type": "git", "url": "https://github.com/spatie/laravel-ignition.git", - "reference": "4ed813d16edb5a1ab0d7f4b1d116c37ee8cdf3c0" + "reference": "bf21cd15aa47fa4ec5d73bbc932005c70261efc8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/spatie/laravel-ignition/zipball/4ed813d16edb5a1ab0d7f4b1d116c37ee8cdf3c0", - "reference": "4ed813d16edb5a1ab0d7f4b1d116c37ee8cdf3c0", + "url": "https://api.github.com/repos/spatie/laravel-ignition/zipball/bf21cd15aa47fa4ec5d73bbc932005c70261efc8", + "reference": "bf21cd15aa47fa4ec5d73bbc932005c70261efc8", "shasum": "" }, "require": { @@ -9608,7 +9762,7 @@ "type": "github" } ], - "time": "2023-08-23T06:24:34+00:00" + "time": "2023-10-09T12:55:26+00:00" }, { "name": "symfony/yaml", @@ -9684,16 +9838,16 @@ }, { "name": "ta-tikoma/phpunit-architecture-test", - "version": "0.7.4", + "version": "0.7.5", "source": { "type": "git", "url": "https://github.com/ta-tikoma/phpunit-architecture-test.git", - "reference": "abe1f8a5f4635e7cbe0a8a37d6b8d20c687af0f2" + "reference": "9eb08437e8f0c0c75cc947a373cf49672c335827" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/ta-tikoma/phpunit-architecture-test/zipball/abe1f8a5f4635e7cbe0a8a37d6b8d20c687af0f2", - "reference": "abe1f8a5f4635e7cbe0a8a37d6b8d20c687af0f2", + "url": "https://api.github.com/repos/ta-tikoma/phpunit-architecture-test/zipball/9eb08437e8f0c0c75cc947a373cf49672c335827", + "reference": "9eb08437e8f0c0c75cc947a373cf49672c335827", "shasum": "" }, "require": { @@ -9701,7 +9855,7 @@ "php": "^8.1.0", "phpdocumentor/reflection-docblock": "^5.3.0", "phpunit/phpunit": "^10.1.1", - "symfony/finder": "^6.2.7" + "symfony/finder": "^6.2.7 || ^7.0.0" }, "require-dev": { "laravel/pint": "^1.9.0", @@ -9737,9 +9891,9 @@ ], "support": { "issues": "https://github.com/ta-tikoma/phpunit-architecture-test/issues", - "source": "https://github.com/ta-tikoma/phpunit-architecture-test/tree/0.7.4" + "source": "https://github.com/ta-tikoma/phpunit-architecture-test/tree/0.7.5" }, - "time": "2023-08-03T06:50:14+00:00" + "time": "2023-10-12T15:31:50+00:00" }, { "name": "theseer/tokenizer", diff --git a/config/activitylog.php b/config/activitylog.php new file mode 100644 index 0000000..29d6f1a --- /dev/null +++ b/config/activitylog.php @@ -0,0 +1,52 @@ + env('ACTIVITY_LOGGER_ENABLED', true), + + /* + * When the clean-command is executed, all recording activities older than + * the number of days specified here will be deleted. + */ + 'delete_records_older_than_days' => 365, + + /* + * If no log name is passed to the activity() helper + * we use this default log name. + */ + 'default_log_name' => 'default', + + /* + * You can specify an auth driver here that gets user models. + * If this is null we'll use the current Laravel auth driver. + */ + 'default_auth_driver' => null, + + /* + * If set to true, the subject returns soft deleted models. + */ + 'subject_returns_soft_deleted_models' => true, + + /* + * This model will be used to log activity. + * It should implement the Spatie\Activitylog\Contracts\Activity interface + * and extend Illuminate\Database\Eloquent\Model. + */ + 'activity_model' => \Spatie\Activitylog\Models\Activity::class, + + /* + * This is the name of the table that will be created by the migration and + * used by the Activity model shipped with this package. + */ + 'table_name' => 'activity_log', + + /* + * This is the database connection that will be used by the migration and + * the Activity model shipped with this package. In case it's not set + * Laravel's database.default will be used instead. + */ + 'database_connection' => env('ACTIVITY_LOGGER_DB_CONNECTION'), +]; diff --git a/database/migrations/2023_10_12_080056_create_activity_log_table.php b/database/migrations/2023_10_12_080056_create_activity_log_table.php new file mode 100644 index 0000000..7c05bc8 --- /dev/null +++ b/database/migrations/2023_10_12_080056_create_activity_log_table.php @@ -0,0 +1,27 @@ +create(config('activitylog.table_name'), function (Blueprint $table) { + $table->bigIncrements('id'); + $table->string('log_name')->nullable(); + $table->text('description'); + $table->nullableMorphs('subject', 'subject'); + $table->nullableMorphs('causer', 'causer'); + $table->json('properties')->nullable(); + $table->timestamps(); + $table->index('log_name'); + }); + } + + public function down() + { + Schema::connection(config('activitylog.database_connection'))->dropIfExists(config('activitylog.table_name')); + } +} diff --git a/database/migrations/2023_10_12_080057_add_event_column_to_activity_log_table.php b/database/migrations/2023_10_12_080057_add_event_column_to_activity_log_table.php new file mode 100644 index 0000000..7b797fd --- /dev/null +++ b/database/migrations/2023_10_12_080057_add_event_column_to_activity_log_table.php @@ -0,0 +1,22 @@ +table(config('activitylog.table_name'), function (Blueprint $table) { + $table->string('event')->nullable()->after('subject_type'); + }); + } + + public function down() + { + Schema::connection(config('activitylog.database_connection'))->table(config('activitylog.table_name'), function (Blueprint $table) { + $table->dropColumn('event'); + }); + } +} diff --git a/database/migrations/2023_10_12_080058_add_batch_uuid_column_to_activity_log_table.php b/database/migrations/2023_10_12_080058_add_batch_uuid_column_to_activity_log_table.php new file mode 100644 index 0000000..8f7db66 --- /dev/null +++ b/database/migrations/2023_10_12_080058_add_batch_uuid_column_to_activity_log_table.php @@ -0,0 +1,22 @@ +table(config('activitylog.table_name'), function (Blueprint $table) { + $table->uuid('batch_uuid')->nullable()->after('properties'); + }); + } + + public function down() + { + Schema::connection(config('activitylog.database_connection'))->table(config('activitylog.table_name'), function (Blueprint $table) { + $table->dropColumn('batch_uuid'); + }); + } +} diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index bee7ef0..8090ebe 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -12,7 +12,7 @@ class DatabaseSeeder extends Seeder */ public function run(): void { - $this->call(BaseQuotesSeeder::class); $this->call(PriceyBotSeeder::class); + $this->call(BaseQuotesSeeder::class); } } diff --git a/resources/views/admin/logs.blade.php b/resources/views/admin/logs.blade.php new file mode 100644 index 0000000..dca138b --- /dev/null +++ b/resources/views/admin/logs.blade.php @@ -0,0 +1,5 @@ + +
+ +
+
diff --git a/resources/views/components/icons/square-stack.blade.php b/resources/views/components/icons/square-stack.blade.php new file mode 100644 index 0000000..324890c --- /dev/null +++ b/resources/views/components/icons/square-stack.blade.php @@ -0,0 +1,4 @@ +{{-- https://heroicons.com/ --}} + + + diff --git a/resources/views/components/paginator.blade.php b/resources/views/components/paginator.blade.php new file mode 100644 index 0000000..2fb0392 --- /dev/null +++ b/resources/views/components/paginator.blade.php @@ -0,0 +1,106 @@ +@if ($paginator->hasPages()) + +@endif diff --git a/resources/views/components/sidebar-nav.blade.php b/resources/views/components/sidebar-nav.blade.php index 63f05db..bb56c17 100644 --- a/resources/views/components/sidebar-nav.blade.php +++ b/resources/views/components/sidebar-nav.blade.php @@ -3,7 +3,7 @@ {{ $svg ?? '' }} diff --git a/resources/views/components/sidebar.blade.php b/resources/views/components/sidebar.blade.php index c0accde..1ae50cd 100644 --- a/resources/views/components/sidebar.blade.php +++ b/resources/views/components/sidebar.blade.php @@ -31,7 +31,14 @@ Send Quote +
  • + + + Logs + +
  • + @endif diff --git a/resources/views/livewire/guest/navigation.blade.php b/resources/views/livewire/guest/navigation.blade.php index 6de4550..240c1e1 100644 --- a/resources/views/livewire/guest/navigation.blade.php +++ b/resources/views/livewire/guest/navigation.blade.php @@ -1,4 +1,4 @@ -
    +
    @auth
    -