fylzero

fylzero

Member Since 5 Years Ago

Chicago, IL

Experience Points
231,970
Total
Experience

3,030 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
1621
Lessons
Completed
Best Reply Awards
103
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.

Level 47
231,970 XP
Feb
26
2 days ago
Activity icon

Replied to How To Get POST Only Data In Laravel 6

@martinw12

if ($request->isMethod('post')) {
    $thing = $request->input('thing');
}
Activity icon

Awarded Best Reply on Change Model Namespace On Project Creation

@gabotronix I think that would be tricky to maintain... but you could certainly do it.

I do this manually for all my projects as well. It usually doesn't take long enough to justify a script or command for me. Though, admittedly, that would be nice.

I think if I was going to do this, I'd just write a bash script and keep it in my home directory... then execute it with an alias.

Make a bash script like setup.sh

mkdir app/Models
mv app/User.php app/Models
sed -i '' 's/App/App\Models/g' app/Models/User.php
sed -i '' 's/App\User/App\Models\User/g' app/Http/Controllers/Auth/RegisterController.php
sed -i '' 's/App\User/App\Models\User/g' config/auth.php
sed -i '' 's/App\User/App\Models\User/g' database/factories/UserFactory.php
composer dump-autoload
echo 'Your Laravel app is now setup to use Models directory!'

Then execute from the root of a new Laravel project with sh setup.sh

Just built and used this on a fresh project. Works great!

Feb
25
3 days ago
Activity icon

Awarded Best Reply on Dompdf Page Break Issue

@shing_shing This is the answer. Maybe change what element you're applying it to. Start from the outer and just keep adding it to inner elements until it solves the issue.

page-break-inside: avoid;

Activity icon

Replied to Laravel Dynamic Database Connections

@noorcs Please mark best answer.

Feb
24
4 days ago
Activity icon

Replied to What Approach To Only Allow Specific "@domain.com" To Register?

@bobbybouwmann Yup, wound up going the custom rule with split value route. I try to avoid regex when I can. For anyone interested, here is where I landed...

app/Http/Controllers/Auth/RegisterController.php

protected function validator(array $data)
{
    return Validator::make($data, [
        'name' => ['required', 'string', 'max:255'],
        'email' => [
            'required',
            'string',
            'email', 'max:255',
            'unique:users',
            new SpecificDomainsOnly
        ],
        'password' => ['required', 'string', 'min:8', 'confirmed'],
    ]);
}
php artisan make:rule SpecificDomainsOnly

app/Rules/SpecificDomainsOnly.php

public function passes($attribute, $value)
{
    $domain = substr($value, strpos($value, '@') + 1);

    $domains = [
        'somedomain.com',
        'someotherdomain.com'
        ];

    return in_array($domain, $domains);
}

public function message()
{
    return 'Email must be a company address.';
}
Activity icon

Started a new Conversation What Approach To Only Allow Specific "@domain.com" To Register?

I need to only allow two possible domains to register for a site. I'm thinking of just applying a custom validation but am struggling to think of the best way to do this.

Thoughts? Suggestions? Has anyone else come up with a solid way of doing this they were happy with?

Activity icon

Replied to Do We Have To Implement OAuth2 For All SPA Applications?

@larsonator That youtube video should totally be posted at the top of Laravel Airlock and Passport documentation. It is absolutely brilliant and I've shared it with a ton of people.

Feb
20
1 week ago
Activity icon

Awarded Best Reply on Laravel Or Symfony

@beracah.kings Laravel is Symphony under the hood.

Laravel can run at massive scale. Makes no difference.

Activity icon

Replied to Laravel Or Symfony

@beracah.kings Laravel is Symphony under the hood.

Laravel can run at massive scale. Makes no difference.

Activity icon

Awarded Best Reply on Laravel SPA (Sessions Vs JWT Authentication)

@larsonator Check out Laravel Airlock. It does 2 thing very simple and very well. SPA and API authentication.

https://laravel.com/docs/master/airlock

That tip aside. Watch this video. It gives a good break down of JWT vs the Passport approach.

https://youtu.be/Zv4bUXEwl20

Activity icon

Replied to Spatie Permissions Part Via Role Part Direct

@sigalz Yes, this can be done. It is actually considered a best practice to use can to check for abilities, not roles. You can write your roles to contain cross-cutting abilities. For example an Author, Editor and Admin. An Admin can Edit, so can an Editor. So when you're checking if someone can edit, check if they can edit... don't just check their role.

