wing5wong

wing5wong

Member Since 5 Years Ago

Experience Points 28,935
Experience Level 6

1,065 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 411
Lessons
Completed
Best Reply Awards 11
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.

01 Sep
2 weeks ago

wing5wong started a new conversation Jigsaw / Mix / Fontawesome

Having some trouble getting the fonts folder to be generated on a site im using built with Jigsaw. Unfortunately i just cant seem to figure out the fonts folder - i am under the impression this should be automatically created by webpack and not require a manual copy step within mix.

Any help is appreciated.

my compiled css file includes all the correct CSS - as i can see the following


/*!
 * Font Awesome Free 5.10.2 by @fontawesome - https://fontawesome.com
 * License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
 */
@font-face {
  font-family: "Font Awesome 5 Free";
  font-style: normal;

my webpack.mix.js looks like so:

let mix = require('laravel-mix');
let build = require('./tasks/build.js');

mix.disableSuccessNotifications();
mix.setPublicPath(path.normalize('source/assets/build'));
mix.webpackConfig({
    plugins: [
        build.jigsaw,
        build.browserSync(),
        build.watch(['source/**/*.md', 'source/**/*.php', 'source/**/*.scss', '!source/**/_tmp/*'])
    ]
});

mix.js('source/_assets/js/main.js', 'js')
    .sass('source/_assets/sass/main.scss', 'css')
    .options({
        processCssUrls: false
    }).version();

my main.scss

$fa-font-path: "../webfonts";

@import '[email protected]/fontawesome-free/scss/fontawesome.scss';
@import '[email protected]/fontawesome-free/scss/solid.scss';
@import '[email protected]/fontawesome-free/scss/brands.scss';
@import '../css/swiper.min.css';
@import '../css/customisations.css';
06 Dec
9 months ago

wing5wong left a reply on All Problems With The New Laracasts Design

Thanks @jeffreyway Still not a fan but as log as it’s current I can adapt to it. Unfortunately sytill, if not logged in, the what’s new is not visible. Not ideal when checking in on public PCs or machines not frequently logged in

wing5wong left a reply on All Problems With The New Laracasts Design

@SIANGBOON - Seems unfortunate that @jeffreyway doesnt have the same view on using the old catalog way to find new episodes. Unfortunately ive found myself checking in less and less because of this, as current new content is just not visible at a glance, and it seems like the same 'old' content is hogging the top positions.

This seriously needs to be addressed. i too just found out there are 2 new episodes here https://laracasts.com/series/laravel-from-scratch-2018 that are not visible in the "whats new" link hidden behind your avatar (ONLY WHEN LOGGED IN), or in browse by ticking episode.

Why is this still so difficult to see a chronological release of episodes, especially when not logged in (e.g. checking at work, public computers etc)

Still appreciate your content Jeffrey, but have to again, strongly disagree on your approach to showing episodes.

04 Dec
9 months ago
27 Nov
9 months ago

wing5wong left a reply on Call To A Member Function Session() On Null

You can access session data like

if($request->session()->get('paid.paid')) {
    return redirect('payments/confirmed');
}

docs here https://laravel.com/docs/5.7/session#retrieving-data

if the value is not set, you will get null back.

dd($request->session()->get('cats'));    //null
25 Nov
9 months ago

wing5wong left a reply on All Problems With The New Laracasts Design

@JEFFREYWAY - I dont mean to be rude here @jeffreyway, but you've taken something that was in plain sight and one click to reach something, and moved it behind a concealed avatar which shows a menu (once you find the link here in the first place), or takes 3 clicks from the homepage (browse course > browse > clear filter )and 2 page loads (ok 4 was exaggerating but the page loads makes up for it) - If you are not logged in and just want to see the latest videos, this is the only way - you dont have the profile avatar links to follow

Is there a reasoning for the series filter being applied by default in the "Browse" menu, when there is already a clearly defined "Series" menu option as well?

Whats new should be available from the main menu. In this thread alone there are a few people who bring up exactly the same usability issue.

wing5wong left a reply on Is There A Better Way To Delete A Record?

Thats fine if you want to manually control admin users with a simple flag

wing5wong left a reply on Laravel Dynamic Validator

maybe i dont fully understand, but you can start with a base set of rules, then append rules as needed.

$rules = [
                'email' => 'required|email|unique:users',
                'phone' => 'required|regex:/^\(?[1-9]{2}\)? ?9?\d{4}-?\d{4}$/',
                'name' => 'required',
                'nickname' => 'required',
                'role' => 'required',
                'password' => 'required|min:6'
            ]

// ...


$validator = Validator::make($data, $rules);


or add methods to your roles class to retrieve the validation rules

$validator = Validator::make($data, $role->getValidationRules())

wing5wong left a reply on Forge Cost Questiin

it is additional

18 Nov
10 months ago

wing5wong left a reply on Code Review With If, Switch, Foreach

Design an interface, then create classes for each branch. Then you can do,e.g.

foreach($request->platform as $platform){ (new $platform)->handle(); }

17 Nov
10 months ago

wing5wong left a reply on How To Handle Multidimensional Arrays

you can access array data with dot notation if you just want a cleaner look - https://laravel.com/docs/5.7/requests#retrieving-input

$diet_plan= $request->input('diet_plan');
$diet_days= $request->input('diet_plan.diet_days');
$diet_meals = $request->input('diet_plan.diet_days.dietmeals');
$diet_items= $request->input('diet_plan.diet_days.dietmeals.diet_items');
13 Nov
10 months ago

wing5wong left a reply on Send Email To Admin When A New User Registers

You might want to try events.

https://laravel.com/docs/5.7/events#introduction

dispatch an event (https://laravel.com/docs/5.7/events#dispatching-events) in your postRegister method, then you can listen for it and do whatever you need

11 Nov
10 months ago

wing5wong left a reply on All Problems With The New Laracasts Design

@KYRPAS - Agree with this and I also made a post. It’s become difficult to find episodes, as series have been pushed to the front as the main thing now. https://laracasts.com/discuss/channels/site-improvements/replace-browse-menu-option-with-whats-new-functionality

@jeffreyway hopefully you consider his as it’s 4-5 clicks just to find new episodes now, or concealed behind the hidden nav menu.

10 Nov
10 months ago

wing5wong left a reply on Tailwindcss Doen't Work On IE-11

i dont use IE 11 but theres no way this would be acceptable lol. https://imgur.com/a/h1ArrIX i guess the targe audience is a little different, but you probably want this fixed at least slightly

09 Nov
10 months ago

wing5wong left a reply on 500 Error On Root Route Of Prefix

@jeffreyway not related to the question, but that user profile is still not accessible. rdirects homewith 'you do not have permission to view that url'

wing5wong left a reply on 419 Page Expired While Browsing New Laracasts

Chrome Version 70.0.3538.77 (Official Build) (64-bit) on Windows 1809

wing5wong left a reply on 419 Page Expired While Browsing New Laracasts

i can reproduce the issue simply by visiting the account page and clicking through each of the menu links on the side - eventually the redirect/419 occurs

wing5wong started a new conversation 419 Page Expired While Browsing New Laracasts

Noticed this happening seemingly randomly, and not after periods of inactivity - i have been browsing the page, checking the sections, then the redirect happens

e.g. while browsing /settings/account, i get redirected to /newsletters/subscribe with text "Sorry, your session has expired. Please refresh and try again."

This also occured the first time i logged in after the design change

wing5wong started a new conversation Replace 'browse' Menu Option With 'whats New' Functionality

Hi there,

the new layout is great and all, but its become even harder to just find the latest posted video.

You can click browse, but now there is a default "series" filter applied. to find the latest episode, i need to untick series, or click through the series and then select an episode. It has become difficult to find the latest episode, regardless of series, as it now requires additional clicking

I also found out 2 days later, that clicking my avatar unhides a 'what's new' link (again, an extra click, and a hidden option for what should be basic functionality - seeing the latest video)

Please consider replacing the 'browse' link, with the 'what's new' link, even if the headings remain the same.

If I want to browse a series, that function already exists just by clicking the series tab - the latest series updates are listed right there.

also, it is not entirely obvious that the series link is actually containing a drop-down menu as there is no visual indication

Thanks, and i hope you consider this.

02 Mar
1 year ago

wing5wong left a reply on Laravel : Fetch Data Inside Controller

you should be assigning these lines to variables. request->input() returns a value

$leadnote = str_replace([ '{' , '}' , '[' , ']' ], '|', $request->input('lead_note') );
21 Dec
1 year ago

wing5wong left a reply on Add Multiple Images To Database

you are using elseif. only the first block gets executed ebcause you have selected a file.

 if ($file = $request->file('image')){

            $name = $file->getClientOriginalName();

            $file->move('images/listings', $name);

            $input['image'] = $name;

        }

// was a 2nd image selected?
if ($file1 = $request->file('image1')){

            $name1 = $file1->getClientOriginalName();

            $file1->move('images/listings', $name1);

            $input1['image1'] = $name1;

        }

// was a 3rd image selected?
if ($file2 = $request->file('image2')){

            $name2 = $file2->getClientOriginalName();

            $file2->move('images/listings', $name2);

            $input2['image2'] = $name2;

        }
10 Nov
1 year ago

wing5wong left a reply on Display More Than One Tag On Views

Did you define a post -> tags relationship on your model? it shouldnt return a 4 here, but a collection

 #parameters: array:6 [▼
      
      "title" => "CSS IS FINE1"
      "slug" => "CSS-IS-FINE1"
      "tags" => "4"
      

you only see one tag because you have one single value "4"

02 Jun
2 years ago

wing5wong left a reply on Trying To Create Seeder For Belongstomany Pivot Table

$users = User::first();

You've selected only one user here, did you intend to do that? wouldnt you want a foreach loop over User::all()

11 Aug
3 years ago

wing5wong left a reply on No Supported Encrypter Found. The Cipher And / Or Key Length Are Invalid.

To be honest I haven't done any more yet. Everything appears to function ok despite the log. I will try addin the Apache env and report back some time this week

07 Jul
3 years ago

wing5wong left a reply on How To Do A Complicated Query With Where And Count On Multiple Tables

{{ $totalOpen }}

is an array right, you need to loop and not just echo it

06 Jul
3 years ago

wing5wong left a reply on No Supported Encrypter Found. The Cipher And / Or Key Length Are Invalid.

@DataBound i believe so - db connection and all that are set.

@bashy How can i add this to vhost?

It appears to be quite random, i cant track any specific event to it yet,

wing5wong started a new conversation No Supported Encrypter Found. The Cipher And / Or Key Length Are Invalid.

Have noticed this popping up in my logs. Not sure why Null passed here as the key. it is set, and have run php artisan key:generate multiple times to attempt to resolve this.

Any ideas?

stack trace:

Stack trace:
#0 D:\......\vendor\laravel\framework\src\Illuminate\Encryption\EncryptionServiceProvider.php(25): Illuminate\Encryption\EncryptionServiceProvider->getEncrypterForKeyAndCipher(NULL, 'AES-256-CBC')
//config/app.php
'key' => env('APP_KEY'),

    'cipher' => 'AES-256-CBC',
// .env
APP_KEY=base64:lx/tjlQn7A...............................................
15 Jun
3 years ago

wing5wong left a reply on Overuse Of Fillable

Some people just put all the fields in the model onto the fillable array, rather than just those they should/need to

wing5wong started a new conversation Nested XML Parsing With Orchestra\Parser

I've been given an XML file to parse but im struggling to access some elements. They have the same element name. A short version here so you get an idea about what i am talknig about. Each Learner has multiple <EnrollingProvider> and each <EnrollingProvider> has multiple <Entry> within <NCEAEntries>

<ns3:Learners>
        <ns3:Learner>
            <ns3:LearnerDetails>
                <ns4:NationalStudentNumber>123456789</ns4:NationalStudentNumber>
                <ns2:LearnerName>
                    <ns2:FirstName>John</ns2:FirstName>
                </ns2:LearnerName>
                <ns4:EthnicityCode>21111</ns4:EthnicityCode>
                <ns4:EthnicityCode>11111</ns4:EthnicityCode>
            </ns3:LearnerDetails>
            <ns3:EnrollingProvider>
                <ns4:ProviderNumber>123</ns4:ProviderNumber>
                <ns3:NCEAEntries>
                    <ns3:Entry>
                        <ns3:Standard>
                            <ns2:StandardNumber>90144</ns2:StandardNumber>
                        </ns3:Standard>
                        <ns3:SecondaryResult>
                            <ns3:SecondaryResultCode>A</ns3:SecondaryResultCode>
                        </ns3:SecondaryResult>
                        <ns3:CreditValue>5</ns3:CreditValue>
                    </ns3:Entry>
                </ns3:NCEAEntries>
            </ns3:EnrollingProvider>

The (cutdown - 1 entry) full XML document here: https://gist.github.com/wing5wong/d11092729ec7425c4e9969fdc0dccb03

What i have come up with so far, using Orchestra\Parser package , is as follows, but it doesnt get tthe mutliple entries for EnrollingProvider or Ethnicity code, just the first.

$xml = \XmlParser::load(storage_path('students.xml'));

        $learner = $xml->parse([
            'nsn' => ['uses' => 'ns3:Learners.ns3:Learner.ns3:LearnerDetails.ns4:NationalStudentNumber'],
            'first_name' => ['uses' => 'ns3:Learners.ns3:Learner.ns3:LearnerDetails.ns2:LearnerName.ns2:FirstName'],
            'middle_name' => ['uses' => 'ns3:Learners.ns3:Learner.ns3:LearnerDetails.ns2:LearnerName.ns2:MiddleName'],
            'last_name' => ['uses' => 'ns3:Learners.ns3:Learner.ns3:LearnerDetails.ns2:LearnerName.ns2:LastName'],
            'gender' => ['uses' => 'ns3:Learners.ns3:Learner.ns3:LearnerDetails.ns2:GenderCode'],
            'birth_date' => ['uses' => 'ns3:Learners.ns3:Learner.ns3:LearnerDetails.ns4:BirthDate'],
            'local_id' => ['uses' => 'ns3:Learners.ns3:Learner.ns3:LearnerDetails.ns2:LocalIdentifier'],
            'ethnicity' => ['uses' => 'ns3:Learners.ns3:Learner.ns3:LearnerDetails.ns4:EthnicityCode'],

            'enrollingProvider.number' => ['uses'=>'ns3:Learners.ns3:Learner.ns3:EnrollingProvider.ns4:ProviderNumber'],
            'enrollingProvider.ncea_entries' => ['uses'=>'ns3:Learners.ns3:Learner.ns3:EnrollingProvider.ns3:NCEAEntries.ns3:Entry[AcademicYear,ns3:Standard.ns2:StandardNumber,ns3:Standard.ns2:StandardVersionNumber,ns3:LevelCode,ns3:SecondaryResult.ns3:SecondaryResultCode,ns3:SecondaryResult.ns3:CompletedDate,ns3:CreditValue,ns3:FundingYearLevelCode,ns3:AssessingProvider.ns4:ProviderNumber,ns3:AssessingProvider.ProviderLocationNumber]'
            ]

            ]);

        var_dump($learner);

Is there a better way to retrieve this data?

08 Jun
3 years ago

wing5wong left a reply on No Query Results For Model [App\Player]

Are you sure you dont have another route above that? If your die() isnt even being called that is a big sign, otherwise a middleware is interfering

29 May
3 years ago

wing5wong left a reply on SQLSTATE[42S02]: Base Table Or View Not Found

if you want to stick to the 'user' table name, you can also set the tale proerty on the User class.

protected $table = 'user';

27 May
3 years ago

wing5wong left a reply on Store From Check Boxes As An Array.

Nothing wrong with that data. What are you expecting to see?

You should then be able to access those fields in a foreach($model->field as $savedField){ ...}

23 May
3 years ago

wing5wong left a reply on Store From Check Boxes As An Array.

if you dont want to json decode every time, you can add

protected $casts = ['flavours'=>'array'];

to your model to have it done every time you retrieve a model from the DB

22 May
3 years ago

wing5wong left a reply on Where To Put Authorization?

How about a middleware and apply to a route group?

Route::group(['middleware'=>'TeamOwner'], function(){
// protected routes - edit, update, show(?)
});
<?php

namespace App\Http\Middleware;

use Closure;

use App\Team;

class RedirectIfNotTeamOwner
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)

    {
    // Auth logic
        if(!($request->team->user_id === $request->user()->id)) {
            return redirect('/');
        }
        return $next($request);
    }
}
19 May
3 years ago

