brayniverse

brayniverse

Web Analytics Developer at iProspect

London

Member Since 5 Years Ago

Experience Points 21,455
Experience
Level
Lessons Completed 338
Lessons
Completed
Best Reply Awards 2
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.

02 Aug
2 years ago

brayniverse left a reply on Where Are You All From?

@chrisHe I can't believe this thread is still going, I created it over a year ago :D

I wrote a script to scrape the comments a few weeks ago, to discover where people are from, most of the comments are in natural language so they're hard to parse programmatically.

A Laravel Users Map would be excellent. Maybe I'll plot the locations when I have time to spare; I will share it here if I do.

19 Dec
2 years ago

brayniverse started a new conversation Broken Navigation

I just noticed that Laracasts navigation is broken. As you can see in this gif, when you land on the homepage, index, or series pages the navigation links disappear. It is only after refreshing that they become visible again.

broken nav gif

I tried to inspect the source to see if I can give some further insight into why this is happening but there were no JavaScript errors in the console, nor could I figure out what was wrong with the CSS because as soon as I fiddled with any CSS property the viewport would repaint and the navigation items appeared. Sorry.

14 Dec
2 years ago

brayniverse left a reply on Welcome Back Laracasts!

What happened?

30 Nov
2 years ago

brayniverse started a new conversation Latest Laracasts Content

With the new design I don't know where the latest content can be found. Can anybody point me in the right direction?

12 Oct
3 years ago

brayniverse started a new conversation Documentation Tools

Hey everybody :)

My team and I are normally working with a small codebase so documentation tends to be omitted in favour of well-named files, classes, methods, docblocks etc. However, occasionally we also use GitHub's wiki pages or Google Docs to write more detailed documentation. I was wondering; how does everybody else manage their documentation? Are there any tools or processes people use to keep everything maintainable and up-to-date?

16 Sep
3 years ago

brayniverse left a reply on Discussions Link Bug

Well done for finding that @bashy.

brayniverse left a reply on Discussions Link Bug

If it helps you I'm getting several errors in Chrome's console.

Console errors

brayniverse left a reply on Discussions Link Bug

If it helps you I'm getting several errors in Chrome's console.

console errors

brayniverse left a reply on Discussions Link Bug

It could be only my account, have you had a look at my profile?

brayniverse left a reply on Notifications Concept

Thank you @spoon I'll have a read of that.

brayniverse left a reply on Discussions Link Bug

Same with any of the top links "Lessons", "series", and "Collections".

brayniverse started a new conversation Discussions Link Bug

There is a bug where if you click "Discussions" from your own profile it goes to wwwgoogle.com/discuss.

bug screen recording

brayniverse started a new conversation Notifications Concept

I'm working on a concept for handling user notifications where each type of notification may have different dependencies. For example likes, comments, or recommended articles all have a list of dependencies which could be simplified as the following database structure.

Schema::create('notifications', function (Blueprint $table) {
    $table->increments('id');
    $table->integer('user_id')->unsigned();
    $table->integer('sender_id')->unsigned();
    $table->integer('subject_id')->unsigned();
    $table->string('subject_type');
    $table->timestamps();
    $table->softDeletes();
});

Using this structure we can store any of the above as a polymorphic relationship where subject_id, and subject_type are xyz, and App\SomeModel. This is great until you want a custom message for each type of notification because you end up doing a series of if...else...if... or switch conditions. That is not the only gripe I have with the above structure; what if the notification has no sender, say for example, it was triggered because something will expire soon, the sender could be some admin account maybe I'm not sure, I feel as though leaving the sender_id as null or using an admin account feels wrong. Or even the notification has no subject and is something basic such as a HappyBirthdayNotification.

What I'm considering is the following structure:

Schema::create('notifications', function (Blueprint $table) {
    $table->increments('id');
    $table->integer('user_id')->unsigned();
    $table->morphs('message');
    $table->timestamps();
    $table->softDeletes();
});

