nickdavies07

nickdavies07

Member Since 1 Year Ago

Finance Systems Developer at Genting Casinos

Experience Points 26,490
Experience Level 6

3,510 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed 243
Lessons
Completed
Best Reply Awards 1
Best Reply
Awards
  • start-engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist Created with Sketch.

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

05 Jun
3 months ago

nickdavies07 left a reply on Returning First() With Maatwebsite/laravel-excel

@NAKOV - Thanks

This works great although a little annoying to have to convert to an array.

nickdavies07 left a reply on Returning First() With Maatwebsite/laravel-excel

@NAKOV - Thanks. Still no luck unfortunately.

It seems to strip off everything after the where() clause, so the exported CSV is returning all suppliers where the user_id is equal to the auth ID, ignoring latest and first?

nickdavies07 left a reply on Returning First() With Maatwebsite/laravel-excel

@NAKOV - Apologies, my mistake I did mean to write ->last() above.

Unfortunately, using ->last() gives me an undefined method exception BadMethodCallException Call to undefined method Illuminate\Database\Eloquent\Builder::last().

nickdavies07 started a new conversation Returning First() With Maatwebsite/laravel-excel

Is it possible to just return only one row with this Excel export package?

I need to export the last supplier that the currently authenticated user inserted.

I need to do something like this...

class SuppliersExport implements FromQuery
{
    /**
     * @return \Illuminate\Database\Query\Builder
     */
    public function query()
    {
        return Supplier::where('user_id', auth()->id())->first();
    }
}
03 Jun
3 months ago

nickdavies07 left a reply on Homestead Failing To Boot

@SVPERNOVA09 - Hi @svpernova09 - yep I have executed as administrator and rebooted several times. Even uninstalled and reinstalled and still getting the same problem.

31 May
3 months ago

nickdavies07 left a reply on Homestead Failing To Boot

@BOBBYBOUWMANN - Nope, I'm on Windows 10 - specifically 10 Pro 17763.

It is odd; the few things I've come across to try on the web don't seem to work for me, so I'm stuck as to what the problem might be.

30 May
3 months ago

nickdavies07 started a new conversation Homestead Failing To Boot

Seem to be getting a problem booting/creating Homestead VM on Windows.

The terminal output is:-

Stderr: VBoxManage.exe: error: The virtual machine 'homestead-7' has terminated unexpectedly during startup with exit code 1 (0x1).  More details may be available in 'C:\Users\Ndavies\VirtualBox VMs\homestead-7\Logs\VBoxHardening.log'
VBoxManage.exe: error: Details: code E_FAIL (0x80004005), component MachineWrap, interface IMachine

The contents of the VBoxHardening.log file is:-

1a78.e90: Error (rc=-5644):
1a78.e90: Too many regions for ntdll.dll.
1a78.e90: Error (rc=-5644):
1a78.e90: supHardenedWinVerifyProcess failed with Unknown Status -5644 (0xffffe9f4): Too many regions for ntdll.dll.
1a78.e90: Error -5644 in supR3HardNtChildPurify! (enmWhat=5)
1a78.e90: supHardenedWinVerifyProcess failed with Unknown Status -5644 (0xffffe9f4): Too many regions for ntdll.dll.

Anyone know what this could be?

24 May
3 months ago

nickdavies07 started a new conversation JS And CSS Not Loading - New Install

Seem to be having an issue with the JavaScript and CSS not working on a fresh Laravel install.

I have ran npm install and npm run dev and the files exist in public/js/app.js and public/css/app.css but it doesn't seem to be finding the files.

I'm using Laragon to access the sites.

Any ideas what could be happening?

13 May
4 months ago

nickdavies07 left a reply on ReflectionException Class GuzzleHttp\Client Does Not Exist

@DEVFREY - Works like a charm and makes much more sense now.

Thanks!

nickdavies07 started a new conversation ReflectionException Class GuzzleHttp\Client Does Not Exist

I'm building a composer package in Laravel which uses GuzzleHttp Client to make requests to an API.

I seem to be having an issue trying to get it to work though. It doesn't seem to be able to find the package.

I can't really see what the issue might be - I have the correct namespacing, have required and installed the package and done a composer update. I have done composer dump-autoload as well.

Can anyone see what might be the problem here?

Laravel App composer.json

    "autoload": {
        "psr-4": {
            "NickDavies791\MicrosoftAdapter\": "packages/nickdavies791/flysystem-microsoft/src/",
            "App\": "app/"
        },
        "classmap": [
            "database/seeds",
            "database/factories"
        ]
    },
    "autoload-dev": {
        "psr-4": {
            "NickDavies791\MicrosoftAdapter\": "packages/nickdavies791/flysystem-microsoft/src/",
            "Tests\": "tests/"
        }
    }

Package composer.json

{
    "name": "nickdavies791/flysystem-microsoft",
    "description": "A Flysystem adapter for Microsoft Graph services.",
    "license": "MIT",
    "authors": [
        {
            "name": "Nick Davies",
            "email": "[email protected]"
        }
    ],
    "require": {
        "guzzlehttp/guzzle": "^6.3"
    },
    "autoload": {
        "psr-4": {
            "NickDavies791\MicrosoftAdapter\": "src/"
        }
    }
}

src/Http/Controllers/GraphTokenController.php

namespace NickDavies791\MicrosoftAdapter\Http\Controllers;

use App\Http\Controllers\Controller;
use GuzzleHttp\Client;

class GraphTokenController extends Controller
{
    /**
     * The HTTP Client instance.
     *
     * @var Client $client
     */
    protected $client;

