Beispiel #1
0
 /**
  * @param $school
  * @return \Illuminate\View\View
  */
 public function getAdminSent($school)
 {
     $admin = Administrator::where('user_id', \Auth::user()->id)->first();
     $title = "Sent";
     $path = "/" . $school->username . "/admin/mail/sent/";
     $mails = $this->mySent($this->admin_role, $school, $admin->id);
     return view('admin.account.email.inbox', compact('school', 'mails', 'path', 'title'));
 }
Beispiel #2
0
 public function view($route, $title, $notices, $school)
 {
     $user = \Auth::user();
     $admin_schools = null;
     $client_schools = null;
     $administrator = \App\Administrator::where('user_id', $user->id)->first();
     $clients = \App\Client::where('user_id', $user->id)->get();
     if ($administrator != null) {
         $admin_schools = \App\School::where('id', $administrator->school_id)->first();
     }
     $schools = \Auth::user()->schools()->get();
     //dd($school);
     return view($route, compact('school', 'admin_schools', 'schools', 'clients', 'title', 'notices'));
 }
Beispiel #3
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $segments = $request->segments();
     if ($this->auth->guest()) {
         if ($request->ajax()) {
             return response('Unauthorized.', 401);
         } else {
             return redirect($segments[0] . '/admin/login');
         }
     } else {
         $client = \App\Administrator::where('user_id', $request->user()->id)->first();
         if ($client == null) {
             return redirect($segments[0] . '/admin/login')->withInput($request->only('email', 'remember'))->withErrors(['email' => 'You are not a registered admin']);
         }
     }
     return $next($request);
 }
 public function getClientMessages($school, $client)
 {
     $user = \Auth::user();
     $admin_schools = null;
     $client_schools = null;
     $administrator = Administrator::where('user_id', $user->id)->first();
     $clients = Client::where('user_id', $user->id)->get();
     if ($administrator != null) {
         $admin_schools = School::where('id', $administrator->school_id)->first();
     }
     //dd($client_schools);
     $schools = \Auth::user()->schools()->get();
     $post = "/" . $school->username . "/client/forum/" . $client->id . "/";
     $messages = $this->messages($school, 0);
     $client_messages = $this->messages($school, 1, $client->class);
     $title = "School Space";
     // dd($client_messages);
     return view('client.account.messenger', compact('title', 'client_messages', 'user', 'client', 'schools', 'admin_schools', 'school', 'clients', 'post', 'messages'));
 }
Beispiel #5
0
 /**
  * Reusable bit of code that allows for the sending of mail to school's clients
  * @param $request
  * @param $school
  * @return mixed
  * @internal param $schoolId
  */
 public function sendToClient($request, $school, $user)
 {
     $receiver = Client::where('admNo', $request->admNo)->first();
     $admin = \App\Administrator::where('user_id', $user->id)->first();
     $mail = new SendMailCommand($user, $request->subject, $request->message, $receiver->user_id, $school->id, $admin != null ? $admin->role : 'admin', $this->role($user->id, $school), 2, $receiver->id, 0);
     return $mail;
 }
Beispiel #6
0
 /**
  * Return the account of the admin
  * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
  * @internal param User $user
  */
 public function getHome()
 {
     $user = \Auth::user();
     $admin_schools = null;
     $client_schools = null;
     $administrator = \App\Administrator::where('user_id', $user->id)->first();
     $clients = \App\Client::where('user_id', $user->id)->get();
     if ($administrator != null) {
         $admin_schools = \App\School::where('id', $administrator->school_id)->first();
     }
     //dd($client_schools);
     $schools = \Auth::user()->schools()->get();
     //dd($schools->count());
     return view('dashboard.index', compact('admin_schools', 'schools', 'clients'));
 }
 /**
  * @param $school
  * @return bool
  */
 public function ifRegistered($school)
 {
     $admin = Administrator::where('user_id', \Auth::user()->id)->first();
     if ($admin != null) {
         if ($admin->school_id == $school->id) {
             return true;
         } else {
             return false;
         }
     } else {
         return false;
     }
 }