ashitvora

ashitvora

Member Since 5 Years Ago

Experience Points
14,935
Total
Experience

65 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
223
Lessons
Completed
Best Reply Awards
4
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.

Level 3
14,935 XP
Jul
26
2 months ago
Activity icon

Started a new conversation How To Display Image From External Source In Nova's Resource List Page

I have a data imported from an external source and want to display an image on the index page. The link to the URL is pointing to S3 but when I use Image field, it prepends app's resources URL to the image and hence image link is broken.

Aug
02
1 year ago
Activity icon

Started a new conversation Need Help In Approaching The Problem

I am working on a product which allows customers to create forms. We provide customers with different templates as the starting point so they can just modify it. One option they have is to choose blank slate so they can build the form from scratch.

The current approach is to use the template as the base and allow users to modify colors, font style, font size etc and it is different for every template that we add. So it's not a generic solution. I wonder if there's a better way to tackle this problem.

What I want at the end is to have an HTML which can be rendered with Vue to handle logic like whether the field is required or not, whether selection one field affects other fields or not (selecting country as the US shows States dropdown whereas, for any other country, states dropdown is not shown, etc).

Any suggestion is very much appreciated.

Thanks :)

Jul
26
1 year ago
Activity icon

Started a new conversation How To Create A Site On Load Balancer Server Created Using Forge?

I have a Load Balancer server created using Forge and I have 5 app servers behind that so requests are balanced between these 5 app servers.

My app allows the user to use their domain name so the approach I am taking is...

  • I ask the user to create an A Record and point their domain to my IP Address
  • Once the user has created the A Record, I manually create a site on the Load Balancer server and configure it to balancer load between all 5 app servers.
  • I then create and activate the SSL Cert created using LetsEncrypt

Now what I need to do is to automate last 2 steps.

I do not see any way to add a site to load balancer server in Forge APIs. Am I missing anything?

Jul
18
1 year ago
Activity icon

Started a new conversation What Ping Path To Specify For ELB?

I am using AWS Classic ELB and when I specify Ping Path as just "/" ELB is marking EC2 as OUT OF SERVICE.

Looks like its not able to reach it. What should be the protocol and path for Pinging the EC2 instances.

Do I need to make any changes in NGINX config on EC2 instances?

May
31
1 year ago
Activity icon

Replied to Downgrading Plan In Forge

@bobbybouwmann It's a monthly plan but irrespective of that, one can not downgrade. If you wish to downgrade, you need to delete that account and create a new one with lower plan. Deleting an account means have to start new instance of the server in new account otherwise existing server wouldn't show up. It kills the whole purpose of using Forge in first place.

Activity icon

Started a new conversation Downgrading Plan In Forge

Hi,

I had signed up for Laravel Forge 2 months ago. Initially, I was on the lowest plan - Hobby and then upgraded since I wanted staging and production server to be different. Then later client decided to move production on AWS with their forge account and hence there was no need for me to have upgraded plan of forge.

Looks like there's no way we can downgrade the plan in forge. That's what their support staff says. Not sure if this is true. If it is, isn't it unethical?

Best Regards, Ashit

Mar
31
1 year ago
Activity icon

Replied to What's The Best Way To Pull Data From Multiple Sources In Eloquent?

@biishmar this will actually paginate users and return all Posts and Comments of every user in descending order.

I want to paginate the UNION of Posts and Comments of the logged in user.

Mar
30
1 year ago
Activity icon

Replied to How Do I Join Two Queries And Then Paginate

@kobear What would be the solution for a similar problem but data is coming from 2 different tables not having similar database structure.

Activity icon

Replied to What's The Best Way To Pull Data From Multiple Sources In Eloquent?

This will return me Posts along with Comments. I need only posts or comments which are added a specific User.

So it will be a collection of objects of both Post and Comment class.

Activity icon

Started a new conversation What's The Best Way To Pull Data From Multiple Sources In Eloquent?

I have a use case where a User can create multiple Posts and Comments. So... User hasMany Posts User hasMany Comments.

I want to pull data which contains both Posts & Comments made by a specific User sorted in descending Order and Paginated.

Current what I did is.. I pull all the Posts and Comments and merge them using Laravel Collection's merge method. After that, I pass it through LengthAwarePaginator.

But with this approach, I have to pull all the Posts and Comments by a specific user which obviously is not good. Is there a better way to tackle this problem in Eloquent.

Thanks in advance :)

Mar
29
1 year ago
Activity icon

Replied to What's The Best Way To Conditionally Hide Certain Properties Of A Relationship?

I am using Policies to check if user can visit a specific route or not. But here it is more of removing certain data based on who is visiting.

