brti

brti

Member Since 4 Years Ago

Experience Points 10,270
Experience Level 3

4,730 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 197
Lessons
Completed
Best Reply Awards 1
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 Oct
2 years ago

brti left a reply on Laravel 5.3 Blank White Screen No Errors

This is most likely a permissions error. You can check buy viewing the log file like so:

sudo cat /var/log/nginx/{site_error_log}.log

This will contain any errors which may have occurred.

23 Jul
2 years ago

brti left a reply on Multiple .env Files. Am I Doing It Right?

It would probably be better if you used the base_path() helper function that would return the full path of the project's directory.

22 Apr
3 years ago

brti left a reply on ES2016 => Instead Of Function()

Try this:

this.$http.get('projects/1/accounts').then(
    response => { console.log('Done!'); }
);
17 Feb
3 years ago

brti started a new conversation Default Session Cookie Not Being Set.

None of the default sessions are being set in my Laravel application, whether it be the session cookie, or the CSRF token. Has anyone had an issue similar to this before, or know how to fix this?

07 Feb
3 years ago

brti started a new conversation Queues, And Time Consuming Jobs.

So I'm using the Laravel Queue service to process jobs that involve building servers as these jobs takes a long time to complete, about 1 - 3 minutes in total.

I have a concern about this however, lets assume that two servers are being built for two separate users, this means that the first job would take 1 - 3 minutes to complete for the first user, before processing the job for the second user, meaning that the second user would have to wait even longer for their server to be built, is there a way of avoiding this, or perhaps having jobs be processed in parallel on separate queues?

03 Feb
3 years ago

brti left a reply on Jobs Not Being Pushed On To Redis Queue, Predis Connection Refused.

Actually, fixed it. The job just takes a long time to process.

brti started a new conversation Jobs Not Being Pushed On To Redis Queue, Predis Connection Refused.

I have this job that needs to be run in the background so I'm using Redis as the queue. Problem is I don't think the job is being pushed onto the queue, when I run php artisan queue:listen it just dumps out a bunch of errors saying:

