bearcodi

CTO at RedHub Pty Ltd

Member Since 4 Years Ago

Canberra

Experience Points
72,800
Total
Experience

2,200 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
811
Lessons
Completed
Best Reply Awards
5
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 15
72,800 XP
Aug
26
3 months ago
Activity icon

Replied to Dusk Test: Browser Apparently Works With Different DB

Dusk tests will tend to run slower that your feature/unit tests as a headless chrome instance is booted per test.

You could try using brianium/paratest this package will run your tests in parallel, depending on how many CPUs you have this could speed up your dusk tests.

Another option is to turn on PHPUnit's caching in your phpunit.xml, this will only remember the tests that have failed:

<?xml version="1.0" encoding="UTF-8"?>
<phpunit cacheResult="true"
         ...>

Then you run ./vendor/bin/phpunit --order-by=defects --stop-on-defect to only run the failed tests.

When the failed tests pass it will continue all the tests, so in case anything fails as a result of your fix your still covered.

Check this article out for expanded tips https://laravel-news.com/tips-to-speed-up-phpunit-tests

Cheers

Aug
25
3 months ago
Activity icon

Replied to App Singleton And No Session

Ahhh, ok if your doing a UnitTest and not a feature test, then you should take a look at this post:

https://laravel-tricks.com/tricks/unit-test-session-store-not-set-on-request

See if that helps you out.

Cheers

Mark

Activity icon

Replied to Change The Css Of The Page In VUE SPA Project With Vue Route

Hi @murilo,

Assuming you have three separate CSS files, you can utilise Vue Router navigation guards and add a global before guard and create a middleware that checks for a route meta tag.


import MiddlewareStylesheet from './MiddlewareStylesheet';


const router = new Router({
  ...

  routes: [
    ...
    
    {
      path: '/',
      name: 'home',
      component: Public,
      meta: {
        stylesheet: 'public'
      }
    },
    
    ...
  ]

  ...
});


router.beforeEach(MiddlewareStylesheet);

Add a simple html stylesheet reference but assign an ID for simpler selection into your base template:

<!DOCTYPE html>
<html lang="en">
  <head>
    ...

    <link id="stylesheet" rel="stylesheet" href="/css/public.css">
  </head>
  <body>
    ...
  </body>
</html>

Using this you can then swap out the pages stylesheet using standard Javascript:

/**
 * Define our route selectable stylesheets
 *
 * @type {Object}
 */
const stylesheets = {
  public: '/css/public.css',
  login: '/css/login.css',
  admin: '/css/admin.css'
}

/**
 * Set the default fallback stylesheet
 * @type {[type]}
 */
const defaultStylesheet = stylesheets.public

const cssElement = document.getElementById('stylesheet')

export default function stylesheet(to, from, next) {

  if (to.meta.stylesheet !== from.meta.stylesheet) {
    cssElement.href = stylesheets[to.meta.stylesheet] || defaultStylesheet
  }

  return next();
}

Check out the sample app at https://codesandbox.io/s/vue-template-e4cpt

Hope this helps you out

Cheers

Activity icon

Replied to Dusk Test: Browser Apparently Works With Different DB

Hi @rudexpunx

I've had a similar issue when starting using Laravel Dusk.

If your unit/feature tests are using a sqlite and the :memory: database shortcut, your dusk tests won't work as dusk is simulating actually running the test through the browser.

You need to setup a .env.dusk.{environment} file and run your migrations/seeds on a sqlite and then local database file, ie databases\testing.sqlite in order for your dusk tests to work.

See Dusk environment handling for more info.

Hope this helps

Cheers

Activity icon

Replied to App Singleton And No Session

Hi,

It could be one of two things, either your not actingAs() a user in your feature test prior to making your http request, for example:

    /** @test */
    
    public function it_checks_if_a_user_needs_to_be_onboarded()
    {
        ...

        $this->actingAs(
            factory(User::class)->create()
        );

        $response = $this->get('/user');

        ...
    }

Or, you could be injecting the wrong class into your MyCustomStateClass. If you using dependency injection make sure your resolving Illuminate\Auth\AuthManager and not Illuminate\Support\Facades\Auth, as the Auth facade actually resolves the AuthManager .

I've whipped up a working example with feature and unit tests for you to take a look at.

https://github.com/bearcodi/laravel-injecting-middleware-testing-example

Hope it helps

Cheers

Jul
21
4 months ago
Activity icon

Replied to Activity Streaks: How To Return ONLY Collection Of Carbon Objects From Query Scope?

You just need to use the collections pluck() method on your answered_at column prior to calling values()