wing5wong left a reply on Bug MethodNotAllowedHttpException After Authentication?

Which method is not running? to run the Route::patch() you need to make sure to include a {{ method_field('PATCH') }} in your form

What is the Route::auth(); line?

What is line 219?

wing5wong left a reply on Array Vs Database To Populate Radio Inputs

@nickwest you dont store the key, you store the name of the position. e.g. positions field contains: {'center':1, 'guard':0,'forward':1} from this i can tell my user will play as center or forward, but not a guard.

It has the upside of being able to easily add or remove positions as needed. (and the downside of being able to contain invalid, or no longer existing values) as i said - you wouldnt use this for larger systems or 'more important' attributes, only ones with a small, non (non-frequently) changing values.

@Swaz the values get cast on retrieval from the database, not going in. You cant query the database to get the values, you would have to retrieve all the records and filter that collection afterward. If you wanted that functionality, i wouldnt recommend using this method, and you should prefer a table for that column, as it is a 'more important' part of your application (you want to query based on it)

edit maybe you can query the new json column type - i havent used it personally (when i used this, json column type was not usable - i am just storing json in a string field) It looks like https://laravel.com/docs/5.2/queries#json-where-clauses you can though, so $model->positions->center should return 1 in my case

wing5wong left a reply on Array Vs Database To Populate Radio Inputs