Schema::create('notifications_likes', function (Blueprint $table) {
    $table->increments('id');
    $table->integer('liker_id')->unsigned();
    $table->integer('article_id')->unsigned();
});

Schema::create('notifications_recommended_posts', function (Blueprint $table) {
    $table->increments('id');
    $table->integer('post_id')->unsigned();
});

With this structure you can query the notifications table for all notifications for user 1 and even filter the notifications by their type. $user->notifications()->where('message_type', 'App\Notifications\LikeNotification')->get();, you now have the freedom to add new types of notifications with their own dependencies, and with each type of notification having it's own model class you can use a getBodyAttribute method which produces the custom message based on the notification's dependencies.

What I'm hoping for by posting this is for some opinions on whether this is a good approach to solving the problem, if I'm overcomplicating everything.

Finally I would love to have the following api for saving notifications but I haven't been able to figure out the Eloquent relationships yet and would appreciate some advice on making it possible.

$notification = new LikeNotification([...]);
$user->notifyOf($notification);

// and this helper would mimic the same functionality

notify($user)->of($notification);

Any advice on how to setup the relationships and recommendations on a readable api for storing notifications would be greatly appreciated.

Thank you for reading :)

09 Apr
3 years ago

brayniverse started a new conversation Subdomain TLD Wildcard

Hey good people,

I've got a three domains which represent my local, staging, and production environments. I want to use the subdomain api.*, however because it appears I have to specify the full domain path when routing with subdomains I can't see a way to use subdomains without defining the routes for each environment manually.

I want to use laravelcollective/annotations so I am unable to do something like this:

Route::group(['domain' => 'api.'.env('domain')], function()
{
    // ...
});

Has anybody else thought of a solution that would work?

It would be cool if we could do this:

// laravelcollective/annotations
@Controller(domain="api.{local|staging|production}.com")

// native
Route::group(['domain' => 'api.{local|staging|production}.com'], function()
{
    // ...
});
19 Feb
3 years ago

brayniverse left a reply on Conversation Subscriptions

Thank you @bashy and sorry Jeffrey for posting again :)

brayniverse started a new conversation Conversation Subscriptions

I would like to be able to subscribe to a forum thread so that I can be notified (via Laracasts - not email) whenever somebody posts on it.

09 Feb
3 years ago

brayniverse left a reply on [Help] Homestead Directory Missing

Thank you both (@sitesense and @hostianer) for your help. Finally got it working. I tried a few things to resolve my issue and I think it was down to a faulty VM that I removed manually using VirtualBox. Not entirely sure.

Thank you very much for your help, hope you both have a nice day.

brayniverse left a reply on [Help] Homestead Directory Missing

Just got this error:

/vagrant => /Users/christopherbray/.composer/vendor/laravel/homestead
Failed to mount folders in Linux guest. This is usually because
the "vboxsf" file system is not available. Please verify that
the guest additions are properly installed in the guest and
can work properly. The command attempted was:

mount -t vboxsf -o uid=`id -u vagrant`,gid=`getent group vagrant | cut -d: -f3` vagrant /vagrant
mount -t vboxsf -o uid=`id -u vagrant`,gid=`id -g vagrant` vagrant /vagrant

brayniverse left a reply on [Help] Homestead Directory Missing

@sitesense good spot, I just made that change when seeing if changing the directory name worked but even with the correct spelling my directory still isn't mapped correctly.

brayniverse left a reply on [Help] Homestead Directory Missing

@hosianer If I run homestead init I get this error

"[InvalidArgumentException] Homestead has already been initialized."

@sitesense My homestead.yaml file looks like this:

---
ip: "192.168.10.10"
memory: 2048
cpus: 1

authorize: ~/.ssh/id_rsa.pub

keys:
    - ~/.ssh/id_rsa

folders:
    - map: ~/Documents/workspaces/cny/cny.api
      to: /home/vagrant/CNY