$tableDates = Table::answeredByUser($user)
                ->get(['answered_at'])
                ->pluck('answered_at')
                ->values();

This will return a Collection of just the answered_at values, then you still have all the special sauce of Collection methods to play with, or if you just need the raw array you can just append the toArray() method.

Cheers

Activity icon

Replied to My Local Server Address After Php Artisan Serve 127.0.0.1:8000

In your routes file add a route that redirects to the default path you want.

Route::get(‘/‘, function() {
    return redirect(‘/student’);
});
Jul
20
4 months ago
Activity icon

Replied to Which Editor Do You Use To Work?

VS Codium or Atom, switch between both atm

Activity icon

Replied to Tailwind @apply In My Vue Components Styles Block

Have your tried applying the postcss language to the style tag?

<style lang=“postcss”>
      ...
</style>

This should run the style content through PostCss, assuming youre using Laravel mix and have registered tailwind in the PostCss plugins.

Jul
18
4 months ago
Activity icon

Replied to Import Csv In Laravel In Japanese Language

You will need to convert the contents character encoding after the call to file_get_contents as the PHP method uses the system locale setting.

So you would need to pass the file content through mb_convert_encoding do something like this:


$content = file_get_contents('japanese.csv');

$converted = mb_convert_encoding($content, 'UTF-8', 'EUC-JP');

$rows = array_map('str_getcsv', explode("\n", $converted));

var_dump(array_filter($rows));

Which provides the correct output:

array(4) {
  [0]=>
  array(2) {
    [0]=>
    string(6) "ああ"
    [1]=>
    string(6) "嗚呼"
  }
  [1]=>
  array(2) {
    [0]=>
    string(6) "あい"
    [1]=>
    string(3) "相"
  }
  [2]=>
  array(2) {
    [0]=>
    string(6) "あい"
    [1]=>
    string(3) "愛"
  }
}

Note my example CSV file is EUC-JP encoded, see the list of available encodings.

PHP manual for mb_convert_encoding.

Hope this helps!

Activity icon

Replied to After Assign A Data Property Equal To A Props Returns Null..

I tried your code out and your component is fine.

I've whipped up a sandbox to show the result, are you sure your binding your array to the component correctly?

https://codesandbox.io/s/vue-template-gn66g

Activity icon

Replied to In Shared Hosting Environment, How To Hide .env File From Public?

Have you changed the location of the .env file?

A default Laravel install has the .env file located one level up from the public folder and by default shouldn't be accessible.

  laravel\
      -> .env
      -> public\

You might need to check your nginx/apache configuration and check that the web root is public.

Can you provide your nginx/apache host file?

Activity icon

Replied to Exception Handling And Monolog Good Examples

Hi

Its actually a pretty easy solution as Laravel provides customising the exception handler easily.

I've created a sample application for you to have a look at:

https://github.com/bearcodi/laravel-exception-handling-fun

Check out the README.md file for an explanation, hope this helps explain the concept and is along the lines of what your looking todo!

Cheers

Jul
17
4 months ago
Activity icon

Replied to Is A Web Single Application Less Indexed For Google ?

Hi,

This is a good article that will help you get to your answer: https://medium.com/js-dojo/is-my-single-page-app-seo-friendly-be2c827f1c38

In summary, seems like google has kept up with the times (who knew) and the google bot will wait 20 seconds before timing out to allow for asynchronous calls.

Do looks like as long as your page load time is under 20 seconds, and the page does not require an authenticated user, you should be ok.

You could also try looking at implementing Server Side Rendering, checkout https://github.com/spatie/server-side-rendering

Activity icon

Replied to Call To Undefined Relationship [user] On Model [App\Quote].

Hi,

Looks like you have a typo in your Quote model.

Currently your relation for user is pluralized:

<?php
...
class Quote extends Model
{
    ...
    public function users()
    {

        return $this->belongsTo(User::class, 'id');

    }
    ....
}

That's why you're getting an exception when attempting to access the name attribute on $quote->user as the relation on the Quote model doesn't exist.

Try changing it to:

<?php
...
class Quote extends Model
{
    ...
    public function user()
    {

        return $this->belongsTo(User::class, 'id');

    }
    ....
}

You should then be able to access $quote->user->name in your blade templates.

Cheers

Jul
16
4 months ago
Activity icon

Commented on Avoid Flags

I can see your point of view on the IDE side of things, but sometimes I like to jump between IDEs or VIM and prefer not to rely on IntelliSense stuff as a requirement for coding.

This is were @jeffreyway suggestion leads to a nicer reading of the code.

Also, it then allows you to TDD out the length of the temporary delay, or do complex stuff like every time they get muted the delay is increased.