aligajani

aligajani

Member Since 5 Years Ago

London, UK

Experience Points
27,500
Total
Experience

2,500 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
462
Lessons
Completed
Best Reply Awards
1
Best Reply
Awards
  • start your 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-in-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 Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist 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.

Level 6
27,500 XP
Mar
20
1 week ago
Activity icon

Replied to How Do I Use MYSQL_ATTR_SSL_CA In Vapor When .pem File Is In Storage?

Maybe I can cache it on deployment, maybe I can access it directly via a configuration file?

Activity icon

Started a new Conversation How Do I Use MYSQL_ATTR_SSL_CA In Vapor When .pem File Is In Storage?

It always get deleted when deployed to Vapor as the storage folder is purged.

'options' => extension_loaded('pdo_mysql') ? array_filter([
                PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA')
                    ? storage_path() . '/ssl/' . env('MYSQL_ATTR_SSL_CA')
                    : null,
            ]) : [],

I don't want to directly reference it to an s3/cdn asset URL as that will be too slow.

Any tips? PS: It works on local just fine, just not on Vapor.

Mar
10
2 weeks ago
Activity icon

Started a new Conversation Why Does Nova Still Work If I Disable AuthenticateSession Middleware?

I am bit stunned how Laravel Nova is able to function if I disable the following middleware.

\Illuminate\Session\Middleware\AuthenticateSession::class,

I can still use the app, login, modify data et al.

Mar
09
2 weeks ago
Activity icon

Replied to How Can I Have A Select In Nova That Lets Me Store JSON In The Database?

@piljac1 So I implemented a Nova::serving and put in a UserObserver inside it. So far it is not colliding, as I am running a piece of code specific to Nova only. Do you know the sequence these run, that is, which event gets fired first? Nova observer event or the one setup in my dispatchEvents within the model?

Activity icon

Replied to How Can I Have A Select In Nova That Lets Me Store JSON In The Database?

@piljac1 Also, wont having 2 saving model events listen to a change conflict or collide?

Activity icon

Replied to How Can I Have A Select In Nova That Lets Me Store JSON In The Database?

@piljac1 thank you. I already do have model events for creating and saved so I guess nova is already triggering those. Except from what I understand you are suggesting stacking up a nova specific one ?

Activity icon

Replied to How Can I Have A Select In Nova That Lets Me Store JSON In The Database?

@piljac1 good one. I already do have model events. Not sure you mean specific to nova ? Could get messy. Any other ideas ?

Activity icon

Replied to How Can I Have A Select In Nova That Lets Me Store JSON In The Database?

@piljac1 Nope. It adds slashes which I don’t want. I tried escaping slashes but even then same. I tried that it with json encode.

Mar
08
2 weeks ago
Activity icon

Replied to How Can I Have A Select In Nova That Lets Me Store JSON In The Database?

Most of my selects are static, but some are dynamic, like the country selector.

@piljac1 by the way, this is storing it in my database as "{ name: 'Press' }" , correct would be {"name": "Press"}

Activity icon

Started a new Conversation How Can I Instruct Nova To Store The FullUrl Of The S3 Uploads?

  1. This doesn't work because the attachment isn't a valid key.
  2. This is repetitive and I am sure there can be a global way.
->disk('s3')
                ->storeAs(function (Request $request) {
                    $name = sha1($request->attachment->getClientOriginalName()) . '-'
                        . now()->format('D_Y-m-d-T_H-m-s') . '-'
                        . ($request->attachment->getClientOriginalName());
                    $awsBucket = env("AWS_BUCKET");
                    $awsRegion = env("AWS_DEFAULT_REGION");

                    return "https://{$awsBucket}.s3.{$awsRegion}.amazonaws.com/{$name}";
                }),
Activity icon

Started a new Conversation How Can I Have A Select In Nova That Lets Me Store JSON In The Database?

Sorry for the mouthful question, but in my signup page, I have something like this below. When a user selects any of the item from the options below, it gets stored in my database as a JSON value so say I select the 3rd option, it will show up as { name: 'Linkedin' } in my database.

I can technically have more keys inside { name: 'Linkedin' } and it will store that as well, while keeping the name for visibility purposes on the select itself. Is there anything like this possible in Nova, by default?

<SelectInput
                    v-model="form.reference"
                    rules="required"
                    label="How did you hear about us?"
                    :data="[
                        { name: 'Google' },
                        { name: 'Press' },
                        { name: 'Linkedin' },
                        { name: 'Facebook' },
                        { name: 'Twitter' },
                        { name: 'Advert' },
                        { name: 'Paradigm' },
                        { name: 'Referral' },
                        { name: 'Shares Magazine' },
                        { name: 'British Investor Summit' }
                    ]"
                />