[Predis\Connection\ConnectionException]
Connection refused [tcp://127.0.0.1:6379]

Any ideas?

17 Jan
3 years ago

brti left a reply on [5.2][MySQL 5.6] Created_at Field Being Updated On Model Save.

Ok I found a temporary fix, which basically involved manually declaring the timestamp fields like so:

$this->timestamp('created_at')->nullable();
$this->timestamp('updated_at')->useCurrent();

The nullable() function has to be used on the created_at field or else it will default to using the current timestamp whenever a record is updated. Still no idea why this is happening.

brti left a reply on [5.2][MySQL 5.6] Created_at Field Being Updated On Model Save.

In my migration I used $this->timestamps(); to declare the created_at, and updated_at fields. When I look at the schema in MySQL it has the created_at field set to update to the current timestamp whenever the record is changed.

brti started a new conversation [5.2][MySQL 5.6] Created_at Field Being Updated On Model Save.

In my database the created_at field is being updated whenever a model is saved. I'm currently using Laravel 5.2, and MySQL 5.6.

Anyone else having a similar issue?

09 Jan
3 years ago

brti left a reply on Ajax Request 500 Error, Don't Even Hit The Route

It's probably because it's trying to retrieve a model that doesn't exists.

The error is most likely occurring here in your code:

url: '/upvote/ + this.id,

The word this is going to be used in reference to the AJAX object you're creating in jQuery, and not the actual JavaScript object you want to access. So what's happening is it is looking for a property called id on the AJAX object which doesn't exists, and is most likely passing undefined as the route parameter, as opposed to the actual value you wish to pass.

28 Jul
3 years ago

brti left a reply on How To Pass Date Into Route

It would probably be easier to format the date as yyyy-mm-dd using the toDateString() function in Carbon.

http://carbon.nesbot.com/docs/#api-formatting

And to use Carbon in any file just pull it in by putting use Carbon\Carbon; at the top.

24 Jul
3 years ago

brti left a reply on Favorites And Profiles

https://laracasts.com/lessons/favorites-part-2

Fixed link, it seemed to redirect with the . at the end of it which caused it to break.

15 Jul
3 years ago

brti left a reply on Seeding Relationships

Have you tried doing it this way:

'category_id' => Category::orderByRaw('RAND()')->first()->id;

This is the method I use for seeding relationships, and works well for me.

brti left a reply on Sibling Count

It probably would be best with storing the session count in the database table.

brti left a reply on Store Likes And Dislikes In One Table.

Could use a query scope:

public function scopeCountLikes($query)
{
    return $query->likes()->where('liked', 1)->count();
}

public function scopeCountDislikes($query)
{
    return $query->likes()->where('dislike', 1)->count();
}

Then you could write it out like this:

Post::first()->countLikes();

or

Post::first()->countDislikes();

brti left a reply on Store Likes And Dislikes In One Table.

Since you're storing all of the likes and dislikes in one table I would do something like this.

Migration:

$table->increments('id');
$table->integer('thing_id')->unsigned();
$table->foreign('thing_id')->references('id')->on('things');
$table->boolean('liked');
$table->boolean('disliked');

Model Methods:

/**
 * The like relation that will be on the resource that can be liked.
 */
public function likes()
{
    return $this->hasMany('App\Likes');
}

/**
 * The post relation that will be on the like model.
 */
public function post()
{
    return $this->belongsTo('App\Post');
}

brti left a reply on Store Likes And Dislikes In One Table.

The documentation thoroughly goes over how to create an Eloquent model. http://laravel.com/docs/5.1/eloquent#defining-models

Furthermore you can add a foreign key for the user_id to the migration code like so:

$table->integer('user_id')->unsigned();
$table->foreign('user_id')->references('id')->on('users');

brti left a reply on Store Likes And Dislikes In One Table.

$table->increments('id');
$table->integer('thing_id')->unsigned(); // thing references the resource that you want to be liked, for example comment_id or post_id
$table->foreign('thing_id')->references('id')->on('things'); // things references the table of the resource you want to be liked, for example comments, or posts
$table->boolean('liked');
$table->boolean('disliked');

You would then create an Eloquent model and use this to get the likes/dislikes. Again this would be far easier if you had a separate table for both likes and dislikes.

08 Jul
3 years ago

brti left a reply on Laravel 5.1 White Screen In Place Of Errors

Yeah that fixed it, kinda annoying.

brti started a new conversation Laravel 5.1 White Screen In Place Of Errors

Yes I have searched around for solutions to this, and haven't come across any.

I tried php artisan clear-compiled followed by php artisan optimise, and that didn't work, and have also changed the permissions on the storage/ directory by running the command sudo chmod 775 -R storage/ and that didn't work.

I first ran these commands on my host machine, then on the vagrant machine. I also re-provisioned my vagrant machine, which yielded nothing, furthermore I also checked my nginx error logs, but they were empty.

26 Jun
3 years ago

brti left a reply on Broadcasting Event To Specific Client

Ok I seemed to have got it working now. Realised that I put port 8000 instead of 3000 when it did var socket = io('http://socket.dev:3000');

brti left a reply on Broadcasting Event To Specific Client

Yeah I'm using the address socket.dev

brti left a reply on Broadcasting Event To Specific Client

Nope still none. Changed the socket.js file so it would listen on port 8000 instead of 3000, and that didn't work either.

brti left a reply on Broadcasting Event To Specific Client

So when setting up the socket.io connection I should put

var socket = io('socket.dev:8000');

Instead of:

var socket = io('192.168.10.10:8000');
24 Jun
3 years ago

brti left a reply on Broadcasting Event To Specific Client

I have a problem with retrieving the cookies. I run the code that you have put above:

var cookies = cookie.parse(client.handshake.headers.cookie);

console.log(cookies);

I then just dump out the output to see the cookies that are being passed in the request, then when I run the server this is the response I see from console.log(cookies);:

{ io: 'n60obMX5WfAuzEnpAAB' }

From the looks of the it neither the X-CSRF-TOKEN cookie, or the laravel_session cookie are being returned from client.handshake.headers.cookie, and I cannot understand why.

23 Jun
3 years ago

brti left a reply on Broadcasting Event To Specific Client

Thanks for the response. How would I go about getting the session info from the redis DB?

brti started a new conversation Broadcasting Event To Specific Client

What's an easy way of broadcasting an event to a certain client, or a group of clients with socketio, and nodeJS? I have tried to get the Laravel session ID from the cookie with nodeJS but was not successful in doin so.

Here's the code in my socket.js file that handles broadcasting the data to the channel.

redis.psubscribe('*', function(error, count) {});

redis.on('pmessage', function(subscribed, channel, message) {
    console.log(message);

    message = JSON.parse(message);

    io.emit(channel + ':' + message.event, message.data);
});

One way I thought of doing it was by passing through an array of session IDs to the event object and then checking in the socket.js file to see if the current client has a matching session ID. It would probably end up looking something like this:

socket.js file:

message.data.receivers.forEach(receiver) {
    if (receiver == sessionID) {
        io.emit(channe + ':' + message.event, message.data);
    }
}

However this would rely on having to get the session ID from the cookie sent in the request via nodeJS, which I have not been able to do.

Any suggestions?

29 May
4 years ago

brti left a reply on [L4] Using Repository Inside A Filter Method?

I can see that you have the category repository in a dependencies array so why not do this to resolve it out of the IoC container?

App::make($this->dependencies['category']);

As long as the interface you're referring to is bound to an actual implementation it should work. Also make sure you use the App facade within you controller.