longestdrive

longestdrive

Member Since 6 Years Ago

Experience Points
10,275
Total
Experience

4,725 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
75
Lessons
Completed
Best Reply Awards
0
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 3
10,275 XP
Apr
07
1 month ago
Activity icon

Replied to Getting Started With Laravel-Mix. Basics And Complexity

Thanks squiby I'll give that method a try. I'll keep persevering although finding the experience very frustrating.

I think with the Laravel framework it pretty much works straight out of the box yet with Mix it's a lot of trial and error and def not a shallow learning curve

Thank you again for the help

:)

Apr
06
1 month ago
Activity icon

Started a new Conversation Getting Started With Laravel-Mix. Basics And Complexity

Hi

I've been trying to get to grips with Laravel Mix to bring an older app up to date and refactor the front end.

I've had mixed success but each time I get my head round it I take one step forward and one step back. So I'm misunderstanding a number of concepts here I'd like some help with.

My app uses jQuery, bootstrap 3 and a range of js plugins. Some pages need scripts to handle set up such as datatable, form wizards and scripts to handle form controls etc

Up until now I've included the relevant js files in using script tags, concatenated the "plugins".

So here are some problems I've encountered:

  1. **loading Jquery for global access: **

I've tried numerous approaches to get this to work, datatables for example complained $ was not a defined. So after much searching I have this in my webpack.mix.js file:

const mix = require('laravel-mix');
const webpack = require('webpack');

mix.webpackConfig({
    plugins: [
        new webpack.ProvidePlugin({
            '$': 'jquery',
            'jQuery': 'jquery',
            'window.jQuery': 'jquery',
        }),
    ]
});

I assumed this would include jQuery and make it available globally - it didn't so I then added this to my test script:

mix.autoload({
    jquery: ['$', 'window.jQuery']
}).js('resources/js/src/test/test.js', 'public/js-test')
    .extract(['jquery', 'bootstrap', 'bootbox',]);

I thought this again would make it available, but that failed too so finally added this to my test.js file.

/*
* import core plugins
 */

// import $ from 'jquery';
// import jQuery from 'jquery';
// window.$ = window.jQuery = $;

// window.$ = window.jQuery = jQuery;
global.$ = global.jQuery = require('jquery');

Success, this now works for datatables - i've left the other attempts in above as comments so you can see what I've tried.

So - having got this to work for jQuery what is the correct way to do this, why are there so many different ways and why, for something so common, is this so difficult? Are any of the methods duplicating each other?

##2. Plugins.##

Next step to gradually add back the plugins the pages use. With my test script I started to build these up one plugin at a time and deal with the fails. If I keep doing this my compiled script will be a monster size ( a few lines of my code to test have already bloated it to 1.6mb and that's after extracting some files to vendor.

What is the best way to add plugins to the script? Here's what I've tested so far:

//import bootstrap and utilities
import '../core/bootstrap.js';

var moment = require('moment');
var bootbox = require('bootbox');
require('bootstrap-colorpicker');
require('../core/common-plugins.js');

With the moment and bootbox plugin I needed to assign as variables to get them to work. To avoid file bloat I thought I could add these to common-plugin.js which looks like this:

require('block-ui');
require('autosize');
require('bootstrap-confirmation2');
require('bootstrap-daterangepicker');
require('bootstrap-wizard');
require('jquery-colorbox');
require('jquery-slimscroll');
require('jquery-validation');
require('jquery.cookie');
require('magicsuggest');
require('messenger-hubspot');
require('moment');
require('pickadate');
require('select2');
require('timeago');

Some of these work, some don't. I had to move bootbox back to the test.js file to get that to work and gradually doing the same with the rest. So - should I simply revert back to concatenating the plug in scripts as I did before and forget about adding these as requirements. As you can see I'm not sure of the different concepts here so any explanation or best practice would be great :) I'm confused about this!!

I've looked at loads of different approaches but have yet to find one that works or covers this - I thought this would be a common problem?

I'm beginning to regret starting this, but determined to get an approach so I can keep on learning. I've posted similar questions in the past but zero response, so hope someone can point me in the right direction.

Apr
04
1 month ago
Activity icon

Awarded Best Reply on Testing A Secure Route Laravel 5.5 NotFoundHttpException