Activity icon

Started a new Conversation How Can I Put Nova Dashboard On A Domain Using Vapor

Just a dedicated place like admin.* or admin.test.xyz.com and then admin.xyz.com

Activity icon

Replied to Laravel Nova Broken When Setup On Existing Vue-SPA App

Thanks for that packages site. Appreciated. I have more questions about Nova now.

How do I create a record as the designated user while being logged in as an administrator.

In my code I’m using auth()->user() but as an admin I don’t want to assign a record to myself but the designated user I’m creating a record for.

Activity icon

Replied to Laravel Nova Broken When Setup On Existing Vue-SPA App

@ricus Right, thank you. I just made the below work, however, quite tedious setting it up on a lot of models. I am assuming there isn't any one place where I can put this that gives a super admin full rights. Also, from your experience, what is the best practice to white list a bunch of admins that have same rights i.e. full modification access. I know I can have a column in the database, but I was thinking if having it white list by email using in_array() is a bad idea?

public function before($user, $ability)
{
    if ($user->isSuperAdmin()) {
        return true;
    }
}
Activity icon

Replied to Laravel Nova Broken When Setup On Existing Vue-SPA App

@ricus I just realised that I can't edit other people's records. I do have a Policy setup in my own model but I don't think Nova adheres or observes that and probably needs it own model policies. Am I wrong here?

Activity icon

Replied to Laravel Nova Broken When Setup On Existing Vue-SPA App

@ricus Awesome, setting NOVA_GUARD to web fixed it. I am assuming that Nova brings it own login and reset controllers and doesn't tamper with my existing code in any way , except writing NovaServiceProvider in app.php. Am I right?

Activity icon

Replied to Laravel Nova Broken When Setup On Existing Vue-SPA App

@ricus Thanks, I managed to fix the initial issue by turning on web middlewares that I had earlier commented out. Regarding this particular gate, I did put up an email in there but it refresh the pages, doesn't log me in.

It is the same email that is signed up on JWT in the same browser. I noticed that gate takes into effect non-local environments, and I am on a local environment.

This gate determines who can access Nova in non-local environments.
Activity icon

Started a new Conversation Laravel Nova Broken When Setup On Existing Vue-SPA App

To begin with, I can't create admin users using nova:user because I already have a user model which doesn't have a name field and has dozens of other fields which are required. Another problem is the error below which I can't figure out at all.

Facade\Ignition\Exceptions\ViewException Call to a member function any() on string (View: /Users/aligajani/Sites/shadow-platform/nova/resources/views/auth/login.blade.php) https://shadow-platform.test:3000/nova/login

https://flareapp.io/share/17DMdZ5v

Did I just make a big mistake paying $99 for a dashboard that isn't supposed to work on existing SPA apps?

Feb
25
1 month ago
Activity icon

Replied to How Can I Setup Nova Outside Of My Laravel App On A Separate Vapor App?

I didn't mean getting a separate frontend developer to work on Nova. What I mean is the possibility of putting Nova in a separate repo and feeding off from that repo while deploying it to vapor.

Activity icon

Started a new Conversation How Can I Setup Nova Outside Of My Laravel App On A Separate Vapor App?

I am not happy with making my application a big monolith. Ideally, I want someone else to work on the dashboard which means having Nova in a separate repository would be perfect for me.

Activity icon

Replied to Why Doesn't Laravel Vapor Inject ASSET_URL In My Build Step?

@georgeboot Thanks George, but it didn't help me with assets references in .vue files.

Feb
22
1 month ago
Activity icon

Replied to Vapor ASSET_URL And Images In Vue

@georgeboot How does that fix it for assets referenced inside .vue files? It didn’t work for me. I am picking up the ASSET_URL from index.blade.php , using it in a method as a global mixin called CDN() and using that in my .vue files instead. Works but surely there’s a better way.

Feb
21
1 month ago
Activity icon

Replied to Why Doesn't Laravel Vapor Inject ASSET_URL In My Build Step?

@georgeboot mix.setResourceRoot(ASSET_URL); doesn't fix the asset references in .vue files though (?)

Activity icon

Replied to Why Doesn't Laravel Vapor Inject ASSET_URL In My Build Step?

@georgeboot What's your entire code block for this mix.setResourceRoot(ASSET_URL) please?

Activity icon

