dhiman252

dhiman252

Member Since 3 Years Ago

Experience Points
6,780
Total
Experience

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-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 2
6,780 XP
Nov
25
2 years ago
Activity icon

Replied to 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.

Aug
01
3 years ago
Activity icon

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 ?

Jul
09
3 years ago
Activity icon

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.

Jul
06
3 years ago
Activity icon

Started a new conversation Some Jobs To Sync And Some To Database

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

Jun
11
3 years ago
Activity icon

Replied to 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 ?

Activity icon

Replied to 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?

Jun
10
3 years ago
Activity icon

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

Jun
08
3 years ago
Activity icon

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

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

Activity icon

Replied to Example On How To Use Multiple Locales In Your Laravel 5 Website

Does this works well for laravel v5.2 ?

May
25
3 years ago
Activity icon

Replied to Eloquent Query Bindings Does Not Work Properly

Refer the generated query object here: http://prntscr.com/b87aql

Activity icon

Replied to Eloquent Query Bindings Does Not Work Properly

I guess there is some issue with the parameter bindings which is not working as expected.

Activity icon

Replied to 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 * from `notifications` where (`quote_id` in (?) and `provider_seen` = ?) and `message_provider` is not null order by `updated_at` desc

Activity icon

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

May
24
3 years ago
Activity icon

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 ?

Activity icon

Replied to 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.

Activity icon

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 ?

May
20
3 years ago
Activity icon

Replied to 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 ?

Activity icon

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.*

Activity icon

Replied to 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.

May
18
3 years ago
Activity icon

Replied to 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 ?

Activity icon

Replied to Why Event Broadcast Is Queued ?

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

Activity icon

Replied to 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 ?

Activity icon

Replied to 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. ?

Activity icon

Replied to 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 ?

Activity icon

Replied to 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()
    ];
}

} `

I am calling this by event(new NotifyQuoteUpdates ($quote) );

Activity icon

Replied to Why Event Broadcast Is Queued ?

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

Activity icon

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 ?

Apr
26
3 years ago
Activity icon

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 ? For 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.

Apr
24
3 years ago
Activity icon

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 ?

Apr
23
3 years ago
Activity icon

Replied to 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 ?

Activity icon

Replied to 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 ?

Activity icon

Replied to 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.

Apr
22
3 years ago
Activity icon

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 my 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 ?

Apr
16
3 years ago
Activity icon

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 ?

Apr
15
3 years ago
Activity icon

Replied to Blade And Angular Mixing

Thanks all :)

Activity icon

Replied to 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 ?

Apr
13
3 years ago
Activity icon

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:

<div ng-repeat="ratingImage in user.ratingImages track by $index"><img src="@{{ ratingImage }}"/></div>

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 ?

Apr
12
3 years ago
Activity icon

Replied to AngularJS And Blade

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

<div class="author_img_holder"><img src="@{{ user.image}}" alt="" /></div> <div class="rating" > <div ng-repeat="ratingImage in user.ratingImages track by $index"> <img src="@{{ ratingImage }}"/> </div> </div>

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 ?

Mar
31
3 years ago
Activity icon

Replied to Eloquent Related Records

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

Activity icon

Started a new conversation Eloquent Related Records

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

Mar
24
3 years ago
Activity icon

Replied to How To Get Interval Form Carbon Instance

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

Mar
23
3 years ago
Activity icon

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
Mar
02
3 years ago
Activity icon

Replied to Elasticseach With Laravel Eloquent

Thanks noeldiaz :)

Activity icon

Replied to 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 ?

do i need to run a cron job which will update the index everytime a new row is inserted into table ? Or Does this package https://github.com/elasticquent/Elasticquent supports if a row is inserted into the database it will automatically be inserted into the elasticsearch index ?

Activity icon

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.

Feb
25
3 years ago
Activity icon

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.

Feb
11
3 years ago
Activity icon

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 &8#xF3; 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 }}}
Dec
09
3 years ago
Activity icon

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
Dec
08
3 years ago
Activity icon

Started a new conversation Automatically Generate Relations Eloquent

Is there any way we can create relations automatically while we create a model using artisan command ?

Dec
06
3 years ago
Activity icon

Started a new conversation Nesting Level

Hi All,

I am currently working on an application which requires to store categories their sub categories. Following is the table SQL:


CREATE TABLE `categories` (
 `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
 `name` varchar(255) COLLATE utf8_unicode_ci NOT NULL, 
 `parent_id` int(10) unsigned DEFAULT NULL COMMENT 'Parent_id',
 `created_at` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
 `updated_at` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
 PRIMARY KEY (`id`),
 FOREIGN KEY (`parent_id`) REFERENCES `categories` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
--------

I have also generated the Model


namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Categories extends Model { public function subCategories(){ return $this->hasMany('App\Models\Categories', 'parent_id', 'id'); } }

-------------

Now finally i am fetching the results:

$Categories = Categories::whereNull('parent_id')->with('subCategories.subCategories.subCategories.subCategories')->get();
dd($Categories);
----------

Now as you can see in the model query i am fetching the results in the tree format. My question is that how i will get to know about the nesting level of the categories ?