Laravel Beginners Full Course
Laravel Beginners Full Course
Artisan Challenge
Challenge 1
Execute artisan command to get the list of artisan commands
in queue namespace.
The result should be similar to this.
Challenge 2
Execute artisan command to get all details of migrate:refresh command.
The result should be similar to this.
// routes/web.php
Route::get("/about", function() {
return view("about");
});
Request Lifecycle
The Router takes the request, finds the corresponding function to execute and
executes that. Optionally there might be middleware registered on the route.
We will talk more about middlewares, but in a nutshell the purpose of the
middleware is to execute code before the request reaches to the action and
possible block the code. After this the controller will send the response back to
the user, or if the middleware is registered, the response will be passed to
middleware first and then returned to user.
Configuration
Laravel 11 comes with several configuration files out of the box. Many
configuration options are available in .env file as well.
If you don’t need to modify these configuration files feel free to delete them,
the default files exist in vendor folder in Laravel’s core and they will be used
from core.
This will give you the following screen and you need to type the configuration
file name, like: app, or broadcasting
If you know exactly which configuration file you want to publish you can
directly execute php artisan config:publish [FILE_NAME].
Let’s say you published cors configuration file. The content of the file looks
like this.
<?php
return [
/*
|--------------------------------------------------------------------------
| Cross-Origin Resource Sharing (CORS) Configuration
|--------------------------------------------------------------------------
|
| Here you may configure your settings for cross-origin resource
sharing
| or "CORS". This determines what cross-origin operations may execute
| in web browsers. You are free to adjust these settings as needed.
|
| To learn more: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS
|
*/
'max_age' => 0,
];
<?php
return [
];
dump()
Prints the variable information and gives you the location from which it is
printed.
$person = [
"name" => "Zura",
"email" => "[email protected]",
];
dump($person);
dd()
Prints the exact same output as dump() , but stops the script execution.
$person = [
"name" => "Zura",
"email" => "[email protected]",
];
dd($person);
ddd()
Throws exception and start debugging from the line it is written.
Basic Routing
The default routes file is located in routes/web.php.
yukarıdaki örnekte route, get ve post metodunu kullanıyor. Fonksiyonun içine yazılan
Redirect routes
Route::redirect('/home', '/'); // sırasyla nereden nereye
Route::redirect('/home', '/', 301); //301 statu kodu, yukarıda yapılan
şeyle aynı
// the same as
Route::permanentRedirect('/home', '/');
View Routes
Route::view('/contact', 'contact'); bu şeklde kullanarak direkt ekrana view
da döndürebiliriz.
Required Parameters
This code defines a route with required parameter id
/product/1
/product/test
/product/{any_string}
You can also define multiple route parameters in the following way.
/en/product/1
/ka/product/test
/{any_string}/product/{any_string}
/en/product/1/review/123
/ka/product/test/review/foo
/{any_string}/product/{any_string}/review/{any_string}
/product/1
/product/01234
/product/56789
/product/test
/product/123test
/product/test123
/user/zura
/user/thecodeholic
/user/ZURA
/user/zura123
/user/123ZURA
/user/zura123
/user/123thecodeholic
/user/ZURA123
/user/zura.123
/user/123-ZURA
/user/123_ZURA
/en/product/123
/ka/product/456
/test/product/01234
/en/product/123abc
/ka/product/abc456
/en123/product/01234
lang route parameter must contain one of the provided values. Anything else
will not match the route
Route::get("{lang}/products", function(string $lang) {
// ...
})->whereIn("lang", ["en", "ka", "in"]);
/en/products
/ka/products
/in/products
/de/products
/es/products
/test/products
Route::get("/about", function() {
// ...
})->name("about");
When we want to generate URLs without route names the only way to
generate URLs in our application is the following.
$aboutPageUrl = "/about"
// Use $aboutPageUrl in navigation:
// <a href="USE_IT_HERE">About</a>
At some point if you decide to update the URL from /about into /about-
us you have to update it in all 3 places.
In reality it might be used in much more than just 3 places. You might miss
some of the places and did not update which leads to broken and not working
URLs.
Once, you assign name to your route you can generate routes by name.
If you have all your URLs generated with route() function and then you
change the route from /about into /about-us
Route::get("/about-us", function() {
// ...
})->name("about");
Laravel will generate proper URLs and you will not have broken URLs.
Named route with parameter
Route::get("/{lang}/product/{id}", function(string $lang, string $id) {
// ...
})->name("product.view");
$productId = 123;
$lang = "en";
$productViewUrl = "/$lang/product/$productId";
$productId = 123;
$lang = "en";
$productViewUrl = route("product.view", ["lang" => $lang, "id" =>
$productId]);
From the first look you see that you actually write more code, but it has great
benefits. If you update your URL pattern into this
1. You don’t have to update the peace of code where you generate the
URLs.
2. At some point in your code, you might be checking what is the current
route and if you are on product view page, you might execute some
logic. With route names it’s super easy to detect what is the route of the
current request. (Will see it in later lessons).
3. Also when you want to perform redirect to a specific route, doing this
with route name is much easier.
// define a route with name "profile"
Route::get('/user/profile', function () {
// ...
})->name('profile');
Route::get("/current-user", function() {
// Generating Redirects...
return redirect()->route('profile');
// or
return to_route('profile');
});
Route Groups
Route Prefixes
Route::prefix('admin')->group(function () {
Route::get('/users', function () {
// Matches The "/admin/users" URL
});
});//prefixin içine koyudğumuz heer şey içerideki diğer routeların başına
gelecek. Mesela normalde /users ama prefix ile kulandığımızda /admin/users
şeklini alıyor. Ve /users yoluna da tarayıcıdan direkt ulaşılamıyor. Önünde
admin olmalı.
Fallback Routes
Typically when the route is not matched, Laravel will show 404 page, but if you
want to handle all unmatched routes, this is how you can do it.
Route::fallback(function () {
// Handle all unmatched routes
});
Route Caching
Basic Controllers
What is controller?
Controller is a class which is associated to one or more routes and is
responsible for handling requests of that routes. Generally controller is for
grouping similar routes together. For example: ProductController should
contain only logic associated to products, but not anything
else. CarController should not contain logic that is not associated to cars.
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
Now let’s open routes/web.php file and add new route which will be
associated to just created index method.
ℹ️Controller’s methods that are associated to routes are often mentioned as **actions.**
How let’s access http://127.0.0.1:8000/car into browser and you should see
the following output.
Route::controller(\App\Http\Controllers\CarController::class)-
>group(function () {
Route::get("/car", "index");
Route::get("/my-cars", "myCars");
Route::get("/search", "search");
});
Ya hepsini ayrı ayrı tek satırlık normal route kodu olarak yazacağız. Ya da
hepsini guruplayıp bu şekilde yazacağız. Ya da farklı url’lere de gidiyor olabilir
yukarıdaki örnekteki gibi. Sanırım amaç bir controllerle alaklı tüm routeları bir
arada tutmak. Evet controller adını bir kez kullanarak istediğimiz kadar route
oluşturmamızı sağlıyor.
ℹ️**Single Action Controllers** are controllers that are associated to a single route only.
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
__invoke method is the method that will be executed when route will be
matched. This is how we associate the controller to a route.
Route::get("/car", \App\Http\Controllers\ShowCarController::class);
Note that we only provided controller class name when defining route for /car.
We don’t need to provide methods for Single Action Controllers. Çünkü
zaten tek iş yapmakla görevli ve tek metodu var bu yüzden çağırılır çağırılmaz
sadece o işi yapıyor. Route koduna ek olarak metod adı yazmamıza gerek
kalmıyor.
A regular controller with regular methods can also have __invoke method. For
example we can modify our existing CarController and
add __invoke method. Bu şekilde kullandığımızda eğer route kısmına hiçbr
metot adı vermezsek invoke metodunu çalıştırır ama yine aynı controllerı
kullanıp içindeki diğer metodların adını route koduna eklersek bu sefer ilgili
metodu sorunsuz çalıştırır.
Aynı şekilde _invoke olarak oluşturduğun controller dosyasının içine başka bir
metod yazarsan ve yolunu verirsen çalışıyor, yol vermezsen invoke çalışıyor.
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class CarController extends Controller
{
public function __invoke(Request $request)
{
return "From __invoke";
}
💡 At this stage we don’t need `ShowCarController` so, delete it and delete it’s associated
route.
In routes we can use CarController in the following way.
Resource Controllers
💡 Before we talk about Resource Controllers, let’s delete `CarController` delete the routes
associated to it.
In Laravel, a resource controller is a special type of controller that provides a
convenient way to handle typical CRUD (Create, Read, Update, Delete)
operations for a resource such as a database table.
namespace App\Http\Controllers;
use Illuminate\Http\Request;
/**
* Show the form for creating a new resource.
*/
public function create()
{
//
}
/**
* Store a newly created resource in storage.
*/
public function store(Request $request)
{
//
}
/**
* Display the specified resource.
*/
public function show(string $id)
{
//
}
/**
* Show the form for editing the specified resource.
*/
public function edit(string $id)
{
//
}
/**
* Update the specified resource in storage.
*/
public function update(Request $request, string $id)
{
//
}
/**
* Remove the specified resource from storage.
*/
public function destroy(string $id)
{
//
}
}
By using a resource controller, you can write cleaner and more concise code
for handling CRUD operations without having to define each route and
controller action individually. Laravel's resource controllers also integrate
seamlessly with Laravel's route model binding, making it easy to work with
model instances directly in controller methods.
Route::resource('/products', \App\Http\Controllers\
ProductController::class)
->except(['destroy']);
Or if you want to only include specific routes in the declaration you can
provide only method.
Route::resource('/products', \App\Http\Controllers\
ProductController::class)
->only(['index', 'show']);
Route::apiResource('/products', \App\Http\Controllers\
ProductController::class);
If you want to even skip generating create and edit methods in the controller
you can provide --api flag to the controller generation.
You can also register many API resources at once if you provide array
in apiResource method.
Route::apiResource([
'/products', \App\Http\Controllers\ProductController::class,
'/cars', \App\Http\Controllers\CarController::class
]);
💡 For next lessons we don’t need `ProductController` and `CarController` so, delete them and
delete routes associated to them.
Challenge
Problem
Generate a controller with 2 methods: sum and subtract. Define
routes /sum and /subtract which will be associated to the controller
corresponding methods.
Both methods will accept tfwo arguments, both arguments should be numbers.
When accessing /sum route it should print the sum of arguments and when
accessing /subtract method it should print the difference.
Solution
Execute the following artisan command to create MathController
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
💡 We don’t need `MathController` any more so, delete it and delete the routes we defined in
this lesson.
Create HomeController
Create new controller for our final project
Create a view
All blade view must have extension .blade.php .
You can create a file by hand under resources/views directory or execute the
following artisan command.
Open just created file, delete its content and paste the following code.
Now open HomeController and update its index method like this.
If you open application’s home page the result will be something like this.
ℹ️In this case make sure you import `View` facade correctly. `use Illuminate\Support\Facades\
View;`
Bu şekilde View Facade kullanmanın bir çok avantajı var mesela aşağıdaki gibi ::first ile
kullanabiliriz. Parantez içindeki arrrayden ilk sıradakini ekrana verir, eğer ilk sıradakinde bir
sorun varsa ve ulaşılabilir değilse sıradakini verir.
Yukarıda anlattığım şeyi yapmak için bir if bloğu kullanarak söz gelimi view var
mı yok mu kontrol edebiliriz.
Option 1
public function index()
{
return view("index", [
"name" => "Zura",
"surname" => "Sekhniashvili"
]);
}
Option 2
public function index()
{
return view("index")
->with("name", "Zura")
->with("surname", "Sekhniashvili")
;
}
Open http://127.0.0.1:8000/ in your browser and you should see the following
output.
View::share('year', date('Y'));
}
Open hello.blade.php and add the following line at the end of the file.
Challenge
Problem
Create HelloController with welcome method. Create welcome view using
artisan and put it in hello subfolder.
From HelloController::welcome method render welcome view you just
created.
Pass your name and surname to the view and output it in blade file.
Define route /hello so that when you access it, it will output your name and
surname.
Solution
1. Create new controller
3. Create view
13. Now open welcome view and output name and surname
14. <div>
15. {{ $name }} {{ $surname }}
16. </div>
ZURA SEKHNIASHVILI
The output
World
11.x
8.3.0
return view("hello", [
"name" => "Zura",
"surname" => "Sekhniashvili",
"job" => "<b>Developer</b>",
]);
<b>Developer<b/>
This will give you the following output in browser: {{ name }}.
In the similar way, if you want to output Blade directive (You will learn what
more about directives in upcoming sections) in browser you need to
add @ symbol in front of it. For example: If you want to output this in browser,
you will probably see syntax error, because blade engine tries to evaluate
that foreach.
@foreach
But if you add additional @ symbol and write this in your blade file, the output
will be @foreach.
@@foreach
<div>
Name: {{ name }}
Age: {{ age }}
Job: {{ job }}
Hobbies: {{ hobbies}}
@if
</div>
Wrap your section with @verbatim directive.
@verbatim
<div>
Name: {{ name }}
Age: {{ age }}
Job: {{ job }}
Hobbies: {{ hobbies}}
@if
</div>
@endverbatim
Rendering JSON
Let’s add hobbies variable
return view("hello", [
"name" => "Zura",
"surname" => "Sekhniashvili",
"job" => "<b>Developer</b>",
"hobbies" => ["Tennis", "Fishing"]
]);
<script>
const hobbies = {{ Js::from($hobbies) }}
</script>
<script>
const hobbies = JSON.parse('[\u0022Tennis\u0022,\u0022Fishing\u0022]')
</script>
Comments
{{-- Sinle line comment --}}
<button>Click me</button>
{{--
Multi
line
comment
--}}// <!- şeklinde yazdığımız yorum sitede sayfa kaynağını görüntüle
deyince gözüküyor ama yukarıdaki php yorum satırı o şekilde de
görülemiyor.-->
<button>Click me</button>
@if directive
@if (count($cars) > 1)
<p>There is more than 1 car</p>
@endif
@if (count($cars) > 0)
<p>There is at least one car</p>
@else
<p>There are no cars</p>
@endif
@if (count($cars) > 1)
<p>There is at least one car</p>
@elseif (count($cars) === 1)
<p>There is exactly one car</p>
@else
<p>There are no cars</p>
@endif
@unless (false)
<p>unless</p>
@endunless
Yani ifde parantez içi true olduğunda fonksiyon çalışıyordu, burada ise
false olduğunda
The same is
@if (true)
<p>unless</p>
@endif
@isset, @empty
// eğer bi değişkenin tanımlanıp tanımlanmadığını kontrol etmek istersek
isset kullanırı.
@isset($cars)
<p>isset</p>
@endisset
// aynısını yapıyor
@empty($cars)
<p>empty</p>
@endempty
@auth, @guest
//kullanıcı doğrulanmış
@auth
<p>User is authenticated</p>
@endauth
@guest
<p>User is guest</p>
@endguest
Switch Statement - @switch
@switch($country)
@case('ge')
<p>Georgia</p>
@break
@case('uk')
<p>United Kingdom</p>
@break
@case('us')
<p>USA</p>
@break
@default
<p>Unknown Country</p>
@endswitch
@for
@for ($i = 0; $i < 5; $i++)
<p> {{ $i + 1 }}</p>
@endfor
@foreach
@foreach ($cars as $car)
<p>Model: {{ $car->model }}</p>
@endforeach
@forelse
@forelse ($cars as $car)
<p>Model: {{ $car->model }}</p>
@empty
<p>There are no cars</p>
@endforelse
@while
@while (false)
@endwhile
@continue
@foreach ([1, 2, 3, 4, 5] as $n)
@if ($n == 2)
@continue
@endif
<p>{{$n}}</p>
@endforeach
@break
@foreach ([1, 2, 3, 4, 5] as $n)
<p>{{$n}}</p>
@if ($n == 4)
@break
@endif
@endforeach
<button @style([
'background-color: '. $color
])>
{{$text}}
</button>
@include('shared.button')
You can also pass 4th argument to the directive. That needs to be view file
name, which will be rendered if $cars array is empty.
Raw PHP
Declare a variable
@php
$city = 'Tbilisi'
@endphp
<?php
$city = 'Tbilisi';
?>
Import classes
@use("Illuminate\Support\Str")
The equivallent in PHP
<?php
use Illuminate\Support\Str;
?>
💡 The benefit of `@use` directive is that even if you use it multiple times, if the class is
imported it will not throw an error.
Challenge
Problem
Create sub view alert.blade.php which will take two
variables $message and $color and use them in blade file.
Use @style directive to add color to the alert element.
Include that view into another blade file and pass these two variables.
There are many interpretations of this challenge, but the main is that you
create a second blade file, include it into another blade file and you provide
variables.
Solution
Create alert.blade.php in shared folder
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-
scale=1.0" />
<title>@yield('title') | Car Selling Website</title>
</head>
<body>
<header>Your Header</header>
@yield('content')
<footer>Your Footer</footer>
</body>
</html>
1. @yield('title')
2. @yield('content')
@extends('layouts.app')
@section('content')
Home Page content goes here
@endsection
This extends layouts.app blade file, defines title section with Home
Page title and defines section content . In content section you need to put
your home page HTML content.
Output lang
Open layouts.app view file and modify <html> opening tag into this
Copy entire html content into layouts.app view file. Ama az önce yazdığımız
doctype html dosyasını silmedik. O hala duruyor. Sadece biraz aşağıya
kaydırıp üzerine templatedeki index.html kodunu yapıştırdım. Sonra elimizdeki
kodu inceliyoruz. Buradaki kodun bir kısmı layouta ait ama bir kısmı sitenin
spesifik bilgilerini içeriyor. Bu spesifik bilgi kısımlarını kesip ilgili yerlere
yapıştıracağız. Layouta ait, her yerde standart olacak kod burada kalacak.
Cut content starting with <!-- Home Slider --> and ending
with </main> and put it inside home.index view file
inside @section('content').
Şimdi önceden hazırladığımız buradaki koddan gerekli parçaları alıp yeni koda
yapıştıracağız sonra zaten aşağıya kaydırmış olduğumuz bu kodu tamamen
sileceğiz. Bu bir taslaktı.
Normalde burada klasik şekilde lang= en ifadesi vardı ama biz önceden
hazırladığımız kodu buraya ekledik. Şimdi diğer değişiklikleri de
yapalım.
Önceden yazdığımız meta csrf kodunu alıp yeni koddaki title’ın hemen
üzerine geçiriyoruz.
Şimdi js ve css
kodlarını eklemeye
geçiyoruz. Vscode
soldaki js klasorune
sağ tıklayıp
reveal in file explorer seçeneğini seçiyoruz. Buradan template dosyamızı
buluyoruz ve js img ve css adlı üç dosyanın hepsini seçiyoruz. Ve
kopyalıyoruz. Sonra bunları alıp public klasorunun altına koyuyoruz. En
başta js klasorune sağ tıklayıp file explorer açmıştık ama tıkladığımız yer
fark etmiyormuş.
Move the base layout part from layouts.app into layouts.clean view file and
output childContent section, so that final version of layouts.clean file looks
like this. App.blade.phpden aldığımız kodu clean.blade.phpye atıyoruz. Ve
appdan o kısmı siliyoruz. Orada artık sadece header vs yer alacak. App.blade.
phpde sadece header, footer ve @yield kaldı oralar da boş zaten.
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-
scale=1.0" />
<meta name="csrf-token" content="{{ csrf_token() }}">
<title>@yield('title') | {{ config('app.name', 'Laravel') }}</title>
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/
all.min.css"
integrity="sha512-1ycn6IcaQQ40/MKBW2W4Rhis/DbILU74C1vSrLJxCq57o941Ym01SwNsO
MqvEBFlcgUa6xLiPY/NS5R+E6ztJQ=="
crossorigin="anonymous"
referrerpolicy="no-referrer"
/>
<!-- <link
href="https://cdnjs.cloudflare.com/ajax/libs/flowbite/2.2.1/flowbite.min.cs
s"
rel="stylesheet"
/> -->
@yield('childContent')
<script
src="https://cdnjs.cloudflare.com/ajax/libs/scrollReveal.js/4.0.9/
scrollreveal.js"
integrity="sha512-
XJgPMFq31Ren4pKVQgeD+0JTDzn0IwS1802sc+QTZckE6rny7AN2HLReq6Yamwpd2hFe5nJJGZL
vPStWFv5Kww=="
crossorigin="anonymous"
referrerpolicy="no-referrer"
></script>
<script src="js/app.js"></script>
</body>
</html>
Open the header blade file and put the entire <header> tag there.
Also include the header partial file in app layout, so that final content of app
layout looks like this.
@extends('layouts.clean')
@section('childContent')
@include('layouts.partials.header')
@yield('content')
<footer></footer>
@endsection
### `@extends`
- **Anlamı:** Bir şablonun başka bir ana şablonu miras almasını sağlar.
- **Örnek:**
```blade
@extends('layouts.master')
@section('content')
@endsection
```
### `@include`
- **Ne Yapar:** Şablonun bir kısmını başka bir dosyadan alır ve doğrudan
sayfanın içine dahil eder.
- **Örnek:**
```blade
@include('partials.footer')
```
### Özet:
- `@extends` daha büyük bir şablonu (genellikle layout) miras almak için
kullanılır.
- `@include` ise daha küçük, tekrar eden şablon parçalarını bir dosyada
toplamak ve onları farklı dosyalarda kullanmak için kullanılır.
Then create a new view file.viewin içine elimizdeki templatten signup kodunun
main kısmını aldık. Clean layoutu da extend edeceğiz ve tiitle vs dolduracağız.
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
Route::get('/signup', [App\Http\Controllers\SignupController::class,
'create']);
Open auth.signup view file in your Laravel project, delete entire content and
put the following code inside.
@section('childContent')
{{--<main> tag goes here--}}
@endsection
Then replace {{--<main> tag goes here--}} with the actual <main> tag
content you copied from HTML/CSS project.
Problem
Define LoginController and login view. Copy login form from HTML/CSS
project and put in your Laravel login view.
Define /login route as well, so that when you access the URL it will render
the login page.
Solution
Create LoginController by executing
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
Route::get('/login', [App\Http\Controllers\LoginController::class,
'create']);
Open auth.login view file in your Laravel project, delete entire content and
put the following code inside.
@section('title', 'Login')
@section('childContent')
{{--<main> tag goes here--}}
@endsection
Then replace {{--<main> tag goes here--}} with the actual <main> tag
content you copied from HTML/CSS project.
@extends('layouts.clean')
@section('childContent')
@include('layouts.partials.header')
@yield('content')
<footer>
@yield('footerLinks')
</footer>
@endsection
Now let’s open home.index view file and define new section footerLinks.
@section('footerLinks')
<a href="#">Link 3</a>
<a href="#">Link 4</a>
@endsection
Now if we open our application in browser, we will see Link 3 and Link4.
Now let’s assume that we want Link 1 and Link 2 to be always displayed in
footer.
@section('footerLinks')
<a href="#">Link 1</a>
<a href="#">Link 2</a>
@show
The code above is pretty much the same as the following code.
@section('footerLinks')
<a href="#">Link 1</a>
<a href="#">Link 2</a>
@endsection
@yield('footerLinks')
Now if you remove the footerLinks section definition from home.index view
file it will render Link 1 and Link 2, but if you leave the section it will override
and render Link 3 and Link 4, in order both of the links to be rendered you
should update footerLinks section definition in home.index view file in the
following way.
@section('footerLinks')
@parent
<a href="#">Link 3</a>
<a href="#">Link 4</a>
@endsection
More on Directives
@hasSection
@hasSection('navigation')
<div class="pull-right">
@yield('navigation')
</div>
<div class="clearfix"></div>
@endif
@sectionMissing
@sectionMissing('navigation')
<div class="pull-right">
@include('default-navigation')
</div>
@endif
@checked
This directive will print checked text if the expression is true.
@disabled
<input type="checkbox" @disabled(BOOLEAN_EXPRESSION) />
@readonly
<input type="text" @readonly(BOOLEAN_EXPRESSION) />
@required
<input type="text" @required(BOOLEAN_EXPRESSION) />
@selected
<select name="year">
@foreach($years as $year)
<option value="{{ $year }}" @selected($year == date('Y'))>
{{ $year }}
</option>
@endforeach
</select>
@env
@env('staging')
// The application is running in "staging"...
@endenv
@env(['staging', 'production'])
// The application is running in "staging" or "production"...
@endenv
@production
@production
// Production specific content...
@endproduction
@session
@session('successMessage')
<div class="p-4 bg-green-100">
{{ $successMessage }}
</div>
@endsession