aligajani

aligajani

London, UK

Member Since 4 Years Ago

Experience Points 15,310
Experience
Level
Lessons Completed 366
Lessons
Completed
Best Reply Awards 0
Best Answer
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

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

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

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

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    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 Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

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

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

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

16 May
8 months ago

aligajani left a reply on Duplicate Entries On UpdateOrCreate Method

This is a bug in the framework.

09 May
8 months ago

aligajani left a reply on How To Cache An Entire Table Into A Variable Such That It Acts Like A Virtual Database For Heavy Querying?

@jlrdw No, it will be many users and there are many more tables as well. But I don't find it hitting the database 100 times on each page load to calculate something like a meal plan , hence for performance reasons, I wanted it to be cacheable.

aligajani started a new conversation How To Cache An Entire Table Into A Variable So Say 100 Queries Can Be Performed Again It Rather Than The Database?

I have a table with 100 rows and 10 columns. My application requires that I make 50 queries against this table on one page load (app is a meal plan generator). How do I prevent hitting the database? I basically want to resort to caching the entire data from that table into some variable and query against THAT variable, with that variable basically being my virtual database of sorts.

26 Apr
8 months ago

aligajani left a reply on What Is The Proper Way To Store Stats Like Videos A User Has Started Watching And Completed Watching? I Am Looking For Your Opinions.

Thanks but my question is not about API endpoints rather than the eloquent setup for such a thing. I can’t afford an extra API call just to fetch those video-plays.

I’d rather have those sent along with the API request that gets me the videos /video itself. As shown in my mock API response. Also it’s not user uploaded videos. Rather videos uploaded by us.

25 Apr
8 months ago

aligajani started a new conversation What Is The Proper Way To Store Stats Like Videos A User Has Started Watching And Completed Watching?

I have a general idea but I am in dire need of a public opinion on what is the best and most performant option. What I essentially have right now is a user table and a videos table. I want to have a functionality such that I can track if a user started watching a video, or if a user finished watching a video, and store that in my database.

I think a pivot table for such an exercise is the normal way to go about, which means I would have two pivot tables namely user_videos_watched and user_videos_started. Does that make sense? Or should I have one table called user_video_statistics and have columns on those like video_completed, video_started_watching as Booleans?

I need to know what would be the impact of this when I want to do eager loading of my models. Now comes the important part. What I essentially want is to be able to is that when I eager load a set of videos a user should watch, collectively, or even an individual video, I want this information to be fetched from the DB using the minimum number of calls, both this information such as video_completed, video_started_watching in that very model.

Basically, perhaps merged into the model array for consuming on my VueJS components. Here's a very simple example of the type of JSON that I would expect to receive if I do api/user/videos:

{
    "user": {},
    "videos": [{
            "video_id": 1,
            "video_completed": 0,
            "video_started_watching": 1
        },
        {
            "video_id": 2,
            "video_completed": 1,
            "video_started_watching": 1
        }
    ]
}

