Kacper Wojciechowski
- Mentor MyBB
- 858 119 156 43
Witam, nie mam pomysłu w jaki sposób wstrzyknąć kontroler do layoutu aplikacji, mianowicie mam taki kontroler:
blade:
przykladowe uzycie layoutu:
route:
default blade:
Mam nadzieję że wytłumaczyłem o co mi chodzi, z góry dziękuję za pomoc.
<?php
namespace App\Http\Controllers;
use Illuminate\Support\Facades\DB;
use App\Http\Controllers\Controller;
class ReviewsController extends Controller
{
public function index()
{
$reviews = DB::table('reviews')->get();
return view('global.reviews', ['reviews' => $reviews]);
}
}
@isset($reviews)
<div class="user-slider">
<div class="container">
<div class="slider owl-carousel owl-theme">
@foreach ($reviews as $review)
<div class="item">
<div class="inside">
<img src="{{ asset('assets/images/icon.svg') }}" class="icon" alt="icon">
<img src="{{ asset('assets/images/reviews/{{$review->name}}.png') }}" alt="logo-{{ $review->name }}">
<p>{{ $review->text }}</p>
<div class="user">
<a href="{{ $review->domain }}">
<img src="{{ asset('assets/images/reviews/{{$review->name}}_av.png') }}" alt="user">
{{ $review->author }}
<span>{{ $review->author_spec }}</span>
</a>
</div>
</div>
</div>
@endforeach
</div>
</div>
</div>
@endisset
route:
Route::view('/', 'default');
@extends('global.globalTemplate')
@section('content')
kodzik od podstronki
@endsection
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="csrf-token" content="{{ csrf_token() }}">
<title>{{ config('app.name', 'Laravel') }}</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.5">
<link rel="stylesheet" type="text/css" href="{{ asset('assets/css/lib/bootstrap.min.css') }}">
<link rel="stylesheet" type="text/css" href="{{ asset('assets/css/lib/font-awesome.min.css') }}">
<link rel="stylesheet" type="text/css" href="{{ asset('assets/css/lib/owl.carousel.min.css') }}">
<link rel="stylesheet" type="text/css" href="{{ asset('assets/css/lib/animations.min.css') }}">
<link rel="stylesheet" type="text/css" href="{{ asset('assets/css/style.css') }}">
<link rel="stylesheet" type="text/css" href="{{ asset('assets/css/responsive.css') }}">
</head>
<body>
<div class="wrapper">
@yield('content')
</div>
//tu potrzebuje wstrzyknąć pozywzszy kontroler
<script src="{{ asset('assets/js/lib/jquery.js') }}"></script>
<script src="{{ asset('assets/js/lib/bootstrap.min.js') }}"></script>
<script src="{{ asset('assets/js/lib/owl.carousel.min.js') }}"></script>
<script src="{{ asset('assets/js/lib/css3-animate-it.js') }}"></script>
<script src="{{ asset('assets/js/lib/counter.js') }}"></script>
<script src="{{ asset('assets/js/main.js') }}"></script>
</body>
</html>
Mam nadzieję że wytłumaczyłem o co mi chodzi, z góry dziękuję za pomoc.