drewdan

PHP Engineer at Talkative Ltd

Member Since 1 Year Ago

Newport

Experience Points
48,960
Total
Experience

1,040 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
202
Lessons
Completed
Best Reply Awards
38
Best Reply
Awards
  • start your 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-in-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 Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist 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 10
48,960 XP
May
29
3 days ago
Activity icon

Replied to Where To Store OAUTH Token

My thought was, the user would do this once, so it felt a bit clunky to store a token in the database, push something to GTM, and then keep the token. Surely if I needed it, I could just get them to reauth? Rather than saving it for something they may edit once a year, maybe a little more frequently.

Activity icon

Started a new Conversation Where To Store OAUTH Token

Hey Guys,

I am not sure of the best approach to take here.

I am integrating with Google Tag Manager, and I am wondering what the best approach to take is.

I want the user to be able to login to their Google Account via OAUTH and then have their GTM configuration displayed. The goal is to add something to their GTM account specific to our application and then they no longer need to use the integration unless they wish to change something in future. For which I would want them to reauth.

So, my question is, how do I store the $token to use it during the configuration process. Should it be a session variable? Stored in the cache? I do not want to make a database change for this feature, so would rather not store it in the database.

Any thoughts or insight would be swell :)

Cheers Guys!

May
28
4 days ago
Activity icon

Replied to Google API With User Password Auth Rather Than Key

Worked a treat! Ta very much!

Activity icon

Replied to Google API With User Password Auth Rather Than Key

It is oauth2! I thought it was. I think 🙃

I'll have a good read through now. Thank you kindly :)

Activity icon

Replied to User Specific Slack Notifications

The $notifiable should be the current user being notified? And I guess you have the slack webhook url stored in the database for that user?

Is that what you are trying to do here?

Activity icon

Started a new Conversation Google API With User Password Auth Rather Than Key

Hey Guys,

I am trying to build an integration into Google Tag Manager.

Currently, the application I am working with integrates into many google services such as translate and we use the google credentials json file for this.

What I want, is the for the user to visit a page, and they will be presented with a google login prompt, this will then be authenticated and they will be presented with a list of their google tag manager containers and they go from here.

The idea is anyone can login and use this, without needing to have a google cloud account etc.

I am struggling to find documentation on how to do this, mainly because I think I am getting terminology confused. Has anyone seen any documentation/article/tutorials on doing such a thing please?

Cheers! :)

Activity icon

Replied to Import Excel With Value

Help you how? If you wanna show us the code you have written so far and tell us where you are stuck, we can help that way

May
27
5 days ago
Activity icon

Replied to Import Excel With Value

Have you tried using the Laravel Excel package? It's great for uploading and exporting excel spreadsheets

Activity icon

Replied to Https Redirection Is Not Working...

What URL does your app have in the .env file? Has that been set to HTTPS?

Activity icon

Replied to Javascript Stopped Working

Are you pulling in any external libraries? Could any of them have been updated? Maybe to a new major version which had breaking changes?

Activity icon

Replied to How Add Permission To Storage Directory ?

I think you need to change the owner of your storage folder. This error is because the blade files cannot be compiled and stored. It looks like root has ownership of the directory, I think it should be www-data. Are you doing this all in command line? Or do you have a gui to change owners and permissons?

May
26
6 days ago
Activity icon

Replied to I Have An Old Project Using Laravel 5.5 Should I Upgrade To 6.0 Or 7.x?

It's always good to be on the latest version, better security, access to the latest functionality. Enhancments for the latest PHP version too!

Activity icon

Replied to I Have An Old Project Using Laravel 5.5 Should I Upgrade To 6.0 Or 7.x?

Use the upgrade guides to upgrade to 6 and then upgrade to 7. Do it in steps to make it easier or use Laravel Shift - https://laravelshift.com/ it's only a small expense and it's handled form you :)

Activity icon

Replied to Mailable Timeout And Partial Delivery Issues?

It's tricky to diagnose without further information from the mail server. If it is timing out, I'd have expected some log entry on their mail server to say why it timed out.

Might be worth switching the mail provider to mailtrap and recreating the conditions in which the mail sending fails, if you cannot recreate it, then the onus is on their IT contracts to identify the issue then

Activity icon

Replied to Mailable Timeout And Partial Delivery Issues?

Ok, so in those emails, how many recipients are there? 3? Would that make your count higher?

I'm not sure what email server you are running, but on my postfix server, I have loads of strange limits, limit the amount of emails, the amount of client connections per minute, the amount of recipients per minute. So my server can handle large volumes of mail, just not all from the same user at once.

Normally with emails, it's to me a case of, I send it to the email server, if the email server gets it, happy days, that's my worries done, if it fails at this point it's the hardware guys issue. Of course we try catch the emails and if they fail because of something, we report that, but I've never known an email server to accept an email, send to the recipient and cc, but bomb out on the bcc.

Are you running postfix?

Activity icon

Replied to Trait Vs Hepler In Laravel

Yeh, what @martinbean said. I think that's pretty spot on

Activity icon