sites:
    - map: api.cny.dev
      to: /home/vagrant/Cny/public

databases:
    - cny

variables:
    - key: APP_ENV
      value: local

brayniverse started a new conversation [Help] Homestead Directory Missing

Hey people,

I setup homestead the other day and everything worked perfectly, my site was accessible. Then I ran homestead destroy before shutting down my computer and after rebooting I ran homestead up. Now the directory I originally configured is no longer being mapped to homestead and I can't figure out why.

Has anybody else experienced this issue, if so how did you resolve it? If you need more information please let me know.

22 Jan
3 years ago

brayniverse left a reply on Thoughts On React.js

Thanks for the feedback @ludo237 :)

brayniverse started a new conversation Thoughts On React.js

Hey everybody, hope you're having a lovely day.

I want to pick a few brains today to see if anybody has experience using React.js? I just ran through the examples they have on their site and watch a couple of presentations (primarily from core contributors) and it sounds promising, but I'm wondering how it performs in real world projects - I know facebook actively use it but my personal experience with facebook's developer projects hasn't always been positive.

Has anybody used React.js on a project, if so could you answer any of the questions below or give me some of your thoughts.

  1. How does React.js compare to other frameworks such as Angular.js and Ember.js?
  2. Are there any conventions I should be aware of that are noteworthy?
  3. Can you provide me with any resources you found useful on the subject?

Thank you in advance :)

04 Dec
3 years ago

brayniverse left a reply on Which Way To Integrate With Laravel And Angularjs?

It's relative to what you're trying to achieve. If you are creating a full-featured application then I recommend using Laravel for a RESTful API and data persistence and using Angular for your UI and routing. As @RemiC suggested you can create a single view to "bootstrap" your Angular application and let Angular manage view loading, this will result in a speedier experience for your user because not all assets are downloaded each time a user navigates to another page.

If you are creating a basic website with only a few pages it wouldn't hurt just using Laravel to handle routing and using Angular for in-page interactions.

I switch between both types fairly often and there are a couple benefits to the first option.

  • You can switch out Laravel for another solution without having to transfer your templating
  • You can switch out Angular for another front-end framework or mobile app (iOS, Android)

I have had difficulty deciding upon an approach for managing authentication in an Angular app though. My current solution is to check for 403 responses from my RESTful API and redirect the user to a login page (generated by Laravel's routing). Here is an explanation of how to intercept API requests in Angular: http://stackoverflow.com/questions/25041929/angularjs-routeprovider-http-status-403

Hope this helps @markwu, let me know if you have any more questions :)

07 Nov
4 years ago

brayniverse left a reply on What Would You Want?

I would love to see an OAuth authentication driver for L5.

Wouldn't it be possible to implement your own rate-limiting functionality with Middleware? Also some native output transformer support would be a nice touch.

/cc @thepsion5

brayniverse left a reply on What Would You Want?

Role based authentication has become a little easier with the FormRequests because you can check the user's role the in authorized method. It doesn't cover all situations where you'd like to do role based actions but it helps make it easier to implement your own.

/cc @mantasmo @codeatbusiness

06 Nov
4 years ago

brayniverse started a new conversation What Would You Want?

Seeing as L5 won't be out till January that means theres time for new functionality to be added to the framework beforehand. I was wondering, if you had a say what would you like to see added to the framework and why?

For myself I'd LOVE to see native support for UUIDs because I want to know that if I use them, they will work with all types of relationships.

04 Nov
4 years ago

brayniverse left a reply on Where Are You All From?

Wow I'm surprised that there are only a few people from the UK, expected there to be more. Still, I'm impressed by how wide spread we all are.

03 Nov
4 years ago

brayniverse left a reply on Where Are You All From?

@jeffreyway do you get many interesting statistics in your analytics?

brayniverse left a reply on Where Are You All From?

Wow already quite a diverse range of developers

brayniverse started a new conversation Where Are You All From?

I'm wondering how far Laravel's reach extends to. I hail from London myself.

