IMMREX7
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Auth;
use Hash;
use PDF;
class SchoolProfileController extends School\SchoolController {
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index() {
//
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create() {
//
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request) {
//
}
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($id) {
//
}
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function edit($id) {
//
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id) {
//
}
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id) {
//
}
public function editPassword() {
return view('schools.updt_password');
}
public function updatePassword(Request $request) {
$rules = [];
$user = \App\SchoolUser::where('idSchool', '=', Auth::guard('school')->user()->idSchool)->first();
//dd($user);
if ($request->old_password == $user->pwd) {
$this->validate($request, $rules + [
'password' => 'required|min:6|confirmed',
]);
$password = $request->password;
$user->password = bcrypt($password);
$user->pwd = $password;
$user->update();
Auth::login($user);
flash()->success('Password updated successfully.');
} else {
flash()->error('Wrong old password. Authentication failed');
return redirect()->back();
}
return redirect()->back();
}
public function switchDashboard() {
$schools = \App\School::where('schoolCode', '=', Auth::guard('school')->user()->schoolCode)
->where('idSchool', '!=', Auth::guard('school')->user()->idSchool)
->get();
return view('schools.switchdashboard', compact('schools'));
}
public function getEmployees($id) {
$employees = \App\Employee::where('idSchool', '=', $id)->get()->pluck('name', 'idEmployee')->toArray();
return json_encode($employees);
}
public function getStudents($id) {
$students = \App\AdmEntry::where('idSchool', '=', $id)->get()->pluck('name', 'idStudent')->toArray();
return json_encode($students);
}
public function getCustomers($id) {
$students = \App\Customer::where('idSchool', '=', $id)->get()->pluck('customerName', 'idCustomer')->toArray();
return json_encode($students);
}
}
Copyright © 2021 -