I think my method is for option 3 in the OP.

You are not storing each (for sake of example) position in its own table to retrieve the original data for the inputs. These values can be hardcoded (and modified) from one file as and when needed.

This is not a 'bad' option, only one to be careful when using, and only use when confident the values will not change (or change very infrequently)

wing5wong left a reply on Array Vs Database To Populate Radio Inputs

What do you mean keyless, it would be stored in a field related to the data. Im not recommending 1 'assorted_data_all_in_one_field' column

The only thing that changes with this approach is you dont have to maintain a model and table for those options,

for example, signing up to play in a team, i dont need a Position table and model, i only ever want to display the position to choose when signing up/editing, and display it in my views. In this case, its simple to just do this.

// store as json in positions field  and use casts property
first_name, last_name, gender, positions
Sean, Anderson, M, {"center":1,"guard":0,"forward":1}

//player model
protected $casts = ['positions'=>'array'];

// ================
// VS
// ================

// store each position as individual column - we cant iterate over positions easily this way
first_name, last_name, gender, position_center, position_guard, position_forward
Sean, Anderson, M,  1,0,1

// ================
// VS
// ================

//players table
id,first_name, last_name, gender, positions
Sean, Anderson, M,

//player_position
id, player_id,position_id
1,2
1,3

// position
id,name
1, forward
2, guard
3, center