30 Oct
4 years ago

brayniverse left a reply on Threaded Comments

Given a comments table that belongsToMany() Articles

How come a single comment belongs to many articles?

22 Oct
4 years ago

brayniverse left a reply on Roles/Permissions Per Site/project/etc.

The problem with using packages to handle your ACL is that as the projects requirements change you end up hacking the third party package to work for you.

brayniverse left a reply on [L5] Auth Attempts Middleware

Guess it's not an appropriate use case then. Is there a way to use middleware to handle controller responses or is it solely for incoming messages?

brayniverse left a reply on [L5] Auth Attempts Middleware

How would you detect if the login is unsuccessful in the Authenticated middleware class? It handles the incoming request and responds with 401 or redirects if the user is not logged in already.

brayniverse started a new conversation [L5] Auth Attempts Middleware

Would tracking unsuccessful login attempts be an appropriate use of the Middleware feature?

brayniverse left a reply on New Grayish Forum Colors Harder To Read

The new centralised forum thread is nice as well.

brayniverse left a reply on New Grayish Forum Colors Harder To Read

On the topic of colour scheme having inline code and links the same colour make it harder to spot links.

brayniverse left a reply on Cahshier

Cashier is a subscription based billing platform and does not support one-off payments. Sorry.

21 Oct
4 years ago

brayniverse left a reply on Laravel Create A New Record Using Input::all() With Date Fields.

The method that converts your date to a Carbon date is here.

I thought $this->getDateFormat() would return some configurable date format but it doesn't seem to. So the answer to your question depends on what this line does.

brayniverse left a reply on Laravel Create A New Record Using Input::all() With Date Fields.

I just noticed that the getDates method actually merges a variable $this->dates which you can use instead.

class MyModel extends Eloquent
{
    protected $dates = ['my_date_field'];
}

You wouldn't need to set the created_at or updated_at date columns here because the getDates method will merge them behind the scenes.

brayniverse left a reply on Framework For Building An API

If you're just concerned about the HTTP layer you could try something lightweight, for example Silex, and still take advantage of Fractal because it's framework agnostic.

brayniverse left a reply on Manually Set Id Attribute

Use PHP's array_merge with Input::all() to set the ID manually before calling MyModel::create(...).

// Put the array with ID last to prevent Input::all from being able to set the ID
$data = array_merge(Input::all(), [ 'id' => 'custom id' ]);
MyModel::create($data);

This will also require you to put id in the model's fillable property protected $fillable = ['id']; which in my opinion is not desirable.

brayniverse left a reply on Manually Set Id Attribute

You can use the model events to set the model ID when creating. There are a few options for using model events (a quick google will show them) and I think the best is using the model's booting method.

class MyModel extends Eloquent
{
    /**
     * The booting method of the model.
     * 
     * @return void
     */
    public static function boot()
    {
        parent::boot();

        static::creating(function($model)
        {
            $model->{$model->getKeyName()} = 'custom id';

            return true;
        });
    }
}

brayniverse left a reply on Laravel Create A New Record Using Input::all() With Date Fields.

Eloquent has a method called getDates which returns an array of the database columns that need to be converted to dates when creating / saving.

class MyModel extends Eloquent {
    public function getDates()
    {
        return array('my_date_field', 'created_at', 'updated_at');
    }
}

source

By using this you can automatically convert date fields using Model::create(Input::all()).

brayniverse left a reply on Laravel's 5 CssLink

I would opt for URL::asset('...'); because the base tag is applied to URLs that do not include the protocol.

```html ``

In the above example the stylesheet will be http://google.com/static.assets.com.

20 Oct
4 years ago

brayniverse left a reply on Laravel's 5 CssLink

That's because omitting the leading / means the relative path will append to the current pathname, by including the leading / the link will be relative to the root url.

You can find more information about this by Googling relative and absolute urls.

One article I found that appears to explain this in detail is here.

Hope that helps :)