Laravel 5.4 how to make page title dynamic

I have a route to get the initial letter of the artists.

this is my route

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

and this is my controller showArtist method.

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

what I want is on my list page, which lists all the artists in alphabetical order, I made an alphabetical menu similar to this ABC, for example, if you click, it will get all artists with the initial letter A.

but my question is how can I make pages in my title, for example, "Artists asking for the letter A," etc.

@section ('title', 'artist begging with'. $ artist-> letter)

My question is: how to find the meaning of the letters?

please help how to do this?

+4
2

Blade :

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

:

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

, , :

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

<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
+8

Source: https://habr.com/ru/post/1672109/


All Articles