dhiman252

dhiman252

Member Since 3 Years Ago

Experience Points 6,780
Experience Level 2

3,220 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 53
Lessons
Completed
Best Reply Awards 0
Best Reply
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.

25 Nov
2 years ago

dhiman252 left a reply on Socket.io & Redis

I did this with the concept that each message has a sender and receiver object so i created an object with the key sender-receiver so with every message we have a unique key sender-receiver or receiver-sender, so as a message is received it just checks for the current chat object has property of senderKey-receiverKey or receiverKey-senderKey and just pushes the message into the object key array.

01 Aug
2 years ago

dhiman252 started a new conversation Eloquent Relations With Dynamic Parameters

Is there any way that we can pass dynamic parameters to the with query at runtime ? lets say i have the following code:

$user->task()->with('quotes')->get()

Now i want the 'quotes to receive a parameter, so the query would be'

quotes = 5

How can I further substitute a value to the with relation ?

09 Jul
2 years ago

dhiman252 started a new conversation Multiple Laravel Projects On One Server In Different Directories

I have configured 2-3 projects on my server in different directories, the problem I am facing is that when I request for one project(http://www.domain.com/project1) in the browser then after some time I request for another project(http://www.domain.com/project2) then abnormal behavior is seen. Following problems are being observed

  1. The user loges out during request
  2. "No supported encrypter found. The cipher and / or key length are invalid" - error occurs too frequently, not sure have to run the command "php artisan key:generate" but its a temporary fix.
  3. Sometimes the configuration for the project are not loaded, I have set all the parameters for the project in the.env file still sometimes unable to load configurations and database error is displayed is some spanish language
  4. 'Token mismatch' also but not too frequently.

I don't know whether its the bug with the framework or I need to do something with my configurations.

06 Jul
2 years ago

dhiman252 started a new conversation Some Jobs To Sycn And Some To Database

Hi, with Laravel v5.2.* Is there any thing that some jobs mus run immediately and some to database for queue ?

11 Jun
3 years ago

dhiman252 left a reply on Show Users Online

@jekinney can you please put some light on the code, I liked your concept but need to scratch my head to put this to work,so can you please show some code stuff ?

dhiman252 left a reply on Show Users Online

@cklmercer I tried the way you told me but the problem is that if a user navigates from one URLto another his status changes online to offline as I emit on the disconnect event for socket.io, what I want is that whether a user navigates across my web app his status to be fixed online and if the user loges out or closes the browser then it should go offline, how about doing this with socket.io and redis?

10 Jun
3 years ago

dhiman252 started a new conversation Show Users Online

I have to show how many users are online currently, i am using the laravel v5.2, what would be the best way to this approach 1)Using the socket.io 2)redis session

08 Jun
3 years ago

dhiman252 started a new conversation Laravel V5.2 Website Like : Domain.com/{locale}

How can this domain.com/{locale} be achieved in laravel v5.2 ?

dhiman252 left a reply on Example On How To Use Multiple Locales In Your Laravel 5 Website

Does this works well for laravel v5.2 ?

25 May
3 years ago

dhiman252 left a reply on Eloquent Query Bindings Does Not Work Properly

I guess there is an parameter bindings which is not working as expected.

dhiman252 left a reply on Eloquent Query Bindings Does Not Work Properly

It means that in my EventServiceProvider(ESP ) I have place the DB::listen and using that the following code generates the raw query which works fine but the following code does not provide the results $notifications = Notify::with('quote.task.professional','quote.task.user','quote.owner') ->where(function($query) use ($quotes){ $query->whereIn('quote_id',[$quotes]) ->where('provider_seen', Notify::UNSEEN); }) ->whereNotNull('message_provider') ->orderBy('updated_at', 'desc') ->get();

Using DB::Listen in my ESP the following query is returned which when executed in the editor works well: select * fromnotificationswhere (quote_idin (?) andprovider_seen= ?) andmessage_provideris not null order byupdated_atdesc

dhiman252 started a new conversation Eloquent Query Bindings Does Not Work Properly

Please have a review at this link for description: https://github.com/laravel/framework/issues/13685

24 May
3 years ago

dhiman252 started a new conversation Localization

