小编Mah*_*med的帖子

laravel 5.4如何用动态制作页面标题

我有一条获得艺术家首字母的途径.

这是我的路线

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

这是我的控制器showArtist方法

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

我想要的是在我的列表页面中按字母顺序列出所有艺术家,我已经按照这个ABC制作了字母菜单,例如,如果单击它将获得所有艺术家的首字母A.

但我的问题是如何在我的页面标题中做出这样的说法,例如"艺术家用字母A乞讨"等.

@section('title','艺术家乞讨'.$ artist-> letter)

我的问题是如何找到字母值?

请帮忙怎么做到这一点?

php laravel blade laravel-5 laravel-5.4

9
推荐指数
2
解决办法
1万
查看次数

laravel 5.4 迁移 errno: 150“外键约束格式不正确”

有 4 个迁移,如下所示。这是用户表。

 Schema::create('users', function (Blueprint $table) {
            $table->increments('id');
            $table->string('name');
            $table->string('email')->unique();
            $table->string('password');
            $table->rememberToken();
            $table->timestamps();
        });
Run Code Online (Sandbox Code Playgroud)

这就是艺术家的迁徙。

Schema::create('artists', function (Blueprint $table) {
            $table->increments('id');
            $table->string('name');
            $table->string('slug');
            $table->string('image')->nullable();
            $table->text('biography')->nullable();
            $table->integer('week_hits');
            $table->timestamp('week_date');
            $table->timestamp('viewed_now');
            $table->boolean('status')->default(1);
            $table->integer('user_id')->unsigned();
            $table->foreign('user_id')->references('id')->on('users');
            $table->timestamps();
        });
Run Code Online (Sandbox Code Playgroud)

这是歌曲迁移。

Schema::create('songs', function (Blueprint $table) {
            $table->increments('id');
            $table->string('title');
            $table->text('lyrics')->nullable();
            $table->string('mp3');
            $table->string('youtube_id')->nullable();
            $table->timestamp('week_date');
            $table->integer('week_hits')->nullable();
            $table->timestamp('played_now')->nullable();
            $table->timestamp('hits');
            $table->integer('album_id')->unsigned()->nullable();
            $table->foreign('album_id')->references('id')->on('albums');
            $table->integer('artist_id')->unsigned();
            $table->foreign('artist_id')->references('id')->on('artists');
            $table->timestamps();
        });
    }
Run Code Online (Sandbox Code Playgroud)

这是专辑迁移。

Schema::create('albums', function (Blueprint $table) {
            $table->increments('id');
            $table->string('name');
            $table->string('cover');
            $table->integer('artist_id')->unsigned();
            $table->foreign('artist_id')->references('id')->on('artists');
            $table->boolean('status')->default(true);
            $table->timestamp('viewed_now')->nullable();
            $table->integer('week_hits')->nullable();
            $table->timestamp('week_date');
            $table->timestamps();
        });
Run Code Online (Sandbox Code Playgroud)

这是连接多对多、艺术家和歌曲的特色。

Schema::create('featuring', function (Blueprint $table) {
    $table->integer('artist_id')->unsigned()->nullable(); …
Run Code Online (Sandbox Code Playgroud)

laravel laravel-5.4

2
推荐指数
1
解决办法
4629
查看次数

标签 统计

laravel ×2

laravel-5.4 ×2

blade ×1

laravel-5 ×1

php ×1