declare variable in view for loop laravel

Solutions on MaxInterview for declare variable in view for loop laravel by the best coders in the world

showing results for - "declare variable in view for loop laravel"
Emma
04 Jul 2016
1@for ($i = 0; $i < 10; $i++)
2    The current value is {{ $i }}
3@endfor
4
5@foreach ($users as $user)
6    <p>This is user {{ $user->id }}</p>
7@endforeach
8
9@forelse ($users as $user)
10    <li>{{ $user->name }}</li>
11@empty
12    <p>No users</p>
13@endforelse
14
15@while (true)
16    <p>I'm looping again and again.</p>
17@endwhile
Tatiana
30 Oct 2017
1<?php
2
3namespace App\Http\Controllers;
4use Illuminate\Http\Request;
5
6class UserController extends Controller
7{
8    function example()
9    {
10        return view("dashboard", [
11            "title" => "Home Page",
12            "message" => "Hello World"
13        ]);
14    }
15}
Francesca
09 Feb 2020
1@foreach ($posts as $post)
2
3    @if ($post->type == 1)
4        @continue
5    @endif
6
7    @if ($user->type == 5)
8        @break
9    @endif
10
11    <li>{{ $post->title }}</li>
12
13@endforeach
14
15<!-- Alternatively -->
16@foreach ($posts as $post)
17
18    @continue($post->type == 1)
19    @break($post->type == 5)
20
21    <li>{{ $post->title }}</li>
22
23@endforeach
Benjamín
15 Mar 2017
1@push('scripts')
2    <script src="/laravel.js"></script>
3@endpush
Calum
17 Aug 2016
1<!-- Stored in resources/views/layout.blade.php -->
2<html>
3    <head>
4        <title>@yield('title')</title>
5
6        @section('meta_tags')
7            <meta property="og:type" content="website" />
8        @show
9
10        @section('styles')
11            <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Poppins:300,400,500,600,700">
12        @show
13
14        @section('scripts')
15            <script src="{{ url('/js/bundle.min.js') }}"></script>
16        @show
17    </head>
18    <body>
19        @yield('content')
20    </body>
21</html>
Linda
13 Apr 2018
1<!-- Stored in resources/views/child.blade.php -->
2
3@extends('app')
4@section('title', 'About Us')
5
6@section('scripts')
7    @parent
8    <script src="{{ url('/js/analytics.js') }}"></script>
9@show
10
11@section('content')
12    <p>This is my body content.</p>
13@endsection