I have three languages(english,catalan, spanish) setup for my application with the structure described at https://laravel.com/docs/5.2/localization , Now what if I want a translated message in all the three languages ? Means echo trans('messages.welcome'); will give me the my app current language string, if my current language is english it will provide me with the english translation but i need this in all the languages, how can this be achieved ? Is there any function like echo trans('messages.welcome','en'); where we can specify the language I want my text to be translated to ?

dhiman252 left a reply on Self Invoking Command

@ vikramjeets I am already using the queues and have the priorities set, so how can supervisor may help me in this ?

Also using the chat i am storing the data in redis list like this redisClient.lpush('chat',JSON.stringify(chatObj),function (err, res) {});

and at server side I used to get the list contents like this $allData = \Redis::lrange('chat',0,-1); so is there any way using the supervisor can help me in this, I mean as the chat message gets pushed onto the list then I should be able to know and get it from the redis list and save it in my DB.

dhiman252 started a new conversation Self Invoking Command

I am working on a chat app and for this I have used the redis lists to store chat messages, now I want my messages to be save in the DB table, so for this I need to run redis command every minute and get all the data from redis list to my db table, now this can be done using the schedule cron job which is fine, so now is there any way like any command like artisan to call itself after some interval of time ? May be command line application would work ?

20 May
3 years ago

dhiman252 left a reply on Show Notification On Every Request From Database.

Service injection is better, so does it have the effect on the pages where i don't need the service but its injected into the header ?

dhiman252 started a new conversation Show Notification On Every Request From Database.

I have a notification section in my application, so when a user is logged in i want to fetch all the notifications from database and show the count to the user on header, so before every controller action i want to fetch all the notifications and show them.

What is the best possible way to proceed with this ?

I am using the laravel v5.2.*

dhiman252 left a reply on Socket.io & Redis

Yes, I used the socket.io for realtime chat and redis to store data also the redis as broadcast driver at the backend.

18 May
3 years ago

dhiman252 left a reply on Why Event Broadcast Is Queued ?

Looking at the configurations in the app\config\queues.php i have the following parameters for the database. 'database' => [ 'driver' => 'database', 'table' => 'jobs', 'queue' => 'default', 'expire' => 60, ], How to setup multiple queues ?

dhiman252 left a reply on Why Event Broadcast Is Queued ?

Thanks pmall, but i am recieving an error No connector for []

dhiman252 left a reply on Why Event Broadcast Is Queued ?

The problem is that i want the event to be broadcast in realtime, means i have two users chatting and at the same time if a user updates his request then it should immediately broadcast to other users means it should no be queued, the problem if i have many jobs queued in and then if this job is processed after the completion of other jobs it is then not realtime. I hope you got my point ?

dhiman252 left a reply on Why Event Broadcast Is Queued ?

Is this possible that every job to be executed as it is received, not the sync driver so there is no delay in user result. ?

dhiman252 left a reply on Why Event Broadcast Is Queued ?

Actually i want the user to update in realtime for the status of their request, so as i disclose their request it should not be queued insted it should broadcast there and then only. I am using the socket.io and redis for that. How can it be possible to not queue event broadcast when using queue driver database ?

dhiman252 left a reply on Why Event Broadcast Is Queued ?

This is my event class ` namespace App\Events;

use App\Events\Event; use Illuminate\Queue\SerializesModels; use Illuminate\Contracts\Broadcasting\ShouldBroadcast;

class NotifyQuoteUpdates extends Event implements ShouldBroadcast { use SerializesModels;

public $dataQuote;

/**
 * Create a new event instance.
 *
 * @return void
 */
public function __construct($quote)
{
    $this->dataQuote = $this->assignAttributes($quote);
}

public function assignAttributes($quote)
{
    $dataObj = new \stdClass();
    $dataObj->quote = $quote;
    $dataObj->owner = $quote->owner->showGlobally();
    return $dataObj;
}

/**
 * Get the channels the event should be broadcast on.
 *
 * @return array
 */
public function broadcastOn()
{
    return [
        $this->dataQuote->quote->task->fetchAlertPrefix()
    ];
}

} `

dhiman252 left a reply on Why Event Broadcast Is Queued ?

I don't have any event listener insted my event class itself broadcasts the message.

dhiman252 started a new conversation Why Event Broadcast Is Queued ?

I am using the queue driver as the database, now when i fire an event then it gets broadcast to my channel but i don't want to queue it, it should work like sync how can this be done ?

