blade template

 resources/views/ blade template

https://laravel.com/docs/8.x/blade#blade-directives

if not login

For convenience, Blade also provides an @unless directive:

@unless (Auth::check())
You are not signed in.
@endunless

In addition to the conditional directives already discussed, the @isset and @empty directives may be used as convenient shortcuts for their respective PHP functions:

@isset($records)
// $records is defined and is not null...
@endisset
 
@empty($records)
// $records is "empty"...
@endempty

Authentication Directives

The @auth and @guest directives may be used to quickly determine if the current user is authenticated or is a guest:

@auth
// The user is authenticated...
@endauth
 
@guest
// The user is not authenticated...
@endguest

If needed, you may specify the authentication guard that should be checked when using the @auth and @guest directives:

@auth('admin')
// The user is authenticated...
@endauth
 
@guest('admin')
// The user is not authenticated...
@endguest

Environment Directives

You may check if the application is running in the production environment using the @production directive:

@production
// Production specific content...
@endproduction

Or, you may determine if the application is running in a specific environment using the @env directive:

@env('staging')
// The application is running in "staging"...
@endenv
 
@env(['staging', 'production'])
// The application is running in "staging" or "production"...
@endenv

Section Directives

You may determine if a template inheritance section has content using the @hasSection directive:

@hasSection('navigation')
<div class="pull-right">
@yield('navigation')
</div>
 
<div class="clearfix"></div>
@endif

You may use the sectionMissing directive to determine if a section does not have content:

@sectionMissing('navigation')
<div class="pull-right">
@include('default-navigation')
</div>
@endif



foreach,for,forelse,@while,switch

@If@elseif@else@endif

unless if count not there like that examples


issset,empty


loop variable

While iterating through a foreach loop, a $loop variable will be available inside of your loop. This variable provides access to some useful bits of information such as the current loop index and whether this is the first or last iteration through the loop:

@foreach ($users as $user)
@if ($loop->first)
This is the first iteration.
@endif
 
@if ($loop->last)
This is the last iteration.
@endif
 
<p>This is user {{ $user->id }}</p>
@endforeach

If you are in a nested loop, you may access the parent loop's $loop variable via the parent property:

@foreach ($users as $user)
@foreach ($user->posts as $post)
@if ($loop->parent->first)
This is the first iteration of the parent loop.
@endif
@endforeach
@endforeach

The $loop variable also contains a variety of other useful properties:

PropertyDescription
$loop->indexThe index of the current loop iteration (starts at 0).
$loop->iterationThe current loop iteration (starts at 1).
$loop->remainingThe iterations remaining in the loop.
$loop->countThe total number of items in the array being iterated.
$loop->firstWhether this is the first iteration through the loop.
$loop->lastWhether this is the last iteration through the loop.
$loop->evenWhether this is an even iteration through the loop.
$loop->oddWhether this is an odd iteration through the loop.
$loop->depthThe nesting level of the current loop.
$loop->parentWhen in a nested loop, the parent's loop variable.



laravel components
components is simly contstruction is building of blocks
compoent is  piece of code, whcih can reuse any where

php artisan make:component component_name

reources/view/component/alert.blade.php
app/view/compoenents/alert.php
two places file will create
this below call our compoenent in blade

<x-aleert/>
alert.php

public $message ='Meet shah';
public function __construct($message)
{
$this->message=$message;
}



alert.blade.php


<div>
{{$message}}
</div>

x-alert
<x-alert message="vamsi"/>







  1. Which is the Blade's echo statement?

    Marked Answer : {{ $name }}

    Correct Answer : {{ $name }}

  2. Which directives is used to determine if the current user is authenticated?

    Marked Answer : "@auth"

    Correct Answer : "@auth"

  3. Which directive is used to determine if the application is running in the production environment?

    Marked Answer : A and B both

    Correct Answer : A and B both

  4. Which directive is used to determine if a section does not have content?

    Marked Answer : "sectionMissing"

    Correct Answer : "sectionMissing"

  5. Which property is used to gain current loop iteration?

    Marked Answer : $loop->iteration

    Correct Answer : $loop->iteration












No comments:

Post a Comment

Event listening in react

 How we can listen to som eevents some envents fire like click or automatically user enters into input button , that is event on word type i...