    /**
     * GraphTokenController constructor.
     * @param Client $client
     */
    public function __construct(Client $client)
    {
        $this->client = $client;
    }

src/routes.php

Route::group(['namespace' => 'NickDavies791\MicrosoftAdapter\Http\Controllers', 'middleware' => ['web']], function () {
    Route::get('graph/token/authorise', 'GraphTokenController')->name('microsoft.token.auth');
});

src/MicrosoftAdapterServiceProvider.php

namespace NickDavies791\MicrosoftAdapter;

use Illuminate\Support\ServiceProvider;

class MicrosoftAdapterServiceProvider extends ServiceProvider
{
    /**
     * Register services.
     *
     * @return void
     */
    public function register()
    {
        $this->publishes([
            __DIR__ . '/config/microsoft.php' => config_path('microsoft.php')
        ]);
        $this->loadRoutesFrom(__DIR__ . '/routes.php');
    }

    /**
     * Bootstrap services.
     *
     * @return void
     */
    public function boot()
    {
        //
    }
}

Package Folder Structure

https://i.ibb.co/svFb9d2/flysystem.png

19 Mar
5 months ago

nickdavies07 left a reply on Passing Data To Broadcasted Event Authorization Callback

@MARTINBEAN - Thought so. Thanks for the reply. I'll have a re-think!

nickdavies07 started a new conversation Passing Data To Broadcasted Event Authorization Callback

I've just started looking at event broadcasting using Laravel Echo, Laravel Websockets and Vue. I'd like to create a new alert popup which shows when a new asset is created. This alert should only show if the user has access to the school that the new asset is being created for. Something like this: alert-example

My table relationships: I have users, schools and assets tables. Users can belong to many schools and vice versa. An asset can belong to a school, and schools can have many assets.

I have a new event called AssetCreated which is fired when a new asset is created event(new AssetCreated(auth()->user(), $asset)); This event accepts the authenticated user and the asset that has been created. I then have an AssetCreated class:-

    public function broadcastOn()
    {
        return new PrivateChannel('assets');
    }

I've read in the documentation that you can pass the data to the channel like this:-

    public function broadcastOn()
    {
        return new PrivateChannel('assets.' . $this->assets->school_id);
    }
Broadcast::channel('assets.{schoolId}', function ($user, $schoolId) {
    return $user->schools->contains($schoolId)
});

But with this approach I then have to pass the data to Laravel Echo in the Vue component as well...

