brayniverse

Web Analytics Developer at iProspect

Experience

21,455

2 Best Reply Awards

  • Member Since 4 Years Ago
  • 342 Lessons Completed
  • 13 Favorites

2nd August, 2016

brayniverse left a reply on Where Are You All From? • 1 year ago

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

19th December, 2015

brayniverse started a new conversation Broken Navigation • 2 years ago

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.

14th December, 2015

brayniverse left a reply on Welcome Back Laracasts! • 2 years ago

What happened?

30th November, 2015

brayniverse left a reply on Latest Laracasts Content • 2 years ago

Thank you @PhaxeNor

brayniverse started a new conversation Latest Laracasts Content • 2 years ago

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

12th October, 2015

brayniverse started a new conversation Documentation Tools • 2 years ago

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?

16th September, 2015

brayniverse left a reply on Discussions Link Bug • 2 years ago

Well done for finding that @bashy.

brayniverse left a reply on Discussions Link Bug • 2 years ago

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

Console errors

brayniverse left a reply on Discussions Link Bug • 2 years ago

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

console errors

brayniverse left a reply on Discussions Link Bug • 2 years ago

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

brayniverse left a reply on Notifications Concept • 2 years ago

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

brayniverse left a reply on Discussions Link Bug • 2 years ago

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

brayniverse started a new conversation Discussions Link Bug • 2 years ago

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 • 2 years ago

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 :)

9th April, 2015

brayniverse started a new conversation Subdomain TLD Wildcard • 3 years ago

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()
{
    // ...
});

19th February, 2015

brayniverse left a reply on Conversation Subscriptions • 3 years ago

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

brayniverse started a new conversation Conversation Subscriptions • 3 years ago

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.

9th February, 2015

brayniverse left a reply on [Help] Homestead Directory Missing • 3 years ago

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 • 3 years ago

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 • 3 years ago

@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 • 3 years ago

@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 • 3 years ago

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.

22nd January, 2015

brayniverse left a reply on Thoughts On React.js • 3 years ago

Thanks for the feedback @ludo237 :)

brayniverse started a new conversation Thoughts On React.js • 3 years ago

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 :)

4th December, 2014

brayniverse left a reply on Which Way To Integrate With Laravel And Angularjs? • 3 years ago

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 :)

7th November, 2014

brayniverse left a reply on What Would You Want? • 3 years ago

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? • 3 years ago

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

6th November, 2014

brayniverse started a new conversation What Would You Want? • 3 years ago

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.

4th November, 2014

brayniverse left a reply on Where Are You All From? • 3 years ago

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.

3rd November, 2014

brayniverse left a reply on Where Are You All From? • 3 years ago

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

brayniverse left a reply on Where Are You All From? • 3 years ago

Wow already quite a diverse range of developers

brayniverse started a new conversation Where Are You All From? • 3 years ago

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

30th October, 2014

brayniverse left a reply on Threaded Comments • 3 years ago

Given a comments table that belongsToMany() Articles

How come a single comment belongs to many articles?

22nd October, 2014

brayniverse left a reply on Roles/Permissions Per Site/project/etc. • 3 years ago

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 • 3 years ago

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 • 3 years ago

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 • 3 years ago

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 • 3 years ago

The new centralised forum thread is nice as well.

brayniverse left a reply on New Grayish Forum Colors Harder To Read • 3 years ago

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 • 3 years ago

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

21st October, 2014

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

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. • 3 years ago

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 • 3 years ago

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 • 3 years ago

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 • 3 years ago

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. • 3 years ago

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 • 3 years ago

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.

20th October, 2014

brayniverse left a reply on Laravel's 5 CssLink • 3 years ago

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 :)

Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.