Created
December 27, 2023 20:51
-
-
Save REp007/53350e389ad9a6bb3f18882e21fd36bd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{-- Blade Basics: Echoing Variables --}} | |
{{ $variable }} | |
The current UNIX timestamp is {{ time() }}. | |
{{-- Blade Basics: Escaped Raw Output --}} | |
{!! $variable !!} | |
{{-- Blade & JavaScript Frameworks --}} | |
Hello, @{{ name }}. | |
{{-- Blade Basics: Escaping Blade directives --}} | |
@@if() | |
{{-- Control Structures: If Statements --}} | |
@if($condition) | |
// Code to execute if the condition is true | |
@endif | |
{{-- Control Structures: If-Else Statements --}} | |
@if($condition) | |
// Code to execute if the condition is true | |
@else | |
// Code to execute if the condition is false | |
@endif | |
{{-- Control Structures: If-Elseif-Else Statements --}} | |
@if($condition) | |
// code | |
@elseif ($condition) | |
// code | |
@else | |
// ..Code | |
@endif | |
{{-- Looping with Foreach --}} | |
@foreach($items as $item) | |
// Code to iterate over each $item | |
@endforeach | |
{{-- Looping with For --}} | |
@for($i = 0; $i < 5; $i++) | |
// Code to execute for each iteration | |
@endfor | |
{{-- Looping with While --}} | |
@while($condition) | |
// Code to execute while the condition is true | |
@endwhile | |
{{-- Looping Variables: $loop --}} | |
$loop->index | |
$loop->iteration | |
$loop->remaining | |
$loop->count | |
$loop->first | |
$loop->last | |
$loop->even | |
$loop->odd | |
$loop->depth | |
$loop->parent | |
{{-- Comments --}} | |
{{-- This is a Blade comment --}} | |
{{-- Control Structures: Unless --}} | |
@unless ($condition) | |
// Code ... | |
@endunless | |
{{-- Control Structures: Isset --}} | |
@isset() | |
@endisset | |
{{-- Control Structures: Empty --}} | |
@empty() | |
@endempty | |
{{-- Control Structures: Switch --}} | |
@switch() | |
@case | |
@break | |
{{-- ... --}} | |
@default | |
@endswitch | |
{{-- Blade Directives: Auth --}} | |
@auth | |
// The user is authenticated... | |
@endauth | |
{{-- Blade Directives: Guest --}} | |
@guest | |
// The user is not authenticated... | |
@endguest | |
{{-- Including Sub-Views --}} | |
@include('partials.header') | |
{{-- Including Sub-Views with Data --}} | |
@include('view.name', ['some' => 'data']) | |
@includeFirst(['custom.admin', 'admin'], ['status' => 'complete']) | |
@includeWhen($boolean, 'view.name', ['status' => 'complete']) | |
@includeUnless($boolean, 'view.name', ['status' => 'complete']) | |
{{-- Including Sub-Views: Once --}} | |
@once | |
// .... | |
@endonce | |
{{-- Blade Layouts: Extending Layouts --}} | |
@extends('layout.master') | |
{{-- Blade Layouts: Yield Section --}} | |
@yield('content') | |
{{-- Blade Layouts: Sections --}} | |
@section('content') | |
// Main content of the view | |
@endsection | |
{{-- Blade Components: Props --}} | |
@props(['nom']) | |
<x-com :nom="$users" /> | |
{{-- Blade PHP Section --}} | |
@php | |
$counter = 1; | |
@endphp | |
@use('App\Models\Flight') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment