Senin, 01 Januari 2018

Cara Templating untuk semua tampilan blade laravel (tempalting all page blade laravel)

app\Providers\AppServiceProvider

<?php

namespace App\Providers;

use View;
use App\User;
use App\Forum;
use App\Company;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Schema;



class AppServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        Schema::defaultStringLength(191);

        $jumlah_forum = Forum::all()->count();
        $jumlah_saudagar = User::whereNotIn('email', ['admin@ismi.or.id'])->count();
        $jumlah_perusahaan = Company::whereNotIn('user_id', [1])->count();

        View::share ( 'jumlah_forum', $jumlah_forum );
        View::share ( 'jumlah_saudagar', $jumlah_saudagar );
        View::share ( 'jumlah_perusahaan', $jumlah_perusahaan );
    }

    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        //
    }
}