Laravel Tutorials
- What is laravel
- Laravel Installation
- Directory Structure
- htaccess
- Remove public from url
- Artisan Command
- Laravel Configuration
- Routing Configuration
- Namespaces
- Request
- Response
- Controller
- Model
- User Authentication
- Multi User Authentication
- Database Seeding
- Database
- Database Query
- ORM
- One-to-One Relationship
- One-to-Many Relationship
- Many to Many Eloquent Relationship
- Has One Through
- Has Many Through
- Querying Relations
- Middleware
- Laravel Views
- Blade Views
- Print data on view page
- Get Site URL
- Get URL Segment
- Get images from Storage folder
- Clear cache
- Form Class not found
- Flash Message in laravel
- Redirections
- path
- CRUD Projerct
- CRUD in Laravel
- CRUD progran
- Laravel Validation
- Jquery Validation
- Cookie
- Session
- Email Send in laravel
- File uploading
- CSRF Protection
- Helper in Laravel
- Helper Functions
- Guzzle Http Client
- Paypal Payment Gatway Integration
- Cron Job in laravel
- Flash message
- path
- Errors Handling
- Date Format
- Date Format Validation
- Display Image on View Page
- Update User Status using toggle button
- Delete Multiple Records using Checkbox in Laravel?
- Confirmation Before Delete Record
- Delete image from storage
- Remove/Trim Empty & Whitespace From Input Requests
- Block IP Addresses from Accessing Website
- How to Disable New User Registration in Laravel
- Redirect HTTP To HTTPS Using Laravel Middleware
- CKEditor
- slug generate unique
- Prevent Browser's Back Button After Logout
- Datatable dunamically
- encrypt & Decript
- Download File
- Rest API
- Shopping Cart
- Shopping Cart Example
- Dynamic Category-Subcategory Menu
- Ajax Search
- Interview Question
- laravel Tutorilal link
- laravel Tutorilal
Important Links
How to print data on blade view page?
Example 1:-
Controller
File name : HomeController.php
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class HomeController extends Controller
{
public function printname()
{
$name = "mahtab";
return view('admin.test-view',['username'=>$name]);
}
}
View
File name : admin/test-view.php
<!DOCTYPE html>
<html lang="en">
<head>
<title>Mytitle</title>
</head>
<body>
<h2>Welcome {{$username}}</h2>
</body>
</html>
Example 2:-
Controller
File name : HomeController.php
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class HomeController extends Controller
{
public function printname()
{
$student = array('name'=>"mahtab");
return view('admin.test-view',['data'=>$student]);
}
}
view
File name : test-view.php
<!DOCTYPE html>
<html lang="en">
<head>
<title>Mytitle</title>
</head>
<body>
<h2>Student List</h2>
<li>{{$data['name']}}</li>
</body>
</html>
Example 3:-
Controller
File name : HomeController.php
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class HomeController extends Controller
{
public function printname()
{
$student = array(
'name' => "mahtab",
'age' => "36",
'mobile' => "7838897299",
'address'=> "delhi"
);
return view('admin.test-view',['data'=>$student]);
}
}
view
File name : test-view.php
<!DOCTYPE html>
<html lang="en">
<head>
<title>Mytitle</title>
</head>
<body>
<h2>Student List</h2>
<li>{{$data['name']}}</li>
<li>{{$data['age']}}</li>
<li>{{$data['mobile']}}</li>
<li>{{$data['address']}}</li>
</body>
</html>
Example 4:-
Using foreach
File name : HomeController.php
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class HomeController extends Controller
{
public function printname()
{
$student = array(
'name' => "mahtab",
'age' => "36",
'mobile' => "7838897299",
'address'=> "delhi"
);
return view('admin.test-view',['data'=>$student]);
}
}
view
File name : test-view.php
<!DOCTYPE html>
<html lang="en">
<head>
<title>Mytitle</title>
</head>
<body>
<h2>Student List</h2>
@foreach($data as $studinfo)
<li>{{$studinfo}}</li>
@endforeach
<h2>Student List</h2>
@foreach($data as $key => $studinfo)
<li>{{$key}} : {{$studinfo}}</li>
@endforeach
@for($i=0;$i<=5;$i++)
<p>Hello mahtab</p>
@endfor
</body>
</html>
Example 5:-
using if statement
File name : HomeController.php
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class HomeController extends Controller
{
public function printname()
{
$student = array(
'name' => "mahtab",
'age' => "36",
'mobile' => "7838897299",
'address'=> "delhi"
);
return view('admin.test-view',['data'=>$student]);
}
}
view
File name : test-view.php
<!DOCTYPE html>
<html lang="en">
<head>
<title>Mytitle</title>
</head>
<body>
<h2>Student List</h2>
@if($data['name'] == "mahtab")
<li>Hello Itechxpert</li>
@else
<li>woop woop</li>
@endif
</body>
</html>