Think of roles as a way to group abilities, but always check against actual abilities (not simply roles) when writing your code.

If I remember correctly, this video kind of lays out this practice at some point. https://www.youtube.com/watch?v=B2M3FCjRz6w&t=1392s

Activity icon

Replied to How Can I Get The Results Of The Upcoming Month's Birthdays In Laravel

Just as a tip... in Laravel you don't need to use Carbon::today() or Carbon::now()

You can simply use today() or now() as they are date helpers in Laravel that resolve a Carbon instance.

Also, just easier to read imo.

vendor/laravel/framework/src/Illuminate/Foundation/helpers.php

CC: @cyberace @sinnbeck @sti3bas @a4ashraf

Feb
19
1 week ago
Activity icon

Replied to How Do You Protect Vapor From DDoS Spin Ups?

@sinnbeck I wasn't paying close enough attention to that article I posted. The reason their DDoS attack only lasted a few minutes and cost a whopping $1.15 is because they were using Cloudflare DDoS protection.

That's kind of what I was wondering.

Activity icon

Replied to How Do You Protect Vapor From DDoS Spin Ups?

@sinnbeck Yeah, I'm just curious if this is a common concern and if there is sort of a go-to way of mitigating this.

I came across this post...

https://laracasts.com/discuss/channels/vapor/our-laravel-vapor-stats?page=1#reply=569779

Seems like they are just footing the bill for any DDoS attacks. That seems kinda rough.

Activity icon

Started a new Conversation How Do You Protect Vapor From DDoS Spin Ups?

Just curious. I haven't looked into this much yet... but I've been considering moving some apps to Vapor.

How does one make sure that AWS doesn't send you a massive bill if your app is hit with a DDoS attack?

Is there built-in protection for this on the Vapor or AWS side? Do I need to implement Cloudfront?

Curious what, if anything, needs to be done for this. Thanks!

Activity icon

Replied to Is Mixing Javascript With Blade Syntax A Bad Practice?

@joaohamerski The simple answer is... yes, it is considered bad practice. Doesn't mean you can't do it.

Same as using inline styles, right... you can do it, but it makes the specificity hard to override.

Bad practices are just that. Possible things to do... but a bad idea for reasons.

The reason mixing is and html is a bad practice is because it makes it hard to know where the script code lives. Also, it is usually best to let the DOM load before executing js on it... so it usually lives at the bottom of all html or deferred which has the same effect.

Activity icon

Replied to JavaScript Heap Out Of Memory

@goncalolopes I'm going to suggest something that could be extremely wrong / offbase. I would avoid using the word "object" as that is sort of a known magic word in programming. What are the objects actually? Can you put a name to that and change the name to like objName?

This might not be the root of your problem but it is the only glaring issue I see.

Activity icon

Replied to I Need A Laravel Ready Project!!!! Plz If Some One Have It. Plzz I Really Need It Badly..

@abdulrafey38 How much are you offering to pay to have this project built for you? 🤑

Activity icon

Replied to Refactoring Production Database ?

@nader_look I would use migrations and just do every change addictively one at a time to make sure things work and you aren't losing data.

If you need to use SQL. Script everything additively. You can always drop cols after you know everything is good.

Activity icon

Replied to Laravel Registration Issue

@yougotnet Opening a new tab and logging in again will override your current session. Use an incognito window to log in as two users, if needed.

Also, the email verification links are tokenized. Meaning they are unique to the user account. So when you click one, it checks the hash against the account id and logs that user in. Regardless of who is currently logged in. It uses loginById.

Activity icon

Replied to How To Make Airlock Optional?

@bugsysha Correct. That is why checking for an authed user solves this problem. What am I missing?

You're not going to see a user if there is no user. Or he can use the null user package you're suggesting. I just wouldn't architect it this way. To me, checking for an authed user instead of using the request seems easier to follow / doesn't require a package to do.

Bottom line to me is visitors are not the same as users. I'd write the logic to reflect that.

Activity icon

Replied to Return View From Controller With Ajax

@ikram_aurelie This looks N+1 ish to me. You should avoid putting a db call in a loop. That is going to slow things down. Could be why this code is slow. I would try to think about how you can avoid the loop and make this a single query.

foreach($array as $key ) {
    
        $order = DB::table('orders')
            ->join('clients','clients.id1','=','orders.id_client')
            ->where('orders.id',$key)
            ->select('orders.*','clients.*')
            ->get()
            ->toArray();
            
        $orders[] = array_values($order);
    }
Activity icon

Replied to How To Make Airlock Optional?

@maximew If the route is available to both users and visitors... do not wrap it in auth middleware. Instead, through out your controllers do an auth check to see if the user is authed before performing logic.

if (Auth::check()) {
    // The user is logged in...
}

In Blade...

@auth
    // The user is logged in...
@endauth
Activity icon

Replied to JavaScript Heap Out Of Memory

@goncalolopes Ok... why are you adding this? Give more context.

Feb
18
1 week ago
Activity icon

Replied to Laravel SPA (Sessions Vs JWT Authentication)

@larsonator Check out Laravel Airlock. It does 2 thing very simple and very well. SPA and API authentication.

https://laravel.com/docs/master/airlock

That tip aside. Watch this video. It gives a good break down of JWT vs the Passport approach.

https://youtu.be/Zv4bUXEwl20

Activity icon

Replied to Cant Deploy Npm Prod With Forge

@smoketm Are you running npm ci before npm run prod? You need to run npm ci first in your deploy script. Otherwise, it will fail.

Activity icon

Replied to Logging Any Incoming Request

@kiasaty You can do this in a custom middleware...

 public function handle($request, Closure $next)
 {
        $data = [
            'Request Method' => $request->method();
            'Request Path' => $request->path(),
            'Requesting User' => $request->user()->toArray(),
            'Request Params' => $request->all(),
            'Request IP' => $request->ip(),
            'Origin' => $request->header('host'),
        ];

        Log::channel('requests')->info($data);

        return $next($request);
}

You can log to daily logs in storage, Cloudwatch if you're on AWS, a lot of options there.

Activity icon

Replied to Cant Deploy Npm Prod With Forge

@smoketm node_modules is not deployed via git because it is installed when you call npm install or npm ci on your deployment. You should not remove node_modules from .gitignore ever.

Activity icon

Replied to Setup Slack Notifications In Laravel 6

Just an added tip. If you are using VS Code... you can install the extension "PHP Namespace Resolver" and when you right-click on class references, you can select "Import Class" which will automatically import the correct use statement at the top section. Occasionally, it will display a list of class names if there are more than one matching.

Activity icon

Replied to Issue With New Line Using Markdown In Slack Notification...

@sinnbeck Bah! I should've caught that! Yes, that of course works. Thanks!

Activity icon

Started a new Conversation Issue With New Line Using Markdown In Slack Notification...

According to the Laravel docs you can parse markdown in Slack using...

$attachment->title('Exception: File Not Found', $url)
    ->content('File [background.jpg] was *not found*.')
    ->markdown(['text']);

Also in the documentation you are directed to Slack's formatting page for more info on how to format Slack notifications here:

https://api.slack.com/reference/surfaces/formatting#message_formatting

There is says you can add new lines of text by doing this...

You can use multi-line text in app-generated text. Insert a newline by including the string \n in your text.

$attachment->title('Exception: File Not Found', $url)
    ->content('This is a line of text.\nAnd this is another one.')
    ->markdown(['text']);

Suffice it to say this doesn't work. No new line, it just outputs "This is a line of text.\nAnd this is another one." in the Slack message. =T

Does anyone know how I can add a new line in my Slack notification content? Is it possible?

Feb
17
1 week ago
Activity icon

Replied to Laravel Sms Unlimited

@ikram_aurelie You can write your app to use cell company gateway addresses. It would mean you'll need to know the carrier of the user's account. Basically you just email the cell number @ the carrier gateway address as an email and it will forward as an SMS to the user.

This can be done... but honestly, a paid service is the way to go. Nexmo is incredibly inexpensive and intergrates very easily with Laravel.

https://kb.sandisk.com/app/answers/detail/a_id/17056/~/list-of-mobile-carrier-gateway-addresses

Feb
16
1 week ago
Activity icon

Replied to Eloquent Vs. Custom Query

@kiasaty Anyone saying Eloquent is "slow" doesn't really know what the tool is capable of. I just had this conversation with another business unit at my company... basically they didn't want us using the ORM because it is slow and inefficient... which isn't true at all.

Install Telescope. You can find slow queries with this... most of the time using with() in Eloquent will avoid the need for joins and N+1 queries.

I demonstrated this to the other business unit and they were like "oh, ok... wow, yeah, that's really cool".