And if I call `api/user/videos/1 then I should automatically receive:

{
    "video_id": 1,
    "video_completed": 0,
    "video_started_watching": 1
}
15 Apr
9 months ago

aligajani started a new conversation The Class $tries Setting On The Queue Job Isn't Being Honored, But The CLI One Is

I am setting public $tries = 0; on the class that implements ShouldQueue.

This is not being honored at all. However if I set the --tries=0 on the CLI, it works fine.

aligajani started a new conversation Using Queue Driver Sync For My Event Is Blocking If There's An Exception/error

Shouldn't it continue the user's journey despite the queued event error/exception?

24 Mar
9 months ago

aligajani started a new conversation Radio Button Not Honoring Checked State When Inside A Custom Component

Here is the component.

Vue.component('singleselect', {
    template: `
    <div>
        <p class="form__answer">
            <input type="radio" :id="meta.id" :value="meta.value" @click="notifyParent($event.target.value)"
            <label :for="meta.id">
                {{ meta.value }}
            </label>
        </p>
    </div>
    `,
    methods: {
        notifyParent(selected) {
            this.$emit('toparent', {type: this.meta.type, data: selected});
        }
    },
    props: {
        meta: {
            type: Object,
            required: true
        }
        
    }
});

Here is the usage:

                    <singleselect @toparent="inbound($event)" :meta="{type: 'gender', id: 'male', value: 'Male'}"></singleselect>
                    <singleselect @toparent="inbound($event)" :meta="{type: 'gender', id: 'female', value: 'Female'}"></singleselect>                         

Problem is that when I check Male or Female, both of them get checked. Using the earlier simpler way of using v-model didn't cause this issue however. Also, advise me on whether I can shove @toparent somewhere inside the component than outside? But that's a side question if you have time.

23 Mar
9 months ago

aligajani left a reply on Can I Use Mix Outside Of A Laravel Project?

@Cronix I am not looking to use PHP whatsoever because my app's frontend will live entirely on S3/Cloudfront. In that case, how would I go about versioning.

aligajani left a reply on Can I Use Mix Outside Of A Laravel Project?

@Cronix Thanks for that SitePoint link by the way.

But I still don't see how I can use mix() outside of Laravel.

The example in the article is tightly coupled to Laravel.

I don't think the standalone Mix lets us version at all?

In that case, how would I version. Any ideas?

aligajani left a reply on Can I Use Mix Outside Of A Laravel Project?

Thanks @Cronix and @tykus

Any thoughts on whether vue-cli versus Mix ?

aligajani started a new conversation Can I Use Mix Outside Of A Laravel Project?

I really like the simplicity that Mix brings, but I was wondering if I can use it outside of a Laravel project entirely that is a separate frontend hosted on S3? It seems that it is tightly coupled to the Laravel framework?

Also, a separate question. I see that vue-cli can help me achieve what I want, so why would I use Mix? I understand that it has batteries in form of BrowserSync, version hashes etc, but what else should I keep in mind?

22 Oct
1 year ago

aligajani started a new conversation Can I Have Composer Dump-autoload -o In My Composer Scripts Instead Of Php Artisan Commands?

Because having php artisan clear-compiled or php artisan optimize always results into ReflectionException. So would it make sense if I have this bit of snippet in my composer.json script section.

"post-install-cmd": [
            "composer dump-autoload -o"
        ],
        "post-update-cmd": [
            "composer dump-autoload -o"
        ],
18 Oct
1 year ago

aligajani left a reply on ReflectionException Thrown On Composer Update For A File That Exists

@Snapey I tried that too. Still the same.

 protected $subscribe = [
        BoardEventListener::class
    ];

aligajani started a new conversation ReflectionException Thrown On Composer Update For A File That Exists

To make this more interesting, things work just fine if I run composer dump-autoload -o but I am curious why would this throw an error when I run composer update in the first place? I need to get to the bottom of this. A quick fix doesn't make me happy internally.

aligajani at Alis-MBP in ~/Projects/saveeo on master ✗                                                                                    [faaba41c]  4:53
> composer update
> php artisan clear-compiled
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Package guzzle/guzzle is abandoned, you should avoid using it. Use guzzlehttp/guzzle instead.
Generating autoload files
> php artisan optimize

                                                                  
  [ReflectionException]                                           
  Class Saveeo\Board\Observers\BoardEventListener does not exist  

BoardEventListener.php (placed in Saveeo/Board/Observers)

<?php

namespace Saveeo\Board\Observers;

use Saveeo\Services\HashIds\Contracts\HashIds as HashIdService;

class BoardEventListener {

    private $hashIdService;

    public function __construct(HashIdService $hashIdService)
    {
        $this->hashIdService = $hashIdService;
    }

    public function whenBoardIsCreated($event)
    {
        $this->hashIdService->syncHashIdValueOnModelChanges($event, 'board');
    }

    public function whenBoardIsUpdated($event)
    {
        $this->hashIdService->syncHashIdValueOnModelChanges($event, 'board');
    }

    public function subscribe($events)
    {
        $events->listen(
            'Saveeo\Board\Observers\Events\BoardHasBeenCreated',
            'Saveeo\Board\Observers\[email protected]'
        );

        $events->listen(
            'Saveeo\Board\Observers\Events\BoardHasBeenUpdated',
            'Saveeo\Board\Observers\[email protected]'
        );

    }

}

EventServiceProvider.php (placed in Saveeo/Providers)

<?php

namespace Saveeo\Providers;

use Illuminate\Contracts\Events\Dispatcher as DispatcherContract;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;

class EventServiceProvider extends ServiceProvider
{
    /**
     * The event listener mappings for the application.
     *
     * @var array
     */
    protected $listen = [
        //
    ];

    /**
     * The subscriber classes to register.
     *
     * @var array
     */
    protected $subscribe = [
        'Saveeo\Board\Observers\BoardEventListener',
    ];

    /**
     * Register any other events for your application.
     *
     * @param  \Illuminate\Contracts\Events\Dispatcher  $events
     * @return void
     */
    public function boot(DispatcherContract $events) {
        parent::boot($events);

        //
    }
}
17 Oct
1 year ago

aligajani left a reply on Event Subscriber Class Not Found.

@mstnorris This is a hack to solve the problem but I am facing a similar issue and I don't think the root cause is yet to be found. Running composer update should not throw up this error anyway. What might be happening behind the scenes that it is unable to find the file, but it finds it just fine when we run composer dump-autoload -o?

03 Sep
2 years ago

aligajani left a reply on Gulp --production

Same here, any clue?

07 Aug
2 years ago

aligajani left a reply on Retrieving ID Of Updated Record From Closure Query?

@Ruffles Thanks man. Any chance you'd be able to put your words into code by modifying your older example?

05 Aug
2 years ago

aligajani left a reply on Retrieving ID Of Updated Record From Closure Query?

@Ruffles Looks good but it's not scalable. What if I supply relations array. It will not generate the update queries itself?

10 Jul
2 years ago

aligajani left a reply on Retrieving ID Of Updated Record From Closure Query?

@Ruffles Okay, thanks. What if I am trying to access 2 or more relations. How would that work?

aligajani started a new conversation Retrieving ID Of Updated Record From Closure Query?

I am unable to retrieve the ID of the record which is being updated from the below update command. Also, it is strange that when a model is being updated, the updating event never fires.

$this->model->with([$relation => function ($query) use ($column, $value){
                $query->update([$column => $value]);
            }])->whereId($id)->get();
25 Jun
2 years ago

aligajani started a new conversation Ansible Playbooks For Laravel 5

Hey Laracasts,

I would like to share a project I have been working on for the last few nights.

https://github.com/aligajani/ansible-playbooks-laravel-5

30 Jan
2 years ago

aligajani left a reply on How To Properly Do Caching In Laravel 5.2?

@crazytoon Makes sense. I shall try that. On another note, if I am eager loading and I cache an related model separately, would the eager loading call respect the cached item or hit the database directly. How should I approach this. maybe @someguy123 can chip in too.

aligajani left a reply on How To Properly Do Caching In Laravel 5.2?

@someguy123 Hey man, thanks for your reply. I know that. Can you have a glance at this and see if Laravel does something like this internally, or we should craft stuff like this on our own. https://signalvnoise.com/posts/3113-how-key-based-cache-expiration-works

aligajani started a new conversation How To Properly Do Caching In Laravel 5.2?

I am intending to build a caching layer for an app that I am working on. The current Laravel 5.2 caching library is very helpful when it comes to remembering queries and shoving them in memcached for an X amount of time.

Let's say I shove a note/1 into the cache. Now a user updates the cache. I see no mechanism of invalidation here. Do I have to build this on my own or is there some hidden Laravel magic ?

Basically, a user creates a note. It goes into cache and gets remembered forever. Then, he accesses it again. It's a cache HIT. Now, he changes a word in it. I want a mechanism of invalidating, re-caching and returning the item.

23 Dec
3 years ago

aligajani left a reply on Error When Attempting To Use Homestead W/ PHP-7

I did the same @joedawson and I still get php5-fpm: unrecognized service

aligajani left a reply on Error When Attempting To Use Homestead W/ PHP-7

Still 502, I updated the .sock to php7.0

23 Nov
3 years ago

aligajani left a reply on Why Is My Artisan Command Not Running?

Right, and it gives me this:

  [ErrorException]                                     
  array_merge() expects at least 1 parameter, 0 given 

aligajani left a reply on Why Is My Artisan Command Not Running?

@martinbean ,and how do I run the command?

aligajani left a reply on Why Is My Artisan Command Not Running?

@martinbean Thank you for your reply, but I get this below

aligajani@Alis-iMac:~/Code/base-api$ ./artisan backport-purchases --site-url="learn.x.com"
                                          
  [InvalidArgumentException]               
  The "site-url" argument does not exist.  
   
backport-purchases [--site-url="..."]

aligajani left a reply on Why Is My Artisan Command Not Running?

@toniperic

"Option mode \"learn.x.com or learn.y.com\" is not valid.

aligajani left a reply on Why Is My Artisan Command Not Running?

@EliasSoares Okay, and what is your command like?

aligajani left a reply on Why Is My Artisan Command Not Running?

Doesn't work either. @EliasSoares , that didn't work either, says, option does not exist.

aligajani left a reply on Why Is My Artisan Command Not Running?

Guys, I am using Laravel 4.2.

Of course, it is registered.

aligajani started a new conversation Why Is My Artisan Command Not Running?

I have this and whenever I try to run it like:

php artisan commandName --site-url=learn.x.com it says:

                                           
  [RuntimeException]                       
  The "--site-url" option does not exist.  
                                           
  public function getArguments() {
        return [
            ['site-url',
             InputArgument::REQUIRED,
             "learn.x.com or learn.y.com"]
        ];
    }
19 Nov
3 years ago

aligajani left a reply on Laravel 'No Space Left On Device' Error

Guys, here is some update:

Filesystem      Size  Used Avail Use% Mounted on
/dev/xvda1      7.8G  4.5G  2.9G  61% /
none            4.0K     0  4.0K   0% /sys/fs/cgroup
udev            3.9G   12K  3.9G   1% /dev
tmpfs           799M  408K  799M   1% /run
none            5.0M     0  5.0M   0% /run/lock
none            3.9G  4.0K  3.9G   1% /run/shm
none            100M     0  100M   0% /run/user

aligajani started a new conversation Laravel 'No Space Left On Device' Error

Guys, recently, my app with 2000+ users is having issues.

It shows a whoops since a few days and this is the error. Any one know what's up?

I temporarily resolve this with cache:clear but it seems to popup again.

[2015-11-19 12:29:19] production.ERROR: exception 'ErrorException' with message 'file_put_contents(/home/forge/default/app/storage/sessions/764dc5150bd00eafb9b032c57f9dd16b1b278d8d): failed to open stream: No space left on device' in /home/forge/default/bootstrap/compiled.php:4221
Stack trace:
#0 [internal function]: Illuminate\Exception\Handler->handleError(2, 'file_put_conten...', '/home/forge/def...', 4221, Array)
#1 /home/forge/default/bootstrap/compiled.php(4221): file_put_contents('/home/forge/def...', 'a:4:{s:6:"_toke...', 2)
#2 /home/forge/default/vendor/laravel/framework/src/Illuminate/Session/FileSessionHandler.php(69): Illuminate\Filesystem\Filesystem->put('/home/forge/def...', 'a:4:{s:6:"_toke...', true)
#3 /home/forge/default/bootstrap/compiled.php(7999): Illuminate\Session\FileSessionHandler->write('764dc5150bd00ea...', 'a:4:{s:6:"_toke...')
#4 /home/forge/default/bootstrap/compiled.php(7849): Illuminate\Session\Store->save()
#5 /home/forge/default/bootstrap/compiled.php(7827): Illuminate\Session\Middleware->closeSession(Object(Illuminate\Session\Store))
#6 /home/forge/default/bootstrap/compiled.php(8432): Illuminate\Session\Middleware->handle(Object(Illuminate\Http\Request), 1, true)
#7 /home/forge/default/bootstrap/compiled.php(8379): Illuminate\Cookie\Queue->handle(Object(Illuminate\Http\Request), 1, true)
#8 /home/forge/default/bootstrap/compiled.php(11049): Illuminate\Cookie\Guard->handle(Object(Illuminate\Http\Request), 1, true)
#9 /home/forge/default/bootstrap/compiled.php(657): Stack\StackedHttpKernel->handle(Object(Illuminate\Http\Request))
#10 /home/forge/default/public/index.php(49): Illuminate\Foundation\Application->run()
#11 {main} [] []

03 Oct
3 years ago

aligajani left a reply on S3 Has Suddenly Stopped Uploading My Files

God dammit, I ran this on my OSX and it fixed it.

ntpdate us.pool.ntp.org

aligajani left a reply on S3 Has Suddenly Stopped Uploading My Files

Okay I ran composer update, now getting this:

Next exception 'Aws\S3\Exception\S3Exception' with message 'Error executing "PutObject" on "https://s3-eu-west-1.amazonaws.com/saveeo/laravel/uploads/l2297010978132d175116353e243b0a6.jpg"; AWS HTTP error: Client error response [url] https://s3-eu-west-1.amazonaws.com/saveeo/laravel/uploads/l2297010978132d175116353e243b0a6.jpg [status code] 403 [reason phrase] Forbidden RequestTimeTooSkewed (client): The difference between the request time and the current time is too large. - <?xml version="1.0" encoding="UTF-8"?>
<Error><Code>RequestTimeTooSkewed</Code><Message>The difference between the request time and the current time is too large.</Message><RequestTime>20151003T184331Z</RequestTime><ServerTime>2015-10-03T19:11:01Z</ServerTime><MaxAllowedSkewMilliseconds>900000</MaxAllowedSkewMilliseconds><RequestId>269881828C041E99</RequestId><HostId>r67ymAQ04Ke+KnZMPeCttymWAOnbuNzQpYnXMwVlUerHwFvnXbdgi4ydUKLtMYs0TVJSMa2TLHY=</HostId></Error>' in /home/vagrant/mrgeeklabs/saveeo/vendor/aws/aws-sdk-php/src/WrappedHttpHandler.php:152

aligajani started a new conversation S3 Has Suddenly Stopped Uploading My Files

I am getting this weird error and nothing in my code has changed ever since, everything remains the same. Basically, I come back 2 weeks later to my repository and try to upload a file on S3, and I get this:

403 Forbidden (Request-ID: 1F717BDD47C48BA2)

Precisely, this is the error in more detail:

Next exception 'Aws\S3\Exception\S3Exception' with message 'Error executing "HeadObject" on "https://s3-eu-west-1.amazonaws.com/saveeo/laravel/uploads/hbf4a43d46371c22e4a04e2558047872.jpg"; AWS HTTP error: Client error response [url] https://s3-eu-west-1.amazonaws.com/saveeo/laravel/uploads/hbf4a43d46371c22e4a04e2558047872.jpg [status code] 403 [reason phrase] Forbidden (client): 403 Forbidden (Request-ID: 1F717BDD47C48BA2) - ' in /home/vagrant/mrgeeklabs/saveeo/vendor/aws/aws-sdk-php/src/WrappedHttpHandler.php:152

06 Sep
3 years ago

aligajani started a new conversation Why Is FormRequest Assuming My Payload Data Structure?

Usually FormRequests work fine if the data structure is like:

[ 'id' , 'name', 'age' ] but it breaks down when the data incoming is [ 'user' => [ ] ].

It says, fields are required even when they're there.