Browse Source
First init
First init
Add User Registrations and Login Add User chage password Add User reset password Add Manage Projects (with tests) Add Manage Users (with test) Add Manage Roles Add Manage Permissions Add Manage Project Paymentspull/1/head
commit
8b9b14919a
256 changed files with 21152 additions and 0 deletions
-
28.env.example
-
3.gitattributes
-
6.gitignore
-
33app/Console/Commands/Inspire.php
-
30app/Console/Kernel.php
-
92app/Entities/Backups/BackupsRepository.php
-
21app/Entities/BaseRepository.php
-
106app/Entities/EloquentRepository.php
-
16app/Entities/Masters/Master.php
-
14app/Entities/Masters/MasterPresenter.php
-
18app/Entities/Masters/MastersRepository.php
-
12app/Entities/Options/Option.php
-
38app/Entities/Options/OptionsRepository.php
-
28app/Entities/Pages/PagesRepository.php
-
27app/Entities/Payments/Payment.php
-
23app/Entities/Payments/PaymentPresenter.php
-
24app/Entities/Payments/PaymentsRepository.php
-
16app/Entities/Projects/Feature.php
-
30app/Entities/Projects/FeaturesRepository.php
-
34app/Entities/Projects/Project.php
-
24app/Entities/Projects/ProjectPresenter.php
-
80app/Entities/Projects/ProjectsRepository.php
-
12app/Entities/References/Reference.php
-
70app/Entities/Users/HasRoles.php
-
23app/Entities/Users/Permission.php
-
39app/Entities/Users/Role.php
-
21app/Entities/Users/User.php
-
62app/Entities/Users/UserPresenter.php
-
75app/Entities/Users/UsersRepository.php
-
8app/Events/Event.php
-
50app/Exceptions/Handler.php
-
138app/Http/Controllers/AuthController.php
-
84app/Http/Controllers/BackupsController.php
-
13app/Http/Controllers/Controller.php
-
79app/Http/Controllers/MastersController.php
-
29app/Http/Controllers/PagesController.php
-
79app/Http/Controllers/PaymentsController.php
-
80app/Http/Controllers/Projects/FeaturesController.php
-
99app/Http/Controllers/Projects/ProjectsController.php
-
65app/Http/Controllers/References/OptionsController.php
-
66app/Http/Controllers/Users/PermissionsController.php
-
85app/Http/Controllers/Users/RolesController.php
-
82app/Http/Controllers/Users/UsersController.php
-
54app/Http/Kernel.php
-
30app/Http/Middleware/Authenticate.php
-
17app/Http/Middleware/EncryptCookies.php
-
26app/Http/Middleware/RedirectIfAuthenticated.php
-
33app/Http/Middleware/RoleMiddleware.php
-
17app/Http/Middleware/VerifyCsrfToken.php
-
43app/Http/Requests/Accounts/ChangePasswordRequest.php
-
39app/Http/Requests/Accounts/LoginRequest.php
-
50app/Http/Requests/Accounts/RegisterRequest.php
-
38app/Http/Requests/Accounts/UpdateProfileRequest.php
-
52app/Http/Requests/Backups/BackupUploadRequest.php
-
31app/Http/Requests/Backups/CreateRequest.php
-
31app/Http/Requests/Backups/DeleteRequest.php
-
32app/Http/Requests/Masters/CreateRequest.php
-
31app/Http/Requests/Masters/DeleteRequest.php
-
32app/Http/Requests/Masters/UpdateRequest.php
-
31app/Http/Requests/Options/CreateRequest.php
-
32app/Http/Requests/Payments/CreateRequest.php
-
31app/Http/Requests/Payments/DeleteRequest.php
-
35app/Http/Requests/Payments/UpdateRequest.php
-
45app/Http/Requests/Projects/CreateRequest.php
-
31app/Http/Requests/Projects/DeleteRequest.php
-
38app/Http/Requests/Projects/UpdateRequest.php
-
10app/Http/Requests/Request.php
-
35app/Http/Requests/Users/CreateRequest.php
-
30app/Http/Requests/Users/DeleteRequest.php
-
32app/Http/Requests/Users/Permissions/CreateRequest.php
-
31app/Http/Requests/Users/Permissions/DeleteRequest.php
-
32app/Http/Requests/Users/Permissions/UpdateRequest.php
-
32app/Http/Requests/Users/Roles/CreateRequest.php
-
31app/Http/Requests/Users/Roles/DeleteRequest.php
-
32app/Http/Requests/Users/Roles/UpdateRequest.php
-
35app/Http/Requests/Users/UpdateRequest.php
-
10app/Http/routes.php
-
20app/Http/routes/account.php
-
14app/Http/routes/backup.php
-
182app/Http/routes/helpers.php
-
8app/Http/routes/pages.php
-
9app/Http/routes/payments.php
-
17app/Http/routes/projects.php
-
13app/Http/routes/references.php
-
20app/Http/routes/users.php
-
21app/Jobs/Job.php
-
0app/Listeners/.gitkeep
-
0app/Policies/.gitkeep
-
35app/Providers/AppServiceProvider.php
-
48app/Providers/AuthServiceProvider.php
-
33app/Providers/EventServiceProvider.php
-
32app/Providers/FormFieldServiceProvider.php
-
32app/Providers/OptionServiceProvider.php
-
44app/Providers/RouteServiceProvider.php
-
10app/Services/Facades/FormField.php
-
10app/Services/Facades/Option.php
-
306app/Services/FormField.php
-
35app/Services/Option.php
-
217app/helpers.php
-
51artisan
@ -0,0 +1,28 @@ |
|||
APP_ENV=local |
|||
APP_DEBUG=true |
|||
APP_KEY=SomeRandomString |
|||
|
|||
APP_LOCALE=id |
|||
APP_TIMEZONE=Asia/Makassar |
|||
|
|||
DB_HOST=127.0.0.1 |
|||
DB_DATABASE=homestead |
|||
DB_USERNAME=homestead |
|||
DB_PASSWORD=secret |
|||
|
|||
CACHE_DRIVER=file |
|||
SESSION_DRIVER=file |
|||
QUEUE_DRIVER=sync |
|||
|
|||
REDIS_HOST=127.0.0.1 |
|||
REDIS_PASSWORD=null |
|||
REDIS_PORT=6379 |
|||
|
|||
MAIL_DRIVER=smtp |
|||
MAIL_HOST=mailtrap.io |
|||
MAIL_PORT=2525 |
|||
MAIL_USERNAME=null |
|||
MAIL_PASSWORD=null |
|||
MAIL_ENCRYPTION=null |
|||
MAIL_FROM=null |
|||
MAIL_NAME=null |
|||
@ -0,0 +1,3 @@ |
|||
* text=auto |
|||
*.css linguist-vendored |
|||
*.less linguist-vendored |
|||
@ -0,0 +1,6 @@ |
|||
/vendor |
|||
/node_modules |
|||
/public/storage |
|||
Homestead.yaml |
|||
Homestead.json |
|||
.env |
|||
@ -0,0 +1,33 @@ |
|||
<?php |
|||
|
|||
namespace App\Console\Commands; |
|||
|
|||
use Illuminate\Console\Command; |
|||
use Illuminate\Foundation\Inspiring; |
|||
|
|||
class Inspire extends Command |
|||
{ |
|||
/** |
|||
* The name and signature of the console command. |
|||
* |
|||
* @var string |
|||
*/ |
|||
protected $signature = 'inspire'; |
|||
|
|||
/** |
|||
* The console command description. |
|||
* |
|||
* @var string |
|||
*/ |
|||
protected $description = 'Display an inspiring quote'; |
|||
|
|||
/** |
|||
* Execute the console command. |
|||
* |
|||
* @return mixed |
|||
*/ |
|||
public function handle() |
|||
{ |
|||
$this->comment(PHP_EOL.Inspiring::quote().PHP_EOL); |
|||
} |
|||
} |
|||
@ -0,0 +1,30 @@ |
|||
<?php |
|||
|
|||
namespace App\Console; |
|||
|
|||
use Illuminate\Console\Scheduling\Schedule; |
|||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel; |
|||
|
|||
class Kernel extends ConsoleKernel |
|||
{ |
|||
/** |
|||
* The Artisan commands provided by your application. |
|||
* |
|||
* @var array |
|||
*/ |
|||
protected $commands = [ |
|||
// Commands\Inspire::class,
|
|||
]; |
|||
|
|||
/** |
|||
* Define the application's command schedule. |
|||
* |
|||
* @param \Illuminate\Console\Scheduling\Schedule $schedule |
|||
* @return void |
|||
*/ |
|||
protected function schedule(Schedule $schedule) |
|||
{ |
|||
// $schedule->command('inspire')
|
|||
// ->hourly();
|
|||
} |
|||
} |
|||
@ -0,0 +1,92 @@ |
|||
<?php |
|||
|
|||
namespace App\Entities\Backups; |
|||
|
|||
use App\Entities\Options\Option; |
|||
use BackupManager\Filesystems\Destination; |
|||
use BackupManager\Manager; |
|||
use League\Flysystem\FileExistsException; |
|||
use League\Flysystem\FileNotFoundException; |
|||
use Storage; |
|||
|
|||
/** |
|||
* Backups Repository Class |
|||
*/ |
|||
class BackupsRepository |
|||
{ |
|||
protected $storage; |
|||
protected $storageType; |
|||
|
|||
public function __construct() |
|||
{ |
|||
$this->storageType = 'local'; |
|||
$this->storage = Storage::disk($this->storageType); |
|||
} |
|||
|
|||
public function getAllFiles() |
|||
{ |
|||
$backups = \File::allFiles(storage_path('app/backup/db')); |
|||
|
|||
// Sort files by modified time DESC
|
|||
usort($backups, function($a, $b) { |
|||
return -1 * strcmp($a->getMTime(), $b->getMTime()); |
|||
}); |
|||
|
|||
return $backups; |
|||
} |
|||
|
|||
public function create($backupData) |
|||
{ |
|||
$manager = app()->make(Manager::class); |
|||
$fileName = $backupData['file_name'] ?: date('Y-m-d_Hi'); |
|||
try { |
|||
$manager->makeBackup()->run('mysql', [ |
|||
new Destination($this->storageType, 'backup/db/' . $fileName) |
|||
], 'gzip'); |
|||
|
|||
return $fileName; |
|||
|
|||
} catch (FileExistsException $e) { |
|||
flash()->error('Database tidak dapat dibackup dengan Nama File yang sama.'); |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
public function restore($fileName) |
|||
{ |
|||
try { |
|||
$manager = app()->make(Manager::class); |
|||
$manager->makeRestore()->run($this->storageType, 'backup/db/' . $fileName, 'mysql', 'gzip'); |
|||
return true; |
|||
|
|||
} catch (FileNotFoundException $e) { |
|||
flash()->error('Tidak dapat mengembalikan Database.'); |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
public function delete($fileName) |
|||
{ |
|||
if ($this->storage->has('backup/db/' . $fileName)) { |
|||
$this->storage->delete('backup/db/' . $fileName); |
|||
|
|||
return true; |
|||
} |
|||
|
|||
return false; |
|||
} |
|||
|
|||
public function proccessBackupFileUpload($req) |
|||
{ |
|||
$file = $req->file('backup_file'); |
|||
|
|||
if ($this->storage->has('backup/db/' . $file->getClientOriginalName())) { |
|||
flash()->error('Upload file gagal, terdapat Nama File yang sama.'); |
|||
return false; |
|||
} |
|||
|
|||
$result = $this->storage->put('backup/db/' . $file->getClientOriginalName(), file_get_contents($file)); |
|||
|
|||
return $result; |
|||
} |
|||
} |
|||
@ -0,0 +1,21 @@ |
|||
<?php |
|||
|
|||
namespace App\Entities; |
|||
|
|||
use App\Entities\Users\User; |
|||
|
|||
/** |
|||
* Base Repository Class |
|||
*/ |
|||
abstract class BaseRepository extends EloquentRepository { |
|||
|
|||
public function getCustomersList() |
|||
{ |
|||
return User::orderBy('name')->hasRoles(['customer'])->lists('name','id'); |
|||
} |
|||
|
|||
public function getWorkersList() |
|||
{ |
|||
return User::orderBy('name')->hasRoles(['worker'])->lists('name','id'); |
|||
} |
|||
} |
|||
@ -0,0 +1,106 @@ |
|||
<?php |
|||
|
|||
namespace App\Entities; |
|||
|
|||
use App\Exceptions\EntityNotFoundException; |
|||
use Illuminate\Database\Eloquent\Model; |
|||
|
|||
/** |
|||
* Eloquent Repository Class |
|||
*/ |
|||
abstract class EloquentRepository |
|||
{ |
|||
protected $_paginate = 25; |
|||
protected $model; |
|||
|
|||
public function __construct(Model $model) |
|||
{ |
|||
$this->model = $model; |
|||
} |
|||
|
|||
public function setModel(Model $model) |
|||
{ |
|||
$this->model = $model; |
|||
} |
|||
|
|||
public function getAll($q) |
|||
{ |
|||
return $this->model->latest() |
|||
->where('name','like','%'.$q.'%') |
|||
->paginate($this->_paginate); |
|||
} |
|||
|
|||
public function getById($id) |
|||
{ |
|||
return $this->getBy($this->model->getKeyName(), $id); |
|||
} |
|||
|
|||
public function getBy($column, $value) |
|||
{ |
|||
$model = $this->model->newQuery()->where($column, $value)->get(); |
|||
if ($model->count() > 1) |
|||
return $model; |
|||
|
|||
return $model->first(); |
|||
} |
|||
|
|||
public function requireById($id) |
|||
{ |
|||
$model = $this->getById($id); |
|||
if ( ! $model ) |
|||
throw new EntityNotFoundException($id, $this->model->getTable()); |
|||
return $model; |
|||
} |
|||
|
|||
public function getNewInstance($attributes = []) |
|||
{ |
|||
return $this->model->newInstance($attributes); |
|||
} |
|||
|
|||
public function create($data) |
|||
{ |
|||
if ($data instanceof Model) |
|||
{ |
|||
return $this->storeEloquentModel($data); |
|||
} else { |
|||
foreach ($data as $key => $value) { |
|||
if (!$data[$key]) $data[$key] = null; |
|||
} |
|||
return $this->storeArray($data); |
|||
} |
|||
} |
|||
|
|||
public function update($data = [], $modelId) |
|||
{ |
|||
foreach ($data as $key => $value) { |
|||
if (!$data[$key]) $data[$key] = null; |
|||
} |
|||
|
|||
$model = $this->requireById($modelId); |
|||
$model->update($data); |
|||
return $model; |
|||
} |
|||
|
|||
public function delete($modelId) |
|||
{ |
|||
$model = $this->requireById($modelId); |
|||
return $model->delete(); |
|||
} |
|||
|
|||
protected function storeEloquentModel(Model $model) |
|||
{ |
|||
if ($model->getDirty()) |
|||
{ |
|||
return $model->save(); |
|||
} else { |
|||
return $model->touch(); |
|||
} |
|||
} |
|||
|
|||
protected function storeArray($data) |
|||
{ |
|||
$model = $this->getNewInstance($data); |
|||
$this->storeEloquentModel($model); |
|||
return $model; |
|||
} |
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
<?php |
|||
|
|||
namespace App\Entities\Masters; |
|||
|
|||
use App\Entities\Masters\MasterPresenter; |
|||
use Illuminate\Database\Eloquent\Model; |
|||
use Laracasts\Presenter\PresentableTrait; |
|||
|
|||
class Master extends Model { |
|||
|
|||
use PresentableTrait; |
|||
|
|||
protected $presenter = MasterPresenter::class; |
|||
protected $guarded = ['id','created_at','updated_at']; |
|||
|
|||
} |
|||
@ -0,0 +1,14 @@ |
|||
<?php |
|||
|
|||
namespace App\Entities\Masters; |
|||
|
|||
use Laracasts\Presenter\Presenter; |
|||
|
|||
class MasterPresenter extends Presenter |
|||
{ |
|||
public function fullName() |
|||
{ |
|||
return $this->name; |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,18 @@ |
|||
<?php |
|||
|
|||
namespace App\Entities\Masters; |
|||
|
|||
use App\Entities\BaseRepository; |
|||
|
|||
/** |
|||
* Masters Repository Class |
|||
*/ |
|||
class MastersRepository extends BaseRepository |
|||
{ |
|||
protected $model; |
|||
|
|||
public function __construct(Master $model) |
|||
{ |
|||
parent::__construct($model); |
|||
} |
|||
} |
|||
@ -0,0 +1,12 @@ |
|||
<?php |
|||
|
|||
namespace App\Entities\Options; |
|||
|
|||
use Illuminate\Database\Eloquent\Model; |
|||
|
|||
class Option extends Model { |
|||
|
|||
protected $fillable = ['key','value']; |
|||
protected $table = 'site_options'; |
|||
public $timestamps = false; |
|||
} |
|||
@ -0,0 +1,38 @@ |
|||
<?php |
|||
|
|||
namespace App\Entities\Options; |
|||
|
|||
use App\Entities\BaseRepository; |
|||
use App\Exceptions\OptionNotFoundException; |
|||
use App\Exceptions\OptionUpdateException; |
|||
use App\Exceptions\OptionDeleteException; |
|||
|
|||
/** |
|||
* Options Repository Class |
|||
*/ |
|||
class OptionsRepository extends BaseRepository |
|||
{ |
|||
protected $model; |
|||
|
|||
public function __construct(Option $model) |
|||
{ |
|||
parent::__construct($model); |
|||
} |
|||
|
|||
public function getAll($q = null) |
|||
{ |
|||
return Option::all(); |
|||
} |
|||
|
|||
public function save($optionsData) |
|||
{ |
|||
$options = $this->getAll(); |
|||
foreach ($optionsData as $key => $value) { |
|||
$option = $options->where('key', $key)->first(); |
|||
$option->value = $value; |
|||
$option->save(); |
|||
} |
|||
|
|||
return 'saved'; |
|||
} |
|||
} |
|||
@ -0,0 +1,28 @@ |
|||
<?php |
|||
|
|||
namespace App\Entities\Pages; |
|||
|
|||
use App\Entities\BaseRepository; |
|||
use App\Entities\Options\Option; |
|||
use App\Entities\Payments\Payment; |
|||
|
|||
/** |
|||
* Pages Repository Class |
|||
*/ |
|||
class PagesRepository extends BaseRepository |
|||
{ |
|||
public function __construct(Option $model) |
|||
{ |
|||
$this->model = $model; |
|||
} |
|||
|
|||
public function getTotalIncome() |
|||
{ |
|||
return Payment::whereType(1)->sum('amount'); |
|||
} |
|||
|
|||
public function getTotalExpenditure() |
|||
{ |
|||
return Payment::whereType(0)->sum('amount'); |
|||
} |
|||
} |
|||
@ -0,0 +1,27 @@ |
|||
<?php |
|||
|
|||
namespace App\Entities\Payments; |
|||
|
|||
use App\Entities\Payments\PaymentPresenter; |
|||
use App\Entities\Projects\Project; |
|||
use App\Entities\Users\User; |
|||
use Illuminate\Database\Eloquent\Model; |
|||
use Laracasts\Presenter\PresentableTrait; |
|||
|
|||
class Payment extends Model { |
|||
|
|||
use PresentableTrait; |
|||
|
|||
protected $presenter = PaymentPresenter::class; |
|||
protected $guarded = ['id','created_at','updated_at']; |
|||
|
|||
public function project() |
|||
{ |
|||
return $this->belongsTo(Project::class); |
|||
} |
|||
|
|||
public function customer() |
|||
{ |
|||
return $this->belongsTo(User::class, 'customer_id'); |
|||
} |
|||
} |
|||
@ -0,0 +1,23 @@ |
|||
<?php |
|||
|
|||
namespace App\Entities\Payments; |
|||
|
|||
use Laracasts\Presenter\Presenter; |
|||
|
|||
class PaymentPresenter extends Presenter |
|||
{ |
|||
public function amount() |
|||
{ |
|||
return $this->entity->type == 0 ? formatRp(-$this->entity->amount) : formatRp($this->entity->amount); |
|||
} |
|||
|
|||
public function projectLink() |
|||
{ |
|||
return link_to_route('projects.show', $this->project->name, [$this->project_id]); |
|||
} |
|||
|
|||
public function projectPaymentsLink() |
|||
{ |
|||
return link_to_route('projects.payments', trans('project.payments'), [$this->project_id]); |
|||
} |
|||
} |
|||
@ -0,0 +1,24 @@ |
|||
<?php |
|||
|
|||
namespace App\Entities\Payments; |
|||
|
|||
use App\Entities\BaseRepository; |
|||
|
|||
/** |
|||
* Payments Repository Class |
|||
*/ |
|||
class PaymentsRepository extends BaseRepository |
|||
{ |
|||
protected $model; |
|||
|
|||
public function __construct(Payment $model) |
|||
{ |
|||
parent::__construct($model); |
|||
} |
|||
|
|||
public function getAll($q) |
|||
{ |
|||
return $this->model->latest() |
|||
->paginate($this->_paginate); |
|||
} |
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
<?php |
|||
|
|||
namespace App\Entities\Projects; |
|||
|
|||
use App\Entities\Projects\FeaturePresenter; |
|||
use Illuminate\Database\Eloquent\Model; |
|||
use Laracasts\Presenter\PresentableTrait; |
|||
|
|||
class Feature extends Model { |
|||
|
|||
use PresentableTrait; |
|||
|
|||
protected $presenter = FeaturePresenter::class; |
|||
protected $guarded = ['id','created_at','updated_at']; |
|||
|
|||
} |
|||
@ -0,0 +1,30 @@ |
|||
<?php |
|||
|
|||
namespace App\Entities\Projects; |
|||
|
|||
use App\Entities\BaseRepository; |
|||
|
|||
/** |
|||
* Features Repository Class |
|||
*/ |
|||
class FeaturesRepository extends BaseRepository |
|||
{ |
|||
protected $model; |
|||
|
|||
public function __construct(Feature $model) |
|||
{ |
|||
parent::__construct($model); |
|||
} |
|||
|
|||
public function requireProjectById($projectId) |
|||
{ |
|||
return Project::findOrFail($projectId); |
|||
} |
|||
|
|||
public function create($featureData) |
|||
{ |
|||
dd($featureData); |
|||
$featureData['feature_value'] = $featureData['proposal_value']; |
|||
return $this->storeArray($featureData); |
|||
} |
|||
} |
|||
@ -0,0 +1,34 @@ |
|||
<?php |
|||
|
|||
namespace App\Entities\Projects; |
|||
|
|||
use App\Entities\Payments\Payment; |
|||
use App\Entities\Projects\ProjectPresenter; |
|||
use App\Entities\Users\User; |
|||
use Illuminate\Database\Eloquent\Model; |
|||
use Laracasts\Presenter\PresentableTrait; |
|||
|
|||
class Project extends Model { |
|||
|
|||
use PresentableTrait; |
|||
|
|||
protected $presenter = ProjectPresenter::class; |
|||
protected $guarded = ['id','created_at','updated_at']; |
|||
// protected $dates = ['start_date','end_date'];
|
|||
|
|||
public function features() |
|||
{ |
|||
return $this->hasMany(Feature::class); |
|||
} |
|||
|
|||
public function payments() |
|||
{ |
|||
return $this->hasMany(Payment::class)->orderBy('date','desc'); |
|||
} |
|||
|
|||
public function customer() |
|||
{ |
|||
return $this->belongsTo(User::class,'customer_id'); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,24 @@ |
|||
<?php |
|||
|
|||
namespace App\Entities\Projects; |
|||
|
|||
use Laracasts\Presenter\Presenter; |
|||
|
|||
class ProjectPresenter extends Presenter |
|||
{ |
|||
public function customerNameAndEmail() |
|||
{ |
|||
return $this->customer_id ? $this->customer->name . ' (' . $this->customer->email . ')' : '-'; |
|||
} |
|||
|
|||
public function projectLink() |
|||
{ |
|||
return link_to_route('projects.show', $this->name, [$this->id]); |
|||
} |
|||
|
|||
public function status() |
|||
{ |
|||
return getProjectStatusesList($this->entity->status_id); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,80 @@ |
|||
<?php |
|||
|
|||
namespace App\Entities\Projects; |
|||
|
|||
use App\Entities\BaseRepository; |
|||
use App\Entities\Users\User; |
|||
use DB; |
|||
use Option; |
|||
|
|||
/** |
|||
* Projects Repository Class |
|||
*/ |
|||
class ProjectsRepository extends BaseRepository |
|||
{ |
|||
protected $model; |
|||
|
|||
public function __construct(Project $model) |
|||
{ |
|||
parent::__construct($model); |
|||
} |
|||
|
|||
public function getProjects($q, $statusId) |
|||
{ |
|||
$statusIds = array_keys(getProjectStatusesList()); |
|||
|
|||
return $this->model->latest() |
|||
->where(function($query) use ($q, $statusId, $statusIds) { |
|||
$query->where('name','like','%'.$q.'%'); |
|||
if ($statusId && in_array($statusId, $statusIds)) |
|||
$query->where('status_id', $statusId); |
|||
}) |
|||
->withCount('payments') |
|||
->paginate($this->_paginate); |
|||
} |
|||
|
|||
public function create($projectData) |
|||
{ |
|||
$projectData['project_value'] = $projectData['proposal_value'] ?: 0; |
|||
$projectData['owner_id'] = auth()->id(); |
|||
DB::beginTransaction(); |
|||
|
|||
if ($projectData['customer_id'] == '') { |
|||
$customer = $this->createNewCustomer($projectData['customer_name'], $projectData['customer_email']); |
|||
$projectData['customer_id'] = $customer->id; |
|||
} |
|||
unset($projectData['customer_name']); |
|||
unset($projectData['customer_email']); |
|||
|
|||
$project = $this->storeArray($projectData); |
|||
DB::commit(); |
|||
return $project; |
|||
} |
|||
|
|||
public function getStatusName($statusId) |
|||
{ |
|||
return getProjectStatusesList($statusId); |
|||
} |
|||
|
|||
public function createNewCustomer($customerName, $customerEmail) |
|||
{ |
|||
$newCustomer = new User; |
|||
$newCustomer->name = $customerName; |
|||
$newCustomer->email = $customerEmail; |
|||
$newCustomer->username = str_replace(' ', '_', strtolower($customerName)); |
|||
$newCustomer->password = Option::get('default_password', 'member'); |
|||
$newCustomer->remember_token = str_random(10); |
|||
$newCustomer->save(); |
|||
$newCustomer->assignRole('customer'); |
|||
return $newCustomer; |
|||
} |
|||
|
|||
public function delete($projectId) |
|||
{ |
|||
$project = $this->requireById($projectId); |
|||
$project->payments()->delete(); |
|||
$project->features()->delete(); |
|||
|
|||
return $project->delete(); |
|||
} |
|||
} |
|||
@ -0,0 +1,12 @@ |
|||
<?php |
|||
|
|||
namespace App\Entities\References; |
|||
|
|||
use Illuminate\Database\Eloquent\Model; |
|||
|
|||
class Reference extends Model { |
|||
|
|||
protected $fillable = ['cat','code','name']; |
|||
protected $table = 'references'; |
|||
public $timestamps = false; |
|||
} |
|||
@ -0,0 +1,70 @@ |
|||
<?php |
|||
|
|||
namespace App\Entities\Users; |
|||
|
|||
trait HasRoles |
|||
{ |
|||
|
|||
/** |
|||
* A user may have multiple roles. |
|||
* |
|||
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany |
|||
*/ |
|||
public function roles() |
|||
{ |
|||
return $this->belongsToMany(Role::class); |
|||
} |
|||
|
|||
/** |
|||
* Assign the given role to the user. |
|||
* |
|||
* @param string $role |
|||
* @return mixed |
|||
*/ |
|||
public function assignRole($role) |
|||
{ |
|||
return $this->roles()->save( |
|||
Role::whereName($role)->firstOrFail() |
|||
); |
|||
} |
|||
|
|||
/** |
|||
* Determine if the user has the given role. |
|||
* |
|||
* @param mixed $role |
|||
* @return boolean |
|||
*/ |
|||
public function hasRole($role) |
|||
{ |
|||
if (is_string($role)) { |
|||
return $this->roles->contains('name', $role); |
|||
} |
|||
|
|||
return !! $role->intersect($this->roles)->count(); |
|||
} |
|||
|
|||
/** |
|||
* Determine if the user may perform the given permission. |
|||
* |
|||
* @param Permission $permission |
|||
* @return boolean |
|||
*/ |
|||
public function hasPermission(Permission $permission) |
|||
{ |
|||
return $this->hasRole($permission->roles); |
|||
} |
|||
|
|||
public function hasRoles(array $roleNameArray) |
|||
{ |
|||
return $this->roles->contains(function($key, $role) use ($roleNameArray) { |
|||
return in_array($role->name, $roleNameArray); |
|||
}); |
|||
} |
|||
|
|||
public function scopeHasRoles($query, array $roleNameArray) |
|||
{ |
|||
return $query->whereHas('roles', function($q) use ($roleNameArray) { |
|||
$q->whereIn('name',$roleNameArray); |
|||
}); |
|||
} |
|||
} |
|||
@ -0,0 +1,23 @@ |
|||
<?php |
|||
|
|||
namespace App\Entities\Users; |
|||
|
|||
use Illuminate\Database\Eloquent\Model; |
|||
|
|||
class Permission extends Model |
|||
{ |
|||
protected $table = 'roles_permissions'; |
|||
|
|||
protected $fillable = ['type','name','label']; |
|||
public $timestamps = false; |
|||
|
|||
/** |
|||
* A permission can be applied to roles. |
|||
* |
|||
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany |
|||
*/ |
|||
public function roles() |
|||
{ |
|||
return $this->belongsToMany(Role::class, 'user_role_permission'); |
|||
} |
|||
} |
|||
@ -0,0 +1,39 @@ |
|||
<?php |
|||
|
|||
namespace App\Entities\Users; |
|||
|
|||
use Illuminate\Database\Eloquent\Model; |
|||
|
|||
class Role extends Model |
|||
{ |
|||
protected $table = 'roles_permissions'; |
|||
|
|||
protected $fillable = ['type','name','label']; |
|||
public $timestamps = false; |
|||
|
|||
/** |
|||
* A role may be given various permissions. |
|||
* |
|||
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany |
|||
*/ |
|||
public function permissions() |
|||
{ |
|||
return $this->belongsToMany(Permission::class, 'user_role_permission'); |
|||
} |
|||
|
|||
/** |
|||
* Grant the given permission to a role. |
|||
* |
|||
* @param Permission $permission |
|||
* @return mixed |
|||
*/ |
|||
public function givePermissionTo(Permission $permission) |
|||
{ |
|||
return $this->permissions()->save($permission); |
|||
} |
|||
|
|||
public function users() |
|||
{ |
|||
return $this->belongsToMany(User::class, 'role_user'); |
|||
} |
|||
} |
|||
@ -0,0 +1,21 @@ |
|||
<?php |
|||
|
|||
namespace App\Entities\Users; |
|||
|
|||
use App\Entities\Users\UserPresenter; |
|||
use Illuminate\Foundation\Auth\User as Authenticatable; |
|||
use Laracasts\Presenter\PresentableTrait; |
|||
|
|||
class User extends Authenticatable |
|||
{ |
|||
use PresentableTrait, HasRoles; |
|||
|
|||
protected $fillable = ['name', 'username', 'email', 'password']; |
|||
protected $hidden = ['password', 'remember_token']; |
|||
protected $presenter = UserPresenter::class; |
|||
|
|||
public function setPasswordAttribute($value) |
|||
{ |
|||
$this->attributes['password'] = bcrypt($value); |
|||
} |
|||
} |
|||
@ -0,0 +1,62 @@ |
|||
<?php |
|||
|
|||
namespace App\Entities\Users; |
|||
|
|||
use Html; |
|||
use Laracasts\Presenter\Presenter; |
|||
|
|||
class UserPresenter extends Presenter |
|||
{ |
|||
public function displayRoles() |
|||
{ |
|||
$string = ''; |
|||
foreach($this->roles as $key => $role) { |
|||
$string .= ($key != 0) ? ' | ' : ''; |
|||
$string .= $role->label; |
|||
} |
|||
|
|||
return $string; |
|||
} |
|||
|
|||
public function rolesLink() |
|||
{ |
|||
$string = ''; |
|||
foreach($this->roles as $key => $role) { |
|||
$string .= ($key != 0) ? ' | ' : ''; |
|||
$string .= link_to_route('users.index', $role->label, ['role' => $role->name], ['title' => 'Lihat semua ' . $role->label]); |
|||
} |
|||
|
|||
return $string; |
|||
} |
|||
|
|||
public function usernameRoles() |
|||
{ |
|||
$string = $this->username . ' ('; |
|||
foreach($this->roles as $key => $role) { |
|||
$string .= ($key != 0) ? ' | ' : ''; |
|||
$string .= $role->label; |
|||
} |
|||
$string .= ')'; |
|||
|
|||
return $string; |
|||
} |
|||
|
|||
public function displayPermissions() |
|||
{ |
|||
$string = '<ul class="permissions-list">'; |
|||
foreach($this->roles as $key => $role) { |
|||
foreach ($role->permissions as $key2 => $permission) { |
|||
$string .= '<li>' . $permission->label . '</li>'; |
|||
} |
|||
} |
|||
$string .= '</ul>'; |
|||
|
|||
return $string; |
|||
} |
|||
|
|||
public function photo() |
|||
{ |
|||
return Html::image('assets/imgs/icon_user_1.png', $this->name, ['width' => '100px']); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,75 @@ |
|||
<?php |
|||
namespace App\Entities\Users; |
|||
|
|||
use App\Entities\BaseRepository; |
|||
use App\Exceptions\UpdateUserException; |
|||
use App\Exceptions\UserDeleteException; |
|||
use App\Exceptions\UserNotFoundException; |
|||
use App\Services\Facades\Option; |
|||
|
|||
/** |
|||
* Users Repository Class |
|||
*/ |
|||
class UsersRepository extends BaseRepository |
|||
{ |
|||
|
|||
protected $model; |
|||
|
|||
public function __construct(User $model) |
|||
{ |
|||
parent::__construct($model); |
|||
} |
|||
|
|||
public function getUsers($q, $rolesString) |
|||
{ |
|||
return $this->model->latest() |
|||
->where('name','like','%'.$q.'%') |
|||
->whereHas('roles', function($query) use ($rolesString) { |
|||
if (!is_null($rolesString)) { |
|||
$query->whereIn('name', explode('|', $rolesString)); |
|||
} |
|||
}) |
|||
->paginate($this->_paginate); |
|||
} |
|||
|
|||
public function create($userData) |
|||
{ |
|||
if ($userData['password'] == '') |
|||
$userData['password'] = Option::get('password_default','member'); |
|||
|
|||
$user = $this->storeArray($userData); |
|||
$user->roles()->sync($userData['role']); |
|||
|
|||
return $user; |
|||
} |
|||
|
|||
public function update($userData, $userId) |
|||
{ |
|||
$user = $this->requireById($userId); |
|||
|
|||
foreach ($userData as $key => $value) { |
|||
if ($value == '' || $key == 'role') continue; |
|||
$user->{$key} = $value; |
|||
} |
|||
|
|||
$user->roles()->sync($userData['role']); |
|||
|
|||
if ($user->save()) |
|||
return $user; |
|||
|
|||
throw new UpdateUserException('Failed to update User'); |
|||
} |
|||
|
|||
public function getRolesList() |
|||
{ |
|||
return Role::where('type', 0)->lists('label','id')->all(); |
|||
} |
|||
|
|||
public function delete($userId) |
|||
{ |
|||
$user = $this->requireById($userId); |
|||
$user->roles()->detach(); |
|||
|
|||
return $user->delete(); |
|||
} |
|||
} |
|||
@ -0,0 +1,8 @@ |
|||
<?php |
|||
|
|||
namespace App\Events; |
|||
|
|||
abstract class Event |
|||
{ |
|||
//
|
|||
} |
|||
@ -0,0 +1,50 @@ |
|||
<?php |
|||
|
|||
namespace App\Exceptions; |
|||
|
|||
use Exception; |
|||
use Illuminate\Validation\ValidationException; |
|||
use Illuminate\Auth\Access\AuthorizationException; |
|||
use Illuminate\Database\Eloquent\ModelNotFoundException; |
|||
use Symfony\Component\HttpKernel\Exception\HttpException; |
|||
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; |
|||
|
|||
class Handler extends ExceptionHandler |
|||
{ |
|||
/** |
|||
* A list of the exception types that should not be reported. |
|||
* |
|||
* @var array |
|||
*/ |
|||
protected $dontReport = [ |
|||
AuthorizationException::class, |
|||
HttpException::class, |
|||
ModelNotFoundException::class, |
|||
ValidationException::class, |
|||
]; |
|||
|
|||
/** |
|||
* Report or log an exception. |
|||
* |
|||
* This is a great spot to send exceptions to Sentry, Bugsnag, etc. |
|||
* |
|||
* @param \Exception $e |
|||
* @return void |
|||
*/ |
|||
public function report(Exception $e) |
|||
{ |
|||
parent::report($e); |
|||
} |
|||
|
|||
/** |
|||
* Render an exception into an HTTP response. |
|||
* |
|||
* @param \Illuminate\Http\Request $request |
|||
* @param \Exception $e |
|||
* @return \Illuminate\Http\Response |
|||
*/ |
|||
public function render($request, Exception $e) |
|||
{ |
|||
return parent::render($request, $e); |
|||
} |
|||
} |
|||
@ -0,0 +1,138 @@ |
|||
<?php |
|||
|
|||
namespace App\Http\Controllers; |
|||
|
|||
use App\Entities\Users\User; |
|||
use App\Http\Controllers\Controller; |
|||
use App\Http\Requests\Accounts\ChangePasswordRequest; |
|||
use App\Http\Requests\Accounts\LoginRequest; |
|||
use App\Http\Requests\Accounts\RegisterRequest; |
|||
use App\Http\Requests\Accounts\UpdateProfileRequest; |
|||
use Auth; |
|||
use Illuminate\Contracts\Auth\Guard; |
|||
use Illuminate\Contracts\Auth\PasswordBroker; |
|||
use Illuminate\Foundation\Auth\ResetsPasswords; |
|||
use Illuminate\Foundation\Auth\ThrottlesLogins; |
|||
use Illuminate\Http\Request; |
|||
|
|||
class AuthController extends Controller { |
|||
|
|||
use ResetsPasswords, ThrottlesLogins; |
|||
|
|||
private $user; |
|||
|
|||
public function __construct(Guard $auth, PasswordBroker $passwords) |
|||
{ |
|||
$this->user = Auth::user(); |
|||
$this->auth = $auth; |
|||
$this->passwords = $passwords; |
|||
|
|||
$this->middleware('guest', ['only' => [ |
|||
'getLogin', 'postLogin', 'getRegister', 'postRegister', |
|||
'getActivate', 'getEmail', 'postEmail', 'getReset', 'postReset' |
|||
] |
|||
]); |
|||
$this->middleware('auth', ['only' => [ |
|||
'getLogout', 'getChangePassword', 'postChangePassword', |
|||
'getProfile', 'patchProfile' |
|||
] |
|||
]); |
|||
} |
|||
|
|||
public function getLogin() |
|||
{ |
|||
return view('auth.login'); |
|||
} |
|||
|
|||
public function postLogin(LoginRequest $req) |
|||
{ |
|||
$loginData = $req->only('username','password'); |
|||
|
|||
if (Auth::attempt($loginData, $req->has('remember'))) |
|||
{ |
|||
|
|||
flash()->success('Selamat datang kembali ' . Auth::user()->name . '.'); |
|||
return redirect()->intended('home'); |
|||
} |
|||
|
|||
flash()->error('Mohon maaf, anda tidak dapat login, cek kembali username/password anda!'); |
|||
return redirect()->back()->withInput(); |
|||
} |
|||
|
|||
public function getLogout() |
|||
{ |
|||
Auth::logout(); |
|||
|
|||
flash()->success('Anda telah logout.'); |
|||
return redirect()->route('auth.login'); |
|||
} |
|||
|
|||
public function getRegister() |
|||
{ |
|||
return view('auth.register'); |
|||
} |
|||
|
|||
public function postRegister(RegisterRequest $req) |
|||
{ |
|||
$registerData = $req->only('name','username','email','password'); |
|||
|
|||
$user = User::create($registerData); |
|||
$user->assignRole('customer'); |
|||
Auth::login($user); |
|||
|
|||
flash()->success('Selamat datang ' . $user->name . '.'); |
|||
return redirect()->route('home'); |
|||
} |
|||
|
|||
public function getActivate($code) |
|||
{ |
|||
|
|||
} |
|||
|
|||
public function getChangePassword() |
|||
{ |
|||
return view('auth.change-password'); |
|||
} |
|||
|
|||
public function postChangePassword(ChangePasswordRequest $req) |
|||
{ |
|||
$input = $req->except('_token'); |
|||
|
|||
if (app('hash')->check($input['old_password'], $this->user->password)) |
|||
{ |
|||
$this->user->password = $input['password']; |
|||
$this->user->save(); |
|||
|
|||
flash()->success('Password berhasil diubah!'); |
|||
return redirect()->back(); |
|||
} |
|||
|
|||
flash()->error('Password lama tidak cocok!'); |
|||
return redirect()->back(); |
|||
} |
|||
|
|||
public function getProfile() |
|||
{ |
|||
$user = Auth::user(); |
|||
return view('auth.profile', compact('user')); |
|||
} |
|||
|
|||
public function patchProfile(UpdateProfileRequest $req) |
|||
{ |
|||
$this->user->name = $req->get('name'); |
|||
$this->user->save(); |
|||
|
|||
flash()->success('Profil berhasil diupdate.'); |
|||
return redirect()->route('auth.profile'); |
|||
} |
|||
|
|||
/** |
|||
* Overrided from Illuminate\Foundation\Auth\ResetsPasswords |
|||
*/ |
|||
protected function resetPassword($user, $password) |
|||
{ |
|||
$user->password = $password; |
|||
$user->save(); |
|||
Auth::login($user); |
|||
} |
|||
} |
|||
@ -0,0 +1,84 @@ |
|||
<?php |
|||
|
|||
namespace App\Http\Controllers; |
|||
|
|||
use App\Http\Requests\Backups\CreateRequest; |
|||
use App\Http\Requests\Backups\BackupUploadRequest; |
|||
use App\Http\Requests\Backups\DeleteRequest; |
|||
use App\Http\Controllers\Controller; |
|||
use App\Entities\Backups\BackupsRepository; |
|||
|
|||
use Illuminate\Http\Request; |
|||
|
|||
class BackupsController extends Controller { |
|||
|
|||
private $repo; |
|||
|
|||
public function __construct(BackupsRepository $repo) |
|||
{ |
|||
$this->repo = $repo; |
|||
} |
|||
|
|||
public function index(Request $req) |
|||
{ |
|||
$backups = $this->repo->getAllFiles(); |
|||
return view('backups.index',compact('backups')); |
|||
} |
|||
|
|||
public function restore($fileName) |
|||
{ |
|||
return view('backups.restore', compact('fileName')); |
|||
} |
|||
|
|||
public function postRestore(Request $req, $fileName) |
|||
{ |
|||
$result = $this->repo->restore($fileName); |
|||
|
|||
if ($result) |
|||
flash()->success('Database berhasil dikembalikan dengan file ' . $fileName); |
|||
|
|||
return redirect()->route('backups.index'); |
|||
} |
|||
|
|||
public function store(CreateRequest $req) |
|||
{ |
|||
$fileName = $this->repo->create($req->except('_token')); |
|||
|
|||
if ($fileName) |
|||
flash()->success('Backup berhasil dilakukan, nama File : ' . $fileName); |
|||
|
|||
return redirect()->route('backups.index'); |
|||
} |
|||
|
|||
public function delete($fileName) |
|||
{ |
|||
return view('backups.delete', compact('fileName')); |
|||
} |
|||
|
|||
public function destroy(Request $req, $fileName) |
|||
{ |
|||
$result = $this->repo->delete($fileName); |
|||
|
|||
if ($result) |
|||
flash()->success('File ' . $fileName . ' berhasil dihapus.'); |
|||
else |
|||
flash()->error('File ' . $fileName . ' gagal dihapus.'); |
|||
|
|||
return redirect()->route('backups.index'); |
|||
} |
|||
|
|||
public function upload(BackupUploadRequest $req) |
|||
{ |
|||
$result = $this->repo->proccessBackupFileUpload($req); |
|||
if ($result) |
|||
flash()->success('Upload file berhasil.'); |
|||
|
|||
return redirect()->route('backups.index'); |
|||
} |
|||
|
|||
public function download($fileName) |
|||
{ |
|||
return response()->download(storage_path('app') . '/backup/db/'.$fileName); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,13 @@ |
|||
<?php |
|||
|
|||
namespace App\Http\Controllers; |
|||
|
|||
use Illuminate\Foundation\Bus\DispatchesJobs; |
|||
use Illuminate\Routing\Controller as BaseController; |
|||
use Illuminate\Foundation\Validation\ValidatesRequests; |
|||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests; |
|||
|
|||
class Controller extends BaseController |
|||
{ |
|||
use AuthorizesRequests, DispatchesJobs, ValidatesRequests; |
|||
} |
|||
@ -0,0 +1,79 @@ |
|||
<?php |
|||
|
|||
namespace App\Http\Controllers; |
|||
|
|||
use App\Http\Requests\Masters\CreateRequest; |
|||
use App\Http\Requests\Masters\UpdateRequest; |
|||
use App\Http\Requests\Masters\DeleteRequest; |
|||
use App\Http\Controllers\Controller; |
|||
use App\Entities\Masters\MastersRepository; |
|||
|
|||
use Illuminate\Http\Request; |
|||
|
|||
class MastersController extends Controller { |
|||
|
|||
private $repo; |
|||
|
|||
public function __construct(MastersRepository $repo) |
|||
{ |
|||
$this->repo = $repo; |
|||
$this->middleware('auth'); |
|||
} |
|||
|
|||
public function index(Request $req) |
|||
{ |
|||
$masters = $this->repo->getAll($req->get('q')); |
|||
return view('masters.index',compact('masters')); |
|||
} |
|||
|
|||
public function create() |
|||
{ |
|||
return view('masters.create'); |
|||
} |
|||
|
|||
public function store(CreateRequest $req) |
|||
{ |
|||
$master = $this->repo->create($req->except('_token')); |
|||
flash()->success(trans('master.created')); |
|||
return redirect()->route('masters.edit', $master->id); |
|||
} |
|||
|
|||
public function show($masterId) |
|||
{ |
|||
$master = $this->repo->requireById($masterId); |
|||
return view('masters.show', compact('master')); |
|||
} |
|||
|
|||
public function edit($masterId) |
|||
{ |
|||
$master = $this->repo->requireById($masterId); |
|||
return view('masters.edit',compact('master')); |
|||
} |
|||
|
|||
public function update(UpdateRequest $req, $masterId) |
|||
{ |
|||
$master = $this->repo->update($req->except(['_method','_token']), $masterId); |
|||
flash()->success(trans('master.updated')); |
|||
return redirect()->route('masters.edit', $masterId); |
|||
} |
|||
|
|||
public function delete($masterId) |
|||
{ |
|||
$master = $this->repo->requireById($masterId); |
|||
return view('masters.delete', compact('master')); |
|||
} |
|||
|
|||
public function destroy(DeleteRequest $req, $masterId) |
|||
{ |
|||
if ($masterId == $req->get('master_id')) |
|||
{ |
|||
$this->repo->delete($masterId); |
|||
flash()->success(trans('master.deleted')); |
|||
} |
|||
else |
|||
flash()->error(trans('master.undeleted')); |
|||
|
|||
return redirect()->route('masters.index'); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,29 @@ |
|||
<?php |
|||
|
|||
namespace App\Http\Controllers; |
|||
|
|||
use App\Entities\Pages\PagesRepository; |
|||
|
|||
class PagesController extends Controller { |
|||
private $repo; |
|||
|
|||
|
|||
public function __construct(PagesRepository $repo) |
|||
{ |
|||
$this->repo = $repo; |
|||
} |
|||
|
|||
public function home() |
|||
{ |
|||
$totalIncome = $this->repo->getTotalIncome(); |
|||
$totalExpenditure = $this->repo->getTotalExpenditure(); |
|||
|
|||
return view('pages.home', compact('totalIncome','totalExpenditure')); |
|||
} |
|||
|
|||
public function about() |
|||
{ |
|||
return view('pages.about'); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,79 @@ |
|||
<?php |
|||
|
|||
namespace App\Http\Controllers; |
|||
|
|||
use App\Http\Requests\Payments\CreateRequest; |
|||
use App\Http\Requests\Payments\UpdateRequest; |
|||
use App\Http\Requests\Payments\DeleteRequest; |
|||
use App\Http\Controllers\Controller; |
|||
use App\Entities\Payments\PaymentsRepository; |
|||
|
|||
use Illuminate\Http\Request; |
|||
|
|||
class PaymentsController extends Controller { |
|||
|
|||
private $repo; |
|||
|
|||
public function __construct(PaymentsRepository $repo) |
|||
{ |
|||
$this->repo = $repo; |
|||
} |
|||
|
|||
public function index(Request $req) |
|||
{ |
|||
$payments = $this->repo->getAll($req->get('q')); |
|||
return view('payments.index',compact('payments')); |
|||
} |
|||
|
|||
public function create() |
|||
{ |
|||
return view('payments.create'); |
|||
} |
|||
|
|||
public function store(CreateRequest $req) |
|||
{ |
|||
$payment = $this->repo->create($req->except('_token')); |
|||
flash()->success(trans('payment.created')); |
|||
return redirect()->route('payments.edit', $payment->id); |
|||
} |
|||
|
|||
public function show($paymentId) |
|||
{ |
|||
$payment = $this->repo->requireById($paymentId); |
|||
return view('payments.show', compact('payment')); |
|||
} |
|||
|
|||
public function edit($paymentId) |
|||
{ |
|||
$payment = $this->repo->requireById($paymentId); |
|||
$customers = $this->repo->getCustomersList(); |
|||
return view('payments.edit',compact('payment','customers')); |
|||
} |
|||
|
|||
public function update(UpdateRequest $req, $paymentId) |
|||
{ |
|||
$payment = $this->repo->update($req->except(['_method','_token']), $paymentId); |
|||
flash()->success(trans('payment.updated')); |
|||
return redirect()->route('payments.edit', $paymentId); |
|||
} |
|||
|
|||
public function delete($paymentId) |
|||
{ |
|||
$payment = $this->repo->requireById($paymentId); |
|||
return view('payments.delete', compact('payment')); |
|||
} |
|||
|
|||
public function destroy(DeleteRequest $req, $paymentId) |
|||
{ |
|||
if ($paymentId == $req->get('payment_id')) |
|||
{ |
|||
$this->repo->delete($paymentId); |
|||
flash()->success(trans('payment.deleted')); |
|||
} |
|||
else |
|||
flash()->error(trans('payment.undeleted')); |
|||
|
|||
return redirect()->route('payments.index'); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,80 @@ |
|||
<?php |
|||
|
|||
namespace App\Http\Controllers\Projects; |
|||
|
|||
use App\Http\Requests\Features\CreateRequest; |
|||
use App\Http\Requests\Features\UpdateRequest; |
|||
use App\Http\Requests\Features\DeleteRequest; |
|||
use App\Http\Controllers\Controller; |
|||
use App\Entities\Projects\FeaturesRepository; |
|||
|
|||
use Illuminate\Http\Request; |
|||
|
|||
class FeaturesController extends Controller { |
|||
|
|||
private $repo; |
|||
|
|||
public function __construct(FeaturesRepository $repo) |
|||
{ |
|||
$this->repo = $repo; |
|||
} |
|||
|
|||
public function create($projectId) |
|||
{ |
|||
$project = $this->repo->requireProjectById($projectId); |
|||
$workers = $this->repo->getWorkersList(); |
|||
return view('features.create',compact('project','workers')); |
|||
} |
|||
|
|||
public function store(CreateRequest $req) |
|||
{ |
|||
$feature = $this->repo->create($req->except('_token')); |
|||
flash()->success(trans('feature.created')); |
|||
return redirect()->route('features.show', $feature->id); |
|||
} |
|||
|
|||
public function show($featureId) |
|||
{ |
|||
$feature = $this->repo->requireById($featureId); |
|||
return view('features.show', compact('feature')); |
|||
} |
|||
|
|||
public function edit($featureId) |
|||
{ |
|||
$feature = $this->repo->requireById($featureId); |
|||
return view('features.edit',compact('feature')); |
|||
} |
|||
|
|||
public function update(UpdateRequest $req, $featureId) |
|||
{ |
|||
$feature = $this->repo->update($req->except(['_method','_token']), $featureId); |
|||
flash()->success(trans('feature.updated')); |
|||
return redirect()->route('features.edit', $featureId); |
|||
} |
|||
|
|||
public function delete($featureId) |
|||
{ |
|||
$feature = $this->repo->requireById($featureId); |
|||
return view('features.delete', compact('feature')); |
|||
} |
|||
|
|||
public function destroy(DeleteRequest $req, $featureId) |
|||
{ |
|||
if ($featureId == $req->get('feature_id')) |
|||
{ |
|||
$this->repo->delete($featureId); |
|||
flash()->success(trans('feature.deleted')); |
|||
} |
|||
else |
|||
flash()->error(trans('feature.undeleted')); |
|||
|
|||
return redirect()->route('features.index'); |
|||
} |
|||
|
|||
public function tasks($featureId) |
|||
{ |
|||
$feature = $this->repo->requireById($featureId); |
|||
return view('features.features', compact('feature')); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,99 @@ |
|||
<?php |
|||
|
|||
namespace App\Http\Controllers\Projects; |
|||
|
|||
use App\Http\Requests\Projects\CreateRequest; |
|||
use App\Http\Requests\Projects\UpdateRequest; |
|||
use App\Http\Requests\Projects\DeleteRequest; |
|||
use App\Http\Controllers\Controller; |
|||
use App\Entities\Projects\ProjectsRepository; |
|||
|
|||
use Illuminate\Http\Request; |
|||
|
|||
class ProjectsController extends Controller { |
|||
|
|||
private $repo; |
|||
|
|||
public function __construct(ProjectsRepository $repo) |
|||
{ |
|||
$this->repo = $repo; |
|||
} |
|||
|
|||
public function index(Request $req) |
|||
{ |
|||
$status = null; |
|||
$statusId = $req->get('status'); |
|||
if ($statusId) { |
|||
$status = $this->repo->getStatusName($statusId); |
|||
} |
|||
|
|||
$projects = $this->repo->getProjects($req->get('q'), $statusId); |
|||
return view('projects.index',compact('projects','status')); |
|||
} |
|||
|
|||
public function create() |
|||
{ |
|||
$customers = $this->repo->getCustomersList(); |
|||
return view('projects.create', compact('customers')); |
|||
} |
|||
|
|||
public function store(CreateRequest $req) |
|||
{ |
|||
$project = $this->repo->create($req->except('_token')); |
|||
flash()->success(trans('project.created')); |
|||
return redirect()->route('projects.index'); |
|||
} |
|||
|
|||
public function show($projectId) |
|||
{ |
|||
$project = $this->repo->requireById($projectId); |
|||
return view('projects.show', compact('project')); |
|||
} |
|||
|
|||
public function edit($projectId) |
|||
{ |
|||
$project = $this->repo->requireById($projectId); |
|||
$statuses = getProjectStatusesList(); |
|||
$customers = $this->repo->getCustomersList(); |
|||
return view('projects.edit',compact('project','statuses','customers')); |
|||
} |
|||
|
|||
public function update(UpdateRequest $req, $projectId) |
|||
{ |
|||
$project = $this->repo->update($req->except(['_method','_token']), $projectId); |
|||
flash()->success(trans('project.updated')); |
|||
return redirect()->route('projects.edit', $projectId); |
|||
} |
|||
|
|||
public function delete($projectId) |
|||
{ |
|||
$project = $this->repo->requireById($projectId); |
|||
return view('projects.delete', compact('project')); |
|||
} |
|||
|
|||
public function destroy(DeleteRequest $req, $projectId) |
|||
{ |
|||
if ($projectId == $req->get('project_id')) |
|||
{ |
|||
$this->repo->delete($projectId); |
|||
flash()->success(trans('project.deleted')); |
|||
} |
|||
else |
|||
flash()->error(trans('project.undeleted')); |
|||
|
|||
return redirect()->route('projects.index'); |
|||
} |
|||
|
|||
public function features($projectId) |
|||
{ |
|||
$project = $this->repo->requireById($projectId); |
|||
return view('projects.features', compact('project')); |
|||
} |
|||
|
|||
public function payments($projectId) |
|||
{ |
|||
$project = $this->repo->requireById($projectId); |
|||
return view('projects.payments', compact('project')); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,65 @@ |
|||
<?php |
|||
|
|||
namespace App\Http\Controllers\References; |
|||
|
|||
use App\Http\Requests\Options\CreateRequest; |
|||
use App\Http\Requests\Options\DeleteRequest; |
|||
use App\Http\Controllers\Controller; |
|||
use App\Entities\Options\OptionsRepository; |
|||
|
|||
use Illuminate\Http\Request; |
|||
|
|||
class OptionsController extends Controller { |
|||
|
|||
private $repo; |
|||
|
|||
public function __construct(OptionsRepository $repo) |
|||
{ |
|||
$this->repo = $repo; |
|||
} |
|||
|
|||
public function index(Request $req) |
|||
{ |
|||
$options = $this->repo->getAll(); |
|||
return view('options.index',compact('options')); |
|||
} |
|||
|
|||
public function create() |
|||
{ |
|||
return view('options.create'); |
|||
} |
|||
|
|||
public function store(CreateRequest $req) |
|||
{ |
|||
$option = $this->repo->create($req->except('_token')); |
|||
flash()->success(trans('option.created')); |
|||
return redirect()->route('options.index'); |
|||
} |
|||
|
|||
public function delete($optionId) |
|||
{ |
|||
$option = $this->repo->requireById($optionId); |
|||
return view('options.delete', compact('option')); |
|||
} |
|||
|
|||
public function destroy(Request $req, $optionId) |
|||
{ |
|||
if ($optionId == $req->get('option_id')) |
|||
{ |
|||
$this->repo->delete($optionId); |
|||
flash()->success(trans('option.deleted')); |
|||
} |
|||
else |
|||
flash()->error(trans('option.undeleted')); |
|||
|
|||
return redirect()->route('options.index'); |
|||
} |
|||
|
|||
public function save(Request $req) |
|||
{ |
|||
$this->repo->save($req->except(['_method','_token'])); |
|||
flash()->success(trans('option.updated')); |
|||
return redirect()->route('options.index'); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,66 @@ |
|||
<?php |
|||
|
|||
namespace App\Http\Controllers\Users; |
|||
|
|||
use App\Entities\Users\Permission; |
|||
use App\Http\Controllers\Controller; |
|||
use App\Http\Requests\Users\Permissions\CreateRequest; |
|||
use App\Http\Requests\Users\Permissions\DeleteRequest; |
|||
use App\Http\Requests\Users\Permissions\UpdateRequest; |
|||
use Illuminate\Http\Request; |
|||
|
|||
class PermissionsController extends Controller { |
|||
|
|||
public function index(Request $req) |
|||
{ |
|||
$permission = null; |
|||
if ($req->has('act') && in_array($req->get('act'), ['show','edit','del'])) { |
|||
$permission = $this->requireById($req->get('id')); |
|||
} |
|||
|
|||
$permissions = Permission::whereType(1)->withCount('roles')->get(); |
|||
return view('users.permissions',compact('permissions','permission')); |
|||
} |
|||
|
|||
public function store(CreateRequest $req) |
|||
{ |
|||
$permissionData = $req->except('_token'); |
|||
$permissionData['type'] = 1; // Permission Type
|
|||
$permission = Permission::create($permissionData); |
|||
flash()->success(trans('permission.created')); |
|||
return redirect()->route('permissions.index'); |
|||
} |
|||
|
|||
public function update(UpdateRequest $req, $permissionId) |
|||
{ |
|||
$permission = $this->requireById($permissionId); |
|||
$permission->update($req->except(['_method','_token'])); |
|||
flash()->success(trans('permission.updated')); |
|||
return redirect()->back(); |
|||
} |
|||
|
|||
public function delete($permissionId) |
|||
{ |
|||
$permission = $this->requireById($permissionId); |
|||
return view('permissions.delete', compact('permission')); |
|||
} |
|||
|
|||
public function destroy(DeleteRequest $req, $permissionId) |
|||
{ |
|||
if ($permissionId == $req->get('permission_id')) |
|||
{ |
|||
$this->requireById($permissionId)->delete(); |
|||
flash()->success(trans('permission.deleted')); |
|||
} |
|||
else |
|||
flash()->error(trans('permission.undeleted')); |
|||
|
|||
return redirect()->route('permissions.index'); |
|||
} |
|||
|
|||
private function requireById($permissionId) |
|||
{ |
|||
return Permission::findOrFail($permissionId); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,85 @@ |
|||
<?php |
|||
|
|||
namespace App\Http\Controllers\Users; |
|||
|
|||
use App\Entities\Users\Permission; |
|||
use App\Entities\Users\Role; |
|||
use App\Http\Controllers\Controller; |
|||
use App\Http\Requests\Users\Roles\CreateRequest; |
|||
use App\Http\Requests\Users\Roles\DeleteRequest; |
|||
use App\Http\Requests\Users\Roles\UpdateRequest; |
|||
use Illuminate\Http\Request; |
|||
|
|||
class RolesController extends Controller { |
|||
|
|||
public function index(Request $req) |
|||
{ |
|||
// $role = null;
|
|||
if ($req->has('act') && in_array($req->get('act'), ['show','edit','del'])) { |
|||
$role = $this->requireById($req->get('id')); |
|||
if ($req->get('act') == 'show') { |
|||
$permissions = $this->getAllPermissions(); |
|||
} |
|||
} |
|||
|
|||
$roles = Role::whereType(0)->get(); |
|||
return view('users.roles',compact('roles','role','permissions')); |
|||
} |
|||
|
|||
public function store(CreateRequest $req) |
|||
{ |
|||
$roleData = $req->except('_token'); |
|||
$roleData['type'] = 0; // Role Type
|
|||
$role = Role::create($roleData); |
|||
flash()->success(trans('role.created')); |
|||
return redirect()->route('roles.index'); |
|||
} |
|||
|
|||
public function update(UpdateRequest $req, $roleId) |
|||
{ |
|||
$role = $this->requireById($roleId); |
|||
$role->update($req->except(['_method','_token'])); |
|||
flash()->success(trans('role.updated')); |
|||
return redirect()->back(); |
|||
} |
|||
|
|||
public function destroy(DeleteRequest $req, $roleId) |
|||
{ |
|||
if ($roleId == $req->get('role_id')) |
|||
{ |
|||
$role = $this->requireById($roleId); |
|||
$role->permissions()->detach(); |
|||
$role->delete(); |
|||
|
|||
flash()->success(trans('role.deleted')); |
|||
} |
|||
else |
|||
flash()->error(trans('role.undeleted')); |
|||
|
|||
return redirect()->route('roles.index'); |
|||
} |
|||
|
|||
public function updatePermissions(Request $req, $roleId) |
|||
{ |
|||
$role = $this->requireById($roleId); |
|||
if ($req->has('permission')) |
|||
$role->permissions()->sync($req->get('permission')); |
|||
else |
|||
$role->permissions()->detach(); |
|||
|
|||
flash()->success(trans('role.updated')); |
|||
return redirect()->back(); |
|||
} |
|||
|
|||
private function requireById($roleId) |
|||
{ |
|||
return Role::findOrFail($roleId); |
|||
} |
|||
|
|||
private function getAllPermissions() |
|||
{ |
|||
return Permission::whereType(1)->get(); |
|||
} |
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,82 @@ |
|||
<?php |
|||
|
|||
namespace App\Http\Controllers\Users; |
|||
|
|||
use App\Http\Requests\Users\CreateRequest; |
|||
use App\Http\Requests\Users\UpdateRequest; |
|||
use App\Http\Requests\Users\DeleteRequest; |
|||
use App\Http\Controllers\Controller; |
|||
use App\Entities\Users\UsersRepository; |
|||
|
|||
use Illuminate\Http\Request; |
|||
|
|||
class UsersController extends Controller { |
|||
|
|||
private $repo; |
|||
|
|||
public function __construct(UsersRepository $repo) |
|||
{ |
|||
$this->repo = $repo; |
|||
} |
|||
|
|||
public function index(Request $req) |
|||
{ |
|||
$users = $this->repo->getUsers($req->get('q'), $req->get('role')); |
|||
return view('users.index',compact('users')); |
|||
} |
|||
|
|||
public function create() |
|||
{ |
|||
$roles = $this->repo->getRolesList(); |
|||
return view('users.create', compact('roles')); |
|||
} |
|||
|
|||
public function store(CreateRequest $req) |
|||
{ |
|||
$userData = $req->except(['_token','password_confirmation']); |
|||
$user = $this->repo->create($userData); |
|||
flash()->success(trans('user.created')); |
|||
return redirect()->route('users.index'); |
|||
} |
|||
|
|||
public function show($userId) |
|||
{ |
|||
$user = $this->repo->requireById($userId); |
|||
return view('users.show', compact('user')); |
|||
} |
|||
|
|||
public function edit($userId) |
|||
{ |
|||
$user = $this->repo->requireById($userId); |
|||
|
|||
$roles = $this->repo->getRolesList(); |
|||
return view('users.edit',compact('user','roles')); |
|||
} |
|||
|
|||
public function update(UpdateRequest $req, $userId) |
|||
{ |
|||
$userData = $req->except(['_method','_token','password_confirmation']); |
|||
$user = $this->repo->update($userData, $userId); |
|||
flash()->success(trans('user.updated')); |
|||
return redirect()->route('users.edit', $userId); |
|||
} |
|||
|
|||
public function delete($userId) |
|||
{ |
|||
$user = $this->repo->requireById($userId); |
|||
return view('users.delete', compact('user')); |
|||
} |
|||
|
|||
public function destroy(DeleteRequest $req, $userId) |
|||
{ |
|||
if ($userId == $req->get('user_id')) { |
|||
$this->repo->delete($userId); |
|||
flash()->success(trans('user.deleted')); |
|||
} else { |
|||
flash()->error(trans('user.undeleted')); |
|||
} |
|||
|
|||
return redirect()->route('users.index'); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,54 @@ |
|||
<?php |
|||
|
|||
namespace App\Http; |
|||
|
|||
use Illuminate\Foundation\Http\Kernel as HttpKernel; |
|||
|
|||
class Kernel extends HttpKernel |
|||
{ |
|||
/** |
|||
* The application's global HTTP middleware stack. |
|||
* |
|||
* These middleware are run during every request to your application. |
|||
* |
|||
* @var array |
|||
*/ |
|||
protected $middleware = [ |
|||
\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class, |
|||
]; |
|||
|
|||
/** |
|||
* The application's route middleware groups. |
|||
* |
|||
* @var array |
|||
*/ |
|||
protected $middlewareGroups = [ |
|||
'web' => [ |
|||
\App\Http\Middleware\EncryptCookies::class, |
|||
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, |
|||
\Illuminate\Session\Middleware\StartSession::class, |
|||
\Illuminate\View\Middleware\ShareErrorsFromSession::class, |
|||
\App\Http\Middleware\VerifyCsrfToken::class, |
|||
], |
|||
|
|||
'api' => [ |
|||
'throttle:60,1', |
|||
], |
|||
]; |
|||
|
|||
/** |
|||
* The application's route middleware. |
|||
* |
|||
* These middleware may be assigned to groups or used individually. |
|||
* |
|||
* @var array |
|||
*/ |
|||
protected $routeMiddleware = [ |
|||
'auth' => \App\Http\Middleware\Authenticate::class, |
|||
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, |
|||
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, |
|||
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, |
|||
|
|||
'role' => \App\Http\Middleware\RoleMiddleware::class, |
|||
]; |
|||
} |
|||
@ -0,0 +1,30 @@ |
|||
<?php |
|||
|
|||
namespace App\Http\Middleware; |
|||
|
|||
use Closure; |
|||
use Illuminate\Support\Facades\Auth; |
|||
|
|||
class Authenticate |
|||
{ |
|||
/** |
|||
* Handle an incoming request. |
|||
* |
|||
* @param \Illuminate\Http\Request $request |
|||
* @param \Closure $next |
|||
* @param string|null $guard |
|||
* @return mixed |
|||
*/ |
|||
public function handle($request, Closure $next, $guard = null) |
|||
{ |
|||
if (Auth::guard($guard)->guest()) { |
|||
if ($request->ajax() || $request->wantsJson()) { |
|||
return response('Unauthorized.', 401); |
|||
} else { |
|||
return redirect()->guest('auth/login'); |
|||
} |
|||
} |
|||
|
|||
return $next($request); |
|||
} |
|||
} |
|||
@ -0,0 +1,17 @@ |
|||
<?php |
|||
|
|||
namespace App\Http\Middleware; |
|||
|
|||
use Illuminate\Cookie\Middleware\EncryptCookies as BaseEncrypter; |
|||
|
|||
class EncryptCookies extends BaseEncrypter |
|||
{ |
|||
/** |
|||
* The names of the cookies that should not be encrypted. |
|||
* |
|||
* @var array |
|||
*/ |
|||
protected $except = [ |
|||
//
|
|||
]; |
|||
} |
|||
@ -0,0 +1,26 @@ |
|||
<?php |
|||
|
|||
namespace App\Http\Middleware; |
|||
|
|||
use Closure; |
|||
use Illuminate\Support\Facades\Auth; |
|||
|
|||
class RedirectIfAuthenticated |
|||
{ |
|||
/** |
|||
* Handle an incoming request. |
|||
* |
|||
* @param \Illuminate\Http\Request $request |
|||
* @param \Closure $next |
|||
* @param string|null $guard |
|||
* @return mixed |
|||
*/ |
|||
public function handle($request, Closure $next, $guard = null) |
|||
{ |
|||
if (Auth::guard($guard)->check()) { |
|||
return redirect('/'); |
|||
} |
|||
|
|||
return $next($request); |
|||
} |
|||
} |
|||
@ -0,0 +1,33 @@ |
|||
<?php |
|||
|
|||
namespace App\Http\Middleware; |
|||
|
|||
use Closure; |
|||
|
|||
class RoleMiddleware |
|||
{ |
|||
/** |
|||
* Handle an incoming request. |
|||
* |
|||
* @param \Illuminate\Http\Request $request |
|||
* @param \Closure $next |
|||
* @return mixed |
|||
*/ |
|||
public function handle($request, Closure $next, $names) |
|||
{ |
|||
$nameArray = explode('|', $names); |
|||
|
|||
if (auth()->check() == false) { |
|||
return redirect()->guest('auth/login'); |
|||
} |
|||
|
|||
// Cek apakah grup user ada di dalam array $nameArray?
|
|||
if (auth()->user()->hasRoles($nameArray) == false) |
|||
{ |
|||
flash()->error('Anda tidak dapat mengakses halaman ' . $request->path() . '.'); |
|||
return redirect()->route('home'); |
|||
} |
|||
|
|||
return $next($request); |
|||
} |
|||
} |
|||
@ -0,0 +1,17 @@ |
|||
<?php |
|||
|
|||
namespace App\Http\Middleware; |
|||
|
|||
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as BaseVerifier; |
|||
|
|||
class VerifyCsrfToken extends BaseVerifier |
|||
{ |
|||
/** |
|||
* The URIs that should be excluded from CSRF verification. |
|||
* |
|||
* @var array |
|||
*/ |
|||
protected $except = [ |
|||
//
|
|||
]; |
|||
} |
|||
@ -0,0 +1,43 @@ |
|||
<?php |
|||
|
|||
namespace App\Http\Requests\Accounts; |
|||
|
|||
use App\Http\Requests\Request; |
|||
|
|||
class ChangePasswordRequest extends Request |
|||
{ |
|||
/** |
|||
* Determine if the user is authorized to make this request. |
|||
* |
|||
* @return bool |
|||
*/ |
|||
public function authorize() |
|||
{ |
|||
return auth()->check(); |
|||
} |
|||
|
|||
/** |
|||
* Get the validation rules that apply to the request. |
|||
* |
|||
* @return array |
|||
*/ |
|||
public function rules() |
|||
{ |
|||
return [ |
|||
'old_password' => 'required', |
|||
'password' => 'required|between:6,15|confirmed', |
|||
'password_confirmation' => 'required', |
|||
]; |
|||
} |
|||
|
|||
public function messages() |
|||
{ |
|||
return [ |
|||
'old_password.required' => 'Password lama harus diisi.', |
|||
'password.required' => 'Password baru harus diisi.', |
|||
'password.between' => 'Password baru harus antara 6 - 15 karakter.', |
|||
'password.confirmed' => 'Konfirmasi password baru tidak sesuai.', |
|||
'password_confirmation.required' => 'Konfirmasi password baru harus diisi.', |
|||
]; |
|||
} |
|||
} |
|||
@ -0,0 +1,39 @@ |
|||
<?php |
|||
|
|||
namespace App\Http\Requests\Accounts; |
|||
|
|||
use App\Http\Requests\Request; |
|||
|
|||
class LoginRequest extends Request |
|||
{ |
|||
/** |
|||
* Determine if the user is authorized to make this request. |
|||
* |
|||
* @return bool |
|||
*/ |
|||
public function authorize() |
|||
{ |
|||
return auth()->guest(); |
|||
} |
|||
|
|||
/** |
|||
* Get the validation rules that apply to the request. |
|||
* |
|||
* @return array |
|||
*/ |
|||
public function rules() |
|||
{ |
|||
return [ |
|||
'username' => 'required', |
|||
'password' => 'required', |
|||
]; |
|||
} |
|||
|
|||
public function messages() |
|||
{ |
|||
return [ |
|||
'username.required' => 'Username harus diisi.', |
|||
'password.required' => 'Password harus diisi.', |
|||
]; |
|||
} |
|||
} |
|||
@ -0,0 +1,50 @@ |
|||
<?php |
|||
|
|||
namespace App\Http\Requests\Accounts; |
|||
|
|||
use App\Http\Requests\Request; |
|||
|
|||
class RegisterRequest extends Request |
|||
{ |
|||
/** |
|||
* Determine if the user is authorized to make this request. |
|||
* |
|||
* @return bool |
|||
*/ |
|||
public function authorize() |
|||
{ |
|||
return auth()->guest(); |
|||
} |
|||
|
|||
/** |
|||
* Get the validation rules that apply to the request. |
|||
* |
|||
* @return array |
|||
*/ |
|||
public function rules() |
|||
{ |
|||
return [ |
|||
'name' => 'required', |
|||
'username' => 'required|alpha_num', |
|||
'email' => 'required|email|unique:users,email', |
|||
'password' => 'required|between:6,15|confirmed', |
|||
'password_confirmation' => 'required', |
|||
]; |
|||
} |
|||
|
|||
public function messages() |
|||
{ |
|||
return [ |
|||
'name.required' => 'Nama harus diisi.', |
|||
'username.required' => 'Username harus diisi.', |
|||
'username.alpha_num' => 'Username harus berupa huruf dan angka.', |
|||
'email.required' => 'Email harus diisi.', |
|||
'email.email' => 'Email tidak valid.', |
|||
'email.unique' => 'Email ini sudah terdaftar.', |
|||
'password.required' => 'Password harus diisi.', |
|||
'password.between' => 'Password baru harus antara 6 - 15 karakter.', |
|||
'password.confirmed' => 'Konfirmasi password tidak sesuai.', |
|||
'password_confirmation.required' => 'Konfirmasi password harus diisi.', |
|||
]; |
|||
} |
|||
} |
|||
@ -0,0 +1,38 @@ |
|||
<?php |
|||
|
|||
namespace App\Http\Requests\Accounts; |
|||
|
|||
use App\Http\Requests\Request; |
|||
|
|||
class UpdateProfileRequest extends Request |
|||
{ |
|||
/** |
|||
* Determine if the user is authorized to make this request. |
|||
* |
|||
* @return bool |
|||
*/ |
|||
public function authorize() |
|||
{ |
|||
return auth()->check(); |
|||
} |
|||
|
|||
/** |
|||
* Get the validation rules that apply to the request. |
|||
* |
|||
* @return array |
|||
*/ |
|||
public function rules() |
|||
{ |
|||
return [ |
|||
'name' => 'required|max:60' |
|||
]; |
|||
} |
|||
|
|||
public function messages() |
|||
{ |
|||
return [ |
|||
'name.required' => 'Nama harus diisi.', |
|||
'name.max' => 'Nama maksimal 60 karakter.', |
|||
]; |
|||
} |
|||
} |
|||
@ -0,0 +1,52 @@ |
|||
<?php |
|||
|
|||
namespace App\Http\Requests\Backups; |
|||
|
|||
use App\Http\Requests\Request; |
|||
|
|||
class BackupUploadRequest extends Request { |
|||
|
|||
/** |
|||
* Determine if the user is authorized to make this request. |
|||
* |
|||
* @return bool |
|||
*/ |
|||
public function authorize() |
|||
{ |
|||
return auth()->user()->can('manage_backups'); |
|||
} |
|||
|
|||
/** |
|||
* Get the validation rules that apply to the request. |
|||
* |
|||
* @return array |
|||
*/ |
|||
public function rules() |
|||
{ |
|||
return [ |
|||
'backup_file' => 'required|sql_zip' |
|||
]; |
|||
} |
|||
|
|||
public function messages() |
|||
{ |
|||
return [ |
|||
'file.sql_zip' => 'Isian file harus dokumen berjenis .zip, .gz atau .sql', |
|||
]; |
|||
} |
|||
|
|||
protected function getValidatorInstance() |
|||
{ |
|||
$validator = parent::getValidatorInstance(); |
|||
|
|||
$validator->addImplicitExtension('sql_zip', function($attribute, $value, $parameters) { |
|||
if ($value) |
|||
return in_array($value->getClientOriginalExtension(), ['zip','gz','sql']); |
|||
|
|||
return false; |
|||
}); |
|||
|
|||
return $validator; |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,31 @@ |
|||
<?php |
|||
|
|||
namespace App\Http\Requests\Backups; |
|||
|
|||
use App\Http\Requests\Request; |
|||
|
|||
class CreateRequest extends Request { |
|||
|
|||
/** |
|||
* Determine if the user is authorized to make this request. |
|||
* |
|||
* @return bool |
|||
*/ |
|||
public function authorize() |
|||
{ |
|||
return auth()->user()->can('manage_backups'); |
|||
} |
|||
|
|||
/** |
|||
* Get the validation rules that apply to the request. |
|||
* |
|||
* @return array |
|||
*/ |
|||
public function rules() |
|||
{ |
|||
return [ |
|||
'file_name' => 'max:20|alpha_dash', |
|||
]; |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,31 @@ |
|||
<?php |
|||
|
|||
namespace App\Http\Requests\Backups; |
|||
|
|||
use App\Http\Requests\Request; |
|||
|
|||
class DeleteRequest extends Request { |
|||
|
|||
/** |
|||
* Determine if the user is authorized to make this request. |
|||
* |
|||
* @return bool |
|||
*/ |
|||
public function authorize() |
|||
{ |
|||
return auth()->user()->can('manage_backups'); |
|||
} |
|||
|
|||
/** |
|||
* Get the validation rules that apply to the request. |
|||
* |
|||
* @return array |
|||
*/ |
|||
public function rules() |
|||
{ |
|||
return [ |
|||
'file_name' => 'required' |
|||
]; |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,32 @@ |
|||
<?php |
|||
|
|||
namespace App\Http\Requests\Masters; |
|||
|
|||
use App\Http\Requests\Request; |
|||
|
|||
class CreateRequest extends Request { |
|||
|
|||
/** |
|||
* Determine if the user is authorized to make this request. |
|||
* |
|||
* @return bool |
|||
*/ |
|||
public function authorize() |
|||
{ |
|||
return auth()->user()->can('manage_masters'); |
|||
} |
|||
|
|||
/** |
|||
* Get the validation rules that apply to the request. |
|||
* |
|||
* @return array |
|||
*/ |
|||
public function rules() |
|||
{ |
|||
return [ |
|||
'name' => 'required|max:60|unique:masters,name', |
|||
'description' => 'max:255' |
|||
]; |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,31 @@ |
|||
<?php |
|||
|
|||
namespace App\Http\Requests\Masters; |
|||
|
|||
use App\Http\Requests\Request; |
|||
|
|||
class DeleteRequest extends Request { |
|||
|
|||
/** |
|||
* Determine if the user is authorized to make this request. |
|||
* |
|||
* @return bool |
|||
*/ |
|||
public function authorize() |
|||
{ |
|||
return auth()->user()->can('manage_masters'); |
|||
} |
|||
|
|||
/** |
|||
* Get the validation rules that apply to the request. |
|||
* |
|||
* @return array |
|||
*/ |
|||
public function rules() |
|||
{ |
|||
return [ |
|||
'master_id' => 'required' |
|||
]; |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,32 @@ |
|||
<?php |
|||
|
|||
namespace App\Http\Requests\Masters; |
|||
|
|||
use App\Http\Requests\Request; |
|||
|
|||
class UpdateRequest extends Request { |
|||
|
|||
/** |
|||
* Determine if the user is authorized to make this request. |
|||
* |
|||
* @return bool |
|||
*/ |
|||
public function authorize() |
|||
{ |
|||
return auth()->user()->can('manage_masters'); |
|||
} |
|||
|
|||
/** |
|||
* Get the validation rules that apply to the request. |
|||
* |
|||
* @return array |
|||
*/ |
|||
public function rules() |
|||
{ |
|||
return [ |
|||
'name' => 'required|max:60|unique:masters,name,' . $this->segment(2), |
|||
'description' => 'max:255' |
|||
]; |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,31 @@ |
|||
<?php |
|||
|
|||
namespace App\Http\Requests\Options; |
|||
|
|||
use App\Http\Requests\Request; |
|||
|
|||
class CreateRequest extends Request |
|||
{ |
|||
/** |
|||
* Determine if the user is authorized to make this request. |
|||
* |
|||
* @return bool |
|||
*/ |
|||
public function authorize() |
|||
{ |
|||
return auth()->user()->can('manage_options'); |
|||
} |
|||
|
|||
/** |
|||
* Get the validation rules that apply to the request. |
|||
* |
|||
* @return array |
|||
*/ |
|||
public function rules() |
|||
{ |
|||
return [ |
|||
'key' => 'required|max:255|alpha_dash', |
|||
'value' => 'max:255', |
|||
]; |
|||
} |
|||
} |
|||
@ -0,0 +1,32 @@ |
|||
<?php |
|||
|
|||
namespace App\Http\Requests\Masters; |
|||
|
|||
use App\Http\Requests\Request; |
|||
|
|||
class CreateRequest extends Request { |
|||
|
|||
/** |
|||
* Determine if the user is authorized to make this request. |
|||
* |
|||
* @return bool |
|||
*/ |
|||
public function authorize() |
|||
{ |
|||
return auth()->user()->can('manage_masters'); |
|||
} |
|||
|
|||
/** |
|||
* Get the validation rules that apply to the request. |
|||
* |
|||
* @return array |
|||
*/ |
|||
public function rules() |
|||
{ |
|||
return [ |
|||
'name' => 'required|max:60|unique:masters,name', |
|||
'description' => 'max:255' |
|||
]; |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,31 @@ |
|||
<?php |
|||
|
|||
namespace App\Http\Requests\Masters; |
|||
|
|||
use App\Http\Requests\Request; |
|||
|
|||
class DeleteRequest extends Request { |
|||
|
|||
/** |
|||
* Determine if the user is authorized to make this request. |
|||
* |
|||
* @return bool |
|||
*/ |
|||
public function authorize() |
|||
{ |
|||
return auth()->user()->can('manage_masters'); |
|||
} |
|||
|
|||
/** |
|||
* Get the validation rules that apply to the request. |
|||
* |
|||
* @return array |
|||
*/ |
|||
public function rules() |
|||
{ |
|||
return [ |
|||
'master_id' => 'required' |
|||
]; |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,35 @@ |
|||
<?php |
|||
|
|||
namespace App\Http\Requests\Payments; |
|||
|
|||
use App\Http\Requests\Request; |
|||
|
|||
class UpdateRequest extends Request { |
|||
|
|||
/** |
|||
* Determine if the user is authorized to make this request. |
|||
* |
|||
* @return bool |
|||
*/ |
|||
public function authorize() |
|||
{ |
|||
return auth()->user()->can('manage_payments'); |
|||
} |
|||
|
|||
/** |
|||
* Get the validation rules that apply to the request. |
|||
* |
|||
* @return array |
|||
*/ |
|||
public function rules() |
|||
{ |
|||
return [ |
|||
'type' => 'required|numeric', |
|||
'amount' => 'required|numeric', |
|||
'date' => 'required|date|date_format:Y-m-d', |
|||
'customer_id' => 'required|numeric', |
|||
'description' => 'required|max:255' |
|||
]; |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,45 @@ |
|||
<?php |
|||
|
|||
namespace App\Http\Requests\Projects; |
|||
|
|||
use App\Http\Requests\Request; |
|||
|
|||
class CreateRequest extends Request { |
|||
|
|||
/** |
|||
* Determine if the user is authorized to make this request. |
|||
* |
|||
* @return bool |
|||
*/ |
|||
public function authorize() |
|||
{ |
|||
return auth()->user()->can('manage_projects'); |
|||
} |
|||
|
|||
/** |
|||
* Get the validation rules that apply to the request. |
|||
* |
|||
* @return array |
|||
*/ |
|||
public function rules() |
|||
{ |
|||
return [ |
|||
'name' => 'required|max:50', |
|||
'proposal_date' => 'date|date_format:Y-m-d', |
|||
'proposal_value' => 'numeric', |
|||
'customer_id' => 'numeric', |
|||
'customer_name' => 'required_without:customer_id|max:60', |
|||
'customer_email' => 'required_without:customer_id|email|unique:users,email', |
|||
'description' => 'max:255', |
|||
]; |
|||
} |
|||
|
|||
public function messages() |
|||
{ |
|||
return [ |
|||
'customer_name.required_without' => 'Nama Customer Wajib diisi.', |
|||
'customer_email.required_without' => 'Email Customer Wajib diisi.', |
|||
]; |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,31 @@ |
|||
<?php |
|||
|
|||
namespace App\Http\Requests\Projects; |
|||
|
|||
use App\Http\Requests\Request; |
|||
|
|||
class DeleteRequest extends Request { |
|||
|
|||
/** |
|||
* Determine if the user is authorized to make this request. |
|||
* |
|||
* @return bool |
|||
*/ |
|||
public function authorize() |
|||
{ |
|||
return auth()->user()->can('manage_projects'); |
|||
} |
|||
|
|||
/** |
|||
* Get the validation rules that apply to the request. |
|||
* |
|||
* @return array |
|||
*/ |
|||
public function rules() |
|||
{ |
|||
return [ |
|||
'project_id' => 'required' |
|||
]; |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,38 @@ |
|||
<?php |
|||
|
|||
namespace App\Http\Requests\Projects; |
|||
|
|||
use App\Http\Requests\Request; |
|||
|
|||
class UpdateRequest extends Request { |
|||
|
|||
/** |
|||
* Determine if the user is authorized to make this request. |
|||
* |
|||
* @return bool |
|||
*/ |
|||
public function authorize() |
|||
{ |
|||
return auth()->user()->can('manage_projects'); |
|||
} |
|||
|
|||
/** |
|||
* Get the validation rules that apply to the request. |
|||
* |
|||
* @return array |
|||
*/ |
|||
public function rules() |
|||
{ |
|||
return [ |
|||
'name' => 'required|max:50', |
|||
'description' => 'max:255', |
|||
'proposal_date' => 'date|date_format:Y-m-d', |
|||
'proposal_value' => 'numeric', |
|||
'start_date' => 'date|date_format:Y-m-d', |
|||
'end_date' => 'date|date_format:Y-m-d', |
|||
'project_value' => 'numeric', |
|||
'customer_id' => 'numeric', |
|||
]; |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,10 @@ |
|||
<?php |
|||
|
|||
namespace App\Http\Requests; |
|||
|
|||
use Illuminate\Foundation\Http\FormRequest; |
|||
|
|||
abstract class Request extends FormRequest |
|||
{ |
|||
//
|
|||
} |
|||
@ -0,0 +1,35 @@ |
|||
<?php |
|||
|
|||
namespace App\Http\Requests\Users; |
|||
|
|||
use App\Http\Requests\Request; |
|||
|
|||
class CreateRequest extends Request |
|||
{ |
|||
/** |
|||
* Determine if the user is authorized to make this request. |
|||
* |
|||
* @return bool |
|||
*/ |
|||
public function authorize() |
|||
{ |
|||
return $this->user()->can('manage_users'); |
|||
} |
|||
|
|||
/** |
|||
* Get the validation rules that apply to the request. |
|||
* |
|||
* @return array |
|||
*/ |
|||
public function rules() |
|||
{ |
|||
return [ |
|||
'name' => 'required|min:5', |
|||
'username' => 'required|alpha_dash|min:4|unique:users,username', |
|||
'email' => 'required|email|unique:users,email', |
|||
'role' => 'required|array', |
|||
'password' => 'between:6,15|confirmed', |
|||
'password_confirmation' => 'required_with:password', |
|||
]; |
|||
} |
|||
} |
|||
@ -0,0 +1,30 @@ |
|||
<?php |
|||
|
|||
namespace App\Http\Requests\Users; |
|||
|
|||
use App\Http\Requests\Request; |
|||
|
|||
class DeleteRequest extends Request |
|||
{ |
|||
/** |
|||
* Determine if the user is authorized to make this request. |
|||
* |
|||
* @return bool |
|||
*/ |
|||
public function authorize() |
|||
{ |
|||
return $this->user()->can('manage_users'); |
|||
} |
|||
|
|||
/** |
|||
* Get the validation rules that apply to the request. |
|||
* |
|||
* @return array |
|||
*/ |
|||
public function rules() |
|||
{ |
|||
return [ |
|||
'user_id' => 'required', |
|||
]; |
|||
} |
|||
} |
|||
@ -0,0 +1,32 @@ |
|||
<?php |
|||
|
|||
namespace App\Http\Requests\Users\Permissions; |
|||
|
|||
use App\Http\Requests\Request; |
|||
|
|||
class CreateRequest extends Request { |
|||
|
|||
/** |
|||
* Determine if the user is authorized to make this request. |
|||
* |
|||
* @return bool |
|||
*/ |
|||
public function authorize() |
|||
{ |
|||
return auth()->user()->can('manage_role_permissions'); |
|||
} |
|||
|
|||
/** |
|||
* Get the validation rules that apply to the request. |
|||
* |
|||
* @return array |
|||
*/ |
|||
public function rules() |
|||
{ |
|||
return [ |
|||
'name' => 'required|max:60|unique:roles_permissions,name', |
|||
'label' => 'required|max:60', |
|||
]; |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,31 @@ |
|||
<?php |
|||
|
|||
namespace App\Http\Requests\Users\Permissions; |
|||
|
|||
use App\Http\Requests\Request; |
|||
|
|||
class DeleteRequest extends Request { |
|||
|
|||
/** |
|||
* Determine if the user is authorized to make this request. |
|||
* |
|||
* @return bool |
|||
*/ |
|||
public function authorize() |
|||
{ |
|||
return auth()->user()->can('manage_role_permissions'); |
|||
} |
|||
|
|||
/** |
|||
* Get the validation rules that apply to the request. |
|||
* |
|||
* @return array |
|||
*/ |
|||
public function rules() |
|||
{ |
|||
return [ |
|||
'permission_id' => 'required' |
|||
]; |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,32 @@ |
|||
<?php |
|||
|
|||
namespace App\Http\Requests\Users\Permissions; |
|||
|
|||
use App\Http\Requests\Request; |
|||
|
|||
class UpdateRequest extends Request { |
|||
|
|||
/** |
|||
* Determine if the user is authorized to make this request. |
|||
* |
|||
* @return bool |
|||
*/ |
|||
public function authorize() |
|||
{ |
|||
return auth()->user()->can('manage_role_permissions'); |
|||
} |
|||
|
|||
/** |
|||
* Get the validation rules that apply to the request. |
|||
* |
|||
* @return array |
|||
*/ |
|||
public function rules() |
|||
{ |
|||
return [ |
|||
'name' => 'required|max:60|unique:roles_permissions,name,' . $this->segment(2), |
|||
'label' => 'required|max:60', |
|||
]; |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,32 @@ |
|||
<?php |
|||
|
|||
namespace App\Http\Requests\Users\Roles; |
|||
|
|||
use App\Http\Requests\Request; |
|||
|
|||
class CreateRequest extends Request { |
|||
|
|||
/** |
|||
* Determine if the user is authorized to make this request. |
|||
* |
|||
* @return bool |
|||
*/ |
|||
public function authorize() |
|||
{ |
|||
return auth()->user()->can('manage_role_permissions'); |
|||
} |
|||
|
|||
/** |
|||
* Get the validation rules that apply to the request. |
|||
* |
|||
* @return array |
|||
*/ |
|||
public function rules() |
|||
{ |
|||
return [ |
|||
'name' => 'required|max:60|unique:roles_permissions,name', |
|||
'label' => 'required|max:60', |
|||
]; |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,31 @@ |
|||
<?php |
|||
|
|||
namespace App\Http\Requests\Users\Roles; |
|||
|
|||
use App\Http\Requests\Request; |
|||
|
|||
class DeleteRequest extends Request { |
|||
|
|||
/** |
|||
* Determine if the user is authorized to make this request. |
|||
* |
|||
* @return bool |
|||
*/ |
|||
public function authorize() |
|||
{ |
|||
return auth()->user()->can('manage_role_permissions'); |
|||
} |
|||
|
|||
/** |
|||
* Get the validation rules that apply to the request. |
|||
* |
|||
* @return array |
|||
*/ |
|||
public function rules() |
|||
{ |
|||
return [ |
|||
'role_id' => 'required' |
|||
]; |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,32 @@ |
|||
<?php |
|||
|
|||
namespace App\Http\Requests\Users\Roles; |
|||
|
|||
use App\Http\Requests\Request; |
|||
|
|||
class UpdateRequest extends Request { |
|||
|
|||
/** |
|||
* Determine if the user is authorized to make this request. |
|||
* |
|||
* @return bool |
|||
*/ |
|||
public function authorize() |
|||
{ |
|||
return auth()->user()->can('manage_role_permissions'); |
|||
} |
|||
|
|||
/** |
|||
* Get the validation rules that apply to the request. |
|||
* |
|||
* @return array |
|||
*/ |
|||
public function rules() |
|||
{ |
|||
return [ |
|||
'name' => 'required|max:60|unique:roles_permissions,name,' . $this->segment(2), |
|||
'label' => 'required|max:60', |
|||
]; |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,35 @@ |
|||
<?php |
|||
|
|||
namespace App\Http\Requests\Users; |
|||
|
|||
use App\Http\Requests\Request; |
|||
|
|||
class UpdateRequest extends Request |
|||
{ |
|||
/** |
|||
* Determine if the user is authorized to make this request. |
|||
* |
|||
* @return bool |
|||
*/ |
|||
public function authorize() |
|||
{ |
|||
return $this->user()->can('manage_users'); |
|||
} |
|||
|
|||
/** |
|||
* Get the validation rules that apply to the request. |
|||
* |
|||
* @return array |
|||
*/ |
|||
public function rules() |
|||
{ |
|||
return [ |
|||
'name' => 'required|min:5', |
|||
'username' => 'required|alpha_dash|min:4|unique:users,username,' . $this->segment(2), |
|||
'email' => 'required|email|unique:users,email,' . $this->segment(2), |
|||
'role' => 'required|array', |
|||
'password' => 'required_with:password_confirmation|between:6,15|confirmed', |
|||
'password_confirmation' => 'required_with:password', |
|||
]; |
|||
} |
|||
} |
|||
@ -0,0 +1,10 @@ |
|||
<?php |
|||
|
|||
require __DIR__ . '/routes/helpers.php'; |
|||
require __DIR__ . '/routes/pages.php'; |
|||
require __DIR__ . '/routes/users.php'; |
|||
require __DIR__ . '/routes/references.php'; |
|||
require __DIR__ . '/routes/account.php'; |
|||
require __DIR__ . '/routes/backup.php'; |
|||
require __DIR__ . '/routes/projects.php'; |
|||
require __DIR__ . '/routes/payments.php'; |
|||
@ -0,0 +1,20 @@ |
|||
<?php |
|||
/** |
|||
* Account Routes |
|||
*/ |
|||
Route::group(['prefix' => 'auth','middleware' => 'web','as'=>'auth.'], function() { |
|||
Route::get('login', ['as'=>'login', 'uses' => 'AuthController@getLogin']); |
|||
Route::post('login', ['as'=>'login', 'uses' => 'AuthController@postLogin']); |
|||
Route::get('logout', ['as'=>'logout', 'uses' => 'AuthController@getLogout']); |
|||
Route::get('register', ['as'=>'register', 'uses' => 'AuthController@getRegister']); |
|||
Route::post('register', ['as'=>'register', 'uses' => 'AuthController@postRegister']); |
|||
Route::get('activate', ['as'=>'activate', 'uses' => 'AuthController@getActivate']); |
|||
Route::get('change-password', ['as'=>'change-password', 'uses' => 'AuthController@getChangePassword']); |
|||
Route::post('change-password', ['as'=>'change-password', 'uses' => 'AuthController@postChangePassword']); |
|||
Route::get('forgot-password', ['as'=>'forgot-password', 'uses' => 'AuthController@getEmail']); |
|||
Route::post('forgot-password', ['as'=>'forgot-password', 'uses' => 'AuthController@postEmail']); |
|||
Route::get('reset/{token}', ['as'=>'reset', 'uses' => 'AuthController@getReset']); |
|||
Route::post('reset', ['as'=>'post-reset', 'uses' => 'AuthController@postReset']); |
|||
Route::get('profile', ['as'=>'profile', 'uses' => 'AuthController@getProfile']); |
|||
Route::patch('profile', ['as'=>'profile', 'uses' => 'AuthController@patchProfile']); |
|||
}); |
|||
@ -0,0 +1,14 @@ |
|||
<?php |
|||
|
|||
Route::group(['middleware' => ['web','role:admin']], function() { |
|||
/** |
|||
* Backups Routes |
|||
*/ |
|||
Route::get('backups/{fileName}/restore', ['as'=>'backups.restore', 'uses'=>'BackupsController@restore']); |
|||
Route::post('backups/{fileName}/restore', ['as'=>'backups.restore', 'uses'=>'BackupsController@postRestore']); |
|||
Route::get('backups/{fileName}/dl', ['as'=>'backups.download', 'uses'=>'BackupsController@download']); |
|||
Route::post('backups/upload', ['as'=>'backups.upload', 'uses'=>'BackupsController@upload']); |
|||
Route::get('backups/{id}/delete', ['as'=>'backups.delete', 'uses'=>'BackupsController@delete']); |
|||
Route::resource('backups','BackupsController'); |
|||
|
|||
}); |
|||
@ -0,0 +1,182 @@ |
|||
<?php |
|||
|
|||
use App\Entities\Projects\Project; |
|||
|
|||
// Event::listen('illuminate.query', function($query)
|
|||
// {
|
|||
// echo $query; echo '<br><br>';
|
|||
// });
|
|||
|
|||
// Route::get('add-customers', function() {
|
|||
// $customers = ['Huda','Om Ekong','Isra Tanjung','Ahmad Fatah','STAI Buntok','Hasto','Jakhoster','Ujang Rahman','Donny','Ipul Batulicin','Joenathan Tanumiha','Prima','Dinas Koperasi UKM Kalsel','Stikes Husada Borneo','Rumah Web','Herbert','Donny Kurniawan'];
|
|||
// foreach ($customers as $customer) {
|
|||
// $user = new App\Entities\Users\User;
|
|||
// $user->name = $customer;
|
|||
// $user->username = str_replace(' ', '_', strtolower($customer));
|
|||
// $user->email = $user->username . '@mail.com';
|
|||
// $user->password = 'member';
|
|||
// $user->save();
|
|||
// $user->assignRole('customer');
|
|||
// }
|
|||
// });
|
|||
|
|||
Route::get('add-existing-payments', function() { |
|||
// $payments = [
|
|||
// ['Frestour.com','500000','2014-05-14','Jasa website','Heru Yugo'],
|
|||
// ['Elfbandung','500000','2014-06-12','Sistem reservasi','Heru Yugo'],
|
|||
// ['Skripsi Ryan','250000','2014-06-21','Input jadwal, export to XL & PDF','Heru Yugo'],
|
|||
// ['Bandungrafting.com','300000','2014-06-30','Jasa website','Heru Yugo'],
|
|||
// ['Cianjurnews.com','150000','2014-07-09','Halaman index','Heru Yugo'],
|
|||
// ['Bandungrafting.com','150000','2014-07-11','Jasa website','Heru Yugo'],
|
|||
// ['Glowinklash.com','250000','2014-07-20','Jasa website','Heru Yugo'],
|
|||
// ['Trijayatrans.com','50000','2014-07-20','Form reservasi email','Heru Yugo'],
|
|||
// ['Skripsi Rotan','500000','2014-08-10','Shopping cart, halaman produk dgn pengurutan produk terlaris, CRUD tarif pengiriman','Andie'],
|
|||
// ['Skripsi Makarizo','500000','2014-08-10','Shopping cart, laporan penjualan, backup database MySQL','Andie'],
|
|||
// ['Stimi-bjm.ac.id','2000000','2014-08-11','DP jasa website','STIMI'],
|
|||
// ['Stimi-bjm.ac.id','-1000000','2014-08-11','DP jasa website, hosting, domain','Heru Yugo'],
|
|||
// ['Belimukena.com','5000000','2014-08-17','Shopping cart, management sistem','Heru Yugo'],
|
|||
// ['Belimukena.com','-500000','2014-08-17','Pembagian belimukena.com','Heru Yugo'],
|
|||
// ['Skripsi Absensi (sms gateway)','700000','2014-08-17','SMS gateway broadcast, input absen dan laporan semester','Andie'],
|
|||
// ['Skripsi SPB (sms gateway)','300000','2014-08-17','SMS gateway broadcast dan laporan','Andie'],
|
|||
// ['Belimukena.com','200000','2014-09-08','Revisi tambahan','Heru Yugo'],
|
|||
// ['Imet18.com','750000','2014-09-12','Sistem informasi laporan prospecting','Heru Yugo'],
|
|||
// ['Livescore','2000000','2014-09-18','Website seperti livescore','Heru Yugo'],
|
|||
// ['Rajabagus','1400000','2014-09-24','Pembuatan import code/voucher dan signup with voucher','Heru Yugo'],
|
|||
// ['Stimi-bjm.ac.id','2000000','2014-10-14','Pelunasan website stimi','STIMI'],
|
|||
// ['Belimukena.com','600000','2014-11-07','Biaya maintenance 2014-11','Heru Yugo'],
|
|||
// ['bandungtraverservice.com','500000','2014-11-13','fee isi content bandung travel service','Heru Yugo'],
|
|||
// ['Belimukena.com','300000','2014-12-08','Biaya maintenance 2014-12','Heru Yugo'],
|
|||
// ['Belimukena.com','100000','2014-12-08','fee buat reject order reason','Heru Yugo'],
|
|||
// ['Legacyvapestore.com','350000','2014-12-12','fee isi content dan buat tutorial','Heru Yugo'],
|
|||
// ['Aplikasi Toko Obat Sholah (Andie)','700000','2014-12-23','fee buat shopping cart apotik dan print nota','Andie'],
|
|||
// ['Panjimitra.co.id','344500','2015-01-02','DP corporate email panjimitra.co.id','Heru Yugo'],
|
|||
// ['Aplikasi Toko Obat Sholah (Andie)','1000000','2015-01-02','fee revisi shopping cart apotik dan management stok','Andie'],
|
|||
// ['Panjimitra.co.id','580000','2015-01-05','Pelunasan corporate email panjimitra.co.id','Heru Yugo'],
|
|||
// ['elfjakarta.com','150000','2015-01-05','DP pembuatan website dan aplikasi reservasi elfjakarta.com','Heru Yugo'],
|
|||
// ['Aplikasi Toko Obat Sholah (Andie)','100000','2015-01-09','Jasa setting printer dan printout nota','Sholah'],
|
|||
// ['Belimukena.com','300000','2015-01-09','Biaya maintenance 2015-01','Heru Yugo'],
|
|||
// ['elfjakarta.com','150000','2015-01-10','Pelunasan Elfjakarta.com','Heru Yugo'],
|
|||
// ['mambabykid.com','250000','2015-01-16','DP MambabyKid.com','Heru Yugo'],
|
|||
// ['mambabykid.com','250000','2015-01-20','Pelunasan Mambabykid.com','Heru Yugo'],
|
|||
// ['Aplikasi Reservasi Frestour','1000000','2015-01-21','DP Payapps','Heru Yugo'],
|
|||
// ['Belimukena.com','300000','2015-02-10','Biaya maintenance 2015-02','Heru Yugo'],
|
|||
// ['alamjayatrans.com','350000','2015-02-20','Buat landing page untuk car rental','Heru Yugo'],
|
|||
// ['Rajatourbandung.com','50000','2015-02-20','Form reservasi email','Heru Yugo'],
|
|||
// ['Belimukena.com','300000','2015-03-04','Biaya maintenance 2015-03','Heru Yugo'],
|
|||
// ['Belimukena.com','350000','2015-03-04','Revisi form cart (ditambahkan custom nama pengirim di akun admin, reseller dan company reseller)','Heru Yugo'],
|
|||
// ['Diskonmobisuzuki.com','350000','2015-03-20','Pembuatan fitur sales area','Eko'],
|
|||
// ['Aplikasi Order','200000','2015-03-22','DP aplikasi order','Heru Yugo'],
|
|||
// ['azka.co.id','300000','2015-03-30','Landing page car rental','Heru Yugo'],
|
|||
// ['Legacyvapestore.com','350000','2015-04-04','DP redesign Legacyvapestore','Heru Yugo'],
|
|||
// ['autodaihatsu.com','300000','2015-04-08','DP pembuatan website sales daihatsu bandung','Heru Yugo'],
|
|||
// ['Belimukena.com','450000','2015-04-13','Biaya maintenance 2015-04 (plus security)','Heru Yugo'],
|
|||
// ['my-trans.co.id','1300000','2015-04-27','DP pembuatan web company profile www.my-trans.co.id','Yamin'],
|
|||
// ['my-trans.co.id','-650000','2015-04-27','Biaya hosting dan domain','Heru Yugo'],
|
|||
// ['berkahsynergy.com','300000','2015-04-28','Pembuatan template berkahsynergy.com (redesign)','Erwin Fastweb'],
|
|||
// ['autodaihatsu.com','200000','2015-04-30','Pelunasan pembuatan website sales daihatsu bandung','Heru Yugo'],
|
|||
// ['Legacyvapestore.com','250000','2015-05-04','Pelunasan redesign website legacyvapestore','Heru Yugo'],
|
|||
// ['Belimukena.com','1350000','2015-05-15','Biaya maintenance 2015-05, 2015-06, 2015-07','Heru Yugo'],
|
|||
// ['Belimukena.com','150000','2015-05-15','Sebagian biaya maintenance 2015-08 (dipake mas yugo/pak Arise)','Heru Yugo'],
|
|||
// ['Aplikasi Toko Obat Sholah (Andie)','100000','2015-05-23','Backup dan restore aplikasi web toko sholah','Sholah'],
|
|||
// ['Aplikasi Toko Obat Sholah','1000000','2015-05-26','DP pembuatan aplikasi','Sholah'],
|
|||
// ['Kursus Private PHP dan Konsul Skripsi','900000','2015-05-28','DP Kursus Private Pemrograman PHP dan Konsultasi Skirpsi','Huda'],
|
|||
// ['my-trans.co.id','500000','2015-05-29','Pembayaran ke 2 website my-trans dan aplikasi connote','Yamin'],
|
|||
// ['my-trans.co.id','1250000','2015-06-22','Pelunasan website my trans','Yamin'],
|
|||
// ['Aplikasi Toko Obat Sholah','700000','2015-06-23','Pelunasan pembuatan aplikasi toko obat Sholah','Sholah'],
|
|||
// ['Ambasadortrans.com','250000','2015-07-01','DP aplikasi reservasi ambasador trans','Heru Yugo'],
|
|||
// ['Kursus Private PHP dan Konsul Skripsi','900000','2015-07-02','Pelunasan Kursus Private Pemrograman PHP dan Konsultasi Skirpsi','Huda'],
|
|||
// ['Aplikasi Reservasi Frestour','1200000','2015-07-06','Pelunasan payapps tourbandung.com dari total (Rp. 1.500.000)','Heru Yugo'],
|
|||
// ['my-trans.co.id','150000','2015-07-08','Pembayaran fitur Konversi kurs dollar Tarif international dan setting email di ponsel','Yamin'],
|
|||
// ['Aplikasi Toko Obat Sholah','100000','2015-07-23','Perbaiki Jaringan toko Sholah','Sholah'],
|
|||
// ['pulaupermata.com','1000000','2015-07-28','Biaya pembuatan website toko permata','Om Ekong'],
|
|||
// ['Belimukena.com','450000','2015-08-10','Biaya maintenance 2015-08','Heru Yugo'],
|
|||
// ['Ambasadortrans.com','100000','2015-08-18','Pembayaran ke 2 (sisa Rp. 150.000)','Heru Yugo'],
|
|||
// ['Stimi-bjm.ac.id','500000','2015-08-19','Pembayaran perbaikan pengumuman kopertis, pasang channel youtube stimi, setting social icons','STIMI'],
|
|||
// ['Belimukena.com','450000','2015-09-07','Biaya maintenance 2015-09','Heru Yugo'],
|
|||
// ['online.my-trans.co.id','4400000','2015-09-08','Pembayaran uang muka aplikasi My-Trans','Yamin'],
|
|||
// ['Stimi-bjm.ac.id','1000000','2015-09-16','Perpanjangan hosting dan domain s/d 2016-10-01','STIMI'],
|
|||
// ['Stimi-bjm.ac.id','-800000','2015-09-16','Transfer to mas Yugo (plus Rp. 100Rb utk talangan perpanjangan Indonet 2015-09)','Heru Yugo'],
|
|||
// ['Aplikasi Apotek Iloenk','1000000','2015-09-27','DP Aplikasi Apotek Iloenk','Isra Tanjung'],
|
|||
// ['Belimukena.com','900000','2015-09-29','Modifikasi kalkulasi ongkir dgn API Rajaongkir (Migrasi Rajaongkir)','Heru Yugo'],
|
|||
// ['Belimukena.com','450000','2015-10-10','Biaya maintenance 2015-10','Heru Yugo'],
|
|||
// ['Aplikasi Toko Obat Sholah','200000','2015-10-13','Install ulang aplikasi Toko Obat dan Restore Database','Sholah'],
|
|||
// ['sia.stimi-bjm.ac.id','5000000','2015-10-28','Uang muka pembuatan aplikasi SIAKAD STIMI Banjarmasin','STIMI'],
|
|||
// ['Aplikasi Apotek Iloenk','1000000','2015-11-02','Pelunasan Aplikasi Apotek Iloenk','Isra Tanjung'],
|
|||
// ['Belimukena.com','450000','2015-11-06','Biaya maintenance 2015-11','Heru Yugo'],
|
|||
// ['Ambasadortrans.com','150000','2015-12-05','Pelunasan','Heru Yugo'],
|
|||
// ['Belimukena.com','450000','2015-12-07','Biaya maintenance 2015-12','Heru Yugo'],
|
|||
// ['DutaKurirBorneo.co.id','525000','2015-12-08','Biaya hosting dan domain','Ahmad Fatah'],
|
|||
// ['DutaKurirBorneo.co.id','-425000','2015-12-08','Biaya hosting dan domain','Heru Yugo'],
|
|||
// ['Aplikasi Reservasi Frestour','100000','2015-12-08','Cicilan Frestour.com Payapps (sisa Rp. 200.000)','Heru Yugo'],
|
|||
// ['Panjimitra.co.id','300000','2015-12-11','Fee hosting domain panjimitra.co.id','Heru Yugo'],
|
|||
// ['stai-almaarif-buntok.ac.id','2300000','2015-12-14','DP+domain+hosting','STAI Buntok'],
|
|||
// ['stai-almaarif-buntok.ac.id','-1800000','2015-12-14','DP+domain+hosting','Heru Yugo'],
|
|||
// ['stai-almaarif-buntok.ac.id','100000','2015-12-14','Bonus dari Yugo','Heru Yugo'],
|
|||
// ['Aplikasi Reservasi Frestour','200000','2015-12-14','Cicilan Frestour.com Payapps (Lunas)','Heru Yugo'],
|
|||
// ['online.my-trans.co.id','4400000','2015-12-15','Pelunasan Aplikasi E-Connote My-trans','Yamin'],
|
|||
// ['online.my-trans.co.id','-300000','2015-12-15','Fee mas yugo','Heru Yugo'],
|
|||
// ['Belimukena.com','450000','2016-01-06','Biaya maintenance 2016-01','Heru Yugo'],
|
|||
// ['borneotaichiclass.com','500000','2016-01-12','DP Website BorneoTaichiClass.com','Hasto'],
|
|||
// ['borneotaichiclass.com','-240000','2016-01-12','Hosting Domain','Jakhoster'],
|
|||
// ['bintangtimur.co.id','1325000','2016-01-21','DP Website BintangTimur.co.id','Ujang Rahman'],
|
|||
// ['bintangtimur.co.id','-825000','2016-01-25','Domain Hosting Website BintangTimur.co.id','Heru Yugo'],
|
|||
// ['borneotaichiclass.com','650000','2016-01-27','Pelunasan Website BorneoTaichiClass.com, domain taichichuanpropatria-bjm.com dan domain kungfupropatria-bjm.com','Hasto'],
|
|||
// ['kungfupropatria-bjm.com','-240000','2016-01-27','domain taichichuanpropatria-bjm.com dan domain kungfupropatria-bjm.com','Jakhoster'],
|
|||
// ['Belimukena.com','450000','2016-02-10','Biaya maintenance 2016-02','Heru Yugo'],
|
|||
// ['majas.co.id','900000','2016-02-19','DP Pembuatan web majas.co.id','Donny'],
|
|||
// ['Aplikasi Apotek Mubarok','1000000','2016-02-24','DP Pembuatan Aplikasi Apotek Mubarok','Ipul Batulicin'],
|
|||
// ['Aplikasi Apotek Mubarok','1000000','2016-02-28','Pelunasan Pembuatan Aplikasi Apotek Mubarok','Ipul Batulicin'],
|
|||
// ['sia.stimi-bjm.ac.id','5000000','2016-03-03','Pelunasan Aplikasi Siakad dan Tracer Study STIMI','STIMI'],
|
|||
// ['Belimukena.com','450000','2016-03-08','Biaya maintenance 2016-03','Heru Yugo'],
|
|||
// ['attelierjewelry.com','1000000','2016-03-10','DP online store attelierjewelry.com','Joenathan Tanumiha'],
|
|||
// ['Aplikasi QRCode Haki','250000','2016-03-18','Cicilan 1 DP','Erwin Fastweb'],
|
|||
// ['Calief Gallery','1500000','2016-03-31','Cicilan 1 DP Aplikasi Order Calief Gallery','Heru Yugo'],
|
|||
// ['Aplikasi QRCode Haki','250000','2016-03-31','Cicilan 2 DP','Erwin Fastweb'],
|
|||
// ['my-trans.co.id','650000','2016-04-04','Biaya hosting dan domain','Yamin'],
|
|||
// ['my-trans.co.id','-650000','2016-04-04','Biaya hosting dan domain','Heru Yugo'],
|
|||
// ['Calief Gallery','1000000','2016-04-04','Cicilan 2 DP Aplikasi Order Calief Gallery','Heru Yugo'],
|
|||
// ['stai-almaarif-buntok.ac.id','2300000','2016-04-04','Pelunasan pembuatan website stai-almaarif-buntok.ac.id','STAI Buntok'],
|
|||
// ['stai-almaarif-buntok.ac.id','-800000','2016-04-04','Pelunasan pembuatan website stai-almaarif-buntok.ac.id','Heru Yugo'],
|
|||
// ['Belimukena.com','450000','2016-04-05','Biaya maintenance 2016-04','Heru Yugo'],
|
|||
// ['stai-almaarif-buntok.ac.id','-400000','2016-04-06','Fee marketing dari pak Prima','Prima'],
|
|||
// ['Bimtek Pemasaran Online','4000000','2016-04-14','Honor narasumber','Dinas Koperasi UKM Kalsel'],
|
|||
// ['sia.stikeshusada-borneo.ac.id','8000000','2016-04-18','DP Aplikasi Siakad dan Tracer Study STIKES HB','Stikes Husada Borneo'],
|
|||
// ['sia.stikeshusada-borneo.ac.id','-2000000','2016-04-19','Fee Aplikasi Siakad STIKES HB','Prima'],
|
|||
// ['Calief Gallery','1800000','2016-04-19','Pelunasan Aplikasi Order Calief Gallery','Heru Yugo'],
|
|||
// ['borneotaichiclass.com','150000','2016-04-26','Fee revisi website dan edit artikel','Hasto'],
|
|||
// ['attelierjewelry.com','-315000','2016-04-27','Domain Hosting Attelierjewelry.com','Rumah Web'],
|
|||
// ['bintangtimur.co.id','1000000','2016-04-28','Pelunasan Website BintangTimur.co.id (belum entry content)','Ujang Rahman'],
|
|||
// ['Aplikasi QRCode Haki','500000','2016-04-29','Cicilan 3 DP','Erwin Fastweb'],
|
|||
// ['Belimukena.com','450000','2016-05-04','Biaya maintenance 2016-05','Heru Yugo'],
|
|||
// ['majas.co.id','-110000','2016-05-10','Domain majas.co.id','Rumah Web'],
|
|||
// ['majas.co.id','-250000','2016-05-11','Hosting 2GB majas.co.id','Jakhoster'],
|
|||
// ['Belimukena.com','450000','2016-06-06','Biaya maintenance 2016-06','Heru Yugo'],
|
|||
// ['Aplikasi Toko Obat Berkah','1900000','2016-06-17','Aplikasi Toko Obat Berkah','Sholah'],
|
|||
// ['Aplikasi e-report CK Balangan','1200000','2016-06-18','DP Aplikasi Pelaporan Online & Domain+Hosting','Herbert'],
|
|||
// ['Aplikasi Direktori KKF','400000','2016-06-18','DP Aplikasi Direktori Pelaku Usaha KKF','Donny Kurniawan'],
|
|||
// ['Aplikasi e-report CK Balangan','-55000','2016-06-24','Domain ckbalangan.web.id','Rumah Web'],
|
|||
// ['Aplikasi QRCode Haki','1000000','2016-06-29','Cicilan 4','Erwin Fastweb'],
|
|||
// ];
|
|||
// $formated = [];
|
|||
// $projects = Project::all();
|
|||
// $customers = App\Entities\Users\User::latest()->hasRoles(['customer'])->get();
|
|||
// // dump($projects->lists('name'));
|
|||
// foreach ($payments as $payment) {
|
|||
// $formated[] = [
|
|||
// 'project_id' => ($project = $projects->where('name', $payment[0])->first()) ? $project->id : 'hit',
|
|||
// 'amount' => abs($payment[1]),
|
|||
// 'type' => $payment[1] < 0 ? 0 : 1,
|
|||
// 'date' => $payment[2],
|
|||
// 'description' => $payment[3],
|
|||
// 'customer_id' => ($customer = $customers->where('name', $payment[4])->first()) ? $customer->id : 'hit',
|
|||
// 'created_at' => $payment[2] . ' 00:00:00',
|
|||
// ];
|
|||
// }
|
|||
|
|||
// DB::beginTransaction();
|
|||
// DB::table('payments')->insert($formated);
|
|||
// DB::commit();
|
|||
|
|||
// echo '<pre>$formated : ', print_r($formated, true), '</pre>';
|
|||
// die();
|
|||
}); |
|||
@ -0,0 +1,8 @@ |
|||
<?php |
|||
|
|||
/** |
|||
* Pages Routes |
|||
*/ |
|||
Route::get('/', function () { return redirect()->route('home'); }); |
|||
Route::get('about', ['as'=>'about', 'uses' => 'PagesController@about', 'middleware'=>['web']]); |
|||
Route::get('home', ['as'=>'home', 'uses' => 'PagesController@home', 'middleware'=>['web','auth']]); |
|||
@ -0,0 +1,9 @@ |
|||
<?php |
|||
|
|||
Route::group(['middleware' => ['web','role:admin']], function() { |
|||
/** |
|||
* Payments Routes |
|||
*/ |
|||
Route::get('payments/{id}/delete', ['as'=>'payments.delete', 'uses'=>'PaymentsController@delete']); |
|||
Route::resource('payments','PaymentsController'); |
|||
}); |
|||
@ -0,0 +1,17 @@ |
|||
<?php |
|||
|
|||
Route::group(['middleware' => ['web','role:admin'], 'namespace' => 'Projects'], function() { |
|||
/** |
|||
* Projects Routes |
|||
*/ |
|||
Route::get('projects/{id}/delete', ['as'=>'projects.delete', 'uses'=>'ProjectsController@delete']); |
|||
Route::get('projects/{id}/features', ['as'=>'projects.features', 'uses'=>'ProjectsController@features']); |
|||
Route::get('projects/{id}/payments', ['as'=>'projects.payments', 'uses'=>'ProjectsController@payments']); |
|||
Route::resource('projects','ProjectsController'); |
|||
|
|||
/** |
|||
* Features Routes |
|||
*/ |
|||
Route::get('projects/{id}/features/create', ['as'=>'features.create', 'uses'=>'FeaturesController@create']); |
|||
Route::resource('features','FeaturesController',['except' => ['index','create']]); |
|||
}); |
|||
@ -0,0 +1,13 @@ |
|||
<?php |
|||
|
|||
Route::group(['namespace' => 'References','middleware'=>['web','role:admin']], function() { |
|||
/** |
|||
* Options Routes |
|||
*/ |
|||
Route::get('options', ['as'=>'options.index' , 'uses'=>'OptionsController@index']); |
|||
Route::get('options/create', ['as'=>'options.create' , 'uses'=>'OptionsController@create']); |
|||
Route::post('options/store', ['as'=>'options.store' , 'uses'=>'OptionsController@store']); |
|||
Route::patch('options/save', ['as'=>'options.save' , 'uses'=>'OptionsController@save']); |
|||
Route::get('options/{id}/delete', ['as'=>'options.delete' , 'uses'=>'OptionsController@delete']); |
|||
Route::delete('options/{optionId}/destroy', ['as'=>'options.destroy' , 'uses'=>'OptionsController@destroy']); |
|||
}); |
|||
@ -0,0 +1,20 @@ |
|||
<?php |
|||
|
|||
Route::group(['middleware' => ['web','role:admin'], 'namespace' => 'Users'], function() { |
|||
/** |
|||
* Users Routes |
|||
*/ |
|||
Route::get('users/{id}/delete', ['as'=>'users.delete', 'uses'=>'UsersController@delete']); |
|||
Route::resource('users','UsersController'); |
|||
|
|||
/** |
|||
* Permissions Routes |
|||
*/ |
|||
Route::resource('permissions','PermissionsController'); |
|||
|
|||
/** |
|||
* Roles Routes |
|||
*/ |
|||
Route::resource('roles','RolesController'); |
|||
Route::post('roles/{id}/update-permissions', ['as' => 'roles.update-permissions', 'uses' => 'RolesController@updatePermissions']); |
|||
}); |
|||
@ -0,0 +1,21 @@ |
|||
<?php |
|||
|
|||
namespace App\Jobs; |
|||
|
|||
use Illuminate\Bus\Queueable; |
|||
|
|||
abstract class Job |
|||
{ |
|||
/* |
|||
|-------------------------------------------------------------------------- |
|||
| Queueable Jobs |
|||
|-------------------------------------------------------------------------- |
|||
| |
|||
| This job base class provides a central location to place any logic that |
|||
| is shared across all of your jobs. The trait included with the class |
|||
| provides access to the "onQueue" and "delay" queue helper methods. |
|||
| |
|||
*/ |
|||
|
|||
use Queueable; |
|||
} |
|||
@ -0,0 +1,35 @@ |
|||
<?php |
|||
|
|||
namespace App\Providers; |
|||
|
|||
use App\Entities\Projects\Project; |
|||
use DB; |
|||
use Illuminate\Support\ServiceProvider; |
|||
|
|||
class AppServiceProvider extends ServiceProvider |
|||
{ |
|||
/** |
|||
* Bootstrap any application services. |
|||
* |
|||
* @return void |
|||
*/ |
|||
public function boot() |
|||
{ |
|||
require_once app_path() . '/helpers.php'; |
|||
$projectCounts = Project::select(DB::raw('status_id, count(id) as count')) |
|||
->groupBy('status_id') |
|||
->lists('count','status_id') |
|||
->all(); |
|||
view()->share('projectCounts', $projectCounts); |
|||
} |
|||
|
|||
/** |
|||
* Register any application services. |
|||
* |
|||
* @return void |
|||
*/ |
|||
public function register() |
|||
{ |
|||
//
|
|||
} |
|||
} |
|||
@ -0,0 +1,48 @@ |
|||
<?php |
|||
|
|||
namespace App\Providers; |
|||
|
|||
use App\Entities\Users\Permission; |
|||
use Illuminate\Contracts\Auth\Access\Gate as GateContract; |
|||
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider; |
|||
|
|||
class AuthServiceProvider extends ServiceProvider |
|||
{ |
|||
/** |
|||
* The policy mappings for the application. |
|||
* |
|||
* @var array |
|||
*/ |
|||
protected $policies = [ |
|||
'App\Model' => 'App\Policies\ModelPolicy', |
|||
]; |
|||
|
|||
/** |
|||
* Register any application authentication / authorization services. |
|||
* |
|||
* @param \Illuminate\Contracts\Auth\Access\Gate $gate |
|||
* @return void |
|||
*/ |
|||
public function boot(GateContract $gate) |
|||
{ |
|||
$this->registerPolicies($gate); |
|||
|
|||
// Dynamically register permissions with Laravel's Gate.
|
|||
foreach ($this->getPermissions() as $permission) { |
|||
$gate->define($permission->name, function ($user) use ($permission) { |
|||
return $user->hasPermission($permission); |
|||
}); |
|||
} |
|||
|
|||
} |
|||
|
|||
/** |
|||
* Fetch the collection of site permissions. |
|||
* |
|||
* @return \Illuminate\Database\Eloquent\Collection |
|||
*/ |
|||
protected function getPermissions() |
|||
{ |
|||
return Permission::with('roles')->get(); |
|||
} |
|||
} |
|||
@ -0,0 +1,33 @@ |
|||
<?php |
|||
|
|||
namespace App\Providers; |
|||
|
|||
use Illuminate\Contracts\Events\Dispatcher as DispatcherContract; |
|||
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider; |
|||
|
|||
class EventServiceProvider extends ServiceProvider |
|||
{ |
|||
/** |
|||
* The event listener mappings for the application. |
|||
* |
|||
* @var array |
|||
*/ |
|||
protected $listen = [ |
|||
'App\Events\SomeEvent' => [ |
|||
'App\Listeners\EventListener', |
|||
], |
|||
]; |
|||
|
|||
/** |
|||
* Register any other events for your application. |
|||
* |
|||
* @param \Illuminate\Contracts\Events\Dispatcher $events |
|||
* @return void |
|||
*/ |
|||
public function boot(DispatcherContract $events) |
|||
{ |
|||
parent::boot($events); |
|||
|
|||
//
|
|||
} |
|||
} |
|||
@ -0,0 +1,32 @@ |
|||
<?php |
|||
|
|||
namespace App\Providers; |
|||
|
|||
use Illuminate\Support\ServiceProvider; |
|||
use App\Services\FormField; |
|||
|
|||
class FormFieldServiceProvider extends ServiceProvider |
|||
{ |
|||
/** |
|||
* Bootstrap the application services. |
|||
* |
|||
* @return void |
|||
*/ |
|||
public function boot() |
|||
{ |
|||
//
|
|||
} |
|||
|
|||
/** |
|||
* Register the application services. |
|||
* |
|||
* @return void |
|||
*/ |
|||
public function register() |
|||
{ |
|||
$this->app['formField'] = $this->app->share(function($app) |
|||
{ |
|||
return new FormField(); |
|||
}); |
|||
} |
|||
} |
|||
@ -0,0 +1,32 @@ |
|||
<?php |
|||
|
|||
namespace App\Providers; |
|||
|
|||
use Illuminate\Support\ServiceProvider; |
|||
use App\Services\Option; |
|||
|
|||
class OptionServiceProvider extends ServiceProvider |
|||
{ |
|||
/** |
|||
* Bootstrap the application services. |
|||
* |
|||
* @return void |
|||
*/ |
|||
public function boot() |
|||
{ |
|||
//
|
|||
} |
|||
|
|||
/** |
|||
* Register the application services. |
|||
* |
|||
* @return void |
|||
*/ |
|||
public function register() |
|||
{ |
|||
$this->app['option'] = $this->app->share(function($app) |
|||
{ |
|||
return new Option(); |
|||
}); |
|||
} |
|||
} |
|||
@ -0,0 +1,44 @@ |
|||
<?php |
|||
|
|||
namespace App\Providers; |
|||
|
|||
use Illuminate\Routing\Router; |
|||
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider; |
|||
|
|||
class RouteServiceProvider extends ServiceProvider |
|||
{ |
|||
/** |
|||
* This namespace is applied to the controller routes in your routes file. |
|||
* |
|||
* In addition, it is set as the URL generator's root namespace. |
|||
* |
|||
* @var string |
|||
*/ |
|||
protected $namespace = 'App\Http\Controllers'; |
|||
|
|||
/** |
|||
* Define your route model bindings, pattern filters, etc. |
|||
* |
|||
* @param \Illuminate\Routing\Router $router |
|||
* @return void |
|||
*/ |
|||
public function boot(Router $router) |
|||
{ |
|||
//
|
|||
|
|||
parent::boot($router); |
|||
} |
|||
|
|||
/** |
|||
* Define the routes for the application. |
|||
* |
|||
* @param \Illuminate\Routing\Router $router |
|||
* @return void |
|||
*/ |
|||
public function map(Router $router) |
|||
{ |
|||
$router->group(['namespace' => $this->namespace], function ($router) { |
|||
require app_path('Http/routes.php'); |
|||
}); |
|||
} |
|||
} |
|||
@ -0,0 +1,10 @@ |
|||
<?php |
|||
|
|||
namespace App\Services\Facades; |
|||
|
|||
use Illuminate\Support\Facades\Facade; |
|||
|
|||
class FormField extends Facade |
|||
{ |
|||
protected static function getFacadeAccessor() { return 'formField'; } |
|||
} |
|||
@ -0,0 +1,10 @@ |
|||
<?php |
|||
|
|||
namespace App\Services\Facades; |
|||
|
|||
use Illuminate\Support\Facades\Facade; |
|||
|
|||
class Option extends Facade |
|||
{ |
|||
protected static function getFacadeAccessor() { return 'option'; } |
|||
} |
|||
@ -0,0 +1,306 @@ |
|||
<?php |
|||
|
|||
namespace App\Services; |
|||
use Form; |
|||
use Illuminate\Support\Collection; |
|||
use Illuminate\Support\MessageBag; |
|||
use Session; |
|||
|
|||
/** |
|||
* FormField Class (Site FormField Service) |
|||
*/ |
|||
class FormField |
|||
{ |
|||
|
|||
protected $errorBag; |
|||
protected $options; |
|||
protected $fieldParams; |
|||
|
|||
public function __construct() |
|||
{ |
|||
$this->errorBag = Session::get('errors', new MessageBag);; |
|||
} |
|||
|
|||
public function text($name, $options = []) |
|||
{ |
|||
$hasError = $this->errorBag->has($name) ? 'has-error' : ''; |
|||
$htmlForm = '<div class="form-group ' . $hasError . '">'; |
|||
|
|||
$value = isset($options['value']) ? $options['value'] : null; |
|||
$type = isset($options['type']) ? $options['type'] : 'text'; |
|||
|
|||
$fieldParams = ['class'=>'form-control']; |
|||
if (isset($options['class'])) { $fieldParams['class'] .= ' ' . $options['class']; } |
|||
|
|||
$htmlForm .= $this->setFormFieldLabel($name, $options); |
|||
|
|||
if (isset($options['addon'])) { $htmlForm .= '<div class="input-group">'; } |
|||
if (isset($options['addon']['before'])) { |
|||
$htmlForm .= '<span class="input-group-addon">' . $options['addon']['before'] . '</span>'; |
|||
} |
|||
if (isset($options['readonly']) && $options['readonly'] == true) { $fieldParams += ['readonly']; } |
|||
if (isset($options['disabled']) && $options['disabled'] == true) { $fieldParams += ['disabled']; } |
|||
if (isset($options['required']) && $options['required'] == true) { $fieldParams += ['required']; } |
|||
if (isset($options['min'])) { $fieldParams += ['min' => $options['min']]; } |
|||
if (isset($options['placeholder'])) { $fieldParams += ['placeholder' => $options['placeholder']]; } |
|||
if (isset($options['style'])) { $fieldParams += ['style' => $options['style']]; } |
|||
if (isset($options['id'])) { $fieldParams += ['id' => $options['id']]; } |
|||
|
|||
$htmlForm .= Form::input($type, $name, $value, $fieldParams); |
|||
|
|||
if (isset($options['addon']['after'])) { |
|||
$htmlForm .= '<span class="input-group-addon">' . $options['addon']['after'] . '</span>'; |
|||
} |
|||
if (isset($options['addon'])) { $htmlForm .= '</div>'; } |
|||
if (isset($options['info'])) { |
|||
$class = isset($options['info']['class']) ? $options['info']['class'] : 'info'; |
|||
$htmlForm .= '<p class="text-' . $class . ' small">' . $options['info']['text'] . '</p>'; |
|||
} |
|||
$htmlForm .= $this->errorBag->first($name, '<span class="form-error">:message</span>'); |
|||
|
|||
$htmlForm .= '</div>'; |
|||
|
|||
return $htmlForm; |
|||
} |
|||
|
|||
public function textarea($name, $options = []) |
|||
{ |
|||
$hasError = $this->errorBag->has($name) ? 'has-error' : ''; |
|||
$htmlForm = '<div class="form-group ' . $hasError . '">'; |
|||
|
|||
$rows = isset($options['rows']) ? $options['rows'] : 5; |
|||
$value = isset($options['value']) ? $options['value'] : null; |
|||
|
|||
$fieldParams = ['class'=>'form-control','rows' => $rows]; |
|||
|
|||
if (isset($options['readonly']) && $options['readonly'] == true) { $fieldParams += ['readonly']; } |
|||
if (isset($options['disabled']) && $options['disabled'] == true) { $fieldParams += ['disabled']; } |
|||
if (isset($options['required']) && $options['required'] == true) { $fieldParams += ['required']; } |
|||
if (isset($options['placeholder'])) { $fieldParams += ['placeholder' => $options['placeholder']]; } |
|||
|
|||
$htmlForm .= $this->setFormFieldLabel($name, $options); |
|||
|
|||
$htmlForm .= Form::textarea($name, $value, $fieldParams); |
|||
$htmlForm .= $this->errorBag->first($name, '<span class="form-error">:message</span>'); |
|||
$htmlForm .= '</div>'; |
|||
|
|||
return $htmlForm; |
|||
} |
|||
|
|||
public function select($name, $selectOptions, $options = []) |
|||
{ |
|||
$hasError = $this->errorBag->has($name) ? 'has-error' : ''; |
|||
$htmlForm = '<div class="form-group ' . $hasError . '">'; |
|||
|
|||
$value = isset($options['value']) ? $options['value'] : null; |
|||
|
|||
$fieldParams = ['class'=>'form-control']; |
|||
if (isset($options['class'])) { $fieldParams['class'] .= ' ' . $options['class']; } |
|||
|
|||
if (isset($options['readonly']) && $options['readonly'] == true) { $fieldParams += ['readonly']; } |
|||
if (isset($options['disabled']) && $options['disabled'] == true) { $fieldParams += ['disabled']; } |
|||
if (isset($options['required']) && $options['required'] == true) { $fieldParams += ['required']; } |
|||
if (isset($options['multiple']) && $options['multiple'] == true) { $fieldParams += ['multiple', 'name' => $name . '[]']; } |
|||
if (isset($options['placeholder'])) { $fieldParams += ['placeholder' => $options['placeholder']]; } |
|||
|
|||
$htmlForm .= $this->setFormFieldLabel($name, $options); |
|||
|
|||
$htmlForm .= Form::select($name, $selectOptions, $value, $fieldParams); |
|||
$htmlForm .= $this->errorBag->first($name, '<span class="form-error">:message</span>'); |
|||
|
|||
$htmlForm .= '</div>'; |
|||
|
|||
return $htmlForm; |
|||
} |
|||
|
|||
public function multiSelect($name, $selectOptions, $options = []) |
|||
{ |
|||
$options['multiple'] = true; |
|||
|
|||
return $this->select($name, $selectOptions, $options); |
|||
} |
|||
|
|||
public function email($name, $options = []) |
|||
{ |
|||
$options['type'] = 'email'; |
|||
return $this->text($name, $options); |
|||
} |
|||
|
|||
public function password($name, $options = []) |
|||
{ |
|||
$options['type'] = 'password'; |
|||
return $this->text($name, $options); |
|||
} |
|||
|
|||
public function radios($name, array $radioOptions, $options = []) |
|||
{ |
|||
$hasError = $this->errorBag->has($name) ? 'has-error' : ''; |
|||
|
|||
$htmlForm = '<div class="form-group ' . $hasError . '">'; |
|||
$htmlForm .= $this->setFormFieldLabel($name, $options); |
|||
|
|||
$listStyle = isset($options['list_style']) ? $options['list_style'] : 'inline'; |
|||
$htmlForm .= '<ul class="radio list-' . $listStyle . '">'; |
|||
|
|||
foreach ($radioOptions as $key => $option) { |
|||
|
|||
$value = null; |
|||
$fieldParams = ['id' => $name . '_' . $key]; |
|||
|
|||
if (isset($options['value']) && $options['value'] == $key) { $value = true; } |
|||
if (isset($options['v-model'])) { $fieldParams += ['v-model' => $options['v-model']]; } |
|||
|
|||
$htmlForm .= '<li><label for="' . $name . '_' . $key . '">'; |
|||
$htmlForm .= Form::radio($name, $key, $value, $fieldParams); |
|||
$htmlForm .= $option; |
|||
$htmlForm .= ' </label></li>'; |
|||
} |
|||
$htmlForm .= '</ul>'; |
|||
$htmlForm .= $this->errorBag->first($name, '<span class="form-error">:message</span>'); |
|||
|
|||
$htmlForm .= '</div>'; |
|||
|
|||
return $htmlForm; |
|||
} |
|||
|
|||
public function checkboxes($name, array $checkboxOptions, $options = []) |
|||
{ |
|||
$hasError = $this->errorBag->has($name) ? 'has-error' : ''; |
|||
$htmlForm = '<div class="form-group ' . $hasError . '">'; |
|||
|
|||
$htmlForm .= $this->setFormFieldLabel($name, $options); |
|||
|
|||
$listStyle = isset($options['list_style']) ? $options['list_style'] : 'inline'; |
|||
$htmlForm .= '<ul class="checkbox list-' . $listStyle . '">'; |
|||
|
|||
$value = isset($options['value']) ? $options['value'] : new Collection; |
|||
|
|||
foreach ($checkboxOptions as $key => $option) { |
|||
$fieldParams = ['id' => $name . '_' . $key]; |
|||
if (isset($options['v-model'])) { $fieldParams += ['v-model' => $options['v-model']]; } |
|||
|
|||
$htmlForm .= '<li><label for="' . $name . '_' . $key . '">'; |
|||
$htmlForm .= Form::checkbox($name . '[]', $key, $value->contains($key), $fieldParams); |
|||
$htmlForm .= $option; |
|||
$htmlForm .= ' </label></li>'; |
|||
} |
|||
$htmlForm .= '</ul>'; |
|||
$htmlForm .= $this->errorBag->first($name, '<span class="form-error">:message</span>'); |
|||
$htmlForm .= '</div>'; |
|||
|
|||
return $htmlForm; |
|||
} |
|||
|
|||
public function textDisplay($name, $value, $options = []) |
|||
{ |
|||
$label = isset($options['label']) ? $options['label'] : str_split_ucwords($name); |
|||
|
|||
$htmlForm = '<div class="form-group">'; |
|||
$htmlForm .= Form::label($name, $label, ['class'=>'control-label']); |
|||
$htmlForm .= '<div class="form-control" readonly>' . $value . '</div>'; |
|||
$htmlForm .= '</div>'; |
|||
|
|||
return $htmlForm; |
|||
} |
|||
|
|||
public function file($name, $options = []) |
|||
{ |
|||
$hasError = $this->errorBag->has($name) ? 'has-error' : ''; |
|||
$label = isset($options['label']) ? $options['label'] : str_split_ucwords($name); |
|||
|
|||
$htmlForm = '<div class="form-group ' . $hasError . '">'; |
|||
$htmlForm .= $this->setFormFieldLabel($name, $options); |
|||
|
|||
$fieldParams = ['class'=>'form-control']; |
|||
if (isset($options['class'])) { $fieldParams['class'] .= ' ' . $options['class']; } |
|||
if (isset($options['multiple']) && $options['multiple'] == true) { |
|||
$name = $name . '[]'; |
|||
$fieldParams += ['multiple' => true]; |
|||
} |
|||
|
|||
$htmlForm .= Form::file($name, $fieldParams); |
|||
if (isset($options['info'])) { |
|||
$htmlForm .= '<p class="text-' . $options['info']['class'] . ' small">' . $options['info']['text'] . '</p>'; |
|||
} |
|||
$htmlForm .= $this->errorBag->first($name, '<span class="form-error">:message</span>'); |
|||
$htmlForm .= '</div>'; |
|||
|
|||
return $htmlForm; |
|||
} |
|||
|
|||
public function delete($form_params = [], $button_label = 'x', $button_options = [], $hiddenFields = []) |
|||
{ |
|||
$form_params['method'] = 'delete'; |
|||
$form_params['class'] = isset($form_params['class']) ? $form_params['class'] : 'del-form'; |
|||
$form_params['style'] = isset($form_params['style']) ? $form_params['style'] : 'display:inline'; |
|||
|
|||
if (! isset($button_options['class'])) |
|||
$button_options['class'] = 'pull-right'; |
|||
|
|||
if (! isset($button_options['title'])) |
|||
$button_options['title'] = 'Remove this'; |
|||
|
|||
$htmlForm = Form::open($form_params); |
|||
if (!empty($hiddenFields)) |
|||
{ |
|||
foreach ($hiddenFields as $k => $v) |
|||
{ |
|||
$htmlForm .= Form::hidden($k, $v); |
|||
} |
|||
} |
|||
$htmlForm .= Form::submit($button_label, $button_options); |
|||
$htmlForm .= Form::close(); |
|||
|
|||
return $htmlForm; |
|||
} |
|||
|
|||
public function arrays($name, array $fieldKeys, $options = []) |
|||
{ |
|||
$hasError = $this->errorBag->has($name) ? 'has-error' : ''; |
|||
$label = isset($options['label']) ? $options['label'] : str_split_ucwords($name); |
|||
|
|||
$htmlForm = '<div class="form-group ' . $hasError . '">'; |
|||
$htmlForm .= Form::label($name, $label, ['class'=>'control-label']); |
|||
|
|||
if (empty($contents) == false) { |
|||
foreach ($checkboxOptions as $key => $option) { |
|||
$htmlForm .= '<div class="row">'; |
|||
$htmlForm .= Form::text($name . '[]', $key); |
|||
$htmlForm .= '</div>'; |
|||
} |
|||
} |
|||
|
|||
$htmlForm .= '<div class="new-' . $name . ' row">'; |
|||
$htmlForm .= '<div class="col-md-4">'; |
|||
$htmlForm .= Form::text($fieldKeys[0], null, ['class' => 'form-control']); |
|||
$htmlForm .= '</div>'; |
|||
$htmlForm .= '<div class="col-md-8 row">'; |
|||
$htmlForm .= Form::text($fieldKeys[1], null, ['class' => 'form-control']); |
|||
$htmlForm .= '</div>'; |
|||
$htmlForm .= '</div>'; |
|||
$htmlForm .= '<a id="add-service" class="btn btn-info btn-xs pull-right"><i class="fa fa-plus fa-fw"></i></a>'; |
|||
|
|||
$htmlForm .= $this->errorBag->first($name, '<span class="form-error">:message</span>'); |
|||
$htmlForm .= '</div>'; |
|||
|
|||
return $htmlForm; |
|||
} |
|||
|
|||
public function price($name, $options = []) |
|||
{ |
|||
$options['type'] = 'number'; |
|||
$options['addon'] = ['before' => isset($options['currency']) ? $options['currency'] : 'Rp']; |
|||
$options['class'] = 'text-right'; |
|||
return $this->text($name, $options); |
|||
} |
|||
|
|||
private function setFormFieldLabel($name, $options) |
|||
{ |
|||
if (isset($options['label']) && $options['label'] != false) { |
|||
$label = isset($options['label']) ? $options['label'] : str_split_ucwords($name); |
|||
return Form::label($name, $label, ['class'=>'control-label']) . ' '; |
|||
} elseif (! isset($options['label'])) { |
|||
return Form::label($name, str_split_ucwords($name), ['class'=>'control-label']) . ' '; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,35 @@ |
|||
<?php |
|||
|
|||
namespace App\Services; |
|||
|
|||
use App\Entities\Options\Option as SiteOption; |
|||
use Cache; |
|||
|
|||
/** |
|||
* Option Class (Site Option Service) |
|||
*/ |
|||
class Option |
|||
{ |
|||
|
|||
protected $option; |
|||
|
|||
public function __construct() |
|||
{ |
|||
// if (Cache::has('option_all')) {
|
|||
// $this->option = Cache::get('option_all');
|
|||
// } else {
|
|||
// $this->option = SiteOption::all();
|
|||
// Cache::put('option_all', $this->option, 60);
|
|||
// }
|
|||
$this->option = SiteOption::all(); |
|||
} |
|||
|
|||
public function get($key, $default = '') |
|||
{ |
|||
$option = $this->option->where('key', $key)->first(); |
|||
if ($option) { |
|||
return $option->value; |
|||
} |
|||
return $default; |
|||
} |
|||
} |
|||
@ -0,0 +1,217 @@ |
|||
<?php |
|||
|
|||
/** |
|||
* Rupiah Format |
|||
* @param int $number money in integer format |
|||
* @return string money in string format |
|||
*/ |
|||
function formatNo($number) |
|||
{ |
|||
return number_format($number, 0,',','.'); |
|||
} |
|||
|
|||
function formatRp($number) |
|||
{ |
|||
if ($number == 0) { return '-'; } |
|||
if ($number < 0) |
|||
return '- Rp. ' . formatNo(abs($number)); |
|||
|
|||
return 'Rp. ' . formatNo($number); |
|||
} |
|||
|
|||
function formatDecimal($number) |
|||
{ |
|||
return number_format($number, 2,',','.'); |
|||
} |
|||
|
|||
/** |
|||
* Delete button |
|||
* @param array $form_params Delete form attribute |
|||
* @param string $button_label Button text |
|||
* @param array $button_options Button option |
|||
* @return string Delete Button Form |
|||
*/ |
|||
function delete_button($form_params = [], $button_label = 'Delete', $button_options = [], $hiddenFields = []) |
|||
{ |
|||
$form_params['method'] = 'delete'; |
|||
$form_params['class'] = isset($form_params['class']) ? $form_params['class'] : 'del-form'; |
|||
$form_params['style'] = isset($form_params['style']) ? $form_params['style'] : 'display:inline'; |
|||
|
|||
if (! isset($button_options['class'])) |
|||
$button_options['class'] = 'pull-right'; |
|||
|
|||
if (! isset($button_options['title'])) |
|||
$button_options['title'] = 'Delete this record'; |
|||
|
|||
$htmlForm = Form::open($form_params); |
|||
if (!empty($hiddenFields)) |
|||
{ |
|||
foreach ($hiddenFields as $k => $v) |
|||
{ |
|||
$htmlForm .= Form::hidden($k, $v); |
|||
} |
|||
} |
|||
$htmlForm .= Form::submit($button_label, $button_options); |
|||
$htmlForm .= Form::close(); |
|||
|
|||
return $htmlForm; |
|||
} |
|||
|
|||
function formatDate($date) |
|||
{ |
|||
if (!$date || $date == '0000-00-00') |
|||
return null; |
|||
|
|||
$explodedDate = explode('-', $date); |
|||
|
|||
if (count($explodedDate) == 3 && checkdate($explodedDate[1], $explodedDate[0], $explodedDate[2])) { |
|||
return $explodedDate[2] . '-' . $explodedDate[1] . '-' . $explodedDate[0]; |
|||
} else if (count($explodedDate) == 3 && checkdate($explodedDate[1], $explodedDate[2], $explodedDate[0])) { |
|||
return $explodedDate[2] . '-' . $explodedDate[1] . '-' . $explodedDate[0]; |
|||
} |
|||
|
|||
throw new App\Exceptions\InvalidDateException('Kesalahan format tanggal'); |
|||
} |
|||
|
|||
function dateId($date) { |
|||
if (is_null($date) || $date == '0000-00-00') |
|||
return '-'; |
|||
|
|||
$explodedDate = explode('-', $date); |
|||
|
|||
if (count($explodedDate) == 3 && checkdate($explodedDate[1], $explodedDate[2], $explodedDate[0])) { |
|||
$months = getMonths(); |
|||
return $explodedDate[2] . ' ' . $months[$explodedDate[1]] . ' ' . $explodedDate[0]; |
|||
} |
|||
|
|||
throw new App\Exceptions\InvalidDateException('Kesalahan format tanggal'); |
|||
} |
|||
|
|||
function monthNumber($number) { |
|||
return str_pad($number, 2, "0", STR_PAD_LEFT); |
|||
} |
|||
|
|||
function monthId($monthNumber) { |
|||
if (is_null($monthNumber)) |
|||
return $monthNumber; |
|||
|
|||
$months = getMonths(); |
|||
$monthNumber = monthNumber($monthNumber); |
|||
return $months[$monthNumber]; |
|||
} |
|||
|
|||
function getMonths() |
|||
{ |
|||
return [ |
|||
'' => 'Pilih Bulan', |
|||
'01' => 'Januari', |
|||
'02' => 'Pebruari', |
|||
'03' => 'Maret', |
|||
'04' => 'April', |
|||
'05' => 'Mei', |
|||
'06' => 'Juni', |
|||
'07' => 'Juli', |
|||
'08' => 'Agustus', |
|||
'09' => 'September', |
|||
'10' => 'Oktober', |
|||
'11' => 'Nopember', |
|||
'12' => 'Desember', |
|||
]; |
|||
} |
|||
|
|||
function getYears() |
|||
{ |
|||
$yearRange = range(2015, date('Y')); |
|||
foreach ($yearRange as $year) { |
|||
$years[$year] = $year; |
|||
} |
|||
return $years; |
|||
} |
|||
|
|||
function str_split_ucwords($string) |
|||
{ |
|||
return ucwords(str_replace('_', ' ', $string)); |
|||
} |
|||
|
|||
function getDays() |
|||
{ |
|||
return $days = [1 => 'Senin','Selasa','Rabu','Kamis','Jumat','Sabtu']; |
|||
} |
|||
|
|||
function getDay($dayIndex = null) |
|||
{ |
|||
$days = getDays(); |
|||
if (!is_null($dayIndex) && in_array($dayIndex, range(1, 7))) return $days[$dayIndex]; |
|||
|
|||
return '-'; |
|||
} |
|||
|
|||
function sanitizeNumber($number) |
|||
{ |
|||
return str_replace(',', '.', $number); |
|||
} |
|||
|
|||
function formatSizeUnits($bytes) |
|||
{ |
|||
if ($bytes >= 1073741824) |
|||
{ |
|||
$bytes = number_format($bytes / 1073741824, 2) . ' GB'; |
|||
} |
|||
elseif ($bytes >= 1048576) |
|||
{ |
|||
$bytes = number_format($bytes / 1048576, 2) . ' MB'; |
|||
} |
|||
elseif ($bytes >= 1024) |
|||
{ |
|||
$bytes = number_format($bytes / 1024, 2) . ' KB'; |
|||
} |
|||
elseif ($bytes > 1) |
|||
{ |
|||
$bytes = $bytes . ' bytes'; |
|||
} |
|||
elseif ($bytes == 1) |
|||
{ |
|||
$bytes = $bytes . ' byte'; |
|||
} |
|||
else |
|||
{ |
|||
$bytes = '0 bytes'; |
|||
} |
|||
|
|||
return $bytes; |
|||
} |
|||
|
|||
/** |
|||
* Overide Laravel Collective link_to_route helper function
|
|||
* @param string $name Name of route |
|||
* @param string $title Text that displayed on view |
|||
* @param array $parameters URL Parameter |
|||
* @param array $attributes The anchor tag atributes |
|||
*/ |
|||
function html_link_to_route($name, $title = null, $parameters = [], $attributes = []) { |
|||
if (array_key_exists('icon', $attributes)) |
|||
$title = '<i class="fa fa-' . $attributes['icon'] . '"></i> ' . $title; |
|||
|
|||
return app('html')->decode(link_to_route($name, $title, $parameters, $attributes)); |
|||
} |
|||
|
|||
function getProjectStatusesList($statusId = null) { |
|||
$statuses = [1 => 'Planned','On Progress','Done','Closed','Canceled','On Hold']; |
|||
|
|||
if (!is_null($statusId) && array_key_exists($statusId, $statuses)) { |
|||
return $statuses[$statusId]; |
|||
} |
|||
|
|||
return $statuses; |
|||
} |
|||
|
|||
function dateDifference($date1 , $date2 , $differenceFormat = '%m Bulan %d Hari' ) |
|||
{ |
|||
$datetime1 = date_create($date1); |
|||
$datetime2 = date_create($date2); |
|||
|
|||
$interval = date_diff($datetime1, $datetime2); |
|||
|
|||
return $interval->format($differenceFormat); |
|||
|
|||
} |
|||
@ -0,0 +1,51 @@ |
|||
#!/usr/bin/env php |
|||
<?php |
|||
|
|||
/* |
|||
|-------------------------------------------------------------------------- |
|||
| Register The Auto Loader |
|||
|-------------------------------------------------------------------------- |
|||
| |
|||
| Composer provides a convenient, automatically generated class loader |
|||
| for our application. We just need to utilize it! We'll require it |
|||
| into the script here so that we do not have to worry about the |
|||
| loading of any our classes "manually". Feels great to relax. |
|||
| |
|||
*/ |
|||
|
|||
require __DIR__.'/bootstrap/autoload.php'; |
|||
|
|||
$app = require_once __DIR__.'/bootstrap/app.php'; |
|||
|
|||
/* |
|||
|-------------------------------------------------------------------------- |
|||
| Run The Artisan Application |
|||
|-------------------------------------------------------------------------- |
|||
| |
|||
| When we run the console application, the current CLI command will be |
|||
| executed in this console and the response sent back to a terminal |
|||
| or another output device for the developers. Here goes nothing! |
|||
| |
|||
*/ |
|||
|
|||
$kernel = $app->make(Illuminate\Contracts\Console\Kernel::class); |
|||
|
|||
$status = $kernel->handle( |
|||
$input = new Symfony\Component\Console\Input\ArgvInput, |
|||
new Symfony\Component\Console\Output\ConsoleOutput |
|||
); |
|||
|
|||
/* |
|||
|-------------------------------------------------------------------------- |
|||
| Shutdown The Application |
|||
|-------------------------------------------------------------------------- |
|||
| |
|||
| Once Artisan has finished running. We will fire off the shutdown events |
|||
| so that any final work may be done by the application before we shut |
|||
| down the process. This is the last thing to happen to the request. |
|||
| |
|||
*/ |
|||
|
|||
$kernel->terminate($input, $status); |
|||
|
|||
exit($status); |
|||
Some files were not shown because too many files changed in this diff
Write
Preview
Loading…
Cancel
Save
Reference in new issue