Eloquent can be SLIGHTLY slower... but you're talking microscopic fractions of a second. Not enough of a justification not to use it.

Activity icon

Replied to Laravel Dusk Doesn't See Passed Vue Props

@arnedb I mean Dusk is for browser/ end to end testing... it wouldn't be aware of props. I believe you'd need Jest or Mocha to test this directly.

Activity icon

Replied to Email Verification Gives 500 In Production But Not Locally

@ericthornton88 Yeah, I do that sometimes if I need to... but usually at 3am when I'm fairly confident no one else is messing with my apps. lol Glad this helped.

Activity icon

Replied to Show Ajax Response With Foreach Loop In Blade

@elc Make a Vue component. Much easier. You don't need to make the entire app an SPA just to use Vue.

Alternately. You just need to create an element on the page that you can append your resulting data to with javascript or jquery as @sti3bas suggested.

Activity icon

Replied to Trying To Access Array Offset On Value Of Type Null

@chron Why not just upgrade Laravel? 5.8 and 6.15.1 are not much different. Keep in mind going from v5 to v6 was just Laravel moving to semver. It is not a massive upgrade.

Pretty much open your composer.json and bump the "laravel/framework": "^6.0" up. I would remove filp/whoops and replace that with "facade/ignition": "^1.4",. Then run composer require laravel/helpers to add back the string and array helpers in case any packages use that.

Run composer update. Then regression test your app (basically make sure everything still works). In all likelihood this will just work. If you hit any snags, consult the upgrade guide.

https://laravel.com/docs/6.x/upgrade

Activity icon

Replied to Need Idea.

@ntn0de Caching is basically "scale protection" for things that don't really need to be updated immediately. If that sounds like what you need, then go for it.

Basically if I have users accessing the same data... and that data is called a lot and doesn't need to be to-the-second accurate. I'll decided how long it is acceptable for that data to be refreshed. Sometimes that is 5 minutes, sometimes an hour, sometimes a week. It depends on what is acceptable for that specific use case.

Forward thinking this is great if you know something will cause a bottleneck. In general, you can get a sense of where things slow down and optimize as you go along.

Activity icon

Replied to Best Way To Stream Video In Laravel

@shohagmonzur Why would you need s3 AND a CDN? Are you referring specifically to Cloudfront?

@thefriendlyhacker Also... when you say "streaming" are you referring to merely playing video? ...or what streaming actually means, which is live streaming video? For playing videos, you'll want a CDN... Vimeo is technically a CDN and a very good one for video. Laracasts uses Vimeo for its video player / video hosting. Many CDNs provider their own video player. Limelight is another one I've seen used.

Activity icon

Awarded Best Reply on Email Verification Gives 500 In Production But Not Locally

@ericthornton88 Yes. Because your env file in production doesn't have APP_DEBUG enabled and it shouldn't. You want your production server to display an obfuscated 500 error so as not to display sensitive information it should not be displaying to users or bad actors.

Activity icon

Replied to Email Verification Gives 500 In Production But Not Locally

@ericthornton88 Yes. Because your env file in production doesn't have APP_DEBUG enabled and it shouldn't. You want your production server to display an obfuscated 500 error so as not to display sensitive information it should not be displaying to users or bad actors.

Feb
15
1 week ago
Activity icon

Replied to Add Custom Attribute To Auth:user() During Login

@adrock Couldn't you just return null if the user isn't logged in?

public function getOrgIdAttribute($value)
    {
        if (user is authenticated) {
            return $value;
        }

        return null;
    }
Activity icon

Replied to Different Tables For Customers/users?

@sigalz Going to venture to guess the result of $request->input('role') is User.

If you dd($request->input('role')); what does it return?

Activity icon

Replied to Method 'sort' Not Found In App\Collection

@sraines Just use sortBy for the title.

https://laravel.com/docs/6.x/collections#method-sortby

I think you might have to just add the pivot column to maybe a getter in the model or possibly join that in rather than doing a callback. Not sure.

Activity icon

Replied to Session Suddenly Gone If I Click Href

@youglh Why is this a measurable problem for your app? Is the fact that it isn't showing cookies used on that page actually breaking something? Also, yes, if the application isn't accessing cookies it should not be saying that it is. This is how this works. Look in your dev tools under application cookies. You'll see your cookies are still there. Notice at the top it says "cookies USED". Just because they are not being used doesn't mean they disappeared or are not there.