wing5wong left a reply on Array Vs Database To Populate Radio Inputs

simple options you can store the values as arrays in your code, and save them as json in a text field in the db. then when retrieving a model, set the castsproperty

    $array = ['1','2','3'];
    // ....
    $model->field = json_encode($array);
    $model->save();
// myModel.php
$protected $casts = ['arrayField' => 'array']
    //some view/controller/whatever
    foreach($myModel->arrayField as $field){ ...}

wing5wong left a reply on Cant Build A Working "edit" Function..

public function User()
    {
        return $this->belongsTo('App\User');
    }

change to lower case 'user',

public function user()
    {
        return $this->belongsTo('App\User');
    }

or

update this to have the capital 'User',

$movie->User()->movie()->save();

although it doesnt even need the relationship call at all

$movie->save();
03 Apr
3 years ago

wing5wong left a reply on Prevent Validation When Another Field Isn't Present

the required_if seems like it will do exactly as you want, maybe you could clarify a bit more as to what you want. Do you just not want to validate that field at all? I wouldnt worry about the 1 extra validation - even when not required. This is unliklely to be any issue to performance.

Using the service provider to add extra validation rules would make the most sense - your logic will still be contained in the form request class, only the implementation will be in the service provider.

wing5wong left a reply on FatalErrorException In MailController.php Line 71: Syntax Error, Unexpected '$sender_id' (T_VARIABLE), Expecting Function (T_FUNCTION)

