DNABeast

DNABeast

Member Since 5 Years Ago

Brisbane, Australia

Manager at Civicnet Web Development

Experience Points 45,880
Experience Level 10

4,120 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 672
Lessons
Completed
Best Reply Awards 3
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.

29 Jun
3 weeks ago

DNABeast commented on Frontend Authorization Brainstorming

There was a brief period just before Jeffrey got into VueJs that he did a React series. https://laracasts.com/series/do-you-react

19 Jun
1 month ago

DNABeast left a reply on Overriding Cache::remember

@JOHNBRAUN - That's a clever solution. I now have a Cache::rememberValid macro and it does exactly what I need it to.

DNABeast started a new conversation Overriding Cache::remember

I call some info from an API and I want to cache it because it can be a bit slow.

So I do

$array = \Cache::remember('array_data', now()->addDay(), function() {
    return $this->getApiData();
}

The problem is that sometimes the API is unreliable and I get back an empty array. Of course, in this instance, the cache remembers the empty array and doesn't check again until the cache expires.

I'm currently doing a check before the Cache::remember and if the cache result is an empty array I forget it before trying again.

I was thinking it would be great if I could change the remember method to do this check internally rather than a separate check beforehand.

My question is, is this a good idea? How would I go about over-riding a Laravel method?

11 Mar
4 months ago

DNABeast left a reply on Turning The Slot Default Nodes Into An Array Of The Original Html

@MVD - Thank you, This is definitely a viable option for this use case.

What I'm after is a solution that is a bit more robust. In that I could use it for a list of half images and half divs with the img set as a background image and a text object layered on top of it. Where it didn't matter what the object I fed into it, it was still just an object in the array.

DNABeast started a new conversation Turning The Slot Default Nodes Into An Array Of The Original Html

There is something I can't seem to figure out about the default slot.

I want to make a component that takes any list of html and turns it into a vue array.

So I want to put

<mini-banner>
  <img src="img/pic_1.jpg">
  <img src="img/pic_2.jpg">
  <img src="img/pic_3.jpg">
</mini-banner>

And then in my template have

<div v-for="banners in banner">
  <div v-html="banner"></div>
</div>

And the img tag would render inside the div.

I've played around with $slots.default but can't figure out how to turn the resulting vNode into its original HTML.

27 Feb
4 months ago

DNABeast left a reply on Unable To Build A Markdown Mail From A Test Environment

Thanks for helping.

They're the defaults.

 'Mail' => Illuminate\Support\Facades\Mail::class,

And DanMail was made using the make command with the -m markdown option

php artisan make:mail DanMail -memails.danmail

I've published the mail stuff. I notice in the local environ that it's looking for /resources/views/vendor/mail/html/themes/default.blade.php but not finding it. But it silently ignores the exception thrown.

This is the same exception that's killing it in a testing environ, except, as I say, with HTML rather than the default filename.

DNABeast started a new conversation Unable To Build A Markdown Mail From A Test Environment

I've made a new project. Created a Mailable with a markdown template. I can send the mail from a route.

Route::get('/demo', function () {
    \Mail::to('[email protected]')->send(new \App\Mail\DanMail());
});

But, when I call it from a test environment it tells me...

InvalidArgumentException: View [ **ENTIRE ESCAPED HTML OUTPUT FROM MY MARKDOWN**] not found.

The exception comes from FileViewFinder line 137. Why is the HTML getting sent to where a blade file should be requested?

17 Dec
7 months ago

DNABeast started a new conversation Targeting A Checkbox And Toggling Its State.

I've got two checkboxes in the same object attached to the same v-model.

Let's say one is transfer1 and one is transfer2

When I click the first one, I want the second one to turn on as well (thus allowing it to toggle on or off only when the first one is on)

When I turn the first one off, I want the second one to turn off as well.

I think I want to send a checkbox=false command to a checkbox?

Something like

@click="transfer1.checked = false"
24 Jun
1 year ago

DNABeast left a reply on Ignoring A Vendor Exception

Turns out my instincts were right. I asked a friend and he confirmed that Exceptions should 'bubble up' and to check my Exception was in the correct namespace.

If it's not then the package exception gets thrown before an error to indicate your Exception in is the wrong namespace.

Thanks Colin.

DNABeast started a new conversation Ignoring A Vendor Exception

Hi there team Laravel.

I'm using the NZTim Mailchimp package and in some instances, it can throw an exception.

I want to simply ignore it when this happens and keep processing. I know how to set up a try catch when I'm working on my own code, but when it's the package throwing the exception is there a way to gracefully ignore their Exception?

I tried

try {
    $mc = \Mailchimp::subscribe(config('spacifica.mailchimp_list_id'), $email, $mergeFields = ["FNAME" => $name->implode(' '), "LNAME"=>$last], $confirm = false);
} catch (Exception $e) {
    dd('sanity');
}

But it just threw the exception inside the package. I was hoping exceptions could 'bubble up'.

So should be trying to catch or prevent this exception in my code or should I change the package code to ignore the exception?

10 Jul
2 years ago

DNABeast left a reply on Collection Properties To Json.

Okay. But then when it comes to using that in my view I have to put

{{ $collection['name'] }}

instead of

{{ $collection->name }}

which seems cleaner to me.

Should I not be thinking about this like that?

DNABeast started a new conversation Collection Properties To Json.

I've got a collection that I've set a property on like so...

    $collection = collect([]);
    $collection->name = 'C One';

If I want that turned into json


dd($collection->toJson());

I get nothing back.

What am I misunderstanding about collections?

27 Jun
3 years ago

DNABeast left a reply on Getting A Method To Focus Back On My Loop

Gah! I knew I was missing something obvious. I can send the entire panel through...

@click="changeTitle(panel, 'title 3')"

And then simply refer to it as I expected

changeTitle: function(panel, title){
    panel.title = title;
}
24 Jun
3 years ago

DNABeast started a new conversation Getting A Method To Focus Back On My Loop

I feel like this should be a no brainer but I am struggling.

<div id="app">
        <li v-for="panel in panels">
            {{ panel.title }}
            <button @click="panel.title='Title1'">Title 1</button>
            <button @click="panel.title='Title2'">Title 2</button>

        </li>
    </div>

This code works great. Click a button and the title on the panel switches over. But when I call a method

<div id="app">
        <li v-for="panel in panels">
            {{ panel.title }}
            <button @click="updateTitleMethod">Title 1</button>
            <button @click="updateTitleMethod">Title 2</button>
        </li>
    </div>

I don't know how to target the panel's title. Here's the Vue code...

new Vue({
        el: '#app',
        data: {
            panels: [
                { title: 'default title'},
                { title: 'default title'}
            ]
        },
        methods: {
            updateTitleMethod: function(){
                this.title = 'Title 3'
            }
        }
    });

I thought this.title would "hook" into what I'm after but it's not the case.

08 Jun
3 years ago

DNABeast started a new conversation Does A Melted Server Mean Downtime Using Multi-server?

If I set up a multi-server deployment on Envoyer, and Forge has a load balancer set up between both servers, And then one server catches fire and melts, Does this mean my website stays up? Or will it fail every second time it's requested because half the time the load balancer is looking for Capt. McMeltedserver?

31 May
3 years ago

DNABeast left a reply on Vue File Size & Render Time

If you don't want the brackets to display while it loads take a look at v-cloak. Just set your element to display: none and when it loads cloak displays it again. http://vuejs.org/api/#v-cloak

18 Apr
3 years ago

DNABeast left a reply on ANSI Escape Characters (^[[A, ^[[B, Etc) In Artisan Tinker

Same problem for me. I just discovered that it works fine if you SSH into homestead. That might be enough for you.

07 Apr
3 years ago

DNABeast left a reply on Trouble Setting Up A Homestead Server

Oh. It misses a step there. If you struggle try vagrant global-status to find your VM you'll see a code like 6830134 then type vagrant ssh 6830134 (or just vagrant ssh 64 will work)

DNABeast left a reply on Trouble Setting Up A Homestead Server

https://laravel.com/docs/5.1/homestead#connecting-via-ssh

"You can SSH into your virtual machine by issuing the vagrant ssh terminal command from your Homestead directory.

But, since you will probably need to SSH into your Homestead machine frequently, consider adding the "alias" described above to your host machine to quickly SSH into the Homestead box."

Good luck :)

DNABeast started a new conversation Function Type Best Practice In Tests.

When writing php tests Jeffrey's demos jumped between having functions and public functions. What's best practice in a testing environment? Does it ever matter?

09 Mar
3 years ago

DNABeast left a reply on Dompdf Doesnt Show Currectly View With Bootstrap

I just discovered yesterday that Dompdf doens't load css files. There is a way to do it properly but what I ended up doing was including the css file inline in the html.

<style>
    <?php include(public_path().'/css/print.css');?>
</style>
07 Feb
3 years ago

DNABeast started a new conversation Automating Classes You Use All The Time

I generally put a menu helper class into each project I create. In order to do this I copy the files and the tests across from one to the other. I understand I could create a git project and set up a composer file for it, but are their other options if I'm just sharing the code between personal projects?

21 Jun
4 years ago

DNABeast left a reply on Fuzzy Search With Eloquent/Eloquence

You could make it dynamic. So when they type 'Abstrakt Painting' it remembers that it couldn't find anything and then they'll type in the correction. If it finds an entry associate the first wrong entry with the right entry. You would probably want to give it a weighting of probability as well, that way if it happens muliple times that they type the wrong thing, then the right thing the software has a better sense that they didn't just give up and try something else.

I've always wondered how fuzzy searching works. I expect that there are other better ways of doing it, like finding a percentage of matched letters. You could split the string into an array and then do an array_diff against every possible search in the database. That would take ages though. There's probably some really interesting steps in this process that I don't have the knowledge to consider.

04 Jun
4 years ago

DNABeast left a reply on Changing A Database Column From Text To Integer

phpliteadmin says it's an integer. Is there something I'm not groking?

    Edit    Delete  12  price   INTEGER Yes None    No
03 Jun
4 years ago

DNABeast started a new conversation Changing A Database Column From Text To Integer

I was wondering why my ordering looked this... 10556 2304 3405 7890

Until I realised that I'd managed to set that field as text instead of an integer. GAH! it was ordering alphabetically. And the site was already live. I futzed around for a while trying to figure out how to make a new field and copy the content across then destroy and recreated the field. BLAH! The site would be down for a while even if I didn't make any mistakes.

And then eloquent saved me.

    public function up()
    {
        Schema::table('weddings', function(Blueprint $table)
        {
            $table->integer('price')->change();
        });
    }


    public function down()
    {
        Schema::table('weddings', function(Blueprint $table)
        {
            $table->text('price')->change();
        });
    }

Good God it makes it easy.

06 May
4 years ago

DNABeast left a reply on Auto-format Capitalisation Of A Title.

Oh. Having an exclusion option is clever. So what are the benefits of the changes that you've made to this code. I'm interested in the 'why' just as much as the 'how'.

DNABeast started a new conversation Auto-format Capitalisation Of A Title.

use Illuminate\Support\Str;

function titlecase($newTitle, $oldTitle = Null)
{
    // If title changes more than the CASE then titlecase the string.
    if (! (Str::lower($oldTitle)===Str::lower($newTitle))){
        $newTitle = Str::title($newTitle);
        $tinywords = array( 'a', 'an', 'and', 'as', 'at', 'but', 'by', 'en', 'for',
                            'if', 'in','is', 'of', 'on', 'or', 'the', 'to', 'vs');
        foreach($tinywords as $tinyword){
            // replace uppercase tinyword with lowercase if it's seperated by spaces or pluses or end of line.
            $newTitle = preg_replace('/(?<=.)\b'.Str::title($tinyword).'(?=\b)/', $tinyword, $newTitle);
        }
    }
    return $newTitle;
}
01 Apr
4 years ago

DNABeast started a new conversation Access Session Variables Outside Of Laravel.

CKfinder grabs some config info from a .php file and I needed to be able to set a session variable to show I was logged in. Problem is that this file was called with javascript so didn't touch on Laravel. I needed a way to set a 'logged in' variable that the php SESSION could see.

Initially I would just set $_SESSION['IsAuthorized'] = true; when I logged in. Problem is that the session would log out if the browser closed but the user would still be authorised in Laravel. I finally pinged recently just how cool the middleware was. I simply changed the default Authenticate middleware by adding session variables whenever it checked.

public function handle($request, Closure $next)
    {
        session_start();
        if ($this->auth->guest())
        {
            $_SESSION['IsAuthorized'] = false; 
            if ($request->ajax())
            {
                return response('Unauthorized.', 401);
            }
            else
            {
                return redirect()->guest('login');
            }
        }
        $_SESSION['IsAuthorized'] = true; 
        return $next($request);
    }

Now to get access to the login I just need to start a session and call $_SESSION['IsAuthorized']

If I'm doing something silly please feel free to shoot me down.

22 Mar
4 years ago

DNABeast left a reply on Cleaning HTML Input?

I've had success using Purifier

https://github.com/mewebstudio/Purifier
19 Nov
4 years ago

DNABeast started a new conversation Fixing My Mistakes

I'm really loving the TDD videos and have been trying to follow along but I seem to have hit a limit in my understanding. It occurred to me that it might be worthwhile for you to see what mistakes are being made by someone who is learning as much as they can from the site. And perhaps a valuable project would be to take a look at my project and show people what mistakes I've made or what I've overlooked. I'd be happy to donate my code to this purpose.

It's just a little class to overcome the caching issues with far flung Expiry dates. Probably very similar to what you and Taylor made for Elixir.

My class http://laravel.io/bin/6LmeP

My tests http://laravel.io/bin/1ybWm#2

I'm then putting this

View::Share('cachebuster', App::make('Typesaucer\Cachebuster\Cachebuster'));

in my routes file, adding it to my aliases and then using

<link rel="stylesheet" type="text/css" href="{{ $cachebuster->fire('css/style.css') }}">

to put it in my master document.

Regardless I'm going to keep plugging away and rereading and watching stuff to try to get this code tighter.

11 Nov
4 years ago

DNABeast left a reply on Upload Images With FileSystem L5

It may be that you need to use the copy method.

$tempfilename = $request->file('image')->getRealPath();
$filesystem->copy($tempfilename, 'local/test.jpg');

DNABeast left a reply on Upload Images With FileSystem L5

I don't have a heap of experience here but is that a typo? $flilesystem? It looks like your method isn't injected properly.

11 Oct
4 years ago

DNABeast left a reply on Giving A Route Name An Extension

I had already set up a 301 redirect using php header codes. Turns out iTunes didn't like that. Now that I've set it up with Nginx it's all working like a charm. Thanks.

DNABeast left a reply on Giving A Route Name An Extension

The current solution makes me feel very dirty. I duplicated the index.php file and renamed it podcast_rss.php

then I created a filter that checks the basename of the URL. If it's podcast_rss.php it runs the same code the feed controller does. But I cut and pasted.

Oh Lord forgive me I cut and I pasted.

DNABeast left a reply on Giving A Route Name An Extension

I created a file called podcast_rss.php that was a 301 redirect and itunes coughed up a lung. Gave a 301 error.

DNABeast started a new conversation Giving A Route Name An Extension

So I've got an old rss feed that I want to maintain The old address was http://smartenough.org/podcast_rss.php I've set up the new one using laravel to be at http://smartenough.org/feed It works great BUT I also want to support those old subscribers so I put this line in my route file Route::get('podcast_rss.php', 'RssController@index'); and it seems that route name that end in .php fail giving the error 'No input file specified'.

Is there any way to get this working?

25 Sep
4 years ago

DNABeast started a new conversation Growl When Forge Deploys

Has anyone figured out how to get growl to show a notification once a forge deployment is finished? Is there a way of initiating that from a deploy script or something?

DNABeast left a reply on Installing Repository Hangs

This was eventually solved (by Taylor, so cool).

Turns out my SSH pub key at bit bucket had a typo and this was stalling the install. I have no idea why I could still do a pull request.

19 Sep
4 years ago

DNABeast left a reply on Installing Repository Hangs

Could it be New Relic throwing an error? Would that halt the installation?

DNABeast left a reply on Installing Repository Hangs

Hey! So I managed to get it installed by doing a custom one instead of a bitbucket one.

DNABeast started a new conversation Installing Repository Hangs

I've been using my server for a few months and suddenly, when I try to install a new repository it just sits there for hours telling me it's installing but not doing anything.

I was concerned I'd stuffed up my SSH pub key so I SSHed into the new site (it just had phpinfo) and did a [git init] in the public directory then did a [git pull] and it all worked fine.

Me question is, what else is the Install Repository process doing that could be failing and making it hang?