wing5wong

wing5wong

Member Since 5 Years Ago

Experience Points 27,385
Experience Level 6

2,615 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 396
Lessons
Completed
Best Reply Awards 11
Best Reply
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    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 Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

06 Dec
6 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 machine snot 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, 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
6 months ago
27 Nov
6 months ago

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

You can access session data like ``$request->session()->get('paid')

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

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

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

Something like the below should work

//controller
// assign data somehow
$data = ['paid'=>true];
Session::flash('paid',$data);

if (Session::get('paid.paid') ) {
    return redirect('payments/confirmed');
  }
25 Nov
6 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, or takes 3 clicks and a page load (ok 4 was exaggerating but the page laod makes up for it).

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. A few people have queried this

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
7 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
7 months ago

wing5wong left a reply on How To Handle Multidimensional Arrays

you can access array data with dot notation - 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
7 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
7 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 but to find new episodes now, or concealed behind the hidden nav menu.

10 Nov
7 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
7 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

shouldnt you be assigning these lines to variables

$request->input('lead_note') = 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.

change all the else ifs shown to plain ifs

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"
      

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
2 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
2 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
2 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 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);$xml = \XmlParser::load(storage_path('students.xml'));

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

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

If its hitting the Route model binding are you sure you dont have another similar route? You shouldn't get model binding on an add route, unless there is more to the routes that we cant see

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?

<?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)

    {
        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

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)

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 for example, signing up to play in a team:

// player table
first_name, last_name, gender, positions
Sean, Anderson, M, {"center":1,"guard":0,"forward":1}

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

You 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');
    }

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

do you need an index for 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 separate Admin controllers? Admin\MarketRateController and Admin\ShopController for example

12 Jan
3 years ago

wing5wong left a reply on One Off CSS

Yup

wing5wong left a reply on One Off CSS

I like to use a separate @section('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;
        }

}