Hi

Yes the route is available from the browser but not in testing. The route specifies Https and after a bit of digging the url the test forms specifices Http instead.

In the end the solution was to use the route() helper to create the test url from the route name:

$response = $this->call('GET',route('contact.secure.page'));

This then generates the correct Https url and the page is found

Thanks

Activity icon

Replied to Testing Laravel Mail View

Thank you - apologies - I got stuck into your solution and failed to acknowledge your response :)

Activity icon

Awarded Best Reply on Laravel Mailable Variable Not Found

Quick update - the error no longer appears - so likely something to do with the cache. If it re-occurs after an update Ill clear the cache and see if it makes a difference

Activity icon

Replied to Choosing A New Host - Aws Lightsail Or Another Vps

Hi - thanks all. forgot to feedback and did plump for Forge in the end. Sooooo much simpler! Thank you

Apr
03
1 month ago
Activity icon

Started a new Conversation Updating Js Library/plugins To Work With Es6 Mix

Hi I'm trying to catch up with es6 and start using laravel mix for my assets and JS scripts. I've got mix up and running and trying now to import jquery, bootstrap and a number of plugins into my pages rather than import them through script tags

Here's an example of my scripts:

import $ from 'jquery';
window.$ = window.jQuery = $;

import('jquery-ui');
import('bootstrap');
import('jquery.uniform');
// import('popover');

export var App = function() {

    var currentPage = ''; // current page
    var collapsed = false; //sidebar collapsed
    var is_mobile = false; //is screen mobile?
    var is_mini_menu = false; //is mini-menu activated
    var is_fixed_header = false; //is fixed header activated
    var responsiveFunctions = []; //responsive function holder

// plus a lot more code and functions i've removed for brevity

}

In my mix script I have this:

mix.js('resources/js/src/core/base-script.js', 'public/js/core')
    .extract(['bootstrap', 'jquery-ui', 'jquery.uniform']);

and then in my page I have:

<script src="/js/core/manifest.js"></script>
<script src="/js/core/vendor.js"></script>
<script src="/js/core/base-script.js"></script>

But I'm then getting errors on my page:

Confirmation requires popover.js
Uncaught ReferenceError: App is not defined

popover.js should be part of bootstrap, and App is the main script I'm trying to import

so: What's the best approach to importing js packages - should I just leave them as they are and import the old way using script tags? How should I convert my existing scripts/modules to be compatible with es6

I'm going through the tutorials on laracasts but havent found anything (yet) on importing packages

Any help appreciated - trying to refactor my messy js code base so want to bring it up to date

Thanks

Mar
16
2 months ago
Activity icon

Started a new Conversation Testing With UploadedFile And Intervention/Image Unable To Mock

Hi

I'm trying to create a test of a method that uses intervention/image to resize an image.

In my test I am using:

use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\Storage;
use Intervention\Image\Facades\Image;

However when I try to use it in a test I get an error that the Image Source Unreadable.

I've tried mocking Intervention\Image but to be honest not sure I'm doing it the right way as each time I try it doesn't come up an appropriate response so I'm doing something wrong.

Here's my test code that creates the Image Source Unreadable

public function test_downsize_image_to_specific_width()
    {
        $file = UploadedFile::fake()->image('image.jpg', 1600 );
        Storage::fake('public')->putFileAs('content/articles/', $file, 'image.jpg' );

        $imageFormatter = app( ImageFormatter::class);

        $result = $imageFormatter->handle('content/articles/image.jpg');

        $this->assertEquals(1200, $result->width());
    }

I have tried:

$test = Image::partialMock()->shouldReceive(['make', 'resize'])->once();

Which comes up with an error of Image Source Unreadable

$mock = $this->mock(Image::class)->shouldReceive('make')->once();

Which comes up with an error - Cannot redeclare Mockery_0_Intervention_Image_Facades_Image::shouldReceive()

$test = Image::spy()->shouldHaveReceived('make')->once();

which comes up with the error Mockery\Exception\InvalidCountException : Method make(<Any Arguments>) from Mockery_0_Intervention_Image_ImageManager should be called at least 1 times but called 0 times.

Do I need to use a real file to complete this test?

Any help appreciated - I've posted a question to the developers but no response yet on how to integrate into my tests