 Echo.private('assets.{schoolId}')
    .listen('AssetCreated', ({user}) => {
        this.alert = true;
        this.users.push(user.name);
    })

I'd like to keep the channel name as assets, but I need to verify that the user has access to that asset's school. What would be the best way of approaching this?

15 Mar
6 months ago

nickdavies07 left a reply on Accessing Token Based API Route Via Vue/Axios

@SNAPEY - Since I'm not displaying the token in the vue template I don't think the token is actually visible in the rendered HTML.

All I really want to achieve is to pull some data from the database through Vue, but not have to have this accessible by browsing to the URL. This seemed the simplest approach without having a web route.

nickdavies07 started a new conversation Accessing Token Based API Route Via Vue/Axios

I would like to use the basic token API authentication in Laravel; no real need to set up Laravel Passport just for this request.

I have an API route set up to fetch the user's school i.e.

routes/api.php

Route::middleware('auth:api')->get('/user/school', function (Request $request) {
    return $request->user()->school;
});

I have a Vue component set up with an axios request to get the user's school, passing the token as a prop to the component then accessing through axios' params.

Vue Component

axios.get('/api/user/school', {
    params: {
        'api_token': this.token,
    }
}).then(response => (this.school = response.data))

What would be the best method for passing the api_token to the Vue component to access this data?

Should I just add it as a prop to the component in the blade file and pass it through that way as I have been? i.e.

Blade File

<user-school token={{ auth()->user()->api_token }}></user-school>
12 Mar
6 months ago

nickdavies07 left a reply on Adding Multiple Github Accounts To Forge

@SCREENBEETLE - I didn’t unfortunately. I re-tried the steps I mentioned above and got it to work but it seemed to work sporadically. Our end solution was to just create a single GitHub account for our workplace and use that. Would have loved a solution to this though.

07 Mar
6 months ago

nickdavies07 started a new conversation Cloning Repo On Forge Error - Sed: -e Expression #1, Char 42: Unknown Option To `s'

I've created a new site on Forge and trying to clone a repo into it.

I get the following error when trying to clone and the clone fails: sed: -e expression #1, char 42: unknown option tos'`

Any ideas?

The full output is:-

Cloning into '[email protected]'...
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Package operations: 74 installs, 0 updates, 0 removals
  - Installing doctrine/inflector (v1.3.0): Loading from cache
  - Installing doctrine/lexer (v1.0.1): Loading from cache
  - Installing dragonmantank/cron-expression (v2.2.0): Loading from cache
  - Installing erusev/parsedown (1.7.1): Loading from cache
  - Installing symfony/polyfill-ctype (v1.10.0): Loading from cache
  - Installing phpoption/phpoption (1.5.0): Downloading (connecting...)Downloading (0%)           Downloading (25%)Downloading (70%)Downloading (95%)Downloading (100%)
  - Installing vlucas/phpdotenv (v3.3.2): Downloading (connecting...)Downloading (0%)           Downloading (35%)Downloading (70%)Downloading (100%)
  - Installing symfony/css-selector (v4.2.4): Loading from cache
  - Installing tijsverkoyen/css-to-inline-styles (2.2.1): Loading from cache
  - Installing symfony/polyfill-php72 (v1.10.0): Loading from cache
  - Installing symfony/polyfill-mbstring (v1.10.0): Loading from cache
  - Installing symfony/var-dumper (v4.2.4): Downloading (connecting...)Downloading (0%)           Downloading (5%)Downloading (10%)Downloading (15%)Downloading (20%)Downloading (25%)Downloading (30%)Downloading (35%)Downloading (40%)Downloading (45%)Downloading (50%)Downloading (55%)Downloading (60%)Downloading (70%)Downloading (75%)Downloading (80%)Downloading (85%)Downloading (90%)Downloading (95%)Downloading (100%)
  - Installing symfony/routing (v4.2.4): Downloading (connecting...)Downloading (0%)           Downloading (5%)Downloading (10%)Downloading (15%)Downloading (20%)Downloading (25%)Downloading (30%)Downloading (35%)Downloading (40%)Downloading (45%)Downloading (50%)Downloading (55%)Downloading (60%)Downloading (65%)Downloading (70%)Downloading (75%)Downloading (80%)Downloading (85%)Downloading (90%)Downloading (95%)Downloading (100%)
  - Installing symfony/process (v4.2.4): Loading from cache
  - Installing symfony/http-foundation (v4.2.4): Downloading (connecting...)Downloading (0%)           Downloading (5%)Downloading (10%)Downloading (15%)Downloading (20%)Downloading (25%)Downloading (30%)Downloading (35%)Downloading (40%)Downloading (45%)Downloading (50%)Downloading (55%)Downloading (60%)Downloading (65%)Downloading (70%)Downloading (75%)Downloading (80%)Downloading (85%)Downloading (90%)Downloading (95%)Downloading (100%)
  - Installing symfony/contracts (v1.0.2): Loading from cache
  - Installing symfony/event-dispatcher (v4.2.4): Downloading (connecting...)Downloading (0%)           Downloading (5%)Downloading (10%)Downloading (15%)Downloading (20%)Downloading (25%)Downloading (30%)Downloading (35%)Downloading (40%)Downloading (45%)Downloading (50%)Downloading (55%)Downloading (60%)Downloading (65%)Downloading (100%)
  - Installing psr/log (1.1.0): Loading from cache
  - Installing symfony/debug (v4.2.4): Downloading (connecting...)Downloading (0%)           Downloading (10%)Downloading (15%)Downloading (25%)Downloading (30%)Downloading (45%)Downloading (55%)Downloading (65%)Downloading (70%)Downloading (80%)Downloading (90%)Downloading (100%)
  - Installing symfony/http-kernel (v4.2.4): Downloading (connecting...)Downloading (0%)           Downloading (5%)Downloading (10%)Downloading (15%)Downloading (20%)Downloading (25%)Downloading (30%)Downloading (35%)Downloading (40%)Downloading (45%)Downloading (50%)Downloading (55%)Downloading (60%)Downloading (65%)Downloading (70%)Downloading (75%)Downloading (80%)Downloading (85%)Downloading (90%)Downloading (95%)Downloading (100%)
  - Installing symfony/finder (v4.2.4): Downloading (connecting...)Downloading (0%)           Downloading (5%)Downloading (55%)Downloading (60%)Downloading (65%)Downloading (70%)Downloading (100%)
  - Installing symfony/console (v4.2.4): Downloading (connecting...)Downloading (0%)           Downloading (5%)Downloading (10%)Downloading (15%)Downloading (20%)Downloading (25%)Downloading (30%)Downloading (35%)Downloading (40%)Downloading (45%)Downloading (50%)Downloading (55%)Downloading (60%)Downloading (65%)Downloading (70%)Downloading (75%)Downloading (80%)Downloading (85%)Downloading (90%)Downloading (95%)Downloading (100%)
  - Installing egulias/email-validator (2.1.7): Loading from cache
  - Installing swiftmailer/swiftmailer (v6.1.3): Loading from cache
  - Installing paragonie/random_compat (v9.99.99): Loading from cache
  - Installing ramsey/uuid (3.8.0): Loading from cache
  - Installing psr/simple-cache (1.0.1): Loading from cache
  - Installing psr/container (1.0.0): Loading from cache
  - Installing opis/closure (3.1.6): Loading from cache
  - Installing symfony/translation (v4.2.4): Downloading (connecting...)Downloading (0%)           Downloading (5%)Downloading (10%)Downloading (15%)Downloading (20%)Downloading (25%)Downloading (30%)Downloading (35%)Downloading (40%)Downloading (45%)Downloading (50%)Downloading (55%)Downloading (60%)Downloading (65%)Downloading (70%)Downloading (75%)Downloading (80%)Downloading (85%)Downloading (90%)Downloading (95%)Downloading (100%)
  - Installing nesbot/carbon (2.14.2): Downloading (connecting...)Downloading (0%)           Downloading (5%)Downloading (10%)Downloading (15%)Downloading (20%)Downloading (25%)Downloading (30%)Downloading (35%)Downloading (40%)Downloading (45%)Downloading (50%)Downloading (55%)Downloading (60%)Downloading (65%)Downloading (70%)Downloading (75%)Downloading (80%)Downloading (85%)Downloading (90%)Downloading (95%)Downloading (100%)
  - Installing monolog/monolog (1.24.0): Loading from cache
  - Installing league/flysystem (1.0.50): Loading from cache
  - Installing laravel/framework (v5.8.2): Downloading (connecting...)Downloading (0%)           Downloading (5%)Downloading (10%)Downloading (15%)Downloading (20%)Downloading (25%)Downloading (30%)Downloading (35%)Downloading (40%)Downloading (45%)Downloading (50%)Downloading (55%)Downloading (60%)Downloading (65%)Downloading (70%)Downloading (75%)Downloading (80%)Downloading (85%)Downloading (90%)Downloading (95%)Downloading (100%)
  - Installing fideloper/proxy (4.1.0): Loading from cache
  - Installing jakub-onderka/php-console-color (v0.2): Loading from cache
  - Installing nikic/php-parser (v4.2.1): Loading from cache
  - Installing jakub-onderka/php-console-highlighter (v0.4): Loading from cache
  - Installing dnoegel/php-xdg-base-dir (0.1): Loading from cache
  - Installing psy/psysh (v0.9.9): Loading from cache
  - Installing laravel/tinker (v1.0.8): Loading from cache
  - Installing beyondcode/laravel-dump-server (1.2.2): Loading from cache
  - Installing fzaninotto/faker (v1.8.0): Loading from cache
  - Installing hamcrest/hamcrest-php (v2.0.0): Loading from cache
  - Installing mockery/mockery (1.2.2): Loading from cache
  - Installing filp/whoops (2.3.1): Loading from cache
  - Installing nunomaduro/collision (v2.1.1): Loading from cache
  - Installing webmozart/assert (1.4.0): Loading from cache
  - Installing phpdocumentor/reflection-common (1.0.1): Loading from cache
  - Installing phpdocumentor/type-resolver (0.4.0): Loading from cache
  - Installing phpdocumentor/reflection-docblock (4.3.0): Loading from cache
  - Installing phpunit/php-token-stream (3.0.1): Loading from cache
  - Installing sebastian/version (2.0.1): Loading from cache
  - Installing sebastian/resource-operations (2.0.1): Loading from cache
  - Installing sebastian/recursion-context (3.0.0): Loading from cache
  - Installing sebastian/object-reflector (1.1.1): Loading from cache
  - Installing sebastian/object-enumerator (3.0.3): Loading from cache
  - Installing sebastian/global-state (2.0.0): Loading from cache
  - Installing sebastian/exporter (3.1.0): Loading from cache
  - Installing sebastian/environment (4.1.0): Loading from cache
  - Installing sebastian/diff (3.0.2): Loading from cache
  - Installing sebastian/comparator (3.0.2): Loading from cache
  - Installing phpunit/php-timer (2.1.1): Loading from cache
  - Installing phpunit/php-text-template (1.2.1): Loading from cache
  - Installing phpunit/php-file-iterator (2.0.2): Loading from cache
  - Installing theseer/tokenizer (1.1.0): Loading from cache
  - Installing sebastian/code-unit-reverse-lookup (1.0.1): Loading from cache
  - Installing phpunit/php-code-coverage (6.1.4): Loading from cache
  - Installing doctrine/instantiator (1.1.0): Loading from cache
  - Installing phpspec/prophecy (1.8.0): Loading from cache
  - Installing phar-io/version (2.0.1): Loading from cache
  - Installing phar-io/manifest (1.0.3): Loading from cache
  - Installing myclabs/deep-copy (1.8.1): Loading from cache
  - Installing phpunit/phpunit (7.5.6): Loading from cache
symfony/routing suggests installing doctrine/annotations (For using the annotation loader)
symfony/routing suggests installing symfony/config (For using the all-in-one router or any loader)
symfony/routing suggests installing symfony/dependency-injection (For loading routes from a service)
symfony/routing suggests installing symfony/expression-language (For using expression matching)
symfony/routing suggests installing symfony/yaml (For using the YAML loader)
symfony/contracts suggests installing psr/cache (When using the Cache contracts)
symfony/contracts suggests installing symfony/cache-contracts-implementation
symfony/contracts suggests installing symfony/service-contracts-implementation
symfony/event-dispatcher suggests installing symfony/dependency-injection
symfony/http-kernel suggests installing symfony/browser-kit
symfony/http-kernel suggests installing symfony/config
symfony/http-kernel suggests installing symfony/dependency-injection
symfony/console suggests installing symfony/lock
swiftmailer/swiftmailer suggests installing true/punycode (Needed to support internationalized email addresses, if ext-intl is not installed)
paragonie/random_compat suggests installing ext-libsodium (Provides a modern crypto API that can be used to generate random bytes.)
ramsey/uuid suggests installing ext-libsodium (Provides the PECL libsodium extension for use with the SodiumRandomGenerator)
ramsey/uuid suggests installing ext-uuid (Provides the PECL UUID extension for use with the PeclUuidTimeGenerator and PeclUuidRandomGenerator)
ramsey/uuid suggests installing ircmaxell/random-lib (Provides RandomLib for use with the RandomLibAdapter)
ramsey/uuid suggests installing moontoast/math (Provides support for converting UUID to 128-bit integer (in string form).)
ramsey/uuid suggests installing ramsey/uuid-console (A console application for generating UUIDs with ramsey/uuid)
ramsey/uuid suggests installing ramsey/uuid-doctrine (Allows the use of Ramsey\Uuid\Uuid as Doctrine field type.)
symfony/translation suggests installing symfony/config
symfony/translation suggests installing symfony/yaml
monolog/monolog suggests installing aws/aws-sdk-php (Allow sending log messages to AWS services like DynamoDB)
monolog/monolog suggests installing doctrine/couchdb (Allow sending log messages to a CouchDB server)
monolog/monolog suggests installing ext-amqp (Allow sending log messages to an AMQP server (1.0+ required))
monolog/monolog suggests installing ext-mongo (Allow sending log messages to a MongoDB server)
monolog/monolog suggests installing graylog2/gelf-php (Allow sending log messages to a GrayLog2 server)
monolog/monolog suggests installing mongodb/mongodb (Allow sending log messages to a MongoDB server via PHP Driver)
monolog/monolog suggests installing php-amqplib/php-amqplib (Allow sending log messages to an AMQP server using php-amqplib)
monolog/monolog suggests installing php-console/php-console (Allow sending log messages to Google Chrome)
monolog/monolog suggests installing rollbar/rollbar (Allow sending log messages to Rollbar)
monolog/monolog suggests installing ruflin/elastica (Allow sending log messages to an Elastic Search server)
monolog/monolog suggests installing sentry/sentry (Allow sending log messages to a Sentry server)
league/flysystem suggests installing league/flysystem-aws-s3-v2 (Allows you to use S3 storage with AWS SDK v2)
league/flysystem suggests installing league/flysystem-aws-s3-v3 (Allows you to use S3 storage with AWS SDK v3)
league/flysystem suggests installing league/flysystem-azure (Allows you to use Windows Azure Blob storage)
league/flysystem suggests installing league/flysystem-cached-adapter (Flysystem adapter decorator for metadata caching)
league/flysystem suggests installing league/flysystem-eventable-filesystem (Allows you to use EventableFilesystem)
league/flysystem suggests installing league/flysystem-rackspace (Allows you to use Rackspace Cloud Files)
league/flysystem suggests installing league/flysystem-sftp (Allows you to use SFTP server storage via phpseclib)
league/flysystem suggests installing league/flysystem-webdav (Allows you to use WebDAV storage)
league/flysystem suggests installing league/flysystem-ziparchive (Allows you to use ZipArchive adapter)
league/flysystem suggests installing spatie/flysystem-dropbox (Allows you to use Dropbox storage)
league/flysystem suggests installing srmklive/flysystem-dropbox-v2 (Allows you to use Dropbox storage for PHP 5 applications)
laravel/framework suggests installing aws/aws-sdk-php (Required to use the SQS queue driver and SES mail driver (^3.0).)
laravel/framework suggests installing doctrine/dbal (Required to rename columns and drop SQLite columns (^2.6).)
laravel/framework suggests installing guzzlehttp/guzzle (Required to use the Mailgun and Mandrill mail drivers and the ping methods on schedules (^6.0).)
laravel/framework suggests installing league/flysystem-aws-s3-v3 (Required to use the Flysystem S3 driver (^1.0).)
laravel/framework suggests installing league/flysystem-cached-adapter (Required to use the Flysystem cache (^1.0).)
laravel/framework suggests installing league/flysystem-rackspace (Required to use the Flysystem Rackspace driver (^1.0).)
laravel/framework suggests installing league/flysystem-sftp (Required to use the Flysystem SFTP driver (^1.0).)
laravel/framework suggests installing moontoast/math (Required to use ordered UUIDs (^1.1).)
laravel/framework suggests installing nexmo/client (Required to use the Nexmo transport (^1.0).)
laravel/framework suggests installing pda/pheanstalk (Required to use the beanstalk queue driver (^4.0).)
laravel/framework suggests installing predis/predis (Required to use the redis cache and queue drivers (^1.0).)
laravel/framework suggests installing pusher/pusher-php-server (Required to use the Pusher broadcast driver (^3.0).)
laravel/framework suggests installing symfony/dom-crawler (Required to use most of the crawler integration testing tools (^4.2).)
laravel/framework suggests installing symfony/psr-http-message-bridge (Required to use PSR-7 bridging features (^1.1).)
laravel/framework suggests installing wildbit/swiftmailer-postmark (Required to use Postmark mail driver (^3.0).)
psy/psysh suggests installing ext-pdo-sqlite (The doc command requires SQLite to work.)
psy/psysh suggests installing hoa/console (A pure PHP readline implementation. You'll want this if your PHP install doesn't already support readline or libedit.)
filp/whoops suggests installing whoops/soap (Formats errors as SOAP responses)
sebastian/global-state suggests installing ext-uopz (*)
phpunit/php-code-coverage suggests installing ext-xdebug (^2.6.0)
phpunit/phpunit suggests installing ext-xdebug (*)
phpunit/phpunit suggests installing phpunit/php-invoker (^2.0)
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
Discovered Package: beyondcode/laravel-dump-server
Discovered Package: fideloper/proxy
Discovered Package: laravel/tinker
Discovered Package: nesbot/carbon
Discovered Package: nunomaduro/collision
Package manifest generated successfully.
sed: -e expression #1, char 42: unknown option to `s'
01 Mar
6 months ago

nickdavies07 started a new conversation Adding Multiple Github Accounts To Forge

Is it possible to add multiple Github accounts to Laravel Forge?

I have an additional account I'd like to set up to pull repositories from separate to my own account that is already connected to Forge.

I have tried the following:-