Replied to Why Doesn't Laravel Vapor Inject ASSET_URL In My Build Step?

@georgeboot

I use MIX_BASE_URL for making a reference to my API endpoint over here below.

window.axios.defaults.baseURL = process.env.MIX_BASE_URL;

I have put this in Github Secrets for now, because .env doesn't get committed to source control.

Activity icon

Replied to Why Doesn't Laravel Vapor Inject ASSET_URL In My Build Step?

@georgeboot How are you getting MIX_BASE_URL to work ? Where are you setting that? My bootstrap.js needs that but currently I've set that up in Github Secrets as a hack.

Feb
13
1 month ago
Activity icon

Replied to Why Doesn't Laravel Vapor Inject ASSET_URL In My Build Step?

@georgeboot I contacted Github a while ago and they have no clue either.

Feb
12
1 month ago
Activity icon

Replied to Why Doesn't Laravel Vapor Inject ASSET_URL In My Build Step?

The problem is with Github Actions guys...has anyone managed to access anything process.env.* while using Vapor deploy in Github Actions. I haven't. So I am, as a fall back, using the window.asset_url={} technique and for also using Github secrets. So my MIX_BASE_URL is in Github Secrets. Only then, it is accessible by the workflow while using process.env. Otherwise, Github Actions just returns undefined.

Feb
11
1 month ago
Activity icon

Replied to Why Doesn't Laravel Vapor Inject ASSET_URL In My Build Step?

Did that work? On Github actions ?

Jan
16
2 months ago
Activity icon

Replied to How Do You Standardize Your JSON Responses?

That is an overkill for what I wanted. So I used another one now, flug-responder. So good

Jan
15
2 months ago
Jan
08
2 months ago
Activity icon

Started a new Conversation What Do You Guys Use To Display A Loader Icon For A Component While Its HTTP Request Is Processing?

I was thinking something like this.

<show-loader>
   <component-that-makes-http-request/>
</show-loader>

It is quite painful to have a loading logic set in every component that makes HTTP requests, using data, this and that to set things to true and false after Promises resolve. I am sure you guys are using something more sublime, just curious.

Activity icon

Replied to Why Doesn't Laravel Vapor Inject ASSET_URL In My Build Step?

@themsaid I don't deploy from my machine but I guess you're right. Github Actions is overriding them. I have reached out to them and have't received a response yet. But I suspect it is indeed the case. The last time I deployed via my machine, I wasn't using any assets so have to retest.

Jan
06
2 months ago
Activity icon

Replied to Why Doesn't Laravel Vapor Inject ASSET_URL In My Build Step?

I have contacted them already, but no response yet. Maybe you should tweet them too, please. With your clout, I guess we are certain to get a faster response on Twitter. But thank you.

Activity icon

Replied to Why Doesn't Laravel Vapor Inject ASSET_URL In My Build Step?

@themsaid Thank you Mohamed for taking this up. In Github actions, I am indeed running vapor deploy.

I logged process.env and I don't see ASSET_URL in there. I however do see VAPOR_API_TOKEN.

name: Deploy to staging

on:
  push:
    branches:
      - development

jobs:
  vapor:
    name: Deploy to staging
    runs-on: ubuntu-latest
    steps:
      - uses: actions/[email protected]
      - uses: aligajani/[email protected]
        env:
          VAPOR_API_TOKEN: ${{ secrets.VAPOR_API_TOKEN }}
        with:
          args: "deploy staging"

Jan
05
2 months ago
Activity icon

Replied to Why Doesn't Laravel Vapor Inject ASSET_URL In My Build Step?

Guys I talked to Mohammed too and he said to update the Vapor library, however it did not work, so I am using what Paul suggested.

Jan
04
2 months ago
Activity icon

Replied to Why Doesn't Laravel Vapor Inject ASSET_URL In My Build Step?

@fylzero Doesn't work.

I did update my environment files with MIX_ASSET_URL="${ASSET_URL}" and did vapor env:push production. Then ran the below from Github actions using vapor deploy production.

> @ production /github/workspace/.vapor/build/app
> cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js

MIX_ASSET_URL=undefined
 DONE  Compiled successfully in 26430ms10:57:22 AM
Activity icon

Replied to Why Doesn't Laravel Vapor Inject ASSET_URL In My Build Step?

@paulmarshall I could do this Paul, but I am finding the right solution. I have reached out to Taylor and Mohamed. Thank you for your hack though. How are you using this in your app.js? As a computed or a method?

Activity icon

Replied to Why Doesn't Laravel Vapor Inject ASSET_URL In My Build Step?