Replied to Mailable Timeout And Partial Delivery Issues?

How many emails are firing out at once? Could the mail server be getting overwhelmed?

Activity icon

Replied to Use 1 Facade For All Functions

You'd still have to use $this->theme every time you tried to return a view though wouldn't you. Though that is still better than making a custom facade :)

Activity icon

Replied to Use 1 Facade For All Functions

Excellent, yeh, it's just a more natural way to pull a theme depending on the env/config setting.

Glad I could help :)

Activity icon

Awarded Best Reply on Use 1 Facade For All Functions

Can't you just use config('ordx.THEME.FRONTENDTHEME') in your blade partials. I'd assume you have something like app.blade.php which your other blade files extend. So have different app.blade files and when you extend another blade file

@extend(config('ordx.THEME.FRONTENDTHEME');

I definitely don't think you need your own custom facade to return a view, you're trying to reinvent the wheel. You just need to change how you are using the wheel.

Activity icon

Replied to Use 1 Facade For All Functions

Can't you just use config('ordx.THEME.FRONTENDTHEME') in your blade partials. I'd assume you have something like app.blade.php which your other blade files extend. So have different app.blade files and when you extend another blade file

@extend(config('ordx.THEME.FRONTENDTHEME');

I definitely don't think you need your own custom facade to return a view, you're trying to reinvent the wheel. You just need to change how you are using the wheel.

Activity icon

Replied to How To Have Phpmyadmin On Nginx VirtualHost Ubuntu

This guide by digital ocean is really in depth and should step you through setting up a connection to your database with a selection of mysql clients :)

https://www.digitalocean.com/community/tutorials/how-to-connect-to-a-mysql-server-remotely-with-mysql-workbench

Activity icon

Replied to How To Have Phpmyadmin On Nginx VirtualHost Ubuntu

Do you currently access your server using secure shell with a public key?

Activity icon

Replied to Use 1 Facade For All Functions

Yeh, What?! What does your facade do differently to the View class?

Can you share your code with us?

Activity icon

Replied to Stripe Create Payment Method Client Side Vs Server Side

I'd recommend picking a convention and sticking with it. Personally I like doing stuff server side, seems a little more secure as people cannot see the code that's being executed, and you'd eventually need to hit the server to store some data too. So might as well do all of the grafting there.

I think the JavaScript library is more for non native web apps? And other front end focussed development. Though I'm not 100% sure on that

Activity icon

Replied to How To Have Phpmyadmin On Nginx VirtualHost Ubuntu

You would have to create another site, and install phpmyadmin into that directory. I guess there is probably an installer for it these days using composer.

Why not instead try using mysql community workbench and connect to your server with an SSH connection instead, it will be vastly more secure and one less thing to configure on your server

Activity icon

Replied to Question About Cache In Laravel 6 Or 7

The Facade is not a cache method, rather a way of accessing whichever Cache you are using without having to write code specific to that cache driver.

We use Redis, and we have a cache server of its own to handle cache data. In our case, without Caching, the database would not be able to cope with the massive amount of requests.

There are packages about to handle lots of caching for you - https://github.com/GeneaLabs/laravel-model-caching - this package for example will cache model queries, so if the same query is called, it will return the cached version, and the cache will automatically bust if the model changes.

Which one you should use it down to you. I have no experience with Memcache, but I think its much the same as Redis. Database just stores data in the database, this would only really be suitable for small applications, the idea being, it would reduce the amount of database calls, but a bigger call could be replaced with a smaller one.

Me personally, I use Redis in all my applications and would not bother with a database Cache unless I am working in a development environment.

Activity icon

Replied to How To Read Replies When Using Mailgun To Send Mails?

I always use mailgun for transactional email, typically, [email protected] Mailgun also suggests setting up a subdomain like mg.yourdomain.com to send mail from. Why do you need your visitors to reply? Is it something that needs to be tracked?

If it is not, I would just specify a reply to email in your email config, so when your users reply, it gets sent to a specific mailbox that you can monitor.

Activity icon

Replied to Laravel Testing - Can't Connect To DB On Unit Test (but Works Perfectly In Feature Test)?

Can you post a redacted version of your phpunit.xml file?

Activity icon

Replied to How To Test A View Composer

I managed to use this in my test

$mock = $this->mock(View::class);
$mock->shouldReceive('with')->with('some data')->andReturns('foo');

You do not need to pass it as an array unless you are using more than one item. The interface looks like this:

 /**
     * Set expected method calls
     *
     * @param string|array ...$methodNames one or many methods that are expected to be called in this mock
     *
     * @return \Mockery\ExpectationInterface|\Mockery\Expectation|\Mockery\HigherOrderMessage
     */
    public function shouldReceive(...$methodNames);

As its not type hinting an array, it does not need to have an array, but if it has an array, it will use the spread function to pass this method multiple parameters.

Alas though, from the look of it, this does not appear to be your issue.

Maybe try accepting any args for now, see if we can get the test passing that way:

$view->shouldReceive('with')
            ->withAnyArgs()
	    ->andReturn('foo');
May
24
1 week ago
Activity icon

Replied to How To Test A View Composer

I don't think you need that shouldRecieve as an array

$view->shouldReceive('with')
            ->with([
                'categories',
                Category::getParents()
            ])
            ->once();
Activity icon

Awarded Best Reply on Mailgun Does Not Send Any Mails

Ah, your domain is wrong. The domain should match the domain you have authorized in your mailgun account and if you want to change the API endpoint you need to add and env variable for MAILGUN_ENDPOINT.

Activity icon

Replied to How To Get Middleware To Fire?

The middleware fires inbetween the requests and the response. Here, you're newing up a controllers, so that middleware won't fire.

If you did a feature test and did

$this->get('your-route-to-controller');

You would cause the middleware to fire.

I'd recommend a mixture of feature and unit tests to get the best coverage to make sure the middleware is firing.

In our tests we made a custom assertion to assert route has middleware, so we know it's there, even if it doesn't get fired when doing unit tests. And then we have a separate test for the middleware to make sure it does what we want it to do.

Activity icon

Replied to Search With Date Picker And Show Result

Just create a page with a form containing a date picker, the html5 date picker should do the job, pass the data back to the controller and perform your query. Eloquent has some helpful whereDate methods to make the query generation that little bit cleaner and easier.

Once you've done that, show a view and give it the collection of results and output it

Activity icon

Replied to Email Hosting

I have a VM in Azure running webmin/virtualmin where I host my old clients emails. You have to open a support ticket with them now, as they block any email sending by default.

Otherwise I use Microsoft to host my emails on their exchange servers. It's a monthly fee, but I never have to worry about it. For my new clients I'm insisting they run their emails through gsuite or Microsoft, as it's just one less headache. Any transactional email from any website is then sent through mailgun

Activity icon

Replied to Call To A Member Function GetActiveOrder() On Null

$order = tap($activeProject())->getActiveOrder();

Maybe try something like that. Not sure if you'll need first or get after getActiveOrder

May
23
1 week ago
Activity icon

Awarded Best Reply on How To Embed Multiples Videos In Laravel Web Application

You could upload the video and render it using HTML tags. Or use a service like Vimeo, upload to their servers and embed the player into your website. Much like how this website works

May
21
1 week ago
Activity icon

Awarded Best Reply on Laravel Job Failing

You could try to log the failure reason:

/**
* The job failed to process.
*
* @param  Exception  $exception
* @return void
*/
public function failed(Exception $exception)
{
    // Send user notification of failure, etc...
}

and see if that shines any light on whats causing the job to fail

Is the data the same in your local environment to the data you are using on your forge instance?

May
20
1 week ago
Activity icon

Replied to Global Object To All Controllers And Views

Is this custom domain going to be a subdomain? If so, you can do a domain routing:

https://laravel.com/docs/7.x/routing#route-group-subdomain-routing

This makes the subdomain available as the first parameter on your controller methods, and then you can use that in your queries. Or you can apply some global scopes to your models which apply a scope depending on the domain route

Activity icon

Replied to Link Laravel Blade Files Inside VueJS Component

Is there are reason you have chosen to do this with a vue component? Does this need to be reactive? Why not just make a blade partial and include it?

Activity icon

Replied to Save Hasone Eloquent

Yup, so just use the code example I used above, you create it on the relationship and that means the serial automatically inherits the article id

Activity icon

Replied to Changing .env File

I am glad it did, can you mark the best answer please, so people finding the forum can see the best answer straight away :)

May
19
1 week ago
Activity icon

Replied to Sending Mails Using Laravel Mailable In Roundcube Mails

Just did some checks on your domain. Specifically an SMTP test, looks like there might be some issues you need to speak with your hosting company about:

https://mxtoolbox.com/SuperTool.aspx?action=mx%3amail.mnstalryadh.com&run=toolpage

Activity icon

Replied to Mailgun Does Not Send Any Mails

Ah, your domain is wrong. The domain should match the domain you have authorized in your mailgun account and if you want to change the API endpoint you need to add and env variable for MAILGUN_ENDPOINT.

Activity icon

Replied to Email Error

Have you enabled access for less secure apps in Gmail?

Activity icon

Replied to Js File Not Updating In Website.

Have you built the files using npm run dev or npm run build or the yarn equivalent of you're using yarn

Activity icon

Replied to Emails Are Not Sent

There has been a lot of this issue recently.

I think the most common has been incorrect credentials or configuration, wrong port etc, and the the other one was a # in the password, which constitutes the start of a comment in an env file, so you'll need to wrap this in quotes

Activity icon

Replied to For New Website Which Version Of Laravel Is Better 6 Or 7?

Always go with the recent, saved you having to upgrade later in your project, as you'll inevitably have to upgrade eventually unless it's a really short term project

Activity icon

Replied to Vue Custom Component

Cheers, yeh, I think it can be stretched to do what I want it to do, but I think I'm tacking the problem I have with the wrong solution. So it's back to the drawing board, but the answer you gave remains the correct one to my question! :)