Wondering if Middleware is the right place to change the data

Activity icon

Started a new conversation What's The Best Way To Conditionally Hide Certain Properties Of A Relationship?

I have a use case like below... User hasMany Posts Post hasMany Comments Comment belongsTo User

The users can see all the posts, its comments, and the name of the person who commented but the owner of the post can see the Email address of the person who commented other shouldn't be allowed to see it.

Now, I am not passing this data to view but sending it as a JSON response.

What's the best way to approach this problem?

Mar
28
1 year ago
Activity icon

Replied to Lots Of Javascript Created On Running Mix

I had to change mix.config.isProduction to mix.config.production

Activity icon

Replied to Lots Of Javascript Created On Running Mix

Sorry for the late reply but here it is...

let mix = require('laravel-mix');
let ImageminPlugin = require('imagemin-webpack-plugin').default;
let CopyWebpackPlugin = require('copy-webpack-plugin');
let imageminMozjpeg = require('imagemin-mozjpeg');

/*
 |--------------------------------------------------------------------------
 | Mix Asset Management
 |--------------------------------------------------------------------------
 |
 | Mix provides a clean, fluent API for defining some Webpack build steps
 | for your Laravel application. By default, we are compiling the Sass
 | file for the application as well as bundling up all the JS files.
 |
 */

mix.js('resources/assets/js/app.js', 'public/js')
    .sass('resources/assets/css/style.scss', 'public/css')
    .webpackConfig({
      plugins: [
        new CopyWebpackPlugin([{
          from: 'resources/assets/img',
          to: 'img', // Laravel mix will place this in 'public/img'
        }]),
        new ImageminPlugin({
          test: /\.(jpe?g|png|gif|svg)$/i,
          plugins: [
            imageminMozjpeg({
              quality: 80,
            })
          ]
        })
      ]
    });

if (mix.config.production) {
    mix.version();
}
Mar
07
1 year ago
Activity icon

Replied to What's The Best Way To Test A Feature Not Dealing With Calling Third Party API?

I am firing an event when the link is clicked if the first link was already clicked. Is there a way to check if event was fired using automated test?

Activity icon

Replied to What's The Best Way To Test A Feature Not Dealing With Calling Third Party API?

Yes, I can mimic the click event but not sure about... use the mail facade to check if the new email was sent.

Any link you can point me to read more on this?

Mar
06
1 year ago
Activity icon

Started a new conversation What's The Best Way To Test A Feature Not Dealing With Calling Third Party API?

I am working on an app were two people receive an email with 2 links.

  1. Accept
  2. Reject

When both the parties click on ACCEPT link, I want to send an email.

What's the best way to test this using an automated test to make sure email is only sent out when both the parties click ACCEPT.

The default state is PENDING and once the user clicks on any one of the links, the state is changed to ACCEPTED or REJECTED.

Feb
21
1 year ago
Activity icon

Replied to Mix Compiles Bulma Incorrectly

Issue was, my mistake I was trying to load CSS via Script tag. Sorry, couldn't find any option to delete this thread.

Activity icon

Replied to Laravel Mix Doesn't Compile Sass Files