  1. Create new SSH key on server
  2. Copy SSH public key to Github
  3. Create new site on Forge
  4. Choose 'Custom' source control
  5. Enter [email protected]:user/repo.git

However I get the following error message:-

ERROR: Repository not found.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

Any help is greatly appreciated!

22 Feb
6 months ago
20 Feb
6 months ago

nickdavies07 left a reply on Websockets Server On Homestead Using Laravel Websockets

Update: it is that simple. Passing the --port={port} parameter when using php artisan websockets:serve allows a different port to be used.

nickdavies07 started a new conversation Websockets Server On Homestead Using Laravel Websockets

I'm using the beyondcode/laravel-websockets package and I'm trying to start the websockets server on Homestead.

I've SSH'd into Homestead and ran php artisan websockets:serve command to start the server however it keeps throwing back an error saying the address is already in use.

$ php artisan websockets:serve
Starting the WebSocket server on port 6001...

   RuntimeException  : Failed to listen on "tcp://0.0.0.0:6001": Address already in use

  at /home/vagrant/code/websockets/vendor/react/socket/src/TcpServer.php:164
    160|             \STREAM_SERVER_BIND | \STREAM_SERVER_LISTEN,

A quick check with sudo lsof -i -P -n | grep LISTEN shows the vagrant php service is using the port. How would I change the port for websockets, is it just as simple as changing the port in broadcasting.php and restarting the server?

18 Feb
6 months ago

nickdavies07 left a reply on Where To Host

You can set up Forge and DigitalOcean if they are in your price range. I would absolutely recommend Forge if you can, as it will automate everything and makes everything so easy to set up and configure. Or as @cronix mentioned, you can just pay for DigitalOcean and set up the LEMP stack yourself.

You can, if really tight for cash, find a cheap shared hosting company and deploy there but I really wouldn't recommend that. Best sticking to something like DigitalOcean.

13 Feb
7 months ago

nickdavies07 left a reply on Deploying To Forge From Travis CI

Solved!

Couldn't get this to work using cURL, so switched it out to use wget instead. Now make a call to:-

## Deploy dev branch to development server
wget "https://forge.laravel.com/servers/****/sites/****/deploy/http?token="$FORGE_DEVELOPMENT_TOKEN;

Successfully sends a request to the Forge server for each script using the Travis CI deploy command.

12 Feb
7 months ago

nickdavies07 started a new conversation Deploying To Forge From Travis CI

I'm attempting to deploy my application to Forge using Travis CI once certain conditions are met. I'd like the dev branch to be deployed to my development server when Travis passes my tests. Likewise, I'd like my master branch to be deployed to my production server when Travis passes my tests.

I have the following .travis.yml file for deploying:-

deploy:
  # deploy dev to development server
  - provider: script
    script: chmod +x ./scripts/deploy_dev.sh
    on:
      branch: dev
  # deploy master to production server
  - provider: script
    script: chmod +x scripts/deploy_prod.sh
    on:
      branch: master

However, when I commit and push to the dev branch, after Travis has done everything and is ready to deploy, I get the following error:- Skipping a deployment with the script provider because this branch is not permitted: dev.

My deployment scripts work fine when I use the after_success: Travis command, all they're doing is using cURL to send a request to the Forge endpoint to deploy whichever branch.

deploy_dev.sh and deploy_prod.sh

#!/bin/bash

# Trigger deployment
curl -s 'https://forge.laravel.com/servers/*****/sites/*****/deploy/http?token=****************';
echo 'Deployed to Forge'
08 Feb
7 months ago

nickdavies07 left a reply on MAC Key Is Invalid - Tried Everything!?

Solved. Reverted Forge app key.

nickdavies07 started a new conversation MAC Key Is Invalid - Tried Everything!?

I'm encrypting data using the gregoryduckworth/encryptable package.

When deploying my app onto Forge, I cannot view the encrypted data. I get MAC key is invalid error.

The data is fresh, I have a completely empty database, then ran key:generate, then synced my data, so the data in the database should be using this new key.

Tried running optimize:clear to clear caches, and opened in private browsing mode, still get the same error. Even tried using the app key from my local machine and still get the same error.

This all works on my local machine, just not on Forge.

Any ideas?!

06 Feb
7 months ago

nickdavies07 left a reply on Laravel Charts - Not Loading

@REALRANDYALLEN - I've narrowed it down to the require('bootstrap'); line in the app.js file. Commenting that line out allows the charts to work, but then my Bootstrap etc. doesn't work. Do you know what could be causing the conflict?

04 Feb
7 months ago

nickdavies07 started a new conversation Can I Cancel After The Free Trial Without Being Charged?

Can I cancel after the 5 day free trial of forge without being charged or do I get charged the first month?

nickdavies07 left a reply on Laravel Charts - Not Loading

Nope, no errors.

I'm now trying using the @push and @stack blade directives, and it seems as though every time I "click" on the link with the chart the charts don't show, however if I refresh or hard-refresh they show.

My blade files look like this:-

app.blade.php

...
<head>
    <script src="{{ asset('js/app.js') }}" ></script>
    <script src="{{ asset('js/argon.min.js') }}"></script>
    <script src="{{ asset('js/Chart.min.js') }}"></script>
</head>
<body>
@yield('content') // home.blade.php
...
@stack('charts')
</body>

home.blade.php

@extends('app.blade.php')
@section('content')
  @push('charts')
    {!! $chartA->scripts() !!}
    {!! $chartB->scripts() !!}
  @endpush
....

{!! $chartA->container() !!}
{!! $chartB->container() !!}
...
@endsection

The scripts are both loading at the bottom of the page like:-

<script type="text/javascript">
    function zjeripbcunlvmtdshkwfagyxo_create(data) {
        zjeripbcunlvmtdshkwfagyxo_rendered = true;
        var loader_element = document.getElementById("zjeripbcunlvmtdshkwfagyxo_loader");
        loader_element.parentNode.removeChild(loader_element);
        document.getElementById("zjeripbcunlvmtdshkwfagyxo").style.display = 'block';
        window.zjeripbcunlvmtdshkwfagyxo = new Chart(document.getElementById("zjeripbcunlvmtdshkwfagyxo").getContext("2d"), {
            type: data[0].type,
            data: {
                labels: ["September","October","November","December","January"],
                datasets: data
            },
            options: {"maintainAspectRatio":false,"scales":{"xAxes":[],"yAxes":[{"ticks":{"beginAtZero":true}}]}}
        });
    }
    let zjeripbcunlvmtdshkwfagyxo_rendered = false;
let zjeripbcunlvmtdshkwfagyxo_load = function () {
    if (document.getElementById("zjeripbcunlvmtdshkwfagyxo") && !zjeripbcunlvmtdshkwfagyxo_rendered) {
                    zjeripbcunlvmtdshkwfagyxo_create([{"borderWidth":4,"backgroundColor":"#f5365c","borderColor":"#f5365c","fill":false,"data":[20,15,35,15,40],"label":"2018-2019","type":"line"},{"borderWidth":4,"backgroundColor":"#5e72e4","borderColor":"#5e72e4","fill":false,"data":[35,50,7,28,45,15,40,15,65,10,30,35],"label":"2017-2018","type":"line"}])
            }
};
window.addEventListener("load", zjeripbcunlvmtdshkwfagyxo_load);
document.addEventListener("turbolinks:load", zjeripbcunlvmtdshkwfagyxo_load);
</script>

nickdavies07 started a new conversation Laravel Charts - Not Loading

I seem to be having difficulties in getting my charts to display without a hard refresh (ctrl+shift+r).

I'm using the ConsoleTVs/Charts Laravel package with the Chart.js chart set.

I have included the <script src="{{ asset('js/Chart.min.js') }}"></script> in my <head> and below that I have the scripts loading for the charts {!! $chartA->scripts() !!} and {!! $chartB->scripts() !!}

The charts show sporadically though; most of the time they need a hard refresh to show.

I have added version() to my webpack file for the chart.min.js script to prevent it from being cached i.e. mix.js('resources/js/Chart.min.js', 'public/js').version(); but still no luck.

Any advice?

Here's an example of what's happening:- Demo

nickdavies07 left a reply on Using Gregoryduckworth/Encryptable With Spatie/laravel-searchable

@BOBBYBOUWMANN - I've just made a few fields unencrypted for the time being.

Thanks for your help @

21 Jan
7 months ago

nickdavies07 left a reply on SQL Query Builder - Grouping And Ordering

Thanks for your answers.

I had a response that worked on Stackoverflow, so I'll leave that here in case anyone needs it in future!

$concerns = DB::table('concerns')
    ->select(DB::raw('MONTHNAME(created_at) AS month, YEAR(created_at) AS year, count(*) as total'))
    ->whereBetween('created_at', [$start, $end])
    ->groupBy('year', 'month')
    ->orderBy('year', 'asc')
    ->orderByRaw("MONTH(STR_TO_DATE(CONCAT('1 ', month, ' ', year), '%e %M %y')) asc")

nickdavies07 started a new conversation Using Gregoryduckworth/Encryptable With Spatie/laravel-searchable

I'm using the package gregoryduckworth/Encryptable gregoryduckworth/encryptable to encrypt data as it enters the database and I'd also like to set up the spatie/laravel-searchable spatie/laravel-searchable package to search models.

Unfortunately, I'm running into an issue with the data not decrypting when searching. If I search the actual encrypted data i.e. eyJpdiI6Im1sK1dQXC9STlVTMHlvUDVoRFlnaERRPT0iLCJ2YWx1ZSI6ImcwRFFzK0h6Z2NMRGhCc01tVm15aGc9PSIs the result is returned.

Is there any way around this at all?

Student:

// Encrypted attributes
    protected $encryptable = [
        'forename',
        'surname',
        'upn',
        'admission_number'
    ];

Concern:

// Encrypted attributes
    protected $encryptable = [
        'title', 'body'
    ];

HomeController:

    public function search(Request $request)
    {
        $searchResults = (new Search())
            ->registerModel(Student::class, 'forename')
            ->registerModel(Concern::class, 'title')
            ->search($request->input('query'));
        return view('search', compact('searchResults'));
    }
17 Jan
7 months ago

nickdavies07 left a reply on Laravel Forms

You should look at using Vue to do this.

https://vuejs.org/

nickdavies07 started a new conversation SQL Query Builder - Grouping And Ordering

Think this is more an SQL query but here goes...

I need to get a set of results from one of my tables to output to a chart. The chart needs to show "the number of concerns for each month, for this academic year (1st Sept 2018 to 31st August 2018)".

The returned result should look something like:

| month     | total |
|-----------|-------|
| September | 15    |
| October   | 23    |
| December  | 24    |
| January   | 438   |

The problem comes when I try and group the month together; i get an incorrect count value.

The query I currently have is:-

    // Returns 2018-09-01 00:00:00
        $start = Carbon::createMidnightDate(Carbon::now()->subMonths(8)->year, 9, 1);
    // Gets current date
        $end = Carbon::now();

        $concerns = DB::table('concerns')
            ->select(DB::raw('MONTHNAME(created_at) as month, count(*) as total, created_at'))
            ->whereBetween('created_at', [$start, $end])
            ->groupBy('month')
            ->groupBy('created_at')
            ->orderBy('created_at', 'asc')
            ->get()->mapWithKeys(function ($item) {
                return [$item->month => $item->total];
          });

However this returns me:-

| month     | total |
|-----------|-------|
| September | 1     |
| October   | 1     |
| December  | 1     |
| January   | 1     |

It's clearly not adding all of the individual values together because of the grouping of the created_at date, however excluding it prevents me from ordering it due to the MySQL only_full_group_by mode.

Any advice would be hugely appreciated!

14 Jan
8 months ago

nickdavies07 left a reply on Carbon - Get Date Depending On Now() Value

@MIKEMACDOWELL - Brilliant!

So simple, didn't think about it that way. Works like a charm. Thanks

