diff --git a/app/Http/Controllers/DasborController.php b/app/Http/Controllers/DasborController.php index e8ebee60..b7d3d349 100644 --- a/app/Http/Controllers/DasborController.php +++ b/app/Http/Controllers/DasborController.php @@ -2,10 +2,15 @@ namespace App\Http\Controllers; +use App\Models\Identitas; + class DasborController extends Controller { public function index() { - return view('dasbor.index'); + $identitas = new Identitas(); + $data = $identitas->pengaturan(); + + return view('dasbor.index', compact('data')); } } diff --git a/app/Models/Identitas.php b/app/Models/Identitas.php index e9a95c89..59301cc8 100644 --- a/app/Models/Identitas.php +++ b/app/Models/Identitas.php @@ -8,4 +8,24 @@ class Identitas extends Model { use HasFactory; + + protected $table = "identitas"; + + protected $fillable = [ + "nama_aplikasi", "deskripsi", "favicon", + "logo", "nama_kabupaten", "kode_kabupaten", + "nama_provinsi", "kode_provinsi", "sebutan_kab" + ]; + + public static function pengaturan() + { + $identitas = self::first(); + + $data['nama_aplikasi'] = $identitas->nama_aplikasi ?? config('app.namaAplikasi'); + $data['sebutanKab'] = $identitas->sebutan_kab ?? config('app.sebutanKab'); + $nama_kabupaten = preg_replace("/KAB/", "", $identitas->nama_kabupaten) ?? config('app.namaKab'); + $data['nama_kabupaten'] = strtolower($data['sebutanKab']) == 'kota' ? $nama_kabupaten : $data['sebutanKab'] . ' ' . $nama_kabupaten; + + return $data; + } } diff --git a/resources/views/dasbor/index.blade.php b/resources/views/dasbor/index.blade.php index daaa5a73..148ecc0c 100644 --- a/resources/views/dasbor/index.blade.php +++ b/resources/views/dasbor/index.blade.php @@ -12,7 +12,7 @@ @section('content') Selamat datang {{ Auth::user()->username ?? '' }} di Dasbor Utama - {{ config('app.namaAplikasi') . ' ' . config('app.sebutanKab') . ' ' . config('app.namaKab') }}. + {{ ucwords(strtolower($data['nama_aplikasi'])) . ' ' . ucwords(strtolower($data['nama_kabupaten'])) }}.