2017-03-12 1 views
4

가수의 첫 글자를 얻는 경로가 있습니다. laravel 5.4 동적으로 페이지 제목을 만드는 방법

내 경로

Route::get('/artists/{letter}', '[email protected]')->where('letter', '[A-Za-z]+')->name('list'); 

이며,이

public function showArtist($letter){ 
     $artists = Artist::where('name', 'like', $letter.'%')->get(); 
     return view('front.list',compact('artists')); 
    } 

내가 원하는 것은 순으로 모든 아티스트를 나열 내 목록 페이지에, 난 이런 식으로 알파벳 메뉴를 만든 내 컨트롤러 showArtist 방법입니다 예를 들어 ABC를 클릭하면 초기 글자 A를 가진 모든 아티스트를 얻게됩니다.

하지만 제 질문은 어떻게하면 내 페이지 제목에 forexmple을 "Artis 편지 A로 구걸하는 등.

@section ('title', 'artist begging with'. $ 아티스트 -> 편지)

내 질문은 문자 값을 찾는 방법입니까?

수행 방법을 알려주십시오.

답변

3

당신은이 같은보기 블레이드 선택 편지 쓰기 값을 전달할 수 있습니다

return view('front.list',compact('artists','letter')); 

대신 :

return view('front.list',compact('artists')); 

과 지금보기에 당신은 사용할 수 있습니다

<title>Artists begging with {{ $letter }}</title> 
+0

완벽한 아래처럼 블레이드 페이지에서 변경할 수 있습니다. 도와 주셔서 대단히 감사합니다. –

8

하는 경우 다음은 귀하의 마스터 페이지 제목입니다.

<head> 
     <title>App Name - @yield('title')</title> 
    </head> 

다음 페이지 제목은 당신이 언급 한대로 일

@extends('layouts.master') 

@section('title', 'Page Title') 

@section('sidebar') 
@parent 

<p>This is appended to the master sidebar.</p> 
@endsection 

@section('content') 
<p>This is my body content.</p> 
@endsection