    public function scopeResolvedThisAcademicYear($query)
    {
        $start = Carbon::createMidnightDate(Carbon::now()->subMonths(8)->year, 9, 1);
        $end = Carbon::now();
        return $query->whereBetween('resolved_on', [$start, $end]);
    }

11 Jan
8 months ago

nickdavies07 started a new conversation Carbon - Get Date Depending On Now() Value

I'm creating a scope in my model for retrieving values from a database between two dates.

So far, I have this which retrieves entries between 1st Sept 2018 and now. However, I need the first date's year to vary depending on the current date.

I basically need to go back from today to the 1st September 20{xx} depending on the current year, so if it's 26th November 2018, I need to get 1st September 2018, until now() gets passed 1st September 2019, then it should get values between 1st September 2019 and e.g. 7th September 2019.

This is what I have so far, I'm just not sure on how to use Carbon to get the correct date I'm looking for.

    public function scopeResolvedThisAcademicYear($query)
    {
        return $query->whereBetween('resolved_on', ['2018-09-01', Carbon::now()]);
    }

Any help would be hugely appreciated!

04 Dec
9 months ago

nickdavies07 left a reply on Configuring Laravel Envoy With SSH

Solved.

Running Laravel Homestead in Windows environment. Stupidly created the ssh key in Windows instead of in Homestead.

SSH'd into Homestead and created the SSH key there, and ran envoy run test from there, and all works perfectly.

nickdavies07 started a new conversation Configuring Laravel Envoy With SSH

Hi

I'm attempting to configure Envoy to connect via SSH to my server. The production server is at 77.72.0.74.

I have an SSH key available to access the server from my machine - the key is located in Z:\ .ssh\id_rsa

I've set up an ssh config file to allow me to access the server by using ssh clpt and this works successfully, however when I add the host to Envoy.blade.php I get This task did not complete successfully on one of your servers.

Envoy.blade.php

@servers(['remote' => 'clpt', 'local' => ''])

@task('test', ['on' => 'remote'])
    echo "testing...";
@endtask

Z:.ssh\config

Host clpt
    HostName 77.72.0.74
    Port 722
    User nickdavies

Command Line

$ envoy run test
This task did not complete successfully on one of your servers.

Any advice?

12 Nov
10 months ago

nickdavies07 started a new conversation Homestead And PHPStorm - Remote PHP Interpreter

Trying to set up debugging in PHPStorm but keep getting this error when adding Homestead under 'Configure Remote PHP Interpreter'.

Connection to 127.0.0.1 failed.
Failed to load identity file

Vagrant Instance Folder: C:\Users\nick.davies\Homestead Vagrant Host URL: ssh://[email protected]:2222 PHP Interpreter Path: /usr/bin/php

Any ideas what I'm doing wrong?

16 Oct
10 months ago

nickdavies07 left a reply on Using Cretueusebiu/valet-windows Can't Connect To .test Domains

Thanks.

Realised it was because I'm behind a proxy, and the proxy settings didn't have the exceptions set for localhost;127.0.0.1;*.test

All works great now!

15 Oct
11 months ago

nickdavies07 started a new conversation Using Cretueusebiu/valet-windows Can't Connect To .test Domains

Not really Laravel specific, but thought I'd ask anyway. Anyone have any experience using cretueusebiu/valet-windows?

I've installed as per the guide, configured my DNS to point to 127.0.0.1 and ::1. Pinging any of my projects i.e. app.test returns a reply from 127.0.0.1 successfully. However, visiting app.test in the browser returns 'The requested URL could not be retrieved - The system is unable to determine the IP address for app.test'.

When using valet share and then the ngrok URL I can connect, however. i.e. https://2a9dc219.ngrok.io/ will return my Laravel project successfully.

Any ideas?

25 Sep
11 months ago

nickdavies07 left a reply on Eager Loading Nested Relationships

OK I think I've got the wrong end of this when setting up my migrations, and I've set up a category_school link, which I'm now realising should have been a relationship between the asset and the school. Thanks for your help. I'll update what I've got so far to reflect this, and see how I get on. face palm

nickdavies07 left a reply on Eager Loading Nested Relationships

So how would I then display the asset details, the category details and the asset type details altogether in the blade view?

I'm foreach looping the data just using $school->assets at the minute, which is only giving me the school data, the asset data and the finance data, but then how would I access the category data and type data in the same loop?

It needs to be output in a table row.


| Name      | Category      | Type          | Price     |
|---------  |-------------- |-------------- |--------   |
| Asset 1   | Sports Block  | Building      | 16,000    |
| Asset 2   | Server        | IT Equipment  | 1,800     |
| Asset 3   | Laptop        | IT Equipment  | 1,200     |

nickdavies07 started a new conversation Eager Loading Nested Relationships

I'm trying to cut down the queries on my page by making use of Eloquent's nested eager loading relationships.

