75 lines
2.1 KiB
PHP
75 lines
2.1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use Illuminate\Contracts\Support\Renderable;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Collection;
|
|
use Illuminate\Support\Facades\Validator;
|
|
use Illuminate\Support\Facades\Storage;
|
|
use Illuminate\Support\Str;
|
|
use DataTables;
|
|
|
|
use Modules\Seller\Entities\AccountModel;
|
|
use App\Enums\GlobalEnum as Status;
|
|
use App\Models\LogActivites;
|
|
|
|
class DashboardController extends Controller
|
|
{
|
|
public function index()
|
|
{
|
|
$data = [
|
|
'subtitle' => 'Halaman Utama',
|
|
];
|
|
|
|
$getTotalSiswa = AccountModel::where('level', Status::isSiswa)->count();
|
|
$getTotalKonselor = AccountModel::where('level', Status::isKonselor)->count();
|
|
$getTotalUser = AccountModel::count();
|
|
|
|
return view('admin.app.dashboard.index', compact('data', 'getTotalSiswa', 'getTotalKonselor', 'getTotalUser'));
|
|
}
|
|
|
|
public function profile()
|
|
{
|
|
$data = [
|
|
'subtitle' => 'Akun anda',
|
|
];
|
|
|
|
$detail = AccountModel::where('id', user()->id)->first();
|
|
return view('admin.app.users.setting', compact('data', 'detail'));
|
|
}
|
|
|
|
public function update(Request $request)
|
|
{
|
|
$id = user()->id;
|
|
$validator = Validator::make($request->all(), [
|
|
'name' => 'required',
|
|
'email' => 'required'
|
|
]);
|
|
|
|
if ($validator->fails()) {
|
|
return redirect()->back()->withErrors($validator)->withInput();
|
|
}
|
|
|
|
$input = $request->all();
|
|
$findUser = AccountModel::find($id);
|
|
|
|
if($findUser) {
|
|
// update data
|
|
$findUser->name = $input['name'];
|
|
$findUser->email = $input['email'];
|
|
$findUser->phone = $input['phone'];
|
|
if(!empty($input['password'])) {
|
|
$findUser->password = bcrypt($input['password']);
|
|
}
|
|
|
|
// save data
|
|
$findUser->save();
|
|
return redirect()->back()->with('swal', swal_alert('success', 'Data berhasil disimpan'));
|
|
} else {
|
|
return redirect()->back()->with('swal', swal_alert('error', 'Tidak ditemukan data!'));
|
|
}
|
|
}
|
|
}
|