Interesting. Let’s try this. Thanks

Activity icon

Replied to Why Doesn't Laravel Vapor Inject ASSET_URL In My Build Step?

I don’t think you understand what I’m trying to do here. You need to look at the assets part of Vapor documentation. Taylor states that Vapor injects the ASSET_URL on two occasions. The

Build step and the environment. The former is what I’m trying to figure out here. The code I’ve shown is literally what Taylor wrote in the documentation.

Activity icon

Replied to Why Doesn't Laravel Vapor Inject ASSET_URL In My Build Step?

You can actually use MIX_ environment variables to have that file pick up from a local .env file. It works during my local experiments.

Activity icon

Replied to Why Doesn't Laravel Vapor Inject ASSET_URL In My Build Step?

How did you pick it up in app.js? Ideally my goal is to prefix all assets from a computed value or method. What do you suggest ?

Activity icon

Replied to Why Doesn't Laravel Vapor Inject ASSET_URL In My Build Step?

It is working with those helpers but not if I reference process.env.ASSET_URL in my webpack.mix.js and then subsequently process.env.ASSET_PATH in my app.js.

Jan
03
2 months ago
Activity icon

Replied to Why Doesn't Laravel Vapor Inject ASSET_URL In My Build Step?

Vapor injects it but I am not sure why it won't work at the Mix level as it does work elsewhere like assets().

Activity icon

Started a new Conversation Why Doesn't Laravel Vapor Inject ASSET_URL In My Build Step?

This is from my Github action below. You can see that ASSET_URL is empty.

> @ production /github/workspace/.vapor/build/app
> cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js

ASSET URL IS: 
 DONE  Compiled successfully in 26754ms11:23:07 PM

This is my code in webpack.mix.js. The ASSET_URL is not being injected.

