[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: EmailTemplateController.php
<?php namespace App\Http\Controllers; use App\Models\EmailTemplate; use App\Models\EmailTemplateLang; use App\Models\UserEmailTemplate; use App\Models\Utility; use Illuminate\Http\Request; class EmailTemplateController extends Controller { /** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $usr = \Auth::user(); if ($usr->type == 'admin') { $EmailTemplates = EmailTemplate::all(); return view('email_templates.index', compact('EmailTemplates')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } 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 \App\Models\EmailTemplate $emailTemplate * @return \Illuminate\Http\Response */ public function show(EmailTemplate $emailTemplate) { $lang = 'en'; $languages = Utility::languages(); $emailTemplate = EmailTemplate::where('id', '=', $emailTemplate->id)->first(); $currEmailTempLang = EmailTemplateLang::where('parent_id', '=', $emailTemplate->id)->where('lang', 'en')->first(); if (!isset($currEmailTempLang) || empty($currEmailTempLang)) { $currEmailTempLang = EmailTemplateLang::where('parent_id', '=', $emailTemplate->id)->where('lang', 'en')->first(); $currEmailTempLang->lang = $lang; } return view('email_templates.show', compact('emailTemplate', 'languages', 'currEmailTempLang')); } /** * Show the form for editing the specified resource. * * @param \App\Models\EmailTemplate $emailTemplate * @return \Illuminate\Http\Response */ public function edit(EmailTemplate $emailTemplate) { // } /** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param \App\Models\EmailTemplate $emailTemplate * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { $validator = \Validator::make( $request->all(), [ 'from' => 'required', // 'subject' => 'required', // 'content' => 'required', ] ); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $emailTemplate = EmailTemplate::where('id', $id)->first(); $emailTemplate->from = $request->from; $emailTemplate->save(); // $emailLangTemplate = EmailTemplateLang::where('parent_id', '=', $id)->where('lang', '=', $request->lang)->first(); // if record not found then create new record else update it. // if (empty($emailLangTemplate)) { // $emailLangTemplate = new EmailTemplateLang(); // $emailLangTemplate->parent_id = $id; // $emailLangTemplate->lang = $request['lang']; // $emailLangTemplate->subject = $request['subject']; // $emailLangTemplate->content = $request['content']; // $emailLangTemplate->from = $request['from']; // $emailLangTemplate->save(); // } else { // $emailLangTemplate->subject = $request['subject']; // $emailLangTemplate->content = $request['content']; // $emailLangTemplate->from = $request['from']; // $emailLangTemplate->save(); // } return redirect()->route( 'manage.email.language', [ $id, $request->lang, ] )->with('success', __('Email Template Detail successfully updated.')); } /** * Remove the specified resource from storage. * * @param \App\Models\EmailTemplate $emailTemplate * @return \Illuminate\Http\Response */ public function destroy(EmailTemplate $emailTemplate) { // } public function manageEmailLang($id, $lang = 'en') { $languages = Utility::languages(); $emailTemplate = EmailTemplate::where('id', '=', $id)->first(); $currEmailTempLang = EmailTemplateLang::where('parent_id', '=', $id)->where('lang', $lang)->first(); if (!isset($currEmailTempLang) || empty($currEmailTempLang)) { $currEmailTempLang = EmailTemplateLang::where('parent_id', '=', $id)->where('lang', 'en')->first(); $currEmailTempLang->lang = $lang; } return view('email_templates.show', compact('emailTemplate', 'languages', 'currEmailTempLang')); } // Used For Store Email Template Language Wise public function storeEmailLang(Request $request, $id) { $validator = \Validator::make( $request->all(), [ 'subject' => 'required', 'content' => 'required', ] ); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $emailLangTemplate = EmailTemplateLang::where('parent_id', '=', $id)->where('lang', '=', $request->lang)->first(); // if record not found then create new record else update it. if (empty($emailLangTemplate)) { $emailLangTemplate = new EmailTemplateLang(); $emailLangTemplate->parent_id = $id; $emailLangTemplate->lang = $request['lang']; $emailLangTemplate->subject = $request['subject']; $emailLangTemplate->content = $request['content']; $emailLangTemplate->save(); } else { $emailLangTemplate->subject = $request['subject']; $emailLangTemplate->content = $request['content']; $emailLangTemplate->save(); } return redirect()->route( 'manage.email.language', [ $id, $request->lang, ] )->with('success', __('Email Template Detail successfully updated.')); } // Used For Update Status Company Wise. public function updateStatus(Request $request, $slug) { $usr = \Auth::user(); $currentWorkspace = Utility::getWorkspaceBySlug($slug); $user_emails = UserEmailTemplate::where('workspace_id', '=', $currentWorkspace->id)->where('user_id', '=', $usr->id)->get(); if (!$user_emails) { $user_emails = UserEmailTemplate::create( [ 'template_id' => 1, 'user_id' => $usr->id, 'workspace_id' => $currentWorkspace->id, 'is_active' => 0, ] ); $user_emails = UserEmailTemplate::create( [ 'template_id' => 2, 'user_id' => $usr->id, 'workspace_id' => $currentWorkspace->id, 'is_active' => 0, ] ); $user_emails = UserEmailTemplate::create( [ 'template_id' => 3, 'user_id' => $usr->id, 'workspace_id' => $currentWorkspace->id, 'is_active' => 0, ] ); $user_emails = UserEmailTemplate::create( [ 'template_id' => 4, 'user_id' => $usr->id, 'workspace_id' => $currentWorkspace->id, 'is_active' => 0, ] ); } foreach ($user_emails as $user_email) { if (isset($request->New_Client) && $user_email->id == $request->New_Client) { $user_email->is_active = 1; } elseif (isset($request->User_Invited) && $user_email->id == $request->User_Invited) { $user_email->is_active = 1; } elseif (isset($request->Project_Assigned) && $user_email->id == $request->Project_Assigned) { $user_email->is_active = 1; } elseif (isset($request->Contract_Shared) && $user_email->id == $request->Contract_Shared) { $user_email->is_active = 1; } else { $user_email->is_active = 0; } $user_email->save(); } return redirect()->back()->with('success', __('Status successfully updated!')); } }
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: server1.winmanyltd.com
Server IP: 203.161.60.52
PHP Version: 8.3.27
Server Software: Apache
System: Linux server1.winmanyltd.com 4.18.0-553.22.1.el8_10.x86_64 #1 SMP Tue Sep 24 05:16:59 EDT 2024 x86_64
HDD Total: 117.98 GB
HDD Free: 59.81 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
Yes
git:
Yes
User Info
Username: eliosofonline
User ID (UID): 1002
Group ID (GID): 1003
Script Owner UID: 1002
Current Dir Owner: 1002