26 Apr
3 years ago

dhiman252 started a new conversation Socket.io & Redis

I am going to built an application where users can chat to each other, this chat would be one-to-one, Now i have seen the real-time-laravel-with-socket-io on laracast but how can two users will chat with each other ? Foe every two users will there be a channel created ? I really can't figure out that how the message from one user be visible to the intended user not all the users.

dhiman252 left a reply on Laracast Discount Coupon

Thanks Ruffles :) I got discount ;)

24 Apr
3 years ago

dhiman252 started a new conversation When To Use Events And Jobs

I am using the laravel v5.2.* and really confused when should I use events and job. Since event listeners are also queued like jobs so when to user event and when to use jobs ?

Also does laravel supports the identification of the same job placed in the queue at top and bottom ?

dhiman252 started a new conversation Laracast Discount Coupon

Hi Admin, Does Laracasts offers discount coupons to its subscribers ? I had a monthly subscription a few months back and till date I did'nt received any coupon code or offers urging me to join back. Well if we compare to the competitors like lynda.com or pluralsight.com they offers heavy discount to their users who have cancel their subscriptions.

23 Apr
3 years ago

dhiman252 left a reply on Event, Jobs And Queue

Well if my listener classes are getting queued I think then I should stick with the events approach as the same purpose is of creating a job, am I correct in this context ?

dhiman252 left a reply on Event, Jobs And Queue

I made some changes and yes the web response was very good, thanks. Below are my changes 1)Queue drive = database 2)In my event listener class I have added two traits ShouldQueue and InteractsWithQueue Now this works fine for me.

My question is that is the event approach better ? I mean how can I directly execute the job from my eloquent event ?

dhiman252 left a reply on Event, Jobs And Queue

Well thanks premsaurav, can you please provide me an example implementation so that i can get exactly what to do ? Right now I have change my queue driver to database and now I am searching that how a listener can call a job to be pushed on to the queue.

22 Apr
3 years ago

dhiman252 started a new conversation Event, Jobs And Queue

I am using the laravel v5.2.* in my one of the web application, now I need an expert advice in a situation described below: I am using the elastic search in my application, now i have data stored in my database as well as on the elastic server, my problem is that whenever a user is registered on my website I need to push their data to elastic server in order to create a document. For this situation I am currently using the events approach, like whenever a user is created or updated then I raise an event named as PushToElastic(An event file in events directory) when my eloquent saved event is fired.

Now I don't know the exact difference between Events,Jobs,Queues these are new to me with laravel 5.2

What I want is that when a user is created/updated I want to run background job which will update m elastic nodes irrespective of the user waiting for that job to be finished before the web response is generated.

How can I schedule a background job as eloquent saved event is fired without any delay in web response to the user ?

16 Apr
3 years ago

dhiman252 started a new conversation Laravel Log

I want to Log each query and for this I am using the Db:listen() in the EventServiceProvider File, now I want generate a separate log file for every hour which will only contain the queries fired.

Now what is the best possible way to make a separate log file (only for the queries) generated every hour ?

15 Apr
3 years ago

dhiman252 left a reply on Blade And Angular Mixing

Thanks all :)

dhiman252 left a reply on Blade And Angular Mixing

@spekkionu

user is an angular variable and if I tried to remove the @symbol I receive an error that user is undefined.

@ mehany I cannot change it now as the application has been built can you suggest any other way to deal with this ?

13 Apr
3 years ago

dhiman252 started a new conversation Blade And Angular Mixing

In Laravel we can escape {{}} by prefixing the first curly brace with an @ symbol. @{{ $variable }} will return {{ $variable }} and AngularJS can deal with that.

Now, I have an image tag in the blade like the following:

`
        
 
 
     
         
     
`

and when I run this I get the following errors in my firebug console:

`"NetworkError: 404 Not Found - http://xwz.me/home/%7B%7B%20user.image%7D%7D" {{ user.image}} "NetworkError: 404 Not Found - http://xwz.me/home/%7B%7B%20ratingImage%20%7D%7D"`

How to resolve this ?

12 Apr
3 years ago

dhiman252 left a reply on AngularJS And Blade

I have an image tag in the blade like the following:

`start author_row-->

@{{ user.name}}


                                    <span>(@{{ user.review}} reviews)</span>
                                </div>
                                <div class="location">@{{ user.address}}</div>
                                <p>@{{ user.description}}</p>
                                <div class="freequote"><a href="#">{{ trans('front/common.button.getFreeQuotes') }}</a></div>
                            </div>
                        </div>`

and when I run this I get the following errors:

"NetworkError: 404 Not Found - http://woohands.me/home/%7B%7B%20user.image%7D%7D" {{ user.image}} "NetworkError: 404 Not Found - http://woohands.me/home/%7B%7B%20ratingImage%20%7D%7D"

How to resolve this ?

31 Mar
3 years ago

dhiman252 left a reply on Eloquent Related Records

Ok, then please tell me how can I make use of the keyBy() function on related records collection ?

dhiman252 started a new conversation Eloquent Related Records

Please have a look at the question at link: https://github.com/laravel/framework/issues/12941

24 Mar
3 years ago

dhiman252 left a reply on How To Get Interval Form Carbon Instance

the problem i am facing is that how to use a carbon instance with the carbon interval ?

23 Mar
3 years ago

dhiman252 started a new conversation How To Get Interval Form Carbon Instance

I have a created a model and I have the created_at attribute, I need the difference like following Posted on Dec 01, 2014 Closes in 4d 19hr 13m How can this be achieved using the Carbon instance ? One way $date1 = $user->created_at; $date2 = $user->created_at->addMonth();
echo $date2->diffForHumans($date1); But this does not provide the format required like the following: 4d 19hr 13m

02 Mar
3 years ago

dhiman252 left a reply on Elasticseach With Laravel Eloquent

Thanks noeldiaz :)

dhiman252 left a reply on Elasticseach With Laravel Eloquent

Hi,

Thanks for providing me the links, there were really very useful to me.

Now last i have a question: I am using https://github.com/elasticquent/Elasticquent library for elastic search through eloquent models, Now how can my MYSQL database sync with the elasticseach index ?

dhiman252 started a new conversation Elasticseach With Laravel Eloquent

Hi,

I want to integrate the elasticsearch v2.1.* with laravel 5.1 and i dont know anything about the elastic search and how it works with PHP. I would be very thankful if you provide me this information.

25 Feb
3 years ago

dhiman252 started a new conversation Multi-language Laravel Carbon

Hi,

I am working on a project and using the laravel 5.1.27, My app is multi language and i am facing a problem with the carbon instance. I have an Eloquent model in which I have set the dates property. Now when I retrieve the results from the database then my model property is a carbon date instance, now when i run the following code it does not work

Carbon::setLocale('de');
echo Carbon::now()->formatLocalized('%A %d %B %Y'); 
Carbon::setLocale('en');
But when execute the following lines of code then it works:
setlocale(LC_TIME, 'German');
echo Carbon::now()->formatLocalized('%A %d %B %Y');          // Mittwoch 21 Mai 1975
setlocale(LC_TIME, '');
echo Carbon::now()->formatLocalized('%A %d %B %Y');          // Wednesday 21 May 1975

Now My question is that when we execute following command App::setLocale() in my controller constructor then does this also includes the following command ? setlocale(LC_TIME, 'German');

I am not able to translate the carbon instance based on my app current locale.

11 Feb
3 years ago

dhiman252 started a new conversation Show Multi Language Data Blade Laravel

I am creating a multi-language website using laravel 5.1 and my concern is with showing the user content.

I am using spanish as a language and it also contains the special characters

so with is the best possible way to show the content on the website fron the options below:

  1. my trans array = ['twitter_login'=>'Inicia sesión con Twitter']; Show in blade like this {!! trans('login.twitter_login') !!}

  2. my trans array = ['twitter_login'=>'Inicia sesión con Twitter']; Show in blade like this {{{ trans('login.twitter_login') }}}

Which should be used ?

Second, if the user input some code in the text field then how the data should be shown in the blade ?

  1. {{ $val !!}
  2. {!! $val !!}
  3. {!! $val !!}
09 Dec
3 years ago

dhiman252 started a new conversation Eloquent Model IsnewRecord Attribute, BeforeSave, Aftersave Events

Hi team please provide me the way to fetch the following attributes and methods IsnewRecord attribute beforeSave, aftersave Events

for Eloquent Model