mirror of
https://github.com/HDInnovations/UNIT3D-Community-Edition.git
synced 2026-04-24 03:59:08 -05:00
(Update) Applications System 🚀
This commit is contained in:
@@ -57,13 +57,13 @@ class ApplicationController extends Controller
|
||||
$application = new Application();
|
||||
$application->type = $request->input('type');
|
||||
$application->email = $request->input('email');
|
||||
$application->referer = $request->input('referer');
|
||||
$application->referrer = $request->input('referrer');
|
||||
|
||||
if (config('email-white-blacklist.enabled') === 'allow') {
|
||||
$v = validator($request->all(), [
|
||||
'type' => 'required',
|
||||
'email' => 'required|email|unique:invites|unique:users|unique:applications|email_list:allow',
|
||||
'referer' => 'required',
|
||||
'referrer' => 'required',
|
||||
'images.*' => 'filled',
|
||||
'images' => 'min:2',
|
||||
'links.*' => 'filled',
|
||||
@@ -73,7 +73,7 @@ class ApplicationController extends Controller
|
||||
$v = validator($request->all(), [
|
||||
'type' => 'required',
|
||||
'email' => 'required|email|unique:invites|unique:users|unique:applications|email_list:block',
|
||||
'referer' => 'required',
|
||||
'referrer' => 'required',
|
||||
'images.*' => 'filled',
|
||||
'images' => 'min:2',
|
||||
'links.*' => 'filled',
|
||||
@@ -83,7 +83,7 @@ class ApplicationController extends Controller
|
||||
$v = validator($request->all(), [
|
||||
'type' => 'required',
|
||||
'email' => 'required|email|unique:invites|unique:users|unique:applications',
|
||||
'referer' => 'required',
|
||||
'referrer' => 'required',
|
||||
'images.*' => 'filled',
|
||||
'images' => 'min:2',
|
||||
'links.*' => 'filled',
|
||||
@@ -92,7 +92,7 @@ class ApplicationController extends Controller
|
||||
}
|
||||
|
||||
if ($v->fails()) {
|
||||
return redirect()->route('create_application')
|
||||
return redirect()->route('application.create')
|
||||
->with($this->toastr->error($v->errors()->toJson(), 'Whoops!', ['options']));
|
||||
} else {
|
||||
$application->save();
|
||||
|
||||
@@ -12,12 +12,12 @@
|
||||
|
||||
namespace App\Http\Controllers\Staff;
|
||||
|
||||
use App\Invite;
|
||||
use Carbon\Carbon;
|
||||
use App\Application;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use App\Mail\InviteUser;
|
||||
use Brian2694\Toastr\Toastr;
|
||||
use App\Mail\DenyApplication;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
@@ -63,16 +63,17 @@ class ApplicationController extends Controller
|
||||
{
|
||||
$application = Application::withAnyStatus()->with(['user', 'moderated', 'imageProofs', 'urlProofs'])->findOrFail($id);
|
||||
|
||||
return view('Staff.application.application', ['application' => $application]);
|
||||
return view('Staff.application.show', ['application' => $application]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Approve A Application.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param $id
|
||||
* @return Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function approve($id)
|
||||
public function approve(Request $request, $id)
|
||||
{
|
||||
$application = Application::withAnyStatus()->findOrFail($id);
|
||||
|
||||
@@ -88,7 +89,7 @@ class ApplicationController extends Controller
|
||||
$invite->email = $application->email;
|
||||
$invite->code = $code;
|
||||
$invite->expires_on = $current->copy()->addDays(config('other.invite_expire'));
|
||||
$invite->custom = 'Your Application Has Been Approved!';
|
||||
$invite->custom = $request->input('approve_message');
|
||||
|
||||
if (config('email-white-blacklist.enabled') === 'allow') {
|
||||
$v = validator($invite->toArray(), [
|
||||
@@ -108,7 +109,7 @@ class ApplicationController extends Controller
|
||||
}
|
||||
|
||||
if ($v->fails()) {
|
||||
return redirect()->route('applications')
|
||||
return redirect()->route('staff.applications.index')
|
||||
->with($this->toastr->error($v->errors()->toJson(), 'Whoops!', ['options']));
|
||||
} else {
|
||||
Mail::to($application->email)->send(new InviteUser($invite));
|
||||
@@ -117,7 +118,7 @@ class ApplicationController extends Controller
|
||||
// Activity Log
|
||||
\LogActivity::addToLog("Staff member {$user->username} has approved {$application->email} application.");
|
||||
|
||||
return redirect()->route('applications')
|
||||
return redirect()->route('staff.applications.index')
|
||||
->with($this->toastr->success('Application Approved', 'Yay!', ['options']));
|
||||
}
|
||||
} else {
|
||||
@@ -129,17 +130,21 @@ class ApplicationController extends Controller
|
||||
/**
|
||||
* Reject A Application.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param $id
|
||||
* @return Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function reject($id)
|
||||
public function reject(Request $request, $id)
|
||||
{
|
||||
$application = Application::withAnyStatus()->findOrFail($id);
|
||||
|
||||
if ($application->status !== 2) {
|
||||
$application->markRejected();
|
||||
$denied_message = $request->input('denied_message');
|
||||
|
||||
return redirect()->route('applications')
|
||||
Mail::to($application->email)->send(new DenyApplication($denied_message));
|
||||
|
||||
return redirect()->route('staff.applications.index')
|
||||
->with($this->toastr->info('Application Rejected', 'Info!', ['options']));
|
||||
} else {
|
||||
return redirect()->back()
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
/**
|
||||
* NOTICE OF LICENSE.
|
||||
*
|
||||
* UNIT3D is open-sourced software licensed under the GNU General Public License v3.0
|
||||
* The details is bundled with this project in the file LICENSE.txt.
|
||||
*
|
||||
* @project UNIT3D
|
||||
*
|
||||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0
|
||||
* @author HDVinnie
|
||||
*/
|
||||
|
||||
namespace App\Mail;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class DenyApplication extends Mailable
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
public $denied_message;
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($denied_message)
|
||||
{
|
||||
$this->input = $denied_message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the message.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
return $this->markdown('emails.deny_application')->subject('Your Application Has Been Denied!');
|
||||
}
|
||||
}
|
||||
+54
-9
@@ -59,6 +59,7 @@
|
||||
</td>
|
||||
<td>
|
||||
@foreach($application->imageProofs as $key => $img_proof)
|
||||
<li><button id="show-img" type="button" class="btn btn-default" data-toggle="modal" data-target="#image-{{ $img_proof->id }}">Profile Image {{ ++$key }}</button></li>
|
||||
<div id="image-{{ $img_proof->id }}" class="modal fade" aria-labelledby="my-modalLabel" aria-hidden="true" tabindex="-1" role="dialog">
|
||||
<div class="modal-dialog" data-dismiss="modal">
|
||||
<div class="modal-content" >
|
||||
@@ -69,7 +70,6 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<li><button id="show-img" type="button" class="btn btn-default" data-toggle="modal" data-target="#image-{{ $img_proof->id }}">Profile Image {{ ++$key }}</button></li>
|
||||
@endforeach
|
||||
</td>
|
||||
</tr>
|
||||
@@ -83,6 +83,16 @@
|
||||
@endforeach
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<strong>Referrer</strong>
|
||||
</td>
|
||||
<td>
|
||||
<div class="form-group">
|
||||
<textarea name="referrer" cols="30" rows="10" class="form-control" disabled="">{{ $application->referrer }}</textarea>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<strong>Status</strong>
|
||||
@@ -102,14 +112,49 @@
|
||||
<strong>Action</strong>
|
||||
</td>
|
||||
<td>
|
||||
<a href="{{ route('staff.applications.approve', ['id' => $application->id]) }}"
|
||||
class="btn btn-xs btn-success">
|
||||
<i class="{{ config('other.font-awesome') }} fa-check"></i> Approve
|
||||
</a>
|
||||
<a href="{{ route('staff.applications.reject', ['id' => $application->id]) }}"
|
||||
class="btn btn-xs btn-danger">
|
||||
<i class="{{ config('other.font-awesome') }} fa-times"></i> Reject
|
||||
</a>
|
||||
<button type="button" class="btn btn-xs btn-success" data-toggle="modal" data-target="#approve-application">Open Modal</button>
|
||||
|
||||
<div id="approve-application" class="modal fade" role="dialog">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal">×</button>
|
||||
<h4 class="modal-title">Approve This Application</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<textarea title="Approval Message To Applicant" class="form-control" rows="5" name="message" cols="50" id="approve_message"></textarea>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<a href="{{ route('staff.applications.approve', ['id' => $application->id]) }}"
|
||||
class="btn btn-success">
|
||||
<i class="{{ config('other.font-awesome') }} fa-check"></i> Approve
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#deny-application">Open Modal</button>
|
||||
|
||||
<div id="deny-application" class="modal fade" role="dialog">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal">×</button>
|
||||
<h4 class="modal-title">Deny This Application</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<textarea title="Denied Message To Applicant" class="form-control" rows="5" name="message" cols="50" id="denied_message"></textarea>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<a href="{{ route('staff.applications.reject', ['id' => $application->id]) }}"
|
||||
class="btn btn-danger">
|
||||
<i class="{{ config('other.font-awesome') }} fa-times"></i> Reject
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
@@ -105,8 +105,8 @@
|
||||
<hr>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="referer">How Did You Hear About {{ config('other.title') }} And Why Do You Want In? <span class="badge-extra">BBCode @lang('common.is-allowed')</span></label>
|
||||
<textarea name="referer" cols="30" rows="10" maxlength="500" class="form-control"></textarea>
|
||||
<label for="referrer">How Did You Hear About {{ config('other.title') }} And Why Do You Want In? <span class="badge-extra">BBCode @lang('common.is-allowed')</span></label>
|
||||
<textarea name="referrer" cols="30" rows="10" maxlength="500" class="form-control"></textarea>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
@component('mail::message')
|
||||
# Your {{ config('other.title') }} Application
|
||||
|
||||
Your application has been denied for the following reason:
|
||||
|
||||
{{ $denied_message }}
|
||||
|
||||
Thanks,
|
||||
{{ config('other.title') }}
|
||||
@endcomponent
|
||||
Reference in New Issue
Block a user