is this even valid, can you declare a named function inside a conditional?

if(Auth::user()->id == $sender_id || $recipient_id) {
        public function show($mail_id) 
        {
25 Feb
3 years ago

wing5wong left a reply on Best Way Of Updating A Drag/drop Sorting List On The DB Side...

From a laravel 3 project.... pretty much exactly the same

public function post_reorder(){
        $data = Input::get('links');
        
        foreach($data as $k=>$v)
        {
            $link = Link::find($v);
            $link->order_by = $k;
            $link->save();
        }
    }
29 Jan
3 years ago

wing5wong left a reply on Array Validation For Checkboxes / Radio Buttons

i think you need to index the list[] input? havent personally used 5.2 in anything yet

 @foreach($lists as $list)

        <div class="checkbox">
          <label>
            <input type="checkbox" name="list[{{$list->id}}]" value="{{$list->id}}">
          </label>
        </div>

        @endforeach 
13 Jan
3 years ago

wing5wong left a reply on Separate CRUD Operations

Why not separate into multiple Admin controllers? Admin\MarketRateController and Admin\ShopController for example

12 Jan
3 years ago

wing5wong left a reply on One Off CSS

Yup, and the same thing for a JS section

wing5wong left a reply on One Off CSS

I like to use a separate area in my template for this

//template
@yield('page-styles')

alternatively you can give your pages an id and add per-page styling to your main CSS

/** Per page stlyes **/

#myExtraPage {
    .hero {
        background-color: #444;
        }

}
11 Jan
3 years ago

wing5wong left a reply on View Not Inherit All The Data

show an example of your code