// To deal with Laravel Vapor
if (mix.inProduction()) {
    const ASSET_URL = process.env.ASSET_URL;
    console.log("ASSET URL IS: " + ASSET_URL);

    mix.webpackConfig(webpack => {
        return {
            plugins: [
                new webpack.DefinePlugin({
                    "process.env.ASSET_PATH": JSON.stringify(ASSET_URL)
                })
            ],
            output: {
                publicPath: ASSET_URL
            }
        };
    });

However, assets() and mix() helpers in blade on index.blade.php work just fine.

Dec
30
2 months ago
Activity icon

Awarded Best Reply on Laravel Vapor - AWS Lambda Cold Boot

Vapor prewarms the app every 5 minutes. You don't need to do anything. AWS concurrency feature is more expensive and you shouldn't need it if your app has like a few K users at most. Right now, out of the box, Vapor achieves the pre-warm functionality using Cloudwatch events.

Dec
25
3 months ago
Activity icon

Awarded Best Reply on Anyone Figured Out Logging Using Laravel Vapor?

Okay I found the solution in case anyone runs into it after me.

Here's my logging.php configuration. Note stderr.

<?php

use Monolog\Handler\NullHandler;
use Monolog\Handler\StreamHandler;
use Monolog\Handler\SyslogUdpHandler;

return [

    /*
    |--------------------------------------------------------------------------
    | Default Log Channel
    |--------------------------------------------------------------------------
    |
    | This option defines the default log channel that gets used when writing
    | messages to the logs. The name specified in this option should match
    | one of the channels defined in the "channels" configuration array.
    |
    */

    'default' => env('LOG_CHANNEL', 'stack'),

    /*
    |--------------------------------------------------------------------------
    | Log Channels
    |--------------------------------------------------------------------------
    |
    | Here you may configure the log channels for your application. Out of
    | the box, Laravel uses the Monolog PHP logging library. This gives
    | you a variety of powerful log handlers / formatters to utilize.
    |
    | Available Drivers: "single", "daily", "slack", "syslog",
    |                    "errorlog", "monolog",
    |                    "custom", "stack"
    |
    */

    'channels' => [
        'stack' => [
            'driver' => 'stack',
            'channels' => ['vapor', 'bugsnag'],
            'ignore_exceptions' => false,
        ],

        'bugsnag' => [
            'driver' => 'bugsnag',
        ],

        'vapor' => [
            'driver' => 'stack',
            'channels' => ['stderr', 'papertrail'],
            'ignore_exceptions' => false,
        ],

        'single' => [
            'driver' => 'single',
            'path' => storage_path('logs/laravel.log'),
            'level' => 'debug',
        ],

        'daily' => [
            'driver' => 'daily',
            'path' => storage_path('logs/laravel.log'),
            'level' => 'debug',
            'days' => 14,
        ],

        'slack' => [
            'driver' => 'slack',
            'url' => env('LOG_SLACK_WEBHOOK_URL'),
            'username' => 'Laravel Log',
            'emoji' => ':boom:',
            'level' => 'critical',
        ],

        'papertrail' => [
            'driver' => 'monolog',
            'level' => 'debug',
            'handler' => SyslogUdpHandler::class,
            'handler_with' => [
                'host' => env('PAPERTRAIL_URL'),
                'port' => env('PAPERTRAIL_PORT'),
            ],
        ],

        'stderr' => [
            'driver' => 'monolog',
            'handler' => StreamHandler::class,
            'formatter' => env('LOG_STDERR_FORMATTER', "[%datetime%] %channel%.%level_name%: %message% %context% %extra%\n"),
            'with' => [
                'stream' => 'php://stderr',
            ],
        ],

        'syslog' => [
            'driver' => 'syslog',
            'level' => 'debug',
        ],

        'errorlog' => [
            'driver' => 'errorlog',
            'level' => 'debug',
        ],

        'null' => [
            'driver' => 'monolog',
            'handler' => NullHandler::class,
        ],
    ],

];
Activity icon

Replied to Anyone Figured Out Logging Using Laravel Vapor?

Okay I found the solution in case anyone runs into it after me.

Here's my logging.php configuration. Note stderr.

<?php

use Monolog\Handler\NullHandler;
use Monolog\Handler\StreamHandler;
use Monolog\Handler\SyslogUdpHandler;

return [

    /*
    |--------------------------------------------------------------------------
    | Default Log Channel
    |--------------------------------------------------------------------------
    |
    | This option defines the default log channel that gets used when writing
    | messages to the logs. The name specified in this option should match
    | one of the channels defined in the "channels" configuration array.
    |
    */

    'default' => env('LOG_CHANNEL', 'stack'),

    /*
    |--------------------------------------------------------------------------
    | Log Channels
    |--------------------------------------------------------------------------
    |
    | Here you may configure the log channels for your application. Out of
    | the box, Laravel uses the Monolog PHP logging library. This gives
    | you a variety of powerful log handlers / formatters to utilize.
    |
    | Available Drivers: "single", "daily", "slack", "syslog",
    |                    "errorlog", "monolog",
    |                    "custom", "stack"
    |
    */

    'channels' => [
        'stack' => [
            'driver' => 'stack',
            'channels' => ['vapor', 'bugsnag'],
            'ignore_exceptions' => false,
        ],

        'bugsnag' => [
            'driver' => 'bugsnag',
        ],

        'vapor' => [
            'driver' => 'stack',
            'channels' => ['stderr', 'papertrail'],
            'ignore_exceptions' => false,
        ],

        'single' => [
            'driver' => 'single',
            'path' => storage_path('logs/laravel.log'),
            'level' => 'debug',
        ],

        'daily' => [
            'driver' => 'daily',
            'path' => storage_path('logs/laravel.log'),
            'level' => 'debug',
            'days' => 14,
        ],

        'slack' => [
            'driver' => 'slack',
            'url' => env('LOG_SLACK_WEBHOOK_URL'),
            'username' => 'Laravel Log',
            'emoji' => ':boom:',
            'level' => 'critical',
        ],

        'papertrail' => [
            'driver' => 'monolog',
            'level' => 'debug',
            'handler' => SyslogUdpHandler::class,
            'handler_with' => [
                'host' => env('PAPERTRAIL_URL'),
                'port' => env('PAPERTRAIL_PORT'),
            ],
        ],

        'stderr' => [
            'driver' => 'monolog',
            'handler' => StreamHandler::class,
            'formatter' => env('LOG_STDERR_FORMATTER', "[%datetime%] %channel%.%level_name%: %message% %context% %extra%\n"),
            'with' => [
                'stream' => 'php://stderr',
            ],
        ],

        'syslog' => [
            'driver' => 'syslog',
            'level' => 'debug',
        ],

        'errorlog' => [
            'driver' => 'errorlog',
            'level' => 'debug',
        ],

        'null' => [
            'driver' => 'monolog',
            'handler' => NullHandler::class,
        ],
    ],

];
Activity icon

Started a new Conversation Anyone Figured Out Logging Using Laravel Vapor?

Papertrail works on local and never when deployed to Vapor.

'stack' => [
            'driver' => 'stack',
            'channels' => ['papertrail', 'bugsnag'],
        ],