From 619cabb7511b7f3f70639c282830ebeafa202235 Mon Sep 17 00:00:00 2001 From: Deon George Date: Sun, 23 May 2021 00:38:19 +1000 Subject: [PATCH] Framework updates, merges from other packages --- app/Providers/AppServiceProvider.php | 56 +++++++++++++++++++--------- composer.json | 41 +++++++++----------- package.json | 22 +++++------ resources/js/bootstrap.js | 32 +--------------- 4 files changed, 67 insertions(+), 84 deletions(-) diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index ee8ca5b..a277818 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -6,23 +6,43 @@ use Illuminate\Support\ServiceProvider; class AppServiceProvider extends ServiceProvider { - /** - * Register any application services. - * - * @return void - */ - public function register() - { - // - } + /** + * Register any application services. + * + * @return void + */ + public function register() + { + // + } - /** - * Bootstrap any application services. - * - * @return void - */ - public function boot() - { - // - } + /** + * Bootstrap any application services. + * + * @return void + */ + public function boot() + { + // When a query should return 1 object, or FAIL if it doesnt + Builder::macro('singleOrFail',function () { + $result = $this->get(); + + if (($x=$result->count()) == 1) { + return $result->first(); + } + + throw new \Exception(sprintf('Query brings back %d record(s) called for singleOrFail()',$x)); + }); + + // When a query should return 1 object, or NULL if it doesnt + Builder::macro('single',function () { + $result = $this->get(); + + if ($result->count() == 1) { + return $result->first(); + } + + return NULL; + }); + } } diff --git a/composer.json b/composer.json index f076f25..0f8a988 100644 --- a/composer.json +++ b/composer.json @@ -1,9 +1,9 @@ { "name": "laravel/laravel", + "type": "project", "description": "The Laravel Framework.", "keywords": ["framework", "laravel"], "license": "MIT", - "type": "project", "require": { "php": "^8.0", "ext-sockets": "*", @@ -21,14 +21,20 @@ "mockery/mockery": "^1.4.2", "phpunit/phpunit": "^9.3.3" }, + "config": { + "optimize-autoloader": true, + "preferred-install": "dist", + "sort-packages": true + }, + "extra": { + "laravel": { + "dont-discover": [] + } + }, "autoload": { "files": [ "app/helpers.php" ], - "classmap": [ - "database/seeds", - "database/factories" - ], "psr-4": { "App\\": "app/" } @@ -38,29 +44,18 @@ "Tests\\": "tests/" } }, - "extra": { - "laravel": { - "dont-discover": [ - ] - } - }, + "minimum-stability": "dev", + "prefer-stable": true, "scripts": { + "post-autoload-dump": [ + "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump", + "@php artisan package:discover --ansi" + ], "post-root-package-install": [ "@php -r \"file_exists('.env') || copy('.env.example', '.env');\"" ], "post-create-project-cmd": [ "@php artisan key:generate --ansi" - ], - "post-autoload-dump": [ - "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump", - "@php artisan package:discover --ansi" ] - }, - "config": { - "preferred-install": "dist", - "sort-packages": true, - "optimize-autoloader": true - }, - "minimum-stability": "dev", - "prefer-stable": true + } } diff --git a/package.json b/package.json index cb2f688..00c6506 100644 --- a/package.json +++ b/package.json @@ -2,21 +2,17 @@ "private": true, "scripts": { "dev": "npm run development", - "development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js", - "watch": "npm run development -- --watch", - "watch-poll": "npm run watch -- --watch-poll", - "hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js", + "development": "mix", + "watch": "mix watch", + "watch-poll": "mix watch -- --watch-options-poll=1000", + "hot": "mix watch --hot", "prod": "npm run production", - "production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js" + "production": "mix --production" }, "devDependencies": { - "axios": "^0.18", - "bootstrap": "^4.0.0", - "cross-env": "^5.1", - "jquery": "^3.2", - "laravel-mix": "^2.0", - "lodash": "^4.17.5", - "popper.js": "^1.12", - "vue": "^2.5.17" + "axios": "^0.21", + "laravel-mix": "^6.0.6", + "lodash": "^4.17.19", + "postcss": "^8.1.14" } } diff --git a/resources/js/bootstrap.js b/resources/js/bootstrap.js index c1f8ac3..6922577 100644 --- a/resources/js/bootstrap.js +++ b/resources/js/bootstrap.js @@ -1,19 +1,5 @@ - window._ = require('lodash'); -/** - * We'll load jQuery and the Bootstrap jQuery plugin which provides support - * for JavaScript based Bootstrap features such as modals and tabs. This - * code may be modified to fit the specific needs of your application. - */ - -try { - window.Popper = require('popper.js').default; - window.$ = window.jQuery = require('jquery'); - - require('bootstrap'); -} catch (e) {} - /** * We'll load the axios HTTP library which allows us to easily issue requests * to our Laravel back-end. This library automatically handles sending the @@ -24,27 +10,13 @@ window.axios = require('axios'); window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'; -/** - * Next we will register the CSRF Token as a common header with Axios so that - * all outgoing HTTP requests automatically have it attached. This is just - * a simple convenience so we don't have to attach every token manually. - */ - -let token = document.head.querySelector('meta[name="csrf-token"]'); - -if (token) { - window.axios.defaults.headers.common['X-CSRF-TOKEN'] = token.content; -} else { - console.error('CSRF token not found: https://laravel.com/docs/csrf#csrf-x-csrf-token'); -} - /** * Echo exposes an expressive API for subscribing to channels and listening * for events that are broadcast by Laravel. Echo and event broadcasting * allows your team to easily build robust real-time web applications. */ -// import Echo from 'laravel-echo' +// import Echo from 'laravel-echo'; // window.Pusher = require('pusher-js'); @@ -52,5 +24,5 @@ if (token) { // broadcaster: 'pusher', // key: process.env.MIX_PUSHER_APP_KEY, // cluster: process.env.MIX_PUSHER_APP_CLUSTER, -// encrypted: true +// forceTLS: true // });