IMMREX7

aku nok ndi : /home/spdtg/www/schoolmis/app/Http/Controllers/Teacher/
File Up :
aku nok ndi : /home/spdtg/www/schoolmis/app/Http/Controllers/Teacher/TeacherProfileController.php

<?php

namespace App\Http\Controllers\Teacher;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use DB;
use Auth;
use Session;

class TeacherProfileController extends TeacherController {

    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index() {
        $teacher = \App\Teacher::where('idEmployee', '=', Auth::guard('teacher')->user()->idEmployee)->first();
        $school = \App\School::where('idSchool','=',$teacher->idSchool)->first();
        $salstr = \App\SalaryStructure::where('idEmployee', '=', Auth::guard('teacher')->user()->idEmployee)->first();
        $payment_history = \App\EmpPayment::where('idEmployee','=',Auth::guard('teacher')->user()->idEmployee)->get();
        return view('teachers.profile', compact('teacher','payment_history','salstr','school'));
    }

    /**
     * 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() {
        $teacher = \App\Teacher::where('idEmployee', '=', Auth::guard('teacher')->user()->idEmployee)->first();
        $school = \App\School::where('idSchool','=',$teacher->idSchool)->first();
        return view('teachers.updt_password', compact('school'));
    }

    public function updatePassword(Request $request) {
        $rules = [];
        $user = \App\Teacher::where('idEmployee', '=', Auth::guard('teacher')->user()->idEmployee)->first();
        if (!auth()->guard('teacher')->attempt(['mobile' => $user->mobile, 'password' => $request->old_password])) {
            flash()->error('Wrong old password. Authentication failed');
            return redirect()->back();
        }

        $this->validate($request, $rules + [
            'password' => 'required|min:6|confirmed',
        ]);
        $user->pwd = $request['password'];
        $user->password = bcrypt($request['password']);
        $user->update();
        Auth::login($user);
        flash()->success('Password updated successfully.');
        return redirect()->back();
    }
    
    public function setSession(Request $request) {
        Session::put('idFinancialYear', $request->idFinancialYear);
        return redirect('/teacher');
    }

}

Copyright © 2021 - 2025 IMMREX7