  • I have Schools, with many assets and that asset has a finance record.
  • I have Schools, with many categories and that category has a type.

I have tried nested eager loading for these relationships by doing this:


$school = School::with('assets.finance', 'categories.types')->find($id);

Then in the blade view, I've got something like this.


@foreach($school->assets as $asset)
    <td>{{ $school->assets->first()->asset_tag }}</td>
    <td>{{ $school->categories->first()->name }}</td>
@endforeach 

Obviously this doesn't work for getting the categories or the types since I'm using the $school->assets in the foreach.

How would I go about getting the data from the categories relationship?

13 Sep
1 year ago

nickdavies07 left a reply on Accesing Data From Base Tables And Pivot Tables

@maurojunior2011 Thanks! I did the following and it works great.


$school = School::find(request('school'))->categories;
$type = Type::find(request('type'))->categories;

return $school->intersect($type);

Returns a beautiful collection with both collections combined, omitting any values not present in both.

nickdavies07 started a new conversation Accesing Data From Base Tables And Pivot Tables

Cannot get my head round this one.

I have the following:

  • schools (id, name)

  • categories (id, name)

  • types (id, name)

  • Schools can have many Categories and vice versa (pivot as category_school) - (id, category_id, school_id)

  • Types can have many Categories and vice versa (pivot as category_type) - (id, category_id, type_id)

I'm trying to get the data from all tables so I can populate a dropdown select box based on the chosen School and Type. So if a user selects School A, then Type C, all the categories should list for School A and Type C.

Can't figure out how I would access the all the data to be able to do this. So far all I've been able to do is something like $categories = Type::find(request('type'))->categories; to get the categories based on the type requested.

Screen grab of select boxes. https://pasteboard.co/HDHjtey.png

10 Sep
1 year ago

nickdavies07 left a reply on Sorting By Human Readable Date When Using DataTables

I've actually got the data in the view being pulled from the controller, not yet looked at using the server side data source but may be something I do at some point.

Figured out a solution anyway - disabled DataTables sorting using bSort: false so now using sortByDesc('created_at') sorts by the most recent record.

Finally!

nickdavies07 started a new conversation Sorting By Human Readable Date When Using DataTables

Not entirely a Laravel question but have asked this question on DT forum as well. Just thought someone may know!

Is there a way to sort a column by a human readable date?

I use the Carbon date package with the diffForHumans() method to convert my dates to human readable format i.e. 3 days ago, 5 minutes ago etc.

Datatables seems to sort numerically and alphabetically.

Example: https://screenshots.firefox.com/IYm9uC74bz0HaKq8/asset-manager.ngrok.io

Using Laravel's sortBy() and SortByDesc() doesn't seem to affect the column.

27 Jun
1 year ago

nickdavies07 left a reply on Valet Share - Chrome Complains About Deceptive Site

Keep getting the same error.

Firefox it just stops loading the CSS and 407 errors.

Tried setting Laravel asset() to secure_asset() but no change.