IMMREX7
<?php
namespace App\Http\Controllers\School\Library;
use Illuminate\Http\Request;
use App\Http\Controllers\School\SchoolController;
use Auth;
use DB;
class MemberController extends SchoolController
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index(Request $request)
{
$type = $request->type;
$members = [];
if ($request->type == 'student') {
$members = DB::table('students')
->join('classes', 'students.idClass', '=', 'classes.idClass')
->join('sections', 'students.idSection', '=', 'sections.idSection')
->where('students.idSchool', '=', Auth::guard('school')->user()->idSchool)
->where('banForLibrary','=','0')
->select('ecNo','studentDob','idStudent','father_mobile','className','sectionName','father_fname','father_lname','firstName','middleName','lastName')
->get();
} elseif ($request->type == 'employee') {
$members = DB::table('employees')
->join('departments', 'employees.idDepartment', '=', 'departments.idDepartment')
->join('designations', 'employees.idDesignation', '=', 'designations.idDesignation')
->where('employees.idSchool', '=', Auth::guard('school')->user()->idSchool)
->where('banForLibrary','=','0')
->get();
}
return view('schools.library.members', compact('members','type'));
}
public function banMember(Request $request,$type,$id) {
//dd($request->all());
if($type == 'student'){
$member = \App\AdmEntry::where('idStudent', '=', $id)->first();
$member->banForLibrary = '1';
$member->ban_remarks = $request->remarks;
$member->dateOfBan = today_date();
$member->update();
return response()->json(['success' => "SUCCESS"], 200, ['app-status' => 'success']);
}else{
$member = \App\Employee::where('idEmployee', '=', $id)->first();
$member->banForLibrary = '1';
$member->ban_remarks = $request->remarks;
$member->dateOfBan = today_date();
$member->update();
return response()->json(['success' => "SUCCESS"], 200, ['app-status' => 'success']);
}
}
/**
* 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 getMemberDetail($type,$ecno) {
if ($type == 'student') {
$members = DB::table('students')
->join('classes', 'students.idClass', '=', 'classes.idClass')
->join('sections', 'students.idSection', '=', 'sections.idSection')
->where('students.idSchool', '=', Auth::guard('school')->user()->idSchool)
->where('students.ecNo', '=', $ecno)
->select('className','sectionName',DB::raw("CONCAT(ifnull(firstName,' '),ifnull(middleName,' '),ifnull(lastName,' ')) AS name"))
->first();
} elseif ($type == 'employee') {
$members = DB::table('employees')
->join('departments', 'employees.idDepartment', '=', 'departments.idDepartment')
->join('designations', 'employees.idDesignation', '=', 'designations.idDesignation')
->where('employees.idSchool', '=', Auth::guard('school')->user()->idSchool)
->where('employees.enrollmentNo', '=', $ecno)
->select('departmentName as className','designationName as sectionName',DB::raw("CONCAT(ifnull(firstName,' '),ifnull(middleName,' '),ifnull(lastName,' ')) AS name"))
->first();
}
return json_encode($members);
}
public function getMemberLibraryDetail($type,$ecno) {
if ($type == 'student') {
$member = DB::table('students')
->join('classes', 'students.idClass', '=', 'classes.idClass')
->join('sections', 'students.idSection', '=', 'sections.idSection')
->where('students.idSchool', '=', Auth::guard('school')->user()->idSchool)
->where('students.ecNo', '=', $ecno)
->select('idStudent','className','sectionName',DB::raw("CONCAT(ifnull(firstName,' '),ifnull(middleName,' '),ifnull(lastName,' ')) AS name"))
->first();
$issued_books = \App\BookIssueReturn::join('books','book_issue_return.idBook','=','books.idBook')
->where('memberType','=',$type)
->where('idMember','=',$member->idStudent)
->where('isReturn','=','N')
->get();
// $libraryfine = \App\LibraryFineMaster::where('idSchool','=',Auth::guard('school')->user()->idSchool)->first();
// $this->calculateFine();
} elseif ($type == 'employee') {
$member = DB::table('employees')
->join('departments', 'employees.idDepartment', '=', 'departments.idDepartment')
->join('designations', 'employees.idDesignation', '=', 'designations.idDesignation')
->where('employees.idSchool', '=', Auth::guard('school')->user()->idSchool)
->where('employees.enrollmentNo', '=', $ecno)
->select('idEmployee','departmentName as className','designationName as sectionName',DB::raw("CONCAT(ifnull(firstName,' '),ifnull(middleName,' '),ifnull(lastName,' ')) AS name"))
->first();
$issued_books = \App\BookIssueReturn::join('books','book_issue_return.idBook','=','books.idBook')
->where('memberType','=',$type)
->where('idMember','=',$member->idEmployee)
->where('isReturn','=','N')
->get();
// $libraryfine = \App\LibraryFineMaster::where('idSchool','=',Auth::guard('school')->user()->idSchool)->first();
}
$data = [$member,$issued_books];
return json_encode($data);
}
}
Copyright © 2021 -