Skip to content

Application System #531

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 38 commits into from
Jan 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
242be73
(Add) Migrations
HDVinnie Dec 3, 2018
7bc6b98
(Fix) CreateApplicationsTable Migration
HDVinnie Dec 3, 2018
2091d00
(Add) Models
HDVinnie Dec 3, 2018
ccdd4b6
(Add) Base Controllers
HDVinnie Dec 3, 2018
a81de24
(Update) Controllers
HDVinnie Dec 3, 2018
02e933e
(Update) Controllers
HDVinnie Dec 3, 2018
8086615
(Update) Controllers
HDVinnie Dec 3, 2018
5f830f7
(Add) Web Routes
HDVinnie Dec 3, 2018
19ca410
Revert "(Add) Web Routes"
HDVinnie Dec 3, 2018
1acc099
(Add) Routes :new:
HDVinnie Dec 13, 2018
a8ef090
(Add) Base Views :new:
HDVinnie Dec 17, 2018
c448f53
Merge branch 'master' into Application-System
HDVinnie Dec 17, 2018
2eaf8d9
(Update) Application Creation View :rocket:
HDVinnie Dec 17, 2018
ecac711
(Add) Application Staff Routes :new:
HDVinnie Dec 17, 2018
42f82db
(Update) Controllers :rocket:
HDVinnie Dec 17, 2018
323e667
(Add) Staff Daskboard Link :new:
HDVinnie Dec 17, 2018
9a992be
(Add) Staff Base Views :new:
HDVinnie Dec 17, 2018
6079123
(Update) Web Routes :rocket:
HDVinnie Dec 17, 2018
baeedb1
(Update) Models :rocket:
HDVinnie Dec 18, 2018
8ac6c4e
(Update) Controllers :rocket:
HDVinnie Dec 18, 2018
1a5f973
(Add) Applications Link To Staff Dashboard :new:
HDVinnie Dec 18, 2018
490e8da
(Update) Web Routes :rocket:
HDVinnie Dec 18, 2018
4fb09cf
(Update) Views :rocket:
HDVinnie Dec 18, 2018
6aa22b0
Apply fixes from StyleCI
HDVinnie Dec 18, 2018
05052ef
Merge pull request #471 from HDInnovations/analysis-qMag4M
HDVinnie Dec 18, 2018
d96c853
Merge branch 'master' into Application-System
HDVinnie Jan 28, 2019
b8f4adb
(Update) General Cleanup :rocket:
HDVinnie Jan 28, 2019
31fc0f6
(Add) Config Check :rocket:
HDVinnie Jan 28, 2019
4fbd5f9
(Update) Cruddy Routes :rocket:
HDVinnie Jan 28, 2019
2b6569a
(Fix) Migration Typo :bug:
HDVinnie Jan 28, 2019
0f4bd55
(Add) Img Modal and Tab Popup :new:
HDVinnie Jan 28, 2019
1da121e
(Update) Applications System :rocket:
HDVinnie Jan 28, 2019
2d6baeb
Apply fixes from StyleCI
HDVinnie Jan 28, 2019
91131c6
Merge pull request #532 from HDInnovations/analysis-qJLwgD
HDVinnie Jan 28, 2019
fa2dd5c
(Fix) View Meta & Title :bug:
HDVinnie Jan 28, 2019
a7181ba
(Update) It Works! :fire:
HDVinnie Jan 28, 2019
2f49fe3
Apply fixes from StyleCI
HDVinnie Jan 28, 2019
633b2ed
Merge pull request #533 from HDInnovations/analysis-XNvy2y
HDVinnie Jan 28, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions app/Application.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?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;

use Hootlex\Moderation\Moderatable;
use Illuminate\Database\Eloquent\Model;

class Application extends Model
{
use Moderatable;

/**
* Belongs To A User.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function user()
{
return $this->belongsTo(User::class);
}

/**
* Application Has Been Moderated By.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function moderated()
{
return $this->belongsTo(User::class, 'moderated_by');
}

/**
* A Application Has Many Image Proofs.
*
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function imageProofs()
{
return $this->hasMany(ApplicationImageProof::class);
}

/**
* A Application Has Many URL Proofs.
*
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function urlProofs()
{
return $this->hasMany(ApplicationUrlProof::class);
}
}
38 changes: 38 additions & 0 deletions app/ApplicationImageProof.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?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;

use Illuminate\Database\Eloquent\Model;

class ApplicationImageProof extends Model
{
/**
* The Attributes That Are Mass Assignable.
*
* @var array
*/
protected $fillable = [
'application_id',
'image',
];

/**
* Belongs To A Application.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function application()
{
return $this->belongsTo(Application::class);
}
}
38 changes: 38 additions & 0 deletions app/ApplicationUrlProof.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?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;

use Illuminate\Database\Eloquent\Model;

class ApplicationUrlProof extends Model
{
/**
* The Attributes That Are Mass Assignable.
*
* @var array
*/
protected $fillable = [
'application_id',
'url',
];

/**
* Belongs To A Application.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function application()
{
return $this->belongsTo(Application::class);
}
}
116 changes: 116 additions & 0 deletions app/Http/Controllers/Auth/ApplicationController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
<?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\Http\Controllers\Auth;

use App\Application;
use App\ApplicationUrlProof;
use Brian2694\Toastr\Toastr;
use Illuminate\Http\Request;
use App\ApplicationImageProof;
use App\Http\Controllers\Controller;

class ApplicationController extends Controller
{
/**
* @var Toastr
*/
private $toastr;

/**
* ApplicationController Constructor.
*
* @param Toastr $toastr
*/
public function __construct(Toastr $toastr)
{
$this->toastr = $toastr;
}

/**
* Application Add Form.
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function create()
{
return view('auth.application.create');
}

/**
* Add A Application.
*
* @param \Illuminate\Http\Request $request
* @return Illuminate\Http\RedirectResponse
*/
public function store(Request $request)
{
$application = new Application();
$application->type = $request->input('type');
$application->email = $request->input('email');
$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',
'referrer' => 'required',
'images.*' => 'filled',
'images' => 'min:2',
'links.*' => 'filled',
'links' => 'min:2',
]);
} elseif (config('email-white-blacklist.enabled') === 'block') {
$v = validator($request->all(), [
'type' => 'required',
'email' => 'required|email|unique:invites|unique:users|unique:applications|email_list:block',
'referrer' => 'required',
'images.*' => 'filled',
'images' => 'min:2',
'links.*' => 'filled',
'links' => 'min:2',
]);
} else {
$v = validator($request->all(), [
'type' => 'required',
'email' => 'required|email|unique:invites|unique:users|unique:applications',
'referrer' => 'required',
'images.*' => 'filled',
'images' => 'min:2',
'links.*' => 'filled',
'links' => 'min:2',
]);
}

if ($v->fails()) {
return redirect()->route('application.create')
->with($this->toastr->error($v->errors()->toJson(), 'Whoops!', ['options']));
} else {
$application->save();

// Map And Save IMG Proofs
$imgs = collect($request->input('images'))->map(function ($value) {
return new ApplicationImageProof(['image' => $value]);
});
$application->imageProofs()->saveMany($imgs);

// Map And Save URL Proofs
$urls = collect($request->input('links'))->map(function ($value) {
return new ApplicationUrlProof(['url' => $value]);
});
$application->urlProofs()->saveMany($urls);

return redirect()->route('login')
->with($this->toastr->success('Your Application Has Been Submitted. You will receive a email soon!', 'Yay!', ['options']));
}
}
}
Loading