Found the issue. I had missed semi colon after the first import. :(

Activity icon

Started a new conversation Lots Of Javascript Created On Running Mix

Running mix creates quite alot of random javascript files with names like... 0.js 1.js 2.js, etc in public folder.

Is there a way to not have those file?

Activity icon

Started a new conversation Mix Compiles Bulma Incorrectly

I am importing Bulma and Buefy in my style.scss and it compiles without any compile time error but when I load it in the browser, it throws error in the very first line that starts with

@-webkit-keyframes

See screenshot of error message here - https://www.screencast.com/t/39BRVaLE

Feb
15
1 year ago
Activity icon

Started a new conversation Laravel Mix Doesn't Compile Sass Files

I am trying to import Bulma Extensions. Laravel Mix complies all Scss files but not Sass file. It throws this error when we import sass file...

Media query expression must begin with '('

Any idea how to fix this?

Sep
04
2 years ago
Activity icon

Replied to Checking Authority Throws Error

looks like the issue is with @canelse

Sep
02
2 years ago
Activity icon

Replied to Checking Authority Throws Error

Ok. I found one more thing. It throws an error even when I return hard coded false.

Activity icon

Replied to Checking Authority Throws Error

Moreover, the error doesn't seem to be related to Logic. Is it?

Undefined property: Illuminate\Auth\Access\Gate::$check

Unfortunately, googling this sentence doesn't report anything so looks like it's just me facing this issue.

Activity icon

Replied to Checking Authority Throws Error

It works fine if I keep the logic as is but return hard coded true/false.

Gate::define('accessPitch', function ($loggedInUser) {
    $userTags = $loggedInUser->tags()->get()->pluck('id');
    $pitchTags = \App\Entities\Tag::where("name", "like", "PITCH_%")->get()->pluck("id");

    $hasCommonTags = (bool) $userTags->intersect($pitchTags)->count();

    // return $hasCommonTags;
    return true;
});

I also did dd of $hasCommonTags and it returned boolean value. And anyway I'm typecasting it so that shouldn't matter.

Activity icon

Replied to Checking Authority Throws Error

Gate::define('accessPitch', function ($loggedInUser) {
    $userTags = $loggedInUser->tags()->get()->pluck('id');
    $pitchTags = \App\Entities\Tag::where("name", "like", "PITCH_%")->get()->pluck("id");

    $hasCommonTags = (bool) $userTags->intersect($pitchTags)->count();

    return $hasCommonTags;
});

I'm returning boolean value and its throwing error but if I replace the logic with just

return true;

it works without any error.

Activity icon

Started a new conversation Checking Authority Throws Error

I have a policy defined in AuthServiceProvider and in blade file, I access it using @can and it throws following error.

Undefined property: Illuminate\Auth\Access\Gate::$check
Unfortunately, googling this sentence doesn't report anything so looks like it's just me facing this issue.

I'm on Laravel 5.4.

Policy Check in Blade File

@can("use-some-module")
    You have access
@elsecan
    You DO NOT have access
@endcan

Policy Defined in AuthServiceProvider

Gate::define('use-some-module', function ($loggedInUser) {
    return <can access or not>
});
Jun
30
2 years ago
Activity icon

Started a new conversation How To Create CORS Proxy In Laravel?

I'm trying to add an image to HTML5 canvas and source of the URL is cloud front. Now I need to proxy it through my domain as cross origin request doesnt work on canvas.

How can I create a simple proxy using Laravel.

like....

/proxy?url=cloudfronturl

May
26
2 years ago
Activity icon

Replied to How Can I Get Domain Name Used To Visit An App?

@sorcjc $domain = preg_replace('#^https?://#', '', Request::root());

Request is a facade (Illuminate\Support\Facades\Request)

Apr
08
2 years ago
Activity icon

Started a new conversation SSO For Suite Of Apps

I've a bunch of web apps all on different subdomain. I wish to allow users to be able to switch back and forth between different applications w/o having to login to each and every app. This is very much similar to 37Signal's Launchpad which allows their users to jump back and forth between Highrise, Basecamp, Campfire and other apps in their suite.

What's the best way to implement this in Laravel?

Feb
28
2 years ago
Activity icon

Replied to Route Caching In Laravel 5

I'm using Laracollective's annotations package and somehow I've started getting this error and it is driving me nuts.

Aug
16
3 years ago
Activity icon

Replied to How Can I Get Domain Name Used To Visit An App?

I'm using Annotations package by Laracollective. Any way to use that and still get the current domain?

Activity icon

Started a new conversation How Can I Get Domain Name Used To Visit An App?

Use case is, I wish to have same app which serves Main App as well as all White Labeled users. So depending on the Domain user is accessing the app from, I want to display branding and for that I need to know the domain that was used to access this app.

What is the best way to get it?

Aug
12
3 years ago
Activity icon

Replied to How To Run Certain Task At Certain Time?

Scheduling allows us to run certain Command at certain time like a Cron Job but in my case, every event inside it should be fired at a certain time.

Eg. If there are 100 customers, when I pull data for all hundred customers, I will get different number of records and based on that I need to decide when should I again pull records for this customer. So though command runs every minute, it shouldn't pull data every minute.

Activity icon

Replied to RedIrect To Homepage On 404 Error

@mezie Can you paste little more code? Is it like when you make a request to get some resource (Project in your case) and if it is not found, you want to redirect to Home page?

In that case handle ModelNotFoundException in app/Exceptions/Handler.php

Activity icon

Started a new conversation How To Run Certain Task At Certain Time?

Scenario is... I pull certain data from a third party service which return data in chunks of 1000. Now if there are say 10000 records, I need to make 10 different calls.

There is another limitation on how many requests I can make per hour.

So what I wish to do is... depending on how many records I got in this request, I want to schedule next request. So if in current request I got 10K records, next request should go after 2 hrs. If there are 1000 records, next should go in 10 minutes.

Is there any way to do so?

I'm using SQS if there's any way to tell SQS to send me next job after 2hrs or so on.

Thanks in advance.

Aug
09
3 years ago
Activity icon

Started a new conversation What Is The Best Way To Start Multiple Workers And Restart During Deployment?

I've an app where I queue all the requests as they come in but looks like by default forge only creates one worker. Is there a way to start multiple workers so multiple requests can be handled simultaneously.

Also, is there a way to restart worker during every deployment so I don't have to manually do so every time from forge.

Activity icon

Started a new conversation What Is The Best Place To Cache The Data?

In one of my apps I've to make dozens of call to third party application to get the exact data I want and it also limits the number of api requests I can make.

To overcome the delayed response and api throttle problem, I wish to cache the data.

What is the best place to cache the data - Controller or the Service that fetches the data?

At the moment it feels like it should be cached in the Controller since the data I need to generate unique key is in controller and is not being passed to the service. But wondering if Controller should have knowledge about caching stuff. Or should I add one more layer in between Controller and Service which does the caching and forward the request to Service only when there is Cache miss.

Jun
22
3 years ago
Activity icon

Replied to Class 'Dotenv' Not Found In Compile.php After Upgrade

Ran into same issue. @karatechops 's solution worked. :)

May
28
3 years ago
Activity icon

Replied to How To Better Handle "trying To Get Property Of Undefined" Error

Ah! let me check. Wondering if I can have getContactsAttribute when I have contacts relationship.

Activity icon

Replied to How To Better Handle "trying To Get Property Of Undefined" Error

@Snapey How to handle the situation when note itself is not found?

What I have is...

User has contact details and contact details has different properties like phone1, phone2,....phone5.

Now if I try to echo $user->contacts->phone5, there are chances that contact relationship was never created so what I do at the moment is to check if contact exists or not for every property I try to access. Was wondering if there's a better approach to handle this.

Ideally what I would expect is to set all possible fields on contact in Model and when relationship is not found, it returns and object with these properties. Or something similar that is easier to handle.

May
27
3 years ago
Activity icon

Replied to Can Laravel 5 Use Raw PHP Libraries

Not on top of Controller of course but within your controller methods.

eg.

namespace \App\Http\Controllers;

use \App\Http\Controller;
use Scheb\YahooFinanceApi\ApiClient;

class MyController extends  Controller{
    protected $apiClient;

    public __construct(){
        $apiClient = new \Scheb\YahooFinanceApi\ApiClient();
    }
}
Activity icon

Started a new conversation How To Better Handle "trying To Get Property Of Undefined" Error

Many a times we want to display property from a relationship but it sometimes happen that the relationship doesn't exist at all and hence app starts throwing "trying to get property of undefined/non-object" error.

Is there a better way to handle this than checking each and every time we display a property?

May
26
3 years ago
Activity icon

Replied to Install Wordpress With Laravel In Same Domain In Folder Blog

Installing wordpress as subfolder in Laravel.

This is what I tried

location @wp {
  rewrite ^/wordpress(.*) /wordpress/index.php?q=$1;
}

location ^~ /wordpress {
    root /var/www/example.com;
    index index.php index.html index.htm;
    try_files $uri $uri/ @wp;
    location ~ \.php$ {
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $request_filename;
        fastcgi_pass 127.0.0.1:9000;
    }
}

But it throws No input file specified error.

May
25
3 years ago
Activity icon

Replied to Install Wordpress With Laravel In Same Domain In Folder Blog

@bashy Wondering if you have nginx config handy.

Activity icon

Replied to Queue Handler Is Never Called

I found out what the issue was. Not deleting this thread since somebody else may also face the same problem. The issue was I didn't kill my Digital Ocean server and hence supervisor was still running there and listening for Jobs on SQS queue. And in some cases, job was handled by the Worker of Digital Ocean server and updating wrong database. Hence AWS server (which is the actual server) never got chance to process it. :(

Activity icon

Replied to How To Globally Set UK Date Format In Carbon To Auto Update For BST

Dealing with Timezones was tedious in one of my apps and the solution I came up with was...

  • Store dates in UTC in the database
  • In View, instead of displaying date, put it in "data-timestamp" attribute of the HTML Element in which you want to display date.
  • Now use MomentJS to loop through all the element containing "data-timestamp" attribute and display Relative (Humanize) time in that HTML Element.
  • I put this is setInterval so it gets invokes every 60 seconds and update the relative time.
  • What I also make sure is that if time difference is more than 24 hrs, I display Day of the Week and if time difference is more than 7 days, I display Date and Month.

This might work in your case as well.

Activity icon

Replied to Sending Email To A Particular Recipient Based On Day And Time

If one user can have multiple time availability then store it in a different table.

Users

Availability

Relationship -> User hasMany Availability