Professional Documents
Culture Documents
Untitled
Untitled
php
<?php
namespace App\Models;
class listing
{
public static function all()
{
return [
[
'id' => 1,
'title' => "first one",
'desc' => "Lorem ipsum dolor sit amet consectetur, adipisicing
elit. Rerum dolore tempore ipsam impedit ea doloribus quos accusantium unde
necessitatibus officiis!"
],
[
'id' => 2,
'title' => "second one",
'desc' => "Lorem ipsum dolor sit amet consectetur, adipisicing
elit. Rerum dolore tempore ipsam impedit ea doloribus quos accusantium unde
necessitatibus officiis!"
],
[
'id' => 3,
'title' => "third one",
'desc' => "Lorem ipsum dolor sit amet consectetur, adipisicing
elit. Rerum dolore tempore ipsam impedit ea doloribus quos accusantium unde
necessitatibus officiis!"
]
];
}
***********************************************************************************
*********************************
web.php
<?php
use Illuminate\Support\Facades\Route;
use App\Models\listing;
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider and all of them will
| be assigned to the "web" middleware group. Make something great!
|
*/
Route::get('/', function () {
return view('main', [
'heading' => 'latest listings',
'list' => listing::find(1)
]);
});
// Route::get('/listing', function () {
// return view('main', [
// 'heading' => 'latest listings',
// 'listings' => listing::find(2)
// ]);
// });
***********************************************************************************
**************************
main.blade.php
<h1>{{$heading}}</h1>
@if (count($list) != 0)
<span>{{count($list)}}</span>
{{-- @foreach ($lists as $item)
<h2>{{$item['title']}}</h2>
<p>{{$item['desc']}}</p>
@endforeach --}}
@else
<p>no lists found</p>
@endif