abordolo's avatar

abordolo liked a comment+100 XP

2w ago

Laravel From Scratch (2026 Edition): Ep 11, Request Validation

@abordolo I believe that you are correct, well spotted!

From the docs:

You may specify which attributes should be considered data variables using the @props directive at the top of your component's Blade template. All other attributes on the component will be available via the component's attribute bag. If you wish to give a data variable a default value, you may specify the variable's name as the array key and the default value as the array value:

 
@props(['type' => 'info', 'message'])
 
<div {{ $attributes->merge(['class' => 'alert alert-'.$type]) }}>
    {{ $message }}
</div>

Source:

https://laravel.com/docs/12.x/blade#data-properties-attributes


So in this case, the component will assume that $type is always set to 'info', unless specified otherwise.

On the other hand, if $message is not passed, Laravel won't know what to do since it has no default value. That would cause the page to break.

abordolo's avatar

abordolo liked a comment+100 XP

4mos ago

Laravel From Scratch (2026 Edition): Ep 25, Tailwind Theme Setup And Initial UI

Here are the full CSS component files for those looking to copy:

resources/css/components/btn.css

resources/css/components/form.css

abordolo's avatar

abordolo liked a comment+100 XP

4mos ago

Laravel From Scratch (2026 Edition): Ep 25, Tailwind Theme Setup And Initial UI

Color theme for those looking to copy:

    --color-background: oklch(0.12 0 0);
    --color-foreground: oklch(0.95 0 0);
    --color-card: oklch(0.16 0 0);
    --color-primary: oklch(0.65 0.15 160);
    --color-primary-foreground: oklch(0.12 0 0);
    --color-border: oklch(0.24 0 0);
    --color-input: oklch(0.24 0 0);
    --color-muted-foreground: oklch(0.6 0 0);
abordolo's avatar

abordolo wrote a comment+100 XP

4mos ago

Laravel From Scratch (2026 Edition): Ep 18, Authorization Using Policies

And in the controller if we are using authorize method with one parameter, we are using gate:

Gate::authorize(parameter1);

// ex.
Gate::authorize(gateName);

If we are using authorize method with 2 parameters, we are using policies:

Gate::authorize(parameter1, parameter2);

// ex.
Gate::authorize(methodName, modelOrClassInstance);
abordolo's avatar

abordolo wrote a comment+100 XP

4mos ago

Laravel From Scratch (2026 Edition): Ep 18, Authorization Using Policies

Hi @connor1231 ,

This is what is my cencept and I am open to discuss:

  • If we want to apply authorization rule to page level, we should use a gate and if we want to apply authorization rule to a model we should use policy.
  • As Jeffry had mentioned, gates are route closure equivalent of authorization and policies are controller equivalent of authorization for models.
  • If I do not want to display a page to an user, irrespective of whether the page is tied to any model or not, I will reach for gate. For example, an admin can view all ideas of all users. This page should be accessible by only admin.
  • If I want to restrict an user to update an idea created by another user, I will reach for policies. In this case, the update page is more specific to a model.

Regards, Anupam Bordoloi

abordolo's avatar

abordolo wrote a comment+100 XP

5mos ago

Laravel From Scratch (2026 Edition): Ep 11, Request Validation

Blade prop

Hi @jeffry, in the error component, I think, following code gives a default value of 'required' to $name and not make it mandatory like in Vue prop.

@props([
    'name' => 'required',
])