Initial Commit

This commit is contained in:
dann4624 2022-09-28 09:38:08 +02:00
parent cac476f80f
commit 2d04a269e6
355 changed files with 52166 additions and 25 deletions

18
.editorconfig Normal file
View File

@ -0,0 +1,18 @@
root = true
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
trim_trailing_whitespace = true
[*.md]
trim_trailing_whitespace = false
[*.{yml,yaml}]
indent_size = 2
[docker-compose.yml]
indent_size = 4

65
.env.example Normal file
View File

@ -0,0 +1,65 @@
APP_NAME="Lagersystem"
APP_ENV=local
APP_KEY=base64:Szw4MlXOTHB+k8WgUzV9F7++EdnDM2DgCakfIkz+/nk=
APP_DEBUG=true
APP_URL=http://localhost
BARCODE_MODE=dynamic
LOGIN_MODE=ldap
LOG_CHANNEL=stack
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=lagerdb2
DB_USERNAME=lageruser
DB_PASSWORD=5F!Y9px0rkV
BROADCAST_DRIVER=log
CACHE_DRIVER=file
FILESYSTEM_DISK=local
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120
MEMCACHED_HOST=127.0.0.1
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_MAILER=mailjet
MAIL_DRIVER=mailjet
MAIL_HOST=in-v3.mailjet.com
MAIL_PORT=587
MAIL_USERNAME=8baac458ffc2b109bcb7c37524986be0
MAIL_PASSWORD=e2842903df91ad9deb940b12cc3e58e1
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=lageradministrationen@itskp-odense.dk
MAIL_FROM_NAME="${APP_NAME}"
MAILJET_APIKEY=8baac458ffc2b109bcb7c37524986be0
MAILJET_APISECRET=e2842903df91ad9deb940b12cc3e58e1
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=
AWS_USE_PATH_STYLE_ENDPOINT=false
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_HOST=
PUSHER_PORT=443
PUSHER_SCHEME=https
PUSHER_APP_CLUSTER=mt1
VITE_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
VITE_PUSHER_HOST="${PUSHER_HOST}"
VITE_PUSHER_PORT="${PUSHER_PORT}"
VITE_PUSHER_SCHEME="${PUSHER_SCHEME}"
VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

11
.gitattributes vendored Normal file
View File

@ -0,0 +1,11 @@
* text=auto
*.blade.php diff=html
*.css diff=css
*.html diff=html
*.md diff=markdown
*.php diff=php
/.github export-ignore
CHANGELOG.md export-ignore
.styleci.yml export-ignore

37
.gitignore vendored
View File

@ -1,25 +1,16 @@
# ---> Laravel /node_modules
/vendor/ /public/build
node_modules/ /public/hot
/public/storage
/storage/*.key
/vendor
.env
.env.backup
.phpunit.result.cache
Homestead.json
Homestead.yaml
auth.json
npm-debug.log npm-debug.log
yarn-error.log yarn-error.log
/.idea
# Laravel 4 specific /.vscode
bootstrap/compiled.php
app/storage/
# Laravel 5 & Lumen specific
public/storage
public/hot
# Laravel 5 & Lumen specific with changed public path
public_html/storage
public_html/hot
storage/*.key
.env
Homestead.yaml
Homestead.json
/.vagrant
.phpunit.result.cache

View File

@ -0,0 +1,26 @@
<?php
namespace Mailjet\LaravelMailjet;
use Illuminate\Mail\MailServiceProvider;
use Mailjet\LaravelMailjet\Transport\MailjetTransport;
class MailjetMailServiceProvider extends MailServiceProvider
{
/**
* Extended register the Swift Transport instance.
*
* @return void
*/
protected function registerSwiftTransport()
{
parent::registerSwiftTransport();
app('swift.transport')->extend('mailjet', function ($app) {
$config = $this->app['config']->get('services.mailjet', array());
$call = $this->app['config']->get('services.mailjet.transactionnal.call', true);
$options = $this->app['config']->get('services.mailjet.transactionnal.options', array());
return new MailjetTransport(new \Swift_Events_SimpleEventDispatcher(), $config['key'], $config['secret'], $call, $options);
});
}
}

View File

@ -0,0 +1,57 @@
<?php
declare(strict_types=1);
namespace Mailjet\LaravelMailjet;
use Illuminate\Support\Facades\Mail;
use Illuminate\Support\ServiceProvider;
use Mailjet\LaravelMailjet\Services\MailjetService;
use Symfony\Component\Mailer\Bridge\Mailjet\Transport\MailjetTransportFactory;
use Symfony\Component\Mailer\Transport\Dsn;
class MailjetServiceProvider extends ServiceProvider
{
/**
* Bootstrap the application services.
*
* @return void
*/
public function boot(): void
{
Mail::extend('mailjet', function () {
return (new MailjetTransportFactory)->create(
new Dsn(
'mailjet+api',
'default',
config('services.mailjet.key'),
config('services.mailjet.secret')
)
);
});
}
/**
* Register the application services.
*
* @return void
*/
public function register(): void
{
$this->app->singleton('Mailjet', function () {
$config = $this->app['config']->get('services.mailjet', []);
$call = $this->app['config']->get('services.mailjet.common.call', true);
$options = $this->app['config']->get('services.mailjet.common.options', []);
return new MailjetService($config['key'], $config['secret'], $call, $options);
});
}
/**
* @return array
*/
public function provides(): array
{
return ['mailjet'];
}
}

View File

@ -0,0 +1 @@
Copy the files into the "\vendor\mailjet\laravel-mailjet\src" directory

View File

@ -1,3 +1,66 @@
# Lager-v3 <p align="center"><a href="https://laravel.com" target="_blank"><img src="https://raw.githubusercontent.com/laravel/art/master/logo-lockup/5%20SVG/2%20CMYK/1%20Full%20Color/laravel-logolockup-cmyk-red.svg" width="400" alt="Laravel Logo"></a></p>
Redesign of the lending system <p align="center">
<a href="https://travis-ci.org/laravel/framework"><img src="https://travis-ci.org/laravel/framework.svg" alt="Build Status"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/dt/laravel/framework" alt="Total Downloads"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/v/laravel/framework" alt="Latest Stable Version"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/l/laravel/framework" alt="License"></a>
</p>
## About Laravel
Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:
- [Simple, fast routing engine](https://laravel.com/docs/routing).
- [Powerful dependency injection container](https://laravel.com/docs/container).
- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage.
- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent).
- Database agnostic [schema migrations](https://laravel.com/docs/migrations).
- [Robust background job processing](https://laravel.com/docs/queues).
- [Real-time event broadcasting](https://laravel.com/docs/broadcasting).
Laravel is accessible, powerful, and provides tools required for large, robust applications.
## Learning Laravel
Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework.
You may also try the [Laravel Bootcamp](https://bootcamp.laravel.com), where you will be guided through building a modern Laravel application from scratch.
If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains over 2000 video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library.
## Laravel Sponsors
We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the Laravel [Patreon page](https://patreon.com/taylorotwell).
### Premium Partners
- **[Vehikl](https://vehikl.com/)**
- **[Tighten Co.](https://tighten.co)**
- **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)**
- **[64 Robots](https://64robots.com)**
- **[Cubet Techno Labs](https://cubettech.com)**
- **[Cyber-Duck](https://cyber-duck.co.uk)**
- **[Many](https://www.many.co.uk)**
- **[Webdock, Fast VPS Hosting](https://www.webdock.io/en)**
- **[DevSquad](https://devsquad.com)**
- **[Curotec](https://www.curotec.com/services/technologies/laravel/)**
- **[OP.GG](https://op.gg)**
- **[WebReinvent](https://webreinvent.com/?utm_source=laravel&utm_medium=github&utm_campaign=patreon-sponsors)**
- **[Lendio](https://lendio.com)**
## Contributing
Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions).
## Code of Conduct
In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct).
## Security Vulnerabilities
If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [taylor@laravel.com](mailto:taylor@laravel.com). All security vulnerabilities will be promptly addressed.
## License
The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).

32
app/Console/Kernel.php Normal file
View File

@ -0,0 +1,32 @@
<?php
namespace App\Console;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
class Kernel extends ConsoleKernel
{
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
// $schedule->command('inspire')->hourly();
}
/**
* Register the commands for the application.
*
* @return void
*/
protected function commands()
{
$this->load(__DIR__.'/Commands');
require base_path('routes/console.php');
}
}

View File

@ -0,0 +1,50 @@
<?php
namespace App\Exceptions;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Throwable;
class Handler extends ExceptionHandler
{
/**
* A list of exception types with their corresponding custom log levels.
*
* @var array<class-string<\Throwable>, \Psr\Log\LogLevel::*>
*/
protected $levels = [
//
];
/**
* A list of the exception types that are not reported.
*
* @var array<int, class-string<\Throwable>>
*/
protected $dontReport = [
//
];
/**
* A list of the inputs that are never flashed to the session on validation exceptions.
*
* @var array<int, string>
*/
protected $dontFlash = [
'current_password',
'password',
'password_confirmation',
];
/**
* Register the exception handling callbacks for the application.
*
* @return void
*/
public function register()
{
$this->reportable(function (Throwable $e) {
//
});
}
}

220
app/Helpers/Logger.php Normal file
View File

@ -0,0 +1,220 @@
<?php
namespace App\Helpers;
use App\Models\Log;
use App\Models\LogAction;
use Illuminate\Support\Facades\Auth;
class Logger
{
public static function LogCreated(int $loggable_id, string $loggable_type,int $amount = Null, int $target = Null,string $logMessage = Null): void
{
$log = new Log();
$log->user()->associate(Auth::id());
$log->action()->associate(LogAction::firstWhere('name', '=', 'created'));
$log->loggable_type = $loggable_type;
$log->loggable_id = $loggable_id;
$log->target_id = $target;
$log->amount = $amount;
$log->log = $logMessage;
$log->save();
}
public static function LogEdited(int $loggable_id, string $loggable_type,string $logMessage, int $amount = Null, int $target = Null): void
{
$log = new Log();
$log->user()->associate(Auth::id());
$log->action()->associate(LogAction::firstWhere('name', '=', 'edited'));
$log->loggable_type = $loggable_type;
$log->loggable_id = $loggable_id;
$log->target_id = $target;
$log->amount = $amount;
$log->log = $logMessage;
$log->save();
}
public static function LogDeleted(int $loggable_id, string $loggable_type,int $amount = Null, int $target = Null,string $logMessage = Null): void
{
$log = new Log();
$log->user()->associate(Auth::id());
$log->action()->associate(LogAction::firstWhere('name', '=', 'deleted'));
$log->loggable_type = $loggable_type;
$log->loggable_id = $loggable_id;
$log->target_id = $target;
$log->amount = $amount;
$log->log = $logMessage;
$log->save();
}
public static function LogForceDeleted(int $loggable_id, string $loggable_type, string $logMessage = Null,int $amount = Null,int $target = Null,): void
{
$log = new Log();
$log->user()->associate(Auth::id());
$log->action()->associate(LogAction::firstWhere('name', '=', 'force_deleted'));
$log->loggable_type = $loggable_type;
$log->loggable_id = $loggable_id;
$log->target_id = $target;
$log->amount = $amount;
$log->log = $logMessage;
$log->save();
}
public static function LogRestored(int $loggable_id, string $loggable_type, int $amount = Null, int $target = Null,string $logMessage = Null): void
{
$log = new Log();
$log->user()->associate(Auth::id());
$log->action()->associate(LogAction::firstWhere('name', '=', 'restored'));
$log->loggable_type = $loggable_type;
$log->loggable_id = $loggable_id;
$log->target_id = $target;
$log->amount = $amount;
$log->log = $logMessage;
$log->save();
}
public static function LogLent(int $loggable_id, string $loggable_type,int $amount, int $target,string $logMessage = Null): void
{
$log = new Log();
$log->user()->associate(Auth::id());
$log->action()->associate(LogAction::firstWhere('name', '=', 'lent'));
$log->loggable_type = $loggable_type;
$log->loggable_id = $loggable_id;
$log->target_id = $target;
$log->amount = $amount;
$log->log = $logMessage;
$log->save();
}
public static function LogReturn(int $loggable_id, string $loggable_type,int $amount, int $target = Null,string $logMessage = Null): void
{
$log = new Log();
$log->user()->associate(Auth::id());
$log->action()->associate(LogAction::firstWhere('name', '=', 'returned'));
$log->loggable_type = $loggable_type;
$log->loggable_id = $loggable_id;
$log->target_id = $target;
$log->amount = $amount;
$log->log = $logMessage;
$log->save();
}
public static function LogSetup(int $loggable_id, string $loggable_type,int $amount, int $target = Null,string $logMessage = Null): void
{
$log = new Log();
$log->user()->associate(Auth::id());
$log->action()->associate(LogAction::firstWhere('name', '=', 'set up'));
$log->loggable_type = $loggable_type;
$log->loggable_id = $loggable_id;
$log->target_id = $target;
$log->amount = $amount;
$log->log = $logMessage;
$log->save();
}
public static function LogPickup(int $loggable_id, string $loggable_type, int $amount, int $target = Null,string $logMessage = Null): void
{
$log = new Log();
$log->user()->associate(Auth::id());
$log->action()->associate(LogAction::firstWhere('name', '=', 'picked up'));
$log->loggable_type = $loggable_type;
$log->loggable_id = $loggable_id;
$log->target_id = $target;
$log->amount = $amount;
$log->log = $logMessage;
$log->save();
}
public static function LogAdjusted(int $loggable_id, string $loggable_type,string $logMessage, int $amount = Null, int $target = Null): void
{
$log = new Log();
$log->user()->associate(Auth::id());
$log->action()->associate(LogAction::firstWhere('name', '=', 'adjusted'));
$log->loggable_type = $loggable_type;
$log->loggable_id = $loggable_id;
$log->target_id = $target;
$log->amount = $amount;
$log->log = $logMessage;
$log->save();
}
public static function LogAmountAdded(int $loggable_id, string $loggable_type,int $amount,string $logMessage = Null, int $target = Null): void
{
$log = new Log();
$log->user()->associate(Auth::id());
$log->action()->associate(LogAction::firstWhere('name', '=', 'amount_added'));
$log->loggable_type = $loggable_type;
$log->loggable_id = $loggable_id;
$log->target_id = $target;
$log->amount = $amount;
$log->log = $logMessage;
$log->save();
}
public static function LogAmountRemoved(int $loggable_id, string $loggable_type,int $amount,string $logMessage = Null, int $target = Null): void
{
$log = new Log();
$log->user()->associate(Auth::id());
$log->action()->associate(LogAction::firstWhere('name', '=', 'amount_removed'));
$log->loggable_type = $loggable_type;
$log->loggable_id = $loggable_id;
$log->target_id = $target;
$log->amount = $amount;
$log->log = $logMessage;
$log->save();
}
public static function LogReserved(int $loggable_id, string $loggable_type,int $amount, int $target, string $logMessage = Null): void
{
$log = new Log();
$log->user()->associate(Auth::id());
$log->action()->associate(LogAction::firstWhere('name', '=', 'reserved'));
$log->loggable_type = $loggable_type;
$log->loggable_id = $loggable_id;
$log->target_id = $target;
$log->amount = $amount;
$log->log = $logMessage;
$log->save();
}
public static function LogValidated(int $loggable_id, string $loggable_type, int $target,int $amount = Null, string $logMessage = Null): void
{
$log = new Log();
$log->user()->associate(Auth::id());
$log->action()->associate(LogAction::firstWhere('name', '=', 'validated'));
$log->loggable_type = $loggable_type;
$log->loggable_id = $loggable_id;
$log->target_id = $target;
$log->amount = $amount;
$log->log = $logMessage;
$log->save();
}
public static function LogCancelled(int $loggable_id, string $loggable_type, int $target,int $amount = Null, string $logMessage = Null): void
{
$log = new Log();
$log->user()->associate(Auth::id());
$log->action()->associate(LogAction::firstWhere('name', '=', 'cancelled'));
$log->loggable_type = $loggable_type;
$log->loggable_id = $loggable_id;
$log->target_id = $target;
$log->amount = $amount;
$log->log = $logMessage;
$log->save();
}
public static function LogNote(int $loggable_id, string $loggable_type, int $target,string $logMessage, int $amount = Null): void
{
$log = new Log();
$log->user()->associate(Auth::id());
$log->action()->associate(LogAction::firstWhere('name', '=', 'note'));
$log->loggable_type = $loggable_type;
$log->loggable_id = $loggable_id;
$log->target_id = $target;
$log->amount = $amount;
$log->log = $logMessage;
$log->save();
}
}

View File

@ -0,0 +1,40 @@
<?php
namespace App\Helpers;
use Illuminate\Container\Container;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Pagination\Paginator;
use Illuminate\Support\Collection;
class PaginationHelper
{
public static function paginate(Collection $results, $pageSize)
{
$page = Paginator::resolveCurrentPage('page');
$total = $results->count();
return self::paginator($results->forPage($page, $pageSize), $total, $pageSize, $page, [
'path' => Paginator::resolveCurrentPath(),
'pageName' => 'page',
]);
}
/**
* Create a new length-aware paginator instance.
*
* @param \Illuminate\Support\Collection $items
* @param int $total
* @param int $perPage
* @param int $currentPage
* @param array $options
* @return \Illuminate\Pagination\LengthAwarePaginator
*/
protected static function paginator($items, $total, $perPage, $currentPage, $options)
{
return Container::getInstance()->makeWith(LengthAwarePaginator::class, compact(
'items', 'total', 'perPage', 'currentPage', 'options'
));
}
}

View File

@ -0,0 +1,118 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use App\Models\LoanerType;
use App\Models\Permission;
use App\Models\Role;
use App\Models\User;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Contracts\View\Factory;
use Illuminate\Contracts\View\View;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Session;
class LoginController extends Controller
{
/**
* checks login credentials
* @param Request $request
* @return RedirectResponse
*/
public function authenticate(Request $request)
{
//validates username and password
$credentials = $request->validate([
'username' => ['required','string'],
'password' => ['required'],
]);
//gets the user
$user = User::firstWhere('username', "=", $request['username']);
//if user is an AD User or not in the database Check login with AD LDAP
switch(config('app.login_mode')){
case('db'):
if (Auth::guard('nadUser')->attempt($credentials)) {
$request->session()->regenerate();
return $this->getRedirect($user);
}
break;
default:
if (empty($user)) {
//check if user exist on the AD and if it does import the data form the ad and make it an AD User
if ($adUser = \LdapRecord\Models\ActiveDirectory\User::findBy('samaccountname', $request['username'])) {
echo $adUser;
$ad_parts = explode(',',$adUser);
$name_parts = explode('=',$ad_parts[0]);
$name = $name_parts[1];
$ad_user = new User();
$ad_user->guid = $adUser->getConvertedGuid();
$ad_user->domain = 'default';
$ad_user->name = $name;
$ad_user->username = $request['username'];
$ad_user->password = Hash::make($request['password']);
$ad_user->loanerType()->associate(LoanerType::firstWhere('name', "=", 'adUser')->id);
$ad_user->role()->associate(Role::firstWhere('name', "=", 'Elev')->id);
$ad_user->save();
//login with AD
if (Auth::guard('adUser')->attempt(['samaccountname' => $credentials['username'], 'password' => $credentials['password']])) {
$request->session()->regenerate();
return redirect()->route('users.show',['user' => $user]);
}
}
}
elseif($user->loanerType->name === 'adUser'){
if (Auth::guard('adUser')->attempt(['samaccountname' => $credentials['username'], 'password' => $credentials['password']])) {
$request->session()->regenerate();
return redirect()->route('users.show',['user' => $user]);
}
}
elseif ($user->loanerType->name === 'nadUser') {
if (Auth::guard('nadUser')->attempt($credentials)) {
$request->session()->regenerate();
return redirect()->route('users.show',['user' => $user]);
}
}
break;
}
//if the login fails
Auth::logout();
Session::flush();
return back()->withInput($request->input())->withErrors([
'username' => 'The provided credentials do not match our records.',
]);
}
/**
* returns the login page
* @return Application|Factory|View|RedirectResponse
*/
public function login()
{
if(Auth::check()){
return $this->getRedirect(Auth::user());
}
return view('login');
}
/**
* logs a user out of the system
* @return RedirectResponse
*/
public function logout()
{
Auth::logout();
Session::flush();
return redirect()->intended('login');
}
}

View File

@ -0,0 +1,260 @@
<?php
namespace App\Http\Controllers\Cabel;
use App\Helpers\Logger;
use App\Helpers\PaginationHelper;
use App\Http\Controllers\Controller;
use App\Models\CabelCategory;
use App\Models\Permission;
use Illuminate\Auth\Access\Response;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
class CabelCategoryController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View
*/
public function index(Request $request)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'cabelCategories_viewAny'))
? Response::allow()
: Response::deny('you are not the chosen one');
$search_types = [];
array_push($search_types,array("value" => "name", "name" => "name"));
$PerPagination = $request->input('p') ?? 10;
$search_term = $request->input('search_term');
$search_type = $request->input('search_type');
$search_compare = $request->input('search_compare');
if($search_term != ""){
switch ($search_type){
case "name":
switch($search_compare){
case("="):
$categories = CabelCategory::where('name','=',$search_term)->paginate($PerPagination);
break;
default:
$categories = CabelCategory::where('name','like','%' . $search_term . '%')->paginate($PerPagination);
break;
}
break;
}
}
else{
$categories = CabelCategory::Paginate($PerPagination);
}
return view('cabelCategories.index')
->with('search_types',$search_types)
->with('data',$categories)
->with('data_name','cabelCategory')
->with('data_names','cabelCategories')
;
}
/**
* Display a listing of the resource.
*
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View
*/
public function deleted(Request $request)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'cabelCategories_viewAny_deleted'))
? Response::allow()
: Response::deny('you are not the chosen one');
$search_types = [];
array_push($search_types,array("value" => "building", "name" => "building"));
array_push($search_types,array("value" => "room", "name" => "room"));
$PerPagination = $request->input('p') ?? 10;
$search_term = $request->input('search_term');
$search_type = $request->input('search_type');
$search_compare = $request->input('search_compare');
if($search_term != ""){
switch ($search_type){
case "name":
switch($search_compare){
case("="):
$categories = CabelCategory::onlyTrashed()->where('name','=',$search_term)->paginate($PerPagination);
break;
default:
$categories = CabelCategory::onlyTrashed()->where('name','like','%' . $search_term . '%')->paginate($PerPagination);
break;
}
break;
}
}
else{
$categories = CabelCategory::onlyTrashed()->paginate($PerPagination);
}
return view('cabelCategories.deleted')
->with('search_types',$search_types)
->with('data',$categories)
->with('data_name','cabelCategory')
;
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View
*/
public function create()
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'cabelCategories_create'))
? Response::allow()
: Response::deny('you are not the chosen one');
return view('cabelCategories.create');
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\RedirectResponse
*/
public function store(Request $request)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'cabelCategories_create'))
? Response::allow()
: Response::deny('you are not the chosen one');
$category = new CabelCategory();
$category->name = $request->name;
$category->save();
Logger::LogCreated($category->id,get_class($category));
return redirect()->route('cabelCategories.show',['cabelCategory' => $category]);
}
/**
* Display the specified resource.
*
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View
*/
public function show($cabelcategory)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'cabelCategories_view'))
? Response::allow()
: Response::deny('you are not the chosen one');
$object = CabelCategory::where('id','=',$cabelcategory)->withTrashed()->first();
return view('cabelCategories.show')
->with('data',$object)
->with('data_name','cabelCategory')
;
}
/**
* Show the form for editing the specified resource.
*
* @param \App\Models\CabelCategory $cabelcategory
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View
*/
public function edit($cabelcategory)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'cabelCategories_edit'))
? Response::allow()
: Response::deny('you are not the chosen one');
$object = CabelCategory::where('id','=',$cabelcategory)->withTrashed()->first();
return view('cabelCategories.edit')
->with('data',$object)
->with('data_name','cabelCategory')
;
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param \App\Models\CabelCategory $cabelcategory
* @return \Illuminate\Http\RedirectResponse
*/
public function update(Request $request, $cabelcategory)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'cabelCategories_edit'))
? Response::allow()
: Response::deny('you are not the chosen one');
$object = CabelCategory::where('id','=',$cabelcategory)->withTrashed()->first();
Logger::LogEdited($object->id,get_class($object),"Navn : ".$object->name." til ".$request->name);
$object->name = $request->name;
$object->save();
return redirect()->route('cabelCategories.show',['cabelCategory' => $object]);
}
/**
* Remove the specified resource from storage.
*
* @param \App\Models\CabelCategory $cabelcategory
* @return \Illuminate\Http\RedirectResponse
*/
public function destroy($cabelcategory)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'cabelCategories_delete'))
? Response::allow()
: Response::deny('you are not the chosen one');
$object = CabelCategory::where('id','=',$cabelcategory)->withTrashed()->first();
Logger::LogDeleted($object->id,get_class($object));
$object->delete();
return redirect()->route('cabelCategories.index');
}
/**
* Remove the specified resource from storage.
*
* @param \App\Models\CabelCategory $cabelcategory
* @return \Illuminate\Http\RedirectResponse
*/
public function delete_force($cabelcategory)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'cabelCategories_delete_force'))
? Response::allow()
: Response::deny('you are not the chosen one');
$object = CabelCategory::where('id','=',$cabelcategory)->withTrashed()->first();
Logger::LogForceDeleted($object->id,get_class($object));
$object->forceDelete();
return redirect()->route('cabelCategories.deleted');
}
/**
* Remove the specified resource from storage.
*
* @param \App\Models\CabelCategory $cabelcategory
* @return \Illuminate\Http\RedirectResponse
*/
public function restore($cabelcategory)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'cabelCategories_restore'))
? Response::allow()
: Response::deny('you are not the chosen one');
$object = CabelCategory::where('id','=',$cabelcategory)->withTrashed()->first();
$object->restore();
Logger::LogRestored($object->id,get_class($object));
return redirect()->route('cabelCategories.deleted');
}
}

View File

@ -0,0 +1,519 @@
<?php
namespace App\Http\Controllers\Cabel;
use App\Helpers\Logger;
use App\Helpers\PaginationHelper;
use App\Http\Controllers\Controller;
use App\Models\Cabel;
use App\Models\CabelCategory;
use App\Models\Permission;
use App\Models\Product;
use Illuminate\Auth\Access\Response;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
class CabelController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View
*/
public function index(Request $request)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'cabels_viewAny'))
? Response::allow()
: Response::deny('you are not the chosen one');
$search_types = [];
array_push($search_types,array("value" => "name", "name" => "name"));
array_push($search_types,array("value" => "category", "name" => "category"));
array_push($search_types,array("value" => "available", "name" => "available"));
array_push($search_types,array("value" => "loans", "name" => "loaned"));
array_push($search_types,array("value" => "reservations", "name" => "reserved"));
array_push($search_types,array("value" => "total", "name" => "total"));
$PerPagination = $request->input('p') ?? 10;
$search_term = $request->input('search_term');
$search_type = $request->input('search_type');
$search_compare = $request->input('search_compare');
if($search_term != ""){
switch ($search_type){
case "category":
switch($search_compare){
case("="):
$cabels = Cabel::where(function ($query) use ($search_term){
$query->whereHas('category',function ($query) use ($search_term){
$query->where('name','=',$search_term);
});
})->paginate($PerPagination);
break;
default:
$cabels = Cabel::where(function ($query) use ($search_term){
$query->whereHas('category',function ($query) use ($search_term){
$query->where('name','like','%' . $search_term . '%');
});
})->paginate($PerPagination);
break;
}
break;
case "name":
switch($search_compare){
case("="):
$cabels = Cabel::where('name','=',$search_term)->paginate($PerPagination);
break;
default:
$cabels = Cabel::where('name','like','%' . $search_term . '%')->paginate($PerPagination);
break;
}
break;
case "available":
$all_cabels = Cabel::all();
$cabel_collection = collect();
foreach($all_cabels as $cabel){
$loans = count($cabel->loans);
$reservations = count($cabel->reservations);
$total = $cabel->total;
$available = $total - ($loans + $reservations);
switch($search_compare){
case(">="):
if($available >= $search_term){
$cabel_collection->add($cabel);
}
break;
case("<="):
if($available <= $search_term){
$cabel_collection->add($cabel);
}
break;
case("="):
if($available == $search_term){
$cabel_collection->add($cabel);
}
break;
default:
if($available == $search_term){
$cabel_collection->add($cabel);
}
break;
}
}
$cabels = PaginationHelper::paginate($cabel_collection, $PerPagination);
break;
case "loans":
switch($search_compare){
case(">="):
$cabels = Cabel::has('loans', '>=' , $search_term)->paginate($PerPagination);
break;
case("<="):
$cabels = Cabel::has('loans', '<=' , $search_term)->paginate($PerPagination);
break;
case("="):
$cabels = Cabel::has('loans', '=' , $search_term)->paginate($PerPagination);
break;
default:
$cabels = Cabel::has('loans', '=' , $search_term)->paginate($PerPagination);
break;
}
break;
case "reservations":
switch($search_compare){
case(">="):
$cabels = Cabel::has('reservations', '>=' , $search_term)->paginate($PerPagination);
break;
case("<="):
$cabels = Cabel::has('reservations', '<=' , $search_term)->paginate($PerPagination);
break;
case("="):
$cabels = Cabel::has('reservations', '=' , $search_term)->paginate($PerPagination);
break;
default:
$cabels = Cabel::has('reservations', '=' , $search_term)->paginate($PerPagination);
break;
}
break;
case "total":
switch($search_compare){
case(">="):
$cabels = Cabel::where('total','>=',$search_term)->paginate($PerPagination);
break;
case("<="):
$cabels = Cabel::where('total','<=',$search_term)->paginate($PerPagination);
break;
case("="):
$cabels = Cabel::where('total','=',$search_term)->paginate($PerPagination);
break;
default:
$cabels = Cabel::where('total','=',$search_term)->paginate($PerPagination);
break;
}
break;
}
}
else{
$cabels = Cabel::paginate($PerPagination);
}
return view('cabels.index')
->with('search_types',$search_types)
->with('data',$cabels)
->with('data_name','cabel')
->with('data_names','cabels')
;
}
/**
* Display a listing of the resource.
*
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View
*/
public function deleted(Request $request)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'cabels_viewAny_deleted'))
? Response::allow()
: Response::deny('you are not the chosen one');
$search_types = [];
array_push($search_types,array("value" => "name", "name" => "name"));
array_push($search_types,array("value" => "category", "name" => "category"));
array_push($search_types,array("value" => "available", "name" => "available"));
array_push($search_types,array("value" => "loans", "name" => "loaned"));
array_push($search_types,array("value" => "reservations", "name" => "reserved"));
array_push($search_types,array("value" => "total", "name" => "total"));
$PerPagination = $request->input('p') ?? 10;
$search_term = $request->input('search_term');
$search_type = $request->input('search_type');
$search_compare = $request->input('search_compare');
if($search_term != ""){
switch ($search_type){
case "category":
switch($search_compare){
case("="):
$cabels = Cabel::onlyTrashed()->where(function ($query) use ($search_term){
$query->whereHas('category',function ($query) use ($search_term){
$query->where('name','=',$search_term);
});
})->paginate($PerPagination);
break;
default:
$cabels = Cabel::onlyTrashed()->where(function ($query) use ($search_term){
$query->whereHas('category',function ($query) use ($search_term){
$query->where('name','like','%' . $search_term . '%');
});
})->paginate($PerPagination);
break;
}
break;
case "name":
switch($search_compare){
case("="):
$cabels = Cabel::onlyTrashed()->where('name','=',$search_term)->paginate($PerPagination);
break;
default:
$cabels = Cabel::onlyTrashed()->where('name','like','%' . $search_term . '%')->paginate($PerPagination);
break;
}
break;
case "available":
$all_cabels = Cabel::all();
$cabel_collection = collect();
foreach($all_cabels as $cabel){
$loans = count($cabel->loans);
$reservations = count($cabel->reservations);
$total = $cabel->total;
$available = $total - ($loans + $reservations);
switch($search_compare){
case(">="):
if($available >= $search_term){
$cabel_collection->add($cabel);
}
break;
case("<="):
if($available <= $search_term){
$cabel_collection->add($cabel);
}
break;
case("="):
if($available == $search_term){
$cabel_collection->add($cabel);
}
break;
default:
if($available == $search_term){
$cabel_collection->add($cabel);
}
break;
}
}
$cabels = PaginationHelper::paginate($cabel_collection, $PerPagination);
break;
case "loans":
switch($search_compare){
case(">="):
$cabels = Cabel::has('loans', '>=' , $search_term)->paginate($PerPagination);
break;
case("<="):
$cabels = Cabel::has('loans', '<=' , $search_term)->paginate($PerPagination);
break;
case("="):
$cabels = Cabel::has('loans', '=' , $search_term)->paginate($PerPagination);
break;
default:
$cabels = Cabel::has('loans', '=' , $search_term)->paginate($PerPagination);
break;
}
break;
case "reservations":
switch($search_compare){
case(">="):
$cabels = Cabel::has('reservations', '>=' , $search_term)->paginate($PerPagination);
break;
case("<="):
$cabels = Cabel::has('reservations', '<=' , $search_term)->paginate($PerPagination);
break;
case("="):
$cabels = Cabel::has('reservations', '=' , $search_term)->paginate($PerPagination);
break;
default:
$cabels = Cabel::has('reservations', '=' , $search_term)->paginate($PerPagination);
break;
}
break;
case "total":
switch($search_compare){
case(">="):
$cabels = Cabel::where('total','>=',$search_term)->paginate($PerPagination);
break;
case("<="):
$cabels = Cabel::where('total','<=',$search_term)->paginate($PerPagination);
break;
case("="):
$cabels = Cabel::where('total','=',$search_term)->paginate($PerPagination);
break;
default:
$cabels = Cabel::where('total','=',$search_term)->paginate($PerPagination);
break;
}
break;
}
}
else{
$cabels = Cabel::onlyTrashed()->paginate($PerPagination);
}
return view('cabels.deleted')
->with('search_types',$search_types)
->with('data',$cabels)
->with('data_name','cabel')
->with('data_names','cabels')
;
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View
*/
public function create()
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'cabels_create'))
? Response::allow()
: Response::deny('you are not the chosen one');
return view('cabels.create')
->with('categories',CabelCategory::all())
;
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\RedirectResponse
*/
public function store(Request $request)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'cabels_create'))
? Response::allow()
: Response::deny('you are not the chosen one');
$cabel = new Cabel();
$cabel->cabel_category_id = $request->category_id;
$cabel->name = $request->name;
$cabel->save();
Logger::LogCreated($cabel->id,get_class($cabel));
return redirect()->route('cabels.show',['cabel' => $cabel]);
}
/**
* Display the specified resource.
*
* @param \App\Models\Cabel $cabel
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View
*/
public function show($cabel)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'cabels_view'))
? Response::allow()
: Response::deny('you are not the chosen one');
$object = Cabel::where('id','=',$cabel)->withTrashed()->first();
return view('cabels.show')
->with('data',$object)
->with('data_name','cabel')
;
}
/**
* Show the form for editing the specified resource.
*
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View
*/
public function edit($cabel)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'cabels_edit'))
? Response::allow()
: Response::deny('you are not the chosen one');
$object = Cabel::where('id','=',$cabel)->withTrashed()->first();
return view('cabels.edit')
->with('categories',CabelCategory::all())
->with('data',$object)
->with('data_name','cabel')
;
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\RedirectResponse
*/
public function update(Request $request,$cabel)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'cabels_edit'))
? Response::allow()
: Response::deny('you are not the chosen one');
$object = Cabel::where('id','=',$cabel)->withTrashed()->first();
if($object->cabel_category_id != $request->category_id){
$CabelCategory = CabelCategory::where('id','=',$request->category_id)->first();
Logger::LogEdited($object->id,get_class($object),$logMessage = "Kategori : ".$object->category->name." til ".$CabelCategory->name);
$object->cabel_category_id = $request->category_id;
}
if($object->name != $request->name){
Logger::LogEdited($object->id,get_class($object),$logMessage = "Navn : ".$object->name." til ".$request->name);
$object->name = $request->name;
}
$object->save();
return redirect()->route('cabels.show',['cabel' => $cabel]);
}
/**
* Remove the specified resource from storage.
*
* @return \Illuminate\Http\RedirectResponse
*/
public function destroy($cabel)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'cabels_delete'))
? Response::allow()
: Response::deny('you are not the chosen one');
$object = Cabel::where('id','=',$cabel)->withTrashed()->first();
Logger::LogDeleted($object->id,get_class($object));
$object->delete();
return redirect()->route('cabels.index');
}
/**
* Permanently Remove the specified resource from storage.
*
* @return \Illuminate\Http\RedirectResponse
*/
public function delete_force($cabel)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'cabels_delete_force'))
? Response::allow()
: Response::deny('you are not the chosen one');
$object = Cabel::withTrashed()->where('id','=',$cabel)->first();
Logger::LogForceDeleted($object->id,get_class($object));
$object->forceDelete();
return redirect()->route('cabels.index');
}
/**
* Restore the specified resource from storage.
*
* @return \Illuminate\Http\RedirectResponse
*/
public function restore($cabel)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'cabels_restore'))
? Response::allow()
: Response::deny('you are not the chosen one');
$object = Cabel::withTrashed()->where('id','=',$cabel)->first();
$object->restore();
Logger::LogRestored($object->id,get_class($object));
return redirect()->route('cabels.deleted');
}
/**
* Add the specified amount to the Pool.
*
* @return \Illuminate\Http\RedirectResponse
*/
public function amount_add($cabel,Request $request)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'cabels_amount_add'))
? Response::allow()
: Response::deny('you are not the chosen one');
$object = Cabel::where('id','=',$cabel)->first();
$object->total += $request->amount;
$object->save();
Logger::LogAmountAdded($object->id,get_class($object),$request->amount);
return redirect()->route('cabels.show',['cabel' => $cabel]);
}
/**Logger::LogAmountAdded($object->id,get_class($object),$request->amount);
* Remove the specified amount from the Pool.
*
* @return \Illuminate\Http\RedirectResponse
*/
public function amount_remove($cabel,Request $request)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'cabels_amount_remove'))
? Response::allow()
: Response::deny('you are not the chosen one');
$object = Cabel::where('id','=',$cabel)->first();
$object->total -= $request->amount;
$object->save();
Logger::LogAmountRemoved($object->id,get_class($object),$request->amount);
return redirect()->route('cabels.show',['cabel' => $cabel]);
}
}

View File

@ -0,0 +1,13 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller as BaseController;
class Controller extends BaseController
{
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
}

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,278 @@
<?php
namespace App\Http\Controllers\Loan;
use App\Helpers\Logger;
use App\Http\Controllers\Controller;
use App\Models\Note;
use App\Models\NoteType;
use App\Models\Permission;
use Illuminate\Auth\Access\Response;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
class NoteController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View
*/
public function index(Request $request)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'notes_viewAny'))
? Response::allow()
: Response::deny('you are not the chosen one');
$search_types = [];
array_push($search_types,array("value" => "username", "name" => "user"));
array_push($search_types,array("value" => "type", "name" => "type"));
array_push($search_types,array("value" => "note", "name" => "note"));
array_push($search_types,array("value" => "created", "name" => "created_at"));
$PerPagination = $request->input('p') ?? 10;
$search_term = $request->input('search_term');
$search_type = $request->input('search_type');
$search_compare = $request->input('search_compare');
if($search_term != ""){
switch ($search_type){
case "username":
switch($search_compare){
case('='):
$notes = Note::where(function ($query) use ($search_term){
$query->whereHas('user',function ($query) use ($search_term){
$query->where('username','=',$search_term);
});
})->paginate($PerPagination);
break;
default:
$notes = Note::where(function ($query) use ($search_term){
$query->whereHas('user',function ($query) use ($search_term){
$query->where('username','like','%' . $search_term . '%');
});
})->paginate($PerPagination);
break;
}
break;
case "note":
switch($search_compare){
case('='):
$notes = Note::where('note','=',$search_term)->paginate($PerPagination);
break;
default:
$notes = Note::where('note','like','%' . $search_term . '%')->paginate($PerPagination);
break;
}
break;
case "type":
switch($search_compare){
case('='):
$notes = Note::where(function ($query) use ($search_term){
$query->whereHas('type',function ($query) use ($search_term){
$query->where('name','=',$search_term);
});
})->paginate($PerPagination);
break;
default:
$notes = Note::where(function ($query) use ($search_term){
$query->whereHas('type',function ($query) use ($search_term){
$query->where('name','like','%'.$search_term.'%');
});
})->paginate($PerPagination);
break;
}
break;
case "created":
switch($search_compare){
default:
$parts = explode('.',$search_term);
$d = $parts[0];
$m = $parts[1];
$y = $parts[2];
$constructed_date = $y."-".$m."-".$d;
$notes = Note::where('created_at','like','%'.$constructed_date.'%')->paginate($PerPagination);
break;
}
break;
}
}
else{
$notes = Note::Paginate($PerPagination);
}
return view('notes.index')
->with('search_types',$search_types)
->with('data',$notes)
->with('data_name','note')
->with('data_names','notes')
->with('without_create','true')
;
}
/**
* Display a listing of the resource.
*
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View
*/
public function deleted(Request $request)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'notes_viewAny_deleted'))
? Response::allow()
: Response::deny('you are not the chosen one');
$search_types = [];
array_push($search_types,array("value" => "name", "name" => "name"));
$PerPagination = $request->input('p') ?? 10;
$search_term = $request->input('search_term');
$search_type = $request->input('search_type');
$search_compare = $request->input('search_compare');
$notes = Note::onlyTrashed()->Paginate($PerPagination);
return view('notes.deleted')
->with('search_types',$search_types)
->with('data',$notes)
->with('data_name','note')
->with('data_names','notes')
->with('without_create','true')
;
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
//
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
//
}
/**
* Display the specified resource.
*
* @return \Illuminate\Http\Response
*/
public function show($note)
{
//
}
/**
* Show the form for editing the specified resource.
*
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View
*/
public function edit($note)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'notes_edit'))
? Response::allow()
: Response::deny('you are not the chosen one');
$note_obj = Note::withTrashed()->where('id','=',$note)->first();
$note_types = NoteType::all();
return view('notes.edit')
->with('data',$note_obj)
->with('data_name','note')
->with('data_names','notes')
->with('types',$note_types)
;
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\RedirectResponse
*/
public function update(Request $request, $note)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'notes_edit'))
? Response::allow()
: Response::deny('you are not the chosen one');
$note_obj = Note::withTrashed()->where('id','=',$note)->first();
if($note_obj->note_type_id != $request->type){
$type = NoteType::where('id','=',$request->type)->first();
Logger::LogEdited($note_obj->id,get_class($note_obj),"Type : ".$note_obj->type->name." til ".$type->name);
$note_obj->note_type_id = $request->type;
}
if($note_obj->note != $request->note) {
Logger::LogEdited($note_obj->id,get_class($note_obj),"Note : ".$note_obj->note." til ".$request->note);
$note_obj->note = $request->note;
}
$note_obj->save();
return redirect()->route('notes.index');
}
/**
* Remove the specified resource from storage.
*
* @return \Illuminate\Http\RedirectResponse
*/
public function delete($note)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'notes_delete'))
? Response::allow()
: Response::deny('you are not the chosen one');
$note_obj = Note::where('id','=',$note)->first();
Logger::LogDeleted($note_obj->id,get_class($note_obj));
$note_obj->delete();
return redirect()->route('notes.index');
}
/**
* Remove the specified resource from storage.
*
* @return \Illuminate\Http\RedirectResponse
*/
public function delete_force($note)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'notes_delete_force'))
? Response::allow()
: Response::deny('you are not the chosen one');
$note_obj = Note::withTrashed()->where('id','=',$note)->first();
Logger::LogForceDeleted($note_obj->id,get_class($note_obj));
$note_obj->forceDelete();
return redirect()->route('notes.deleted');
}
/**
* Remove the specified resource from storage.
*
* @return \Illuminate\Http\RedirectResponse
*/
public function restore($note)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'notes_restore'))
? Response::allow()
: Response::deny('you are not the chosen one');
$note_obj = Note::withTrashed()->where('id','=',$note)->first();
$note_obj->restore();
Logger::LogRestored($note_obj->id,get_class($note_obj));
return redirect()->route('notes.deleted');
}
}

View File

@ -0,0 +1,223 @@
<?php
namespace App\Http\Controllers\Loan;
use App\Http\Controllers\Controller;
use App\Models\Contract;
use App\Models\Permission;
use App\Models\User;
use DateTime;
use DateTimeZone;
use Illuminate\Auth\Access\Response as Response;
use Illuminate\Http\Request;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Pagination\Paginator;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Response as Fresponse;
use Illuminate\Support\Facades\Storage;
class PdfController extends Controller
{
public function index(Request $request){
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'pdf_viewAny'))
? Response::allow()
: Response::deny('you are not the chosen one');
$search_types = [];
array_push($search_types,array("value" => "user", "name" => "user"));
array_push($search_types,array("value" => "date", "name" => "date"));
array_push($search_types,array("value" => "type", "name" => "type"));
$PerPagination = $request->input('p') ?? 10;
$search_term = $request->input('search_term');
$search_type = $request->input('search_type');
$search_compare = $request->input('search_compare');
if($search_term != ""){
switch ($search_type){
case "user":
switch($search_compare){
case('='):
$contracts = Contract::where(function ($query) use ($search_term){
$query->whereHas('user',function ($query) use ($search_term){
$query->where('username','=',$search_term);
});
})
->orderBy('user_id')
->orderBy('type')
->orderBy('timestamp','desc')
->paginate($PerPagination);
break;
default:
$contracts = Contract::where(function ($query) use ($search_term){
$query->whereHas('user',function ($query) use ($search_term){
$query->where('username','like','%' . $search_term . '%');
});
})
->orderBy('user_id')
->orderBy('type')
->orderBy('timestamp','desc')
->paginate($PerPagination);
break;
}
break;
case "type":
switch($search_compare){
default:
$contracts = Contract::where('type','=',trans($search_term))
->orderBy('user_id')
->orderBy('type')
->orderBy('timestamp','desc')
->paginate($PerPagination);
break;
}
break;
case "date":
switch($search_compare){
case('>='):
$parts = explode(' ',$search_term);
$date_part = $parts[0];
$time_part = $parts[1];
$date_parts = explode('.',$date_part);
$d = $date_parts[0];
$m = $date_parts[1];
$y = $date_parts[2];
$time_parts = explode(':',$time_part);
$h = $time_parts[0];
$i = $time_parts[1];
$s = $time_parts[2];
$date = new DateTime();
$timezone = new DateTimeZone('Europe/Copenhagen');
$date->setTimezone($timezone);
$date->setDate($y,$m,$d);
$date->setTime($h,$i,$s);
$timestamp = $date->getTimestamp();
$contracts = Contract::where('timestamp','>=',$timestamp)
->orderBy('user_id')
->orderBy('type')
->orderBy('timestamp','desc')
->paginate($PerPagination);
break;
case('<='):
$parts = explode(' ',$search_term);
$date_part = $parts[0];
$time_part = $parts[1];
$date_parts = explode('.',$date_part);
$d = $date_parts[0];
$m = $date_parts[1];
$y = $date_parts[2];
$time_parts = explode(':',$time_part);
$h = $time_parts[0];
$i = $time_parts[1];
$s = $time_parts[2];
$date = new DateTime();
$timezone = new DateTimeZone('Europe/Copenhagen');
$date->setTimezone($timezone);
$date->setDate($y,$m,$d);
$date->setTime($h,$i,$s);
$timestamp = $date->getTimestamp();
$contracts = Contract::where('timestamp','<=',$timestamp)
->orderBy('user_id')
->orderBy('type')
->orderBy('timestamp','desc')
->paginate($PerPagination);
break;
default:
$parts = explode(' ',$search_term);
$date_part = $parts[0];
$time_part = $parts[1];
$date_parts = explode('.',$date_part);
$d = $date_parts[0];
$m = $date_parts[1];
$y = $date_parts[2];
$time_parts = explode(':',$time_part);
$h = $time_parts[0];
$i = $time_parts[1];
$s = $time_parts[2];
$date = new DateTime();
$timezone = new DateTimeZone('Europe/Copenhagen');
$date->setTimezone($timezone);
$date->setDate($y,$m,$d);
$date->setTime($h,$i,$s);
$timestamp = $date->getTimestamp();
$contracts = Contract::where('timestamp','=',$timestamp)
->orderBy('user_id')
->orderBy('type')
->orderBy('timestamp','desc')
->paginate($PerPagination);
break;
}
break;
}
}
else{
$contracts = Contract::orderBy('user_id')
->orderBy('type')
->orderBy('timestamp','desc')
->paginate($PerPagination);
}
return view('contracts.index')
->with('search_types',$search_types)
->with('data_name','contract')
->with('data_names','contracts')
->with('data',$contracts)
;
}
public function show(Request $request,$user){
$user_obj = User::where('username','=',$user)->first();
if(empty($user_obj)){
$user_obj = User::where('name','=',$request->user)->first();
}
if(Auth::user()->id != $user_obj->id){
if(!Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'pdf_view'))){
return redirect()->intended(route('users.show',Auth::user()));
}
else{
$user = $request->user;
$type = $request->type;
$timestamp = $request->timestamp;
$file_name = utf8_encode('app/'.$type."/".$user."_".$timestamp.".pdf");
$file_full = storage_path($file_name);
return Fresponse::file($file_full);
}
}
else{
$user = $request->user;
$type = $request->type;
$timestamp = $request->timestamp;
$file_name = utf8_encode('app/'.$type."/".$user."_".$timestamp.".pdf");
$file_full = storage_path($file_name);
return Fresponse::file($file_full);
}
}
public function destroy(Request $request){
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'pdf_delete'))
? Response::allow()
: Response::deny('you are not the chosen one');
$type = $request->type;
$user = $request->user;
$timestamp = $request->timestamp;
$file_name = utf8_encode('app/'.$type."/".$user."_".$timestamp.".pdf");
$file_full = storage_path($file_name);
if(file_exists($file_full)){
unlink($file_full);
}
$user_obj = User::where('username','=',$user)->first();
return redirect()->back();
}
}

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,184 @@
<?php
namespace App\Http\Controllers;
use App\Models\Cabel;
use App\Models\Loan;
use App\Models\LoanType;
use App\Models\Log;
use App\Models\LogAction;
use App\Models\Product;
use Illuminate\Http\Request;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\DB;
class OtherController extends Controller
{
public function logs(Request $request){
$search_types = [];
array_push($search_types,array("value" => "building", "name" => "building"));
array_push($search_types,array("value" => "room", "name" => "room"));
$PerPagination = $request->input('p') ?? 10;
$search_term = $request->input('search_term');
$search_type = $request->input('search_type');
$search_compare = $request->input('search_compare');
$logs = Log::orderBy('created_at','desc')->Paginate($PerPagination);
return view('logs')
->with('search_types',$search_types)
->with('data',$logs)
->with('data_name','log')
->with('data_names','logs')
->with('no_deleted',true)
;
}
public function statistics(Request $request){
$search_types = [];
array_push($search_types,array("value" => "building", "name" => "building"));
array_push($search_types,array("value" => "room", "name" => "room"));
$PerPagination = $request->input('p') ?? 10;
$search_term = $request->input('search_term');
$search_type = $request->input('search_type');
$search_compare = $request->input('search_compare');
$products = Product::all();
$cabels = Cabel::all();
$loans = Loan::where('loan_type_id','=',LoanType::where('name','=','Loan')->first()->id)
->select('*',DB::raw('count(loanable_id) as amount'))
->groupBy('loanable_type','loanable_id')
->get()
;
$reservations = Loan::where('loan_type_id','!=',LoanType::where('name','=','Loan')->first()->id)
->select('*',DB::raw('count(loanable_id) as amount'))
->groupBy('loanable_type','loanable_id')
->get()
;
$log_returned = Log::where('log_action_id','=',LogAction::where('name','=','returned')->first()->id)->get();
$log_returned_placement = Log::where('log_action_id','=',LogAction::where('name','=','returned')->first()->id)
->select('*',DB::raw('SUM(amount) as sum'))
->groupBy('user_id','created_at')
->orderBy('sum','desc')
->get()
;
$log_lent = Log::where('log_action_id','=',LogAction::where('name','=','lent')->first()->id)->get();
$log_lent_placement = Log::where('log_action_id','=',LogAction::where('name','=','lent')->first()->id)
->select('*',DB::raw('SUM(amount) as sum'))
->groupBy('user_id')
->orderBy('sum','desc')
->get()
;
$log_reserved = Log::where('log_action_id','=',LogAction::where('name','=','reserved')->first()->id)->get();
$log_reserved_placement = Log::where('log_action_id','=',LogAction::where('name','=','reserved')->first()->id)
->select('*',DB::raw('SUM(amount) as sum'))
->groupBy('user_id')
->orderBy('sum','desc')
->get()
;
$log_validated = Log::where('log_action_id','=',LogAction::where('name','=','validated')->first()->id)
->select('*',DB::raw('SUM(amount) as sum'))
->groupBy('user_id')
->orderBy('amount','desc')
->get()
;
$log_setups = Log::where('log_action_id','=',LogAction::where('name','=','set up')->first()->id)
->select('*',DB::raw('SUM(amount) as sum'))
->groupBy('user_id')
->orderBy('amount','desc')
->get()
;
$log_pickups = Log::where('log_action_id','=',LogAction::where('name','=','picked up')->first()->id)->get();
$log_pickups_placement = Log::where('log_action_id','=',LogAction::where('name','=','picked up')->first()->id)
->select('*',DB::raw('SUM(amount) as sum'))
->groupBy('user_id')
->orderBy('amount','desc')
->get()
;
$log_notes = Log::where('log_action_id','=',LogAction::where('name','=','note')->first()->id)->get();
$log_notes_placement = Log::where('log_action_id','=',LogAction::where('name','=','note')->first()->id)
->select('*',DB::raw('count(user_id) as amount'))
->groupBy('user_id')
->orderBy('amount','desc')
->get()
;
$total_lent = 0;
$total_reserved = 0;
$total_total = 0;
$lastday_date = Carbon::now()->subDays(1)->toDateTimeString();
$lastday_lent = 0;
$lastday_reserved = 0;
$lastday_returned = 0;
$lastday_notes = 0;
foreach($products as $product){
$total_total += $product->total;
}
foreach($cabels as $cabel){
$total_total += $cabel->total;
}
foreach($loans as $loan){
$total_lent += $loan->amount;
}
foreach($reservations as $reservation){
$total_reserved += $reservation->amount;
}
foreach($log_lent as $loan){
if($loan->created_at >= $lastday_date){
$lastday_lent += $loan->amount;
}
}
foreach($log_reserved as $loan){
if($loan->created_at >= $lastday_date){
$lastday_reserved += $loan->amount;
}
}
foreach($log_returned as $return){
if($return->created_at >= $lastday_date){
$lastday_returned += $return->amount;
}
}
foreach($log_pickups as $pickup){
if($pickup->created_at >= $lastday_date){
$lastday_returned += $pickup->amount;
}
}
foreach($log_notes as $note){
if($note->created_at >= $lastday_date){
$lastday_notes += 1;
}
}
return view('statistics')
->with('search_types',$search_types)
->with('data_name','statistic')
->with('data_names','statistics')
->with('lastday_lent',$lastday_lent)
->with('lastday_reserved',$lastday_reserved)
->with('lastday_returned',$lastday_returned)
->with('lastday_notes',$lastday_notes)
->with('total_lent',$total_lent)
->with('total_reserved',$total_reserved)
->with('total_total',$total_total)
->with('validated',$log_validated)
->with('lent',$log_lent_placement)
->with('reserved',$log_reserved_placement)
->with('setups',$log_setups)
->with('pickups',$log_pickups_placement)
->with('returned',$log_returned_placement)
->with('notes',$log_notes_placement)
;
}
}

View File

@ -0,0 +1,252 @@
<?php
namespace App\Http\Controllers\Product;
use App\Helpers\Logger;
use App\Http\Controllers\Controller;
use App\Models\Brand;
use App\Models\Permission;
use App\Models\Product;
use App\Models\ProductCategory;
use Illuminate\Auth\Access\Response;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
class BrandController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View
*/
public function index(Request $request)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'brands_viewAny'))
? Response::allow()
: Response::deny('you are not the chosen one');
$search_types = [];
array_push($search_types,array("value" => "name", "name" => "name"));
$PerPagination = $request->input('p') ?? 10;
$search_term = $request->input('search_term');
$search_type = $request->input('search_type');
$search_compare = $request->input('search_compare');
if($search_term != ""){
switch ($search_type){
case "name":
switch($search_compare){
case("="):
$brands = Brand::where('name','=',$search_term)->paginate($PerPagination);
break;
default:
$brands = Brand::where('name','like','%' . $search_term . '%')->paginate($PerPagination);
break;
}
break;
}
}
else{
$brands = Brand::paginate($PerPagination);
}
return view('brands.index')
->with('search_types',$search_types)
->with('data',$brands)
->with('data_name','brand')
->with('data_names','brands')
;
}
public function deleted(Request $request)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'brands_viewAny_deleted'))
? Response::allow()
: Response::deny('you are not the chosen one');
$search_types = [];
array_push($search_types,array("value" => "name", "name" => "name"));
$PerPagination = $request->input('p') ?? 10;
$search_term = $request->input('search_term');
$search_type = $request->input('search_type');
$search_compare = $request->input('search_compare');
if($search_term != ""){
switch ($search_type){
case "name":
switch($search_compare){
case("="):
$brands = Brand::onlyTrashed()->where('name','=',$search_term)->paginate($PerPagination);
break;
default:
$brands = Brand::onlyTrashed()->where('name','like','%' . $search_term . '%')->paginate($PerPagination);
break;
}
break;
}
}
else{
$brands = Brand::onlyTrashed()->paginate($PerPagination);
}
return view('brands.deleted')
->with('search_types',$search_types)
->with('data',$brands)
->with('data_name','brand')
->with('data_names','brands')
;
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View
*/
public function create()
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'brands_create'))
? Response::allow()
: Response::deny('you are not the chosen one');
return view('brands.create')
;
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\RedirectResponse
*/
public function store(Request $request)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'brands_create'))
? Response::allow()
: Response::deny('you are not the chosen one');
$brand = new Brand();
$brand->name = $request->name;
$brand->save();
Logger::LogCreated($brand->id,get_class($brand));
return redirect()->route('brands.show',['brand' => $brand]);
}
/**
* Display the specified resource.
*
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View
*/
public function show($brand)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'brands_view'))
? Response::allow()
: Response::deny('you are not the chosen one');
$object = Brand::withTrashed()->where('id','=',$brand)->first();
return view('brands.show')
->with('data',$object)
->with('data_name','brand')
;
}
/**
* Show the form for editing the specified resource.
*
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View
*/
public function edit($brand)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'brands_edit'))
? Response::allow()
: Response::deny('you are not the chosen one');
$object = Brand::withTrashed()->where('id','=',$brand)->first();
return view('brands.edit')
->with('data',$object)
->with('data_name','brand')
;
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param \App\Models\Brand $brand
* @return \Illuminate\Http\RedirectResponse
*/
public function update(Request $request, $brand)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'brands_edit'))
? Response::allow()
: Response::deny('you are not the chosen one');
$object = Brand::withTrashed()->where('id','=',$brand)->first();
if( $object->name != $request->name){
Logger::LogEdited($object->id,get_class($object),"Navn : ".$object->name." til ".$request->name);
$object->name = $request->name;
}
$object->save();
return redirect()->route('brands.show',['brand' => $brand]);
}
/**
* Remove the specified resource from storage.
*
* @return \Illuminate\Http\RedirectResponse
*/
public function destroy($brand)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'brands_delete'))
? Response::allow()
: Response::deny('you are not the chosen one');
$object = Brand::withTrashed()->where('id','=',$brand)->first();
Logger::LogDeleted($object->id,get_class($object));
$object->delete();
return redirect()->route('brands.index');
}
/**
* Restore the specified resource from storage.
*
* @param \App\Models\Brand $brand
* @return \Illuminate\Http\RedirectResponse
*/
public function restore($brand)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'brands_restore'))
? Response::allow()
: Response::deny('you are not the chosen one');
$object = Brand::withTrashed()->where('id','=',$brand)->first();
$object->restore();
Logger::LogRestored($object->id,get_class($object));
return redirect()->route('brands.deleted');
}
/**
* Permanently emove the specified resource from storage.
*
* @param \App\Models\Brand $brand
* @return \Illuminate\Http\RedirectResponse
*/
public function delete_force($brand)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'brands_delete_force'))
? Response::allow()
: Response::deny('you are not the chosen one');
$object = Brand::withTrashed()->where('id','=',$brand)->first();
Logger::LogForceDeleted($object->id,get_class($object));
$object->forceDelete();
return redirect()->route('brands.deleted');
}
}

View File

@ -0,0 +1,257 @@
<?php
namespace App\Http\Controllers\Product;
use App\Helpers\Logger;
use App\Http\Controllers\Controller;
use App\Models\CabelCategory;
use App\Models\Permission;
use App\Models\ProductCategory;
use Illuminate\Auth\Access\Response;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
class ProductCategoryController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View
*/
public function index(Request $request)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'categories_viewAny'))
? Response::allow()
: Response::deny('you are not the chosen one');
$search_types = [];
array_push($search_types,array("value" => "name", "name" => "name"));
$PerPagination = $request->input('p') ?? 10;
$search_term = $request->input('search_term');
$search_type = $request->input('search_type');
$search_compare = $request->input('search_compare');
if($search_term != ""){
switch ($search_type){
case "name":
switch($search_compare){
case("="):
$categories = ProductCategory::where('name','=',$search_term)->paginate($PerPagination);
break;
default:
$categories = ProductCategory::where('name','like','%' . $search_term . '%')->paginate($PerPagination);
break;
}
break;
}
}
else{
$categories = ProductCategory::paginate($PerPagination);
}
return view('categories.index')
->with('search_types',$search_types)
->with('data',$categories)
->with('data_name','category')
->with('data_names','categories')
;
}
/**
* Display a listing of the resource.
*
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View
*/
public function deleted(Request $request)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'categories_viewAny_deleted'))
? Response::allow()
: Response::deny('you are not the chosen one');
$search_types = [];
array_push($search_types,array("value" => "name", "name" => "name"));
$PerPagination = $request->input('p') ?? '10';
$search_term = $request->input('search_term');
$search_type = $request->input('search_type');
$search_compare = $request->input('search_compare');
if($search_term != ""){
switch ($search_type){
case "name":
switch($search_compare){
case("="):
$categories = ProductCategory::onlyTrashed()->where('name','=',$search_term)->paginate($PerPagination);
break;
default:
$categories = ProductCategory::onlyTrashed()->where('name','like','%' . $search_term . '%')->paginate($PerPagination);
break;
}
break;
}
}
else{
$categories = ProductCategory::onlyTrashed()->paginate($PerPagination);
}
return view('categories.deleted')
->with('search_types',$search_types)
->with('data',$categories)
->with('data_name','category')
->with('data_names','categories')
;
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View
*/
public function create()
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'categories_create'))
? Response::allow()
: Response::deny('you are not the chosen one');
return view('categories.create')
;
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\RedirectResponse
*/
public function store(Request $request)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'categories_create'))
? Response::allow()
: Response::deny('you are not the chosen one');
$category = new ProductCategory();
$category->name = $request->name;
$category->save();
Logger::LogCreated($category->id,get_class($category));
return redirect()->route('categories.show',['category' => $category]);
}
/**
* Display the specified resource.
*
* @param \App\Models\ProductCategory $category
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View
*/
public function show($category)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'categories_view'))
? Response::allow()
: Response::deny('you are not the chosen one');
$object = ProductCategory::withTrashed()->where('id','=',$category)->first();
return view('categories.show')
->with('data',$object)
->with('data_name','category')
;
}
/**
* Show the form for editing the specified resource.
*
* @param \App\Models\ProductCategory $category
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View
*/
public function edit($category)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'categories_edit'))
? Response::allow()
: Response::deny('you are not the chosen one');
$object = ProductCategory::withTrashed()->where('id','=',$category)->first();
return view('categories.edit')
->with('data',$object)
->with('data_name','category')
;
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param \App\Models\ProductCategory $category
* @return \Illuminate\Http\RedirectResponse
*/
public function update(Request $request,$category)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'categories_edit'))
? Response::allow()
: Response::deny('you are not the chosen one');
$object = ProductCategory::withTrashed()->where('id','=',$category)->first();
if( $object->name != $request->name){
Logger::LogEdited($object->id,get_class($object),"Navn : ".$object->name." til ".$request->name);
$object->name = $request->name;
}
$object->save();
return redirect()->route('categories.show',['category' => $category]);
}
/**
* Remove the specified resource from storage.
*
* @return \Illuminate\Http\RedirectResponse
*/
public function destroy($category)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'categories_delete'))
? Response::allow()
: Response::deny('you are not the chosen one');
$object = ProductCategory::withTrashed()->where('id','=',$category)->first();
Logger::LogDeleted($object->id,get_class($object));
$object->delete();
return redirect()->route('categories.index');
}
/**
* Remove the specified resource from storage.
*
* @return \Illuminate\Http\RedirectResponse
*/
public function delete_force($category)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'categories_delete_force'))
? Response::allow()
: Response::deny('you are not the chosen one');
$object = ProductCategory::withTrashed()->where('id','=',$category)->first();
Logger::LogForceDeleted($object->id,get_class($object));
$object->forceDelete();
return redirect()->route('categories.deleted');
}
/**
* Remove the specified resource from storage.
*
* @return \Illuminate\Http\RedirectResponse
*/
public function restore($category)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'categories_restore'))
? Response::allow()
: Response::deny('you are not the chosen one');
$object = ProductCategory::withTrashed()->where('id','=',$category)->first();
$object->restore();
Logger::LogRestored($object->id,get_class($object));
return redirect()->route('categories.deleted');
}
}

View File

@ -0,0 +1,506 @@
<?php
namespace App\Http\Controllers\Product;
use App\Helpers\Logger;
use App\Helpers\PaginationHelper;
use App\Http\Controllers\Controller;
use App\Models\Brand;
use App\Models\Permission;
use App\Models\Product;
use App\Models\ProductCategory;
use App\Models\ProductModel;
use App\Models\ProductSubcategory;
use Illuminate\Auth\Access\Response;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
class ProductController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View
*/
public function index(Request $request)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'products_viewAny'))
? Response::allow()
: Response::deny('you are not the chosen one');
$search_types = [];
if(config('app.barcode_mode') == 'static'){
array_push($search_types,array("value" => "barcode", "name" => "barcode"));
}
array_push($search_types,array("value" => "category", "name" => "category"));
array_push($search_types,array("value" => "subcategory", "name" => "subcategory"));
array_push($search_types,array("value" => "brand", "name" => "brand"));
array_push($search_types,array("value" => "model", "name" => "model"));
array_push($search_types,array("value" => "name", "name" => "name"));
array_push($search_types,array("value" => "description", "name" => "description"));
array_push($search_types,array("value" => "available", "name" => "available"));
array_push($search_types,array("value" => "loans", "name" => "loaned"));
array_push($search_types,array("value" => "reservations", "name" => "reserved"));
array_push($search_types,array("value" => "total", "name" => "total"));
$PerPagination = $request->input('p') ?? 10;
$search_term = $request->input('search_term');
$search_type = $request->input('search_type');
$search_compare = $request->input('search_compare');
if($search_term != ""){
switch ($search_type){
case "category":
switch($search_compare){
case("="):
$products = Product::where(function ($query) use ($search_term){
$query->whereHas('category',function ($query) use ($search_term){
$query->where('name','=',$search_term);
});
})->paginate($PerPagination);
break;
default:
$products = Product::where(function ($query) use ($search_term){
$query->whereHas('category',function ($query) use ($search_term){
$query->where('name','like','%' . $search_term . '%');
});
})->paginate($PerPagination);
break;
}
break;
case "subcategory":
switch($search_compare){
case("="):
$products = Product::where(function ($query) use ($search_term){
$query->whereHas('subcategory',function ($query) use ($search_term){
$query->where('name','=',$search_term);
});
})->paginate($PerPagination);
break;
default:
$products = Product::where(function ($query) use ($search_term){
$query->whereHas('subcategory',function ($query) use ($search_term){
$query->where('name','like','%' . $search_term . '%');
});
})->paginate($PerPagination);
break;
}
break;
case "brand":
switch($search_compare){
case("="):
$products = Product::where(function ($query) use ($search_term){
$query->whereHas('brand',function ($query) use ($search_term){
$query->where('name','=',$search_term);
});
})->paginate($PerPagination);
break;
default:
$products = Product::where(function ($query) use ($search_term){
$query->whereHas('brand',function ($query) use ($search_term){
$query->where('name','like','%' . $search_term . '%');
});
})->paginate($PerPagination);
break;
}
break;
case "model":
switch($search_compare){
case("="):
$products = Product::where(function ($query) use ($search_term){
$query->whereHas('model',function ($query) use ($search_term){
$query->where('name','=',$search_term);
});
})->paginate($PerPagination);
break;
default:
$products = Product::where(function ($query) use ($search_term){
$query->whereHas('model',function ($query) use ($search_term){
$query->where('name','like','%' . $search_term . '%');
});
})->paginate($PerPagination);
break;
}
break;
case "name":
switch($search_compare){
case("="):
$products = Product::where('name','=',$search_term)->paginate($PerPagination);
break;
default:
$products = Product::where('name','like','%' . $search_term . '%')->paginate($PerPagination);
break;
}
break;
case "description":
switch($search_compare){
case("="):
$products = Product::where('description','=',$search_term)->paginate($PerPagination);
break;
default:
$products = Product::where('description','like','%' . $search_term . '%')->paginate($PerPagination);
break;
}
break;
case "available":
$all_products = Product::all();
$product_collection = collect();
foreach($all_products as $product){
$loans = count($product->loans);
$reservations = count($product->reservations);
$total = $product->total;
$available = $total - ($loans + $reservations);
switch($search_compare){
case(">="):
if($available >= $search_term){
$product_collection->add($product);
}
break;
case("<="):
if($available <= $search_term){
$product_collection->add($product);
}
break;
case("="):
if($available == $search_term){
$product_collection->add($product);
}
break;
default:
if($available == $search_term){
$product_collection->add($product);
}
break;
}
}
$products = PaginationHelper::paginate($product_collection, $PerPagination);
break;
case "loans":
switch($search_compare){
case(">="):
$products = Product::has('loans', '>=' , $search_term)->paginate($PerPagination);
break;
case("<="):
$products = Product::has('loans', '<=' , $search_term)->paginate($PerPagination);
break;
case("="):
$products = Product::has('loans', '=' , $search_term)->paginate($PerPagination);
break;
default:
$products = Product::has('loans', '=' , $search_term)->paginate($PerPagination);
break;
}
break;
case "reservations":
switch($search_compare){
case(">="):
$products = Product::has('reservations', '>=' , $search_term)->paginate($PerPagination);
break;
case("<="):
$products = Product::has('reservations', '<=' , $search_term)->paginate($PerPagination);
break;
case("="):
$products = Product::has('reservations', '=' , $search_term)->paginate($PerPagination);
break;
default:
$products = Product::has('reservations', '=' , $search_term)->paginate($PerPagination);
break;
}
break;
case "total":
switch($search_compare){
case(">="):
$products = Product::where('total','>=',$search_term)->paginate($PerPagination);
break;
case("<="):
$products = Product::where('total','<=',$search_term)->paginate($PerPagination);
break;
case("="):
$products = Product::where('total','=',$search_term)->paginate($PerPagination);
break;
default:
$products = Product::where('total','=',$search_term)->paginate($PerPagination);
break;
}
break;
}
}
else{
$products = Product::paginate($PerPagination);
}
return view('products.index')
->with('search_types',$search_types)
->with('data',$products)
->with('data_name','product')
->with('data_names','products')
;
}
/**
* Display a listing of the resource.
*
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View
*/
public function deleted(Request $request)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'products_viewAny_deleted'))
? Response::allow()
: Response::deny('you are not the chosen one');
$search_types = [];
if(config('app.barcode_mode') == 'static'){
array_push($search_types,array("value" => "barcode", "name" => "barcode"));
}
array_push($search_types,array("value" => "category", "name" => "category"));
array_push($search_types,array("value" => "subcategory", "name" => "subcategory"));
array_push($search_types,array("value" => "brand", "name" => "brand"));
array_push($search_types,array("value" => "model", "name" => "model"));
array_push($search_types,array("value" => "name", "name" => "name"));
array_push($search_types,array("value" => "description", "name" => "description"));
$PerPagination = $request->input('p') ?? 10;
$search_term = $request->input('search_term');
$search_type = $request->input('search_type');
$search_compare = $request->input('search_compare');
$products = Product::onlyTrashed()->Paginate($PerPagination);
return view('products.deleted')
->with('search_types',$search_types)
->with('data',$products)
->with('data_name','product')
->with('data_names','products')
;
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View
*/
public function create()
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'products_create'))
? Response::allow()
: Response::deny('you are not the chosen one');
return view('products.create')
->with('categories',ProductCategory::all())
->with('subcategories',ProductSubcategory::all())
->with('brands',Brand::has('models')->get())
->with('models',ProductModel::all())
;
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\RedirectResponse
*/
public function store(Request $request)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'products_create'))
? Response::allow()
: Response::deny('you are not the chosen one');
$product = new Product();
if(isset($request->barcode)){
$product->barcode = $request->barcode;
}
$product->product_category_id = $request->category_id;
$product->product_subcategory_id = $request->subcategory_id;
$product->brand_id = $request->brand_id;
$product->product_model_id = $request->model_id;
$product->name = $request->name;
$product->description = $request->description;
$product->save();
Logger::LogCreated($product->id,get_class($product));
return redirect()->route('products.index');
}
/**
* Display the specified resource.
*
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View
*/
public function show($product)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'products_view'))
? Response::allow()
: Response::deny('you are not the chosen one');
$object = Product::withTrashed()->where('id','=',$product)->first();
return view('products.show')
->with('data',$object)
;
}
/**
* Show the form for editing the specified resource.
*
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View
*/
public function edit($product)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'products_edit'))
? Response::allow()
: Response::deny('you are not the chosen one');
$object = Product::withTrashed()->where('id','=',$product)->first();
return view('products.edit')
->with('categories',ProductCategory::withTrashed()->get())
->with('subcategories',ProductSubcategory::withTrashed()->get())
->with('brands',Brand::withTrashed()->has('models')->get())
->with('models',ProductModel::withTrashed()->get())
->with('data',$object)
->with('data_name','product')
;
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\RedirectResponse
*/
public function update(Request $request,$product)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'products_edit'))
? Response::allow()
: Response::deny('you are not the chosen one');
$object = Product::withTrashed()->where('id','=',$product)->first();
if(isset($request->barcode)){
if($object->barcode != $request->barcode){
Logger::LogEdited($object->id,get_class($object),"Stregkode : ".$object->barcode." til ".$request->barcode);
$object->barcode = $request->barcode;
}
}
if($object->product_category_id != $request->category_id) {
$category = ProductCategory::where('id','=', $request->category_id)->first();
Logger::LogEdited($object->id,get_class($object),"Kategori : ".$object->category->name." til ".$category->name);
$object->product_category_id = $request->category_id;
}
if($object->product_subcategory_id != $request->subcategory_id) {
$subcategory = ProductSubcategory::where('id','=', $request->subcategory_id)->first();
Logger::LogEdited($object->id,get_class($object),"Underkategori : ".$object->subcategory->name." til ".$subcategory->name);
$object->product_subcategory_id = $request->subcategory_id;
}
if($object->brand_id != $request->brand_id) {
$brand = Brand::where('id','=', $request->brand_id)->first();
Logger::LogEdited($object->id,get_class($object),"Fabrikant : ".$object->brand_id->name." til ".$brand->name);
$object->brand_id = $request->brand_id;
}
if($object->product_model_id != $request->model_id) {
$model = ProductModel::where('id','=', $request->model_id)->first();
Logger::LogEdited($object->id,get_class($object),"Model : ".$object->model->name." til ".$model->name);
$object->product_model_id = $request->model_id;
}
if($object->name != $request->name) {
Logger::LogEdited($object->id,get_class($object),"Navn : ".$object->name." til ".$request->name);
$object->name = $request->name;
}
if($object->description != $request->description) {
Logger::LogEdited($object->id,get_class($object),"Beskrivels : ".$object->description." til ".$request->description);
$object->description = $request->description;
}
$object->save();
return redirect()->route('products.index');
}
/**
* Remove the specified resource from storage.
*
* @return \Illuminate\Http\RedirectResponse
*/
public function destroy($product)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'products_delete'))
? Response::allow()
: Response::deny('you are not the chosen one');
$object = Product::withTrashed()->where('id','=',$product)->first();
Logger::LogDeleted($object->id,get_class($object));
$object->delete();
return redirect()->route('products.index');
}
/**
* Restore the specified resource from storage.
*
* @return \Illuminate\Http\RedirectResponse
*/
public function restore($product)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'products_restore'))
? Response::allow()
: Response::deny('you are not the chosen one');
$object = Product::withTrashed()->where('id','=',$product)->first();
Logger::LogRestored($object->id,get_class($object));
$object->restore();
return redirect()->route('products.deleted');
}
/**
* Remove the specified resource from storage.
*
* @return \Illuminate\Http\RedirectResponse
*/
public function forceDelete($product)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'products_delete_force'))
? Response::allow()
: Response::deny('you are not the chosen one');
$object = Product::withTrashed()->where('id','=',$product)->first();
Logger::LogForceDeleted($object->id,get_class($object));
$object->forceDelete();
return redirect()->route('products.deleted');
}
/**
* Add the specified amount to the Pool.
*
* @return \Illuminate\Http\RedirectResponse
*/
public function amount_add($product,Request $request)
{
$object = Product::withTrashed()->where('id','=',$product)->first();
$object->total += $request->amount;
$object->save();
Logger::LogAmountAdded($object->id,get_class($object),$request->amount);
return redirect()->route('products.show',['product' => $product]);
}
/**
* Remove the specified amount from the Pool.
*
* @param \App\Models\Product $product
* @return \Illuminate\Http\RedirectResponse
*/
public function amount_remove(Product $product,Request $request)
{
$object = Product::withTrashed()->where('id','=',$product)->first();
$object->total -= $request->amount;
$object->save();
Logger::LogAmountRemoved($object->id,get_class($object),$request->amount);
return redirect()->route('products.show',['product' => $product]);
}
}

View File

@ -0,0 +1,302 @@
<?php
namespace App\Http\Controllers\Product;
use App\Helpers\Logger;
use App\Http\Controllers\Controller;
use App\Models\Brand;
use App\Models\Permission;
use App\Models\ProductCategory;
use App\Models\ProductModel;
use Illuminate\Auth\Access\Response;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
class ProductModelController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View
*/
public function index(Request $request)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'models_viewAny'))
? Response::allow()
: Response::deny('you are not the chosen one');
$search_types = [];
array_push($search_types,array("value" => "name", "name" => "name"));
array_push($search_types,array("value" => "brand", "name" => "brand"));
$PerPagination = $request->input('p') ?? 10;
$search_term = $request->input('search_term');
$search_type = $request->input('search_type');
$search_compare = $request->input('search_compare');
if($search_term != ""){
switch ($search_type){
case "name":
switch($search_compare){
case("="):
$models = ProductModel::where('name','=',$search_term)->paginate($PerPagination);
break;
default:
$models = ProductModel::where('name','like','%' . $search_term . '%')->paginate($PerPagination);
break;
}
break;
case "brand":
switch($search_compare){
case("="):
$models = ProductModel::where(function ($query) use ($search_term){
$query->whereHas('brand',function ($query) use ($search_term){
$query->where('name','=',$search_term);
});
})->paginate($PerPagination);
break;
default:
$models = ProductModel::where(function ($query) use ($search_term){
$query->whereHas('brand',function ($query) use ($search_term){
$query->where('name','like','%' . $search_term . '%');
});
})->paginate($PerPagination);
break;
}
break;
}
}
else{
$models = ProductModel::paginate($PerPagination);
}
return view('models.index')
->with('search_types',$search_types)
->with('data',$models)
->with('data_name','model')
->with('data_names','models')
;
}
/**
* Display a listing of the resource.
*
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View
*/
public function deleted(Request $request)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'models_deleted'))
? Response::allow()
: Response::deny('you are not the chosen one');
$search_types = [];
array_push($search_types,array("value" => "name", "name" => "name"));
array_push($search_types,array("value" => "brand", "name" => "brand"));
$PerPagination = $request->input('p') ?? 10;
$search_term = $request->input('search_term');
$search_type = $request->input('search_type');
$search_compare = $request->input('search_compare');
if($search_term != ""){
switch ($search_type){
case "name":
switch($search_compare){
case("="):
$models = ProductModel::onlyTrashed()->where('name','=',$search_term)->paginate($PerPagination);
break;
default:
$models = ProductModel::onlyTrashed()->where('name','like','%' . $search_term . '%')->paginate($PerPagination);
break;
}
break;
case "brand":
switch($search_compare){
case("="):
$models = ProductModel::onlyTrashed()->where(function ($query) use ($search_term){
$query->whereHas('brand',function ($query) use ($search_term){
$query->where('name','=',$search_term);
});
})->paginate($PerPagination);
break;
default:
$models = ProductModel::onlyTrashed()->where(function ($query) use ($search_term){
$query->whereHas('brand',function ($query) use ($search_term){
$query->where('name','like','%' . $search_term . '%');
});
})->paginate($PerPagination);
break;
}
break;
}
}
else{
$models = ProductModel::onlyTrashed()->paginate($PerPagination);
}
return view('models.deleted')
->with('search_types',$search_types)
->with('data',$models)
->with('data_name','model')
->with('data_names','models')
;
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View
*/
public function create()
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'models_create'))
? Response::allow()
: Response::deny('you are not the chosen one');
return view('models.create')
->with('brands',Brand::all())
;
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\RedirectResponse
*/
public function store(Request $request)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'models_create'))
? Response::allow()
: Response::deny('you are not the chosen one');
$model = new ProductModel();
$model->name = $request->name;
$model->brand_id = $request->brand_id;
$model->save();
Logger::LogCreated($model->id,get_class($model));
return redirect()->route('models.show',['model' => $model]);
}
/**
* Display the specified resource.
*
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View
*/
public function show($model)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'models_view'))
? Response::allow()
: Response::deny('you are not the chosen one');
$object = ProductModel::withTrashed()->where('id','=',$model)->first();
return view('models.show')
->with('data',$object)
;
}
/**
* Show the form for editing the specified resource.
*
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View
*/
public function edit($model)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'models_edit'))
? Response::allow()
: Response::deny('you are not the chosen one');
$object = ProductModel::withTrashed()->where('id','=',$model)->first();
return view('models.edit')
->with('data',$object)
->with('brands',Brand::withTrashed()->get())
->with('data_name','model')
;
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\RedirectResponse
*/
public function update(Request $request,$model)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'models_edit'))
? Response::allow()
: Response::deny('you are not the chosen one');
$object = ProductModel::withTrashed()->where('id','=',$model)->first();
if( $object->name != $request->name){
Logger::LogEdited($object->id,get_class($object),"Navn : ".$object->name." til ".$request->name);
$object->name = $request->name;
}
if( $object->brand_id != $request->brand_id){
$brand = Brand::withTrashed()->where('id','=',$request->brand_id)->first();
Logger::LogEdited($object->id,get_class($object),"Fabrikant : ".$object->brand->name." til ".$brand->name);
$object->brand_id = $request->brand_id;
}
$object->save();
return redirect()->route('models.show',['model' => $model]);
}
/**
* Remove the specified resource from storage.
*
* @return \Illuminate\Http\RedirectResponse
*/
public function destroy($model)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'models_delete'))
? Response::allow()
: Response::deny('you are not the chosen one');
$object = ProductModel::withTrashed()->where('id','=',$model)->first();
Logger::LogDeleted($object->id,get_class($object));
$object->delete();
return redirect()->route('models.index');
}
/**
* Remove the specified resource from storage.
*
* @return \Illuminate\Http\RedirectResponse
*/
public function delete_force($model)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'models_delete_force'))
? Response::allow()
: Response::deny('you are not the chosen one');
$object = ProductModel::withTrashed()->where('id','=',$model)->first();
Logger::LogForceDeleted($object->id,get_class($object));
$object->forceDelete();
return redirect()->route('models.deleted');
}
/**
* Remove the specified resource from storage.
*
* @return \Illuminate\Http\RedirectResponse
*/
public function restore($model)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'models_restore'))
? Response::allow()
: Response::deny('you are not the chosen one');
$object = ProductModel::withTrashed()->where('id','=',$model)->first();
$object->restore();
Logger::LogRestored($object->id,get_class($object));
return redirect()->route('models.deleted');
}
}

View File

@ -0,0 +1,308 @@
<?php
namespace App\Http\Controllers\Product;
use App\Helpers\Logger;
use App\Http\Controllers\Controller;
use App\Models\Permission;
use App\Models\ProductCategory;
use App\Models\ProductSubcategory;
use Illuminate\Auth\Access\Response;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
class ProductSubcategoryController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View
*/
public function index(Request $request)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'subcategories_viewAny'))
? Response::allow()
: Response::deny('you are not the chosen one');
$search_types = [];
array_push($search_types,array("value" => "name", "name" => "name"));
array_push($search_types,array("value" => "category", "name" => "category"));
$PerPagination = $request->input('p') ?? 10;
$search_term = $request->input('search_term');
$search_type = $request->input('search_type');
$search_compare = $request->input('search_compare');
if($search_term != ""){
switch ($search_type){
case "name":
switch($search_compare){
case("="):
$categories = ProductSubcategory::where('name','=',$search_term)->paginate($PerPagination);
break;
default:
$categories = ProductSubcategory::where('name','like','%' . $search_term . '%')->paginate($PerPagination);
break;
}
break;
case "category":
switch($search_compare){
case("="):
$categories = ProductSubcategory::where(function ($query) use ($search_term){
$query->whereHas('category',function ($query) use ($search_term){
$query->where('name','=',$search_term);
});
})->paginate($PerPagination);
break;
default:
$categories = ProductSubcategory::where(function ($query) use ($search_term){
$query->whereHas('category',function ($query) use ($search_term){
$query->where('name','like','%' . $search_term . '%');
});
})->paginate($PerPagination);
break;
}
break;
}
}
else{
$categories = ProductSubcategory::paginate($PerPagination);
}
return view('subcategories.index')
->with('search_types',$search_types)
->with('data',$categories)
->with('data_name','subcategory')
->with('data_names','subcategories')
;
}
/**
* Display a listing of the resource.
*
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View
*/
public function deleted(Request $request)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'subcategories_viewAny_deleted'))
? Response::allow()
: Response::deny('you are not the chosen one');
$search_types = [];
array_push($search_types,array("value" => "name", "name" => "name"));
$PerPagination = $request->input('p') ?? 10;
$search_term = $request->input('search_term');
$search_type = $request->input('search_type');
$search_compare = $request->input('search_compare');
if($search_term != ""){
switch ($search_type){
case "name":
switch($search_compare){
case("="):
$categories = ProductSubcategory::onlyTrashed()->where('name','=',$search_term)->paginate($PerPagination);
break;
default:
$categories = ProductSubcategory::onlyTrashed()->where('name','like','%' . $search_term . '%')->paginate($PerPagination);
break;
}
break;
case "category":
switch($search_compare){
case("="):
$categories = ProductSubcategory::onlyTrashed()->where(function ($query) use ($search_term){
$query->whereHas('category',function ($query) use ($search_term){
$query->where('name','=',$search_term);
});
})->paginate($PerPagination);
break;
default:
$categories = ProductSubcategory::onlyTrashed()->where(function ($query) use ($search_term){
$query->whereHas('category',function ($query) use ($search_term){
$query->where('name','like','%' . $search_term . '%');
});
})->paginate($PerPagination);
break;
}
break;
}
}
else{
$categories = ProductSubcategory::onlyTrashed()->paginate($PerPagination);
}
return view('subcategories.deleted')
->with('search_types',$search_types)
->with('data',$categories)
->with('data_name','subcategory')
->with('data_names','subcategories')
;
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View
*/
public function create()
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'subcategories_create'))
? Response::allow()
: Response::deny('you are not the chosen one');
return view('subcategories.create')
->with('categories',ProductCategory::all())
;
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\RedirectResponse
*/
public function store(Request $request)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'subcategories_create'))
? Response::allow()
: Response::deny('you are not the chosen one');
$subcategory = new ProductSubcategory();
$subcategory->name = $request->name;
$subcategory->product_category_id = $request->category_id;
$subcategory->save();
Logger::LogCreated($subcategory->id,get_class($subcategory));
return redirect()->route('subcategories.show',['subcategory' => $subcategory]);
}
/**
* Display the specified resource.
*
* @param \App\Models\ProductSubcategory $subcategory
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View
*/
public function show($subcategory)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'subcategories_view'))
? Response::allow()
: Response::deny('you are not the chosen one');
$object = ProductSubcategory::withTrashed()->where('id','=',$subcategory)->first();
return view('subcategories.show')
->with('data',$object)
->with('data_name','subcategory')
;
}
/**
* Show the form for editing the specified resource.
*
* @param \App\Models\ProductSubcategory $subcategory
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View
*/
public function edit($subcategory)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'subcategories_edit'))
? Response::allow()
: Response::deny('you are not the chosen one');
$object = ProductSubcategory::withTrashed()->where('id','=',$subcategory)->first();
$data_type = "subcategory";
return view('subcategories.edit')
->with('data',$object)
->with('data_name',$data_type)
->with('categories',ProductCategory::all())
;
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param \App\Models\ProductSubcategory $subcategory
* @return \Illuminate\Http\RedirectResponse
*/
public function update(Request $request,$subcategory)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'subcategories_edit'))
? Response::allow()
: Response::deny('you are not the chosen one');
$object = ProductSubcategory::withTrashed()->where('id','=',$subcategory)->first();
if( $object->name != $request->name){
Logger::LogEdited($object->id,get_class($object),"Navn : ".$object->name." til ".$request->name);
$object->name = $request->name;
}
if( $object->product_category_id != $request->category_id){
$category = ProductCategory::withTrashed()->where('id','=',$request->category_id)->first();
Logger::LogEdited($object->id,get_class($object),"Kategori : ".$object->category->name." til ".$category->name);
$object->product_category_id = $request->category_id;
}
$object->save();
return redirect()->route('subcategories.show',['subcategory' => $subcategory]);
}
/**
* Remove the specified resource from storage.
*
* @return RedirectResponse
*/
public function destroy($subcategory)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'subcategories_delete'))
? Response::allow()
: Response::deny('you are not the chosen one');
$object = ProductSubcategory::withTrashed()->where('id','=',$subcategory)->first();
Logger::LogDeleted($object->id,get_class($object));
$object->delete();
return redirect()->route('subcategories.index');
}
/**
* Permanently Remove the specified resource from storage.
*
* @return RedirectResponse
*/
public function delete_force($subcategory)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'subcategories_delete_force'))
? Response::allow()
: Response::deny('you are not the chosen one');
$object = ProductSubcategory::withTrashed()->where('id','=',$subcategory)->first();
Logger::LogForceDeleted($object->id,get_class($object));
$object->forceDelete();
return redirect()->route('subcategories.deleted');
}
/**
* Restore the specified resource from storage.
*
* @return RedirectResponse
*/
public function restore($subcategory)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'subcategories_restore'))
? Response::allow()
: Response::deny('you are not the chosen one');
$object = ProductSubcategory::withTrashed()->where('id','=',$subcategory)->first();
$object->restore();
Logger::LogRestored($object->id,get_class($object));
return redirect()->route('subcategories.deleted');
}
}

View File

@ -0,0 +1,242 @@
<?php
namespace App\Http\Controllers\Rooms;
use App\Helpers\Logger;
use App\Http\Controllers\Controller;
use App\Models\Building;
use App\Models\Permission;
use App\Models\Role;
use App\Models\Room;
use App\Models\User;
use Illuminate\Auth\Access\Response;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Contracts\View\Factory;
use Illuminate\Contracts\View\View;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
class BuildingController extends Controller
{
/**
* Display a listing of the resource.
*
*/
public function index(Request $request)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'buildings_viewAny'))
? Response::allow()
: Response::deny('you are not the chosen one');
$search_types = [];
array_push($search_types,array("value" => "name", "name" => "name"));
$PerPagination = $request->input('p') ?? 10;
$search_term = $request->input('search_term');
$search_type = $request->input('search_type');
$search_compare = $request->input('search_compare');
if($search_term != ""){
switch ($search_type){
case "name":
$buildings = Building::where(function ($query) use ($search_term){
$query->where('name','like','%' . $search_term . '%');
})->orderBy('name', 'asc')->paginate($PerPagination);
break;
}
}
else{
$buildings = Building::orderBy('name', 'asc')->paginate($PerPagination);
}
return view('buildings.index')
->with('search_types',$search_types)
->with('data',$buildings)
->with('data_name','building')
->with('data_names','buildings')
;
}
/**
* Display a listing of the resource.
*
*/
public function deleted(Request $request)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'buildings_viewAny_deleted'))
? Response::allow()
: Response::deny('you are not the chosen one');
$search_types = [];
array_push($search_types,array("value" => "name", "name" => "name"));
$PerPagination = $request->input('p');
$search_term = $request->input('search_term');
$search_type = $request->input('search_type');
if($search_term != ""){
switch ($search_type){
case "name":
$buildings = Building::where(function ($query) use ($search_term){
$query->where('name','like','%' . $search_term . '%');
})->orderBy('name', 'asc')->paginate($PerPagination);
break;
}
}
else{
$buildings = Building::onlyTrashed()->orderBy('name', 'asc')->paginate($PerPagination);
}
return view('buildings.deleted')
->with('search_types',$search_types)
->with('data',$buildings)
->with('data_name','building')
->with('data_names','buildings')
;
}
/**
* Show the form for creating a new resource.
*
*/
public function create()
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'buildings_create'))
? Response::allow()
: Response::deny('you are not the chosen one');
return view('buildings.create');
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\RedirectResponse
*/
public function store(Request $request)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'buildings_create'))
? Response::allow()
: Response::deny('you are not the chosen one');
$building = new Building();
$building->name = $request->name;
$building->save();
Logger::LogCreated($building->id,get_class($building));
return redirect()->route('buildings.show',['building' => $building]);
}
/**
* Display the specified resource.
*
* @return Application|Factory|View
*/
public function show($building)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'buildings_view'))
? Response::allow()
: Response::deny('you are not the chosen one');
$object = Building::withTrashed()->where('id','=',$building)->first();
return view('buildings.show')
->with('data',$object)
->with('data_name','building')
;
}
/**
* Show the form for editing the specified resource.
*
* @return Application|Factory|View
*/
public function edit($building)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'buildings_edit'))
? Response::allow()
: Response::deny('you are not the chosen one');
$object = Building::withTrashed()->where('id','=',$building)->first();
return view('buildings.edit')
->with('data',$object)
->with('data_name','building')
;
}
/**
* Update the specified resource in storage.
*
*/
public function update(Request $request, $building)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'buildings_edit'))
? Response::allow()
: Response::deny('you are not the chosen one');
$object = Building::withTrashed()->where('id','=',$building)->first();
if( $object->name != $request->name){
Logger::LogEdited($object->id,get_class($object),"Navn : ".$object->name." til ".$request->name);
$object->name = $request->name;
}
$object->save();
return redirect()->route('buildings.show',['building' => $building]);
}
/**
* Remove the specified resource from storage.
*
* @return \Illuminate\Http\RedirectResponse
*/
public function destroy($building)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'buildings_delete'))
? Response::allow()
: Response::deny('you are not the chosen one');
$object = Building::withTrashed()->where('id','=',$building)->first();
Logger::LogDeleted($object->id,get_class($object));
$object->delete();
return redirect()->route('buildings.index');
}
/**
* Permanently Remove the specified resource from storage.
*
* @return \Illuminate\Http\RedirectResponse
*/
public function delete_force($building)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'buildings_delete_force'))
? Response::allow()
: Response::deny('you are not the chosen one');
$object = Building::withTrashed()->where('id','=',$building)->first();
Logger::LogForceDeleted($object->id,get_class($object));
$object->forceDelete();
return redirect()->route('buildings.deleted');
}
/**
* Permanently Remove the specified resource from storage.
*
* @return \Illuminate\Http\RedirectResponse
*/
public function restore($building)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'buildings_restore'))
? Response::allow()
: Response::deny('you are not the chosen one');
$object = Building::withTrashed()->where('id','=',$building)->first();
$object->restore();
Logger::LogRestored($object->id,get_class($object));
return redirect()->route('buildings.deleted');
}
}

View File

@ -0,0 +1,284 @@
<?php
namespace App\Http\Controllers\Rooms;
use App\Helpers\Logger;
use App\Http\Controllers\Controller;
use App\Models\Building;
use App\Models\Loan;
use App\Models\LoanType;
use App\Models\Permission;
use App\Models\Room;
use App\Models\User;
use Illuminate\Auth\Access\Response;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
class RoomController extends Controller
{
/**
* Display a listing of the resource.
*
*/
public function index(Request $request)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'rooms_viewAny'))
? Response::allow()
: Response::deny('you are not the chosen one');
$search_types = [];
array_push($search_types,array("value" => "building", "name" => "building"));
array_push($search_types,array("value" => "name", "name" => "name"));
$PerPagination = $request->input('p') ?? 10;
$search_term = $request->input('search_term');
$search_type = $request->input('search_type');
$search_compare = $request->input('search_compare');
if($search_term != ""){
switch ($search_type){
case "building":
$rooms = Room::where(function ($query) use ($search_term){
$query->whereHas('building',function ($query) use ($search_term){
$query->where('name','like','%' . $search_term . '%');
});
})->join('buildings', 'rooms.building_id', '=', 'buildings.id')->select('rooms.*')->orderBy('buildings.name','asc')->paginate($PerPagination);
break;
case "name":
$rooms = Room::where('rooms.name','like','%' . $search_term . '%')->join('buildings', 'rooms.building_id', '=', 'buildings.id')->select('rooms.*')->orderBy('buildings.name','asc')->paginate($PerPagination);
break;
}
}
else{
$rooms = Room::join('buildings', 'rooms.building_id', '=', 'buildings.id')->select('rooms.*')->orderBy('buildings.name','asc')->paginate($PerPagination);
}
return view('rooms.index')
->with('search_types',$search_types)
->with('data',$rooms)
->with('data_name','room')
->with('data_names','rooms')
;
}
/**
* Display a listing of the resource.
*
*/
public function deleted(Request $request)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'rooms_viewAny_deleted'))
? Response::allow()
: Response::deny('you are not the chosen one');
$search_types = [];
array_push($search_types,array("value" => "building", "name" => "building"));
array_push($search_types,array("value" => "room", "name" => "room"));
$PerPagination = $request->input('p') ?? '10';
$search_term = $request->input('search_term');
$search_type = $request->input('search_type');
if($search_term != ""){
switch ($search_type){
case "building":
$rooms = Room::where(function ($query) use ($search_term){
$query->whereHas('building',function ($query) use ($search_term){
$query->where('name','like','%' . $search_term . '%');
});
})->join('buildings', 'rooms.building_id', '=', 'buildings.id')->select('rooms.*')->orderBy('buildings.name','asc')->paginate($PerPagination);
break;
break;
case "room":
$rooms = Room::where('rooms.name','like','%' . $search_term . '%')->join('buildings', 'rooms.building_id', '=', 'buildings.id')->select('rooms.*')->orderBy('buildings.name','asc')->paginate($PerPagination);
break;
}
}
else{
$rooms = Room::onlyTrashed()->join('buildings', 'rooms.building_id', '=', 'buildings.id')->select('rooms.*')->orderBy('buildings.name','asc')->onlyTrashed()->Paginate($PerPagination);
}
return view('rooms.deleted')
->with('search_types',$search_types)
->with('data',$rooms)
->with('data_name','room')
;
}
/**
* Show the form for creating a new resource.
*
*/
public function create()
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'rooms_create'))
? Response::allow()
: Response::deny('you are not the chosen one');
return view('rooms.create')
->with('buildings',Building::all()->sortBy(['name','asc']))
;
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\RedirectResponse
*/
public function store(Request $request)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'rooms_create'))
? Response::allow()
: Response::deny('you are not the chosen one');
$room = new Room();
$room->building_id = $request->building_id;
$room->name = $request->name;
$room->save();
Logger::LogCreated($room->id,get_class($room));
return redirect()->route('rooms.show',['room' => $room]);
}
/**
* Display the specified resource.
*
* @param \App\Models\Room $room
*/
public function show($room)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'rooms_view'))
? Response::allow()
: Response::deny('you are not the chosen one');
$object = Room::where('id','=',$room)->withTrashed()->first();
$reservations = Loan::where('loan_type_id','!=',LoanType::where('name','=','Loan')->first()->id)
->where('room_id','=',$object->id)
->select('*',DB::raw('count(loanable_id) as amount'))
->groupBy('loanable_type','loanable_id','loan_type_id','room_id')
->orderBy('loan_type_id')
->orderBy('user_id')
->orderBy('date_start')
->orderBy('date_end')
->orderBy('loanable_type')
->orderBy('loanable_id')
->get()
;
return view('rooms.show')
->with('data',$object)
->with('data_name','room')
->with('reservations',$reservations)
;
}
/**
* Show the form for editing the specified resource.
*
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View
*/
public function edit($room)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'rooms_edit'))
? Response::allow()
: Response::deny('you are not the chosen one');
$object = Room::where('id','=',$room)->withTrashed()->first();
return view('rooms.edit')
->with('data',$object)
->with('buildings',Building::all()->sortBy([['name','asc']]))
->with('data_name','room')
;
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\RedirectResponse
*/
public function update(Request $request, $room)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'rooms_edit'))
? Response::allow()
: Response::deny('you are not the chosen one');
$object = Room::where('id','=',$room)->withTrashed()->first();
$object->building_id = $request->building_id;
if( $object->name != $request->name){
Logger::LogEdited($object->id,get_class($object),"Navn : ".$object->name." til ".$request->name);
$object->name = $request->name;
}
if( $object->building_id != $request->building_id){
$building = Building::withTrashed()->where('id','=',$request->building_id)->first();
Logger::LogEdited($object->id,get_class($object),"Navn : ".$object->building->name." til ".$building->name);
$object->building_id = $request->building_id;
}
$object->save();
return redirect()->route('rooms.show',['room' => $room]);
}
/**
* Remove the specified resource from storage.
*
* @return \Illuminate\Http\RedirectResponse
*/
public function destroy($room)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'rooms_delete'))
? Response::allow()
: Response::deny('you are not the chosen one');
$object = Room::where('id','=',$room)->withTrashed()->first();
Logger::LogDeleted($object->id,get_class($object));
$object->delete();
return redirect()->route('rooms.index');
}
/**
* Permanently Remove the specified resource from storage.
*
* @return \Illuminate\Http\RedirectResponse
*/
public function delete_force($room)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'rooms_delete_force'))
? Response::allow()
: Response::deny('you are not the chosen one');
$object = Room::where('id','=',$room)->withTrashed()->first();
Logger::LogForceDeleted($object->id,get_class($object));
$object->forceDelete();
return redirect()->route('rooms.deleted');
}
/**
* Restore the specified resource from storage.
*
* @return \Illuminate\Http\RedirectResponse
*/
public function restore($room)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'rooms_restore'))
? Response::allow()
: Response::deny('you are not the chosen one');
$object = Room::where('id','=',$room)->withTrashed()->first();
$object->restore();
Logger::LogRestored($object->id,get_class($object));
return redirect()->route('rooms.deleted');
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,446 @@
<?php
namespace App\Http\Controllers\User;
use App\Helpers\ActionLogger;
use App\Helpers\Logger;
use App\Http\Controllers\Controller;
use App\Models\Cabelcategory;
use App\Models\Contract;
use App\Models\Loan;
use App\Models\LoanerType;
use App\Models\LoanType;
use App\Models\Note;
use App\Models\Permission;
use App\Models\Role;
use App\Models\User;
use Illuminate\Auth\Access\Response;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Storage;
class UserController extends Controller
{
/**
* Display a listing of the resource.
*
*/
public function index(Request $request)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'users_viewAny'))
? Response::allow()
: Response::deny('you are not the chosen one');
$search_types = [];
array_push($search_types,array("value" => "username", "name" => "username"));
array_push($search_types,array("value" => "name", "name" => "name_full"));
array_push($search_types,array("value" => "role", "name" => "role"));
$PerPagination = $request->input('p') ?? 10;
$search_term = $request->input('search_term');
$search_type = $request->input('search_type');
$search_compare = $request->input('search_compare');
if($search_term != ""){
switch ($search_type){
case "username":
switch($search_compare){
case('='):
$users = User::where(function ($query) use ($search_term){
$query->where('username','=',$search_term);
})->paginate($PerPagination);
break;
default:
$users = User::where(function ($query) use ($search_term){
$query->where('username','like','%' . $search_term . '%');
})->paginate($PerPagination);
break;
}
break;
case "name":
switch($search_compare){
case('='):
$users = User::where(function ($query) use ($search_term){
$query->where('name','=',$search_term);
})->paginate($PerPagination);
break;
default:
$users = User::where(function ($query) use ($search_term){
$query->where('name','like','%' . $search_term . '%');
})->paginate($PerPagination);
break;
}
break;
case "role":
switch($search_compare){
case('='):
$users = User::where(function ($query) use ($search_term){
$query->whereHas('role',function ($query) use ($search_term){
$query->where('name','=',$search_term);
});
})->paginate($PerPagination);
break;
default:
$users = User::where(function ($query) use ($search_term){
$query->whereHas('role',function ($query) use ($search_term){
$query->where('name','like','%' . $search_term . '%');
});
})->paginate($PerPagination);
break;
}
break;
}
}
else{
$users = User::paginate($PerPagination);
}
return view('users.index')
->with('search_types',$search_types)
->with('data',$users)
->with('data_name','user')
->with('data_names','users')
;
}
/**
* Display a listing of the resource.
*
*/
public function deleted(Request $request)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'users_viewAny_deleted'))
? Response::allow()
: Response::deny('you are not the chosen one');
$search_types = [];
array_push($search_types,array("value" => "username", "name" => "username"));
array_push($search_types,array("value" => "name", "name" => "name"));
array_push($search_types,array("value" => "role", "name" => "role"));
$PerPagination = $request->input('p');
$search_term = $request->input('search_term');
$search_type = $request->input('search_type');
$search_compare = $request->input('search_compare');
if($search_term != ""){
switch ($search_type){
case "username":
switch($search_compare){
case('='):
$users = User::onlyTrashed()->where(function ($query) use ($search_term){
$query->where('username','=',$search_term);
})->paginate($PerPagination);
break;
default:
$users = User::onlyTrashed()->where(function ($query) use ($search_term){
$query->where('username','like','%' . $search_term . '%');
})->paginate($PerPagination);
break;
}
break;
case "name":
switch($search_compare){
case('='):
$users = User::onlyTrashed()->where(function ($query) use ($search_term){
$query->where('name','=',$search_term);
})->paginate($PerPagination);
break;
default:
$users = User::onlyTrashed()->where(function ($query) use ($search_term){
$query->where('name','like','%' . $search_term . '%');
})->paginate($PerPagination);
break;
}
break;
case "role":
switch($search_compare){
case('='):
$users = User::onlyTrashed()->where(function ($query) use ($search_term){
$query->whereHas('role',function ($query) use ($search_term){
$query->where('name','=',$search_term);
});
})->paginate($PerPagination);
break;
default:
$users = User::onlyTrashed()->where(function ($query) use ($search_term){
$query->whereHas('role',function ($query) use ($search_term){
$query->where('name','like','%' . $search_term . '%');
});
})->paginate($PerPagination);
break;
}
break;
default:
$users = User::onlyTrashed()->where(function ($query) use ($search_term){
$query->where('username', 'like', '%'.$search_term.'%')
->orWhere('name', 'like', '%'.$search_term.'%')
->orWhereHas('role', function ($query) use ($search_term){
$query->where('name', 'like', '%'.$search_term.'%');
});
})->paginate($PerPagination);
break;
}
}
else{
$users = User::onlyTrashed()->paginate($PerPagination);
}
return view('users.deleted')
->with('search_types',$search_types)
->with('data',$users)
->with('data_name','user')
->with('data_names','users')
;
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View
*/
public function create()
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'user_ceate'))
? Response::allow()
: Response::deny('you are not the chosen one');
$exclude = array();
if(Auth::user()->role->name != "Administrator"){
array_push($exclude,Role::firstWhere("name", "=", "Administrator")->id);
}
return view('users.create')
->with('loanerTypes', LoanerType::all())
->with('roles', Role::all()->except($exclude))
->with('password_input_repeat','true')
;
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\RedirectResponse
*/
public function store(Request $request)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'users_create'))
? Response::allow()
: Response::deny('you are not the chosen one');
$nadUser = LoanerType::where('name','=','nadUser')->first();
$user = new User();
$user->name = $request->name;
$user->username = $request->username;
$user->password = Hash::make($request->password);
$user->loaner_type_id = $nadUser->id;
$user->role_id = $request->role_id;
$user->save();
Logger::LogCreated($user->id,get_class($user));
return redirect()->route('users.index');
}
/**
* Display the specified resource.
*
* @param \App\Models\User $user
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View
*/
public function show($user)
{
$object = User::withTrashed()->where('id','=',$user)->first();
if(Auth::user()->id != $object->id){
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'users_view'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
$loans = Loan::where('loan_type_id','=',LoanType::where('name','=','Loan')->first()->id)
->where('user_id','=',$object->id)
->select('*',DB::raw('count(loanable_id) as amount'))
->groupBy('loanable_type','loanable_id','date_start','date_end')
->orderBy('date_end')
->orderBy('date_start')
->orderBy('loanable_type')
->orderBy('loanable_id')
->get()
;
$reservations = Loan::where('loan_type_id','!=',LoanType::where('name','=','Loan')->first()->id)
->where('user_id','=',$object->id)
->select('*',DB::raw('count(loanable_id) as amount'))
->groupBy('loanable_type','loanable_id','loan_type_id','room_id')
->orderBy('loan_type_id')
->orderBy('room_id')
->orderBy('date_start')
->orderBy('date_end')
->orderBy('loanable_type')
->orderBy('loanable_id')
->get()
;
$notes = Note::where('user_id','=',$object->id)
->get()
;
$contracts = Contract::where('user_id','=',$object->id)
->orderBy('type')
->orderBy('timestamp','desc')
->get()
;
return view('users.show')
->with('data',$object)
->with('loans',$loans)
->with('reservations',$reservations)
->with('contracts',$contracts)
->with('notes',$notes)
;
}
/**
* Show the form for editing the specified resource.
*
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View
*/
public function edit($user)
{
$object = User::withTrashed()->where('id','=',$user)->first();
if(Auth::user()->id != $object->id){
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'users_edit'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
$exclude = array();
if(Auth::user()->role->name != "Administrator"){
array_push($exclude,Role::where("name","=","Administrator")->first()->id);
}
return view('users.edit')
->with('data', $object)
->with('loanerTypes', LoanerType::all())
->with('users', User::all())
->with('roles', Role::all()->except($exclude))
->with('password_input_repeat','true')
->with('data_name', 'user')
->with('data_names', 'users')
;
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\RedirectResponse
*/
public function update(Request $request, $user)
{
$object = User::withTrashed()->where('id','=',$user)->first();
if(Auth::user()->id != $object->id){
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'users_edit'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
return redirect()->route('roles.index');
}
/**
* Remove the specified resource from storage.
*
* @param \App\Models\User $user
* @return \Illuminate\Http\RedirectResponse
*/
public function destroy($user)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'user_delete'))
? Response::allow()
: Response::deny('you are not the chosen one');
$object = User::withTrashed()->where('id','=',$user)->first();
Logger::LogDeleted($object->id,get_class($object));
$object->delete();
return redirect()->route('users.index');
}
/**
* Permanently Remove the specified resource from storage.
*
* @param \App\Models\User $user
* @return \Illuminate\Http\RedirectResponse
*/
public function delete_force($user)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'user_delete_force'))
? Response::allow()
: Response::deny('you are not the chosen one');
$object = User::withTrashed()->where('id','=',$user)->first();
$laptop_files = Storage::files('laptops');
foreach($laptop_files as $file){
$no_dir = str_replace("laptops/", "",$file);
$parts = explode('_',$no_dir);
$file_name = 'app\\'.$file;
$file_full = storage_path($file_name);
if($parts[0] == $object->username){
unlink($file_full);
}
}
$reservation_files = Storage::files('reservation');
foreach($reservation_files as $file){
$no_dir = str_replace("reservation/", "",$file);
$parts = explode('_',$no_dir);
$file_name = 'app\\'.$file;
$file_full = storage_path($file_name);
if($parts[0] == $object->username){
unlink($file_full);
}
}
$contract_files = Storage::files('contracts');
foreach($contract_files as $file){
$no_dir = str_replace("contracts/", "",$file);
$parts = explode('_',$no_dir);
$file_name = 'app\\'.$file;
$file_full = storage_path($file_name);
if($parts[0] == $object->username){
unlink($file_full);
}
}
Logger::LogForceDeleted($object->id,get_class($object));
$object->forceDelete();
return redirect()->route('users.index');
}
/**
* Restore the specified resource from storage.
*
* @param \App\Models\User $user
* @return \Illuminate\Http\RedirectResponse
*/
public function restore($user)
{
Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'user_restore'))
? Response::allow()
: Response::deny('you are not the chosen one');
$object = User::withTrashed()->where('id','=',$user)->first();
$object->restore();
Logger::LogRestored($object->id,get_class($object));
return redirect()->route('users.index');
}
}

67
app/Http/Kernel.php Normal file
View File

@ -0,0 +1,67 @@
<?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<int, class-string|string>
*/
protected $middleware = [
// \App\Http\Middleware\TrustHosts::class,
\App\Http\Middleware\TrustProxies::class,
\Illuminate\Http\Middleware\HandleCors::class,
\App\Http\Middleware\PreventRequestsDuringMaintenance::class,
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
\App\Http\Middleware\TrimStrings::class,
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
];
/**
* The application's route middleware groups.
*
* @var array<string, array<int, class-string|string>>
*/
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,
\Illuminate\Routing\Middleware\SubstituteBindings::class,
],
'api' => [
// \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
'throttle:api',
\Illuminate\Routing\Middleware\SubstituteBindings::class,
],
];
/**
* The application's route middleware.
*
* These middleware may be assigned to groups or used individually.
*
* @var array<string, class-string|string>
*/
protected $routeMiddleware = [
'auth' => \App\Http\Middleware\Authenticate::class,
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
'auth.session' => \Illuminate\Session\Middleware\AuthenticateSession::class,
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
'can' => \Illuminate\Auth\Middleware\Authorize::class,
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
'signed' => \App\Http\Middleware\ValidateSignature::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
];
}

View File

@ -0,0 +1,21 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Auth\Middleware\Authenticate as Middleware;
class Authenticate extends Middleware
{
/**
* Get the path the user should be redirected to when they are not authenticated.
*
* @param \Illuminate\Http\Request $request
* @return string|null
*/
protected function redirectTo($request)
{
if (! $request->expectsJson()) {
return route('login');
}
}
}

View File

@ -0,0 +1,17 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Cookie\Middleware\EncryptCookies as Middleware;
class EncryptCookies extends Middleware
{
/**
* The names of the cookies that should not be encrypted.
*
* @var array<int, string>
*/
protected $except = [
//
];
}

View File

@ -0,0 +1,17 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance as Middleware;
class PreventRequestsDuringMaintenance extends Middleware
{
/**
* The URIs that should be reachable while maintenance mode is enabled.
*
* @var array<int, string>
*/
protected $except = [
//
];
}

View File

@ -0,0 +1,32 @@
<?php
namespace App\Http\Middleware;
use App\Providers\RouteServiceProvider;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
class RedirectIfAuthenticated
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next
* @param string|null ...$guards
* @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
*/
public function handle(Request $request, Closure $next, ...$guards)
{
$guards = empty($guards) ? [null] : $guards;
foreach ($guards as $guard) {
if (Auth::guard($guard)->check()) {
return redirect(RouteServiceProvider::HOME);
}
}
return $next($request);
}
}

View File

@ -0,0 +1,19 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\TrimStrings as Middleware;
class TrimStrings extends Middleware
{
/**
* The names of the attributes that should not be trimmed.
*
* @var array<int, string>
*/
protected $except = [
'current_password',
'password',
'password_confirmation',
];
}

View File

@ -0,0 +1,20 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Http\Middleware\TrustHosts as Middleware;
class TrustHosts extends Middleware
{
/**
* Get the host patterns that should be trusted.
*
* @return array<int, string|null>
*/
public function hosts()
{
return [
$this->allSubdomainsOfApplicationUrl(),
];
}
}

View File

@ -0,0 +1,28 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Http\Middleware\TrustProxies as Middleware;
use Illuminate\Http\Request;
class TrustProxies extends Middleware
{
/**
* The trusted proxies for this application.
*
* @var array<int, string>|string|null
*/
protected $proxies;
/**
* The headers that should be used to detect proxies.
*
* @var int
*/
protected $headers =
Request::HEADER_X_FORWARDED_FOR |
Request::HEADER_X_FORWARDED_HOST |
Request::HEADER_X_FORWARDED_PORT |
Request::HEADER_X_FORWARDED_PROTO |
Request::HEADER_X_FORWARDED_AWS_ELB;
}

View File

@ -0,0 +1,22 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Routing\Middleware\ValidateSignature as Middleware;
class ValidateSignature extends Middleware
{
/**
* The names of the parameters that should be ignored.
*
* @var array<int, string>
*/
protected $ignore = [
// 'fbclid',
// 'utm_campaign',
// 'utm_content',
// 'utm_medium',
// 'utm_source',
// 'utm_term',
];
}

View File

@ -0,0 +1,17 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
class VerifyCsrfToken extends Middleware
{
/**
* The URIs that should be excluded from CSRF verification.
*
* @var array<int, string>
*/
protected $except = [
//
];
}

26
app/Models/Brand.php Normal file
View File

@ -0,0 +1,26 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class Brand extends Model
{
use HasFactory, SoftDeletes;
protected $fillable = [
'name',
];
public function models()
{
return $this->hasMany(ProductModel::class,'brand_id','id')->withTrashed();
}
public function products()
{
return $this->hasMany(Product::class,'brand_id','id')->withTrashed();
}
}

17
app/Models/Building.php Normal file
View File

@ -0,0 +1,17 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class Building extends Model
{
use HasFactory, SoftDeletes;
public function rooms()
{
return $this->hasMany(Room::class,'building_id','id');
}
}

29
app/Models/Cabel.php Normal file
View File

@ -0,0 +1,29 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;
class Cabel extends Model
{
use HasFactory, SoftDeletes;
public function category(): BelongsTo
{
return $this->belongsTo(CabelCategory::class,'cabel_category_id')->withTrashed();
}
public function loans()
{
return $this->morphtoMany(User::class, 'loanable','loans')->where('loan_type_id','=',LoanType::where('name','=','Loan')->first()->id)->withTrashed();
}
public function reservations()
{
return $this->morphtoMany(User::class, 'loanable','loans')->where('loan_type_id','!=',LoanType::where('name','=','Loan')->first()->id)->withTrashed();
}
}

View File

@ -0,0 +1,17 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class CabelCategory extends Model
{
use HasFactory, SoftDeletes;
public function cabels()
{
return $this->hasMany(Cabel::class,'cabel_category_id','id')->withTrashed();
}
}

23
app/Models/Contract.php Normal file
View File

@ -0,0 +1,23 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Contract extends Model
{
use HasFactory;
protected $fillable = [
'timestamp',
'user_id',
'type'
];
public function user()
{
return $this->belongsTo(User::class, 'user_id')->withTrashed();
}
}

42
app/Models/Loan.php Normal file
View File

@ -0,0 +1,42 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Loan extends Model
{
use HasFactory;
protected $fillable = [
'user_id',
'room_id',
'loan_type_id',
'loanable_id',
'loanable_type',
'date_start',
'date_end',
'date_deadline',
];
public function user()
{
return $this->belongsTo(User::class, 'user_id')->withTrashed();
}
public function room()
{
return $this->belongsTo(Room::class, 'room_id')->withTrashed();
}
public function type()
{
return $this->belongsTo(LoanType::class, 'loan_type_id');
}
public function loanable()
{
return $this->morphTo()->withTrashed();
}
}

12
app/Models/LoanType.php Normal file
View File

@ -0,0 +1,12 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class LoanType extends Model
{
use HasFactory;
protected $table = "loan_types";
}

15
app/Models/LoanerType.php Normal file
View File

@ -0,0 +1,15 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class LoanerType extends Model
{
use HasFactory;
protected $fillable = [
'name'
];
}

40
app/Models/Log.php Normal file
View File

@ -0,0 +1,40 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Log extends Model
{
use HasFactory;
protected $fillable = [
'user_id',
'target_id',
'loggable_type',
'loggable_id',
'log',
'amount'
];
public function user()
{
return $this->belongsTo(User::class, 'user_id')->withTrashed();
}
public function target()
{
return $this->belongsTo(User::class, 'target_id')->withTrashed();
}
public function action()
{
return $this->belongsTo(LogAction::class, 'log_action_id');
}
public function loggable()
{
return $this->morphTo()->withTrashed();
}
}

15
app/Models/LogAction.php Normal file
View File

@ -0,0 +1,15 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class LogAction extends Model
{
use HasFactory;
protected $fillable = [
'name'
];
}

36
app/Models/Note.php Normal file
View File

@ -0,0 +1,36 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class Note extends Model
{
use HasFactory, SoftDeletes;
protected $fillable = [
'note_type_id',
'user_id',
'note',
'loanable_type',
'loanable_id'
];
public function user()
{
return $this->belongsTo(User::class,'user_id')->withTrashed();
}
public function type()
{
return $this->belongsTo(NoteType::class,'note_type_id');
}
public function loanable()
{
return $this->morphTo()->withTrashed();
}
}

11
app/Models/NoteType.php Normal file
View File

@ -0,0 +1,11 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class NoteType extends Model
{
use HasFactory;
}

25
app/Models/Permission.php Normal file
View File

@ -0,0 +1,25 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
class Permission extends Model
{
use HasFactory;
protected $fillable = [
'name'
];
/**
* Gets all the Roles with a relation with the Permission(Many to Many through role_has_permission)
* @return BelongsToMany
*/
public function roles(): BelongsToMany
{
return $this->belongsToMany(Role::class, "role_has_permission", "permission_id", "role_id")->withTimestamps();
}
}

43
app/Models/Product.php Normal file
View File

@ -0,0 +1,43 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class Product extends Model
{
use HasFactory, SoftDeletes;
public function category()
{
return $this->belongsTo(ProductCategory::class,'product_category_id','id')->withTrashed();
}
public function subcategory()
{
return $this->belongsTo(ProductSubcategory::class,'product_subcategory_id','id')->withTrashed();
}
public function brand()
{
return $this->belongsTo(Brand::class,'brand_id','id')->withTrashed();
}
public function model()
{
return $this->belongsTo(ProductModel::class,'product_model_id','id')->withTrashed();
}
public function loans()
{
return $this->morphtoMany(User::class, 'loanable','loans')->where('loan_type_id','=',LoanType::where('name','=','Loan')->first()->id);
}
public function reservations()
{
return $this->morphtoMany(User::class, 'loanable','loans')->where('loan_type_id','!=',LoanType::where('name','=','Loan')->first()->id);
}
}

View File

@ -0,0 +1,26 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class ProductCategory extends Model
{
use HasFactory, SoftDeletes;
protected $fillable = [
'name',
];
public function subcategories()
{
return $this->hasMany(ProductSubcategory::class,'product_category_id','id')->withTrashed();
}
public function products()
{
return $this->hasMany(Product::class,'product_category_id','id')->withTrashed();
}
}

View File

@ -0,0 +1,28 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class ProductModel extends Model
{
use HasFactory, SoftDeletes;
protected $fillable = [
'name',
'brand_id'
];
public function brand()
{
return $this->belongsTo(Brand::class,'brand_id','id')->withTrashed();
}
public function products()
{
return $this->hasMany(Product::class,'product_model_id','id')->withTrashed();
}
}

View File

@ -0,0 +1,27 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class ProductSubcategory extends Model
{
use HasFactory, SoftDeletes;
protected $fillable = [
'name',
'product_category_id'
];
public function category()
{
return $this->belongsTo(ProductCategory::class,'product_category_id','id')->withTrashed();
}
public function products()
{
return $this->hasMany(Product::class,'product_subcategory_id','id')->withTrashed();
}
}

33
app/Models/Role.php Normal file
View File

@ -0,0 +1,33 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;
class Role extends Model
{
use HasFactory, SoftDeletes;
protected $fillable = [
'name'
];
/**
* Gets all the Permissions with a relation with the roles(Many to Many through role_has_permission)
* @return BelongsToMany
*/
public function permissions(): BelongsToMany
{
return $this->belongsToMany(Permission::class, "role_has_permission", 'role_id', 'permission_id')->withTimestamps();
}
public function users(): HasMany
{
return $this->hasMany(User::class,'role_id');
}
}

26
app/Models/Room.php Normal file
View File

@ -0,0 +1,26 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class Room extends Model
{
use HasFactory, SoftDeletes;
public function building()
{
return $this->belongsTo(Building::class,'building_id','id')->withTrashed()
;
}
public function reservations()
{
return $this->hasMany(Loan::class,'room_id')
->where('loan_type_id','!=',LoanType::where('name','=','Loan')->first()->id)
;
}
}

79
app/Models/User.php Normal file
View File

@ -0,0 +1,79 @@
<?php
namespace App\Models;
// use Illuminate\Contracts\users\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Laravel\Sanctum\HasApiTokens;
use LdapRecord\Laravel\Auth\LdapAuthenticatable;
use LdapRecord\Laravel\Auth\AuthenticatesWithLdap;
class User extends Authenticatable implements LdapAuthenticatable
{
use HasApiTokens, HasFactory, Notifiable, SoftDeletes, AuthenticatesWithLdap;
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $fillable = [
'name',
'username',
'password',
'guid',
'domain'
];
/**
* The attributes that should be hidden for serialization.
*
* @var array<int, string>
*/
protected $hidden = [
'password',
'remember_token',
];
/**
* Gets the Loaner Type that the users belongs to
* @return BelongsTo
*/
public function loanerType(): BelongsTo
{
return $this->belongsTo(LoanerType::class);
}
/**
* Gets the roles that the users belongs to
* @return BelongsTo
*/
public function role(): BelongsTo
{
return $this->belongsTo(Role::class);
}
public function loans()
{
return $this->hasMany(Loan::class,'user_id')
->where('loan_type_id','=',LoanType::where('name','=','Loan')->first()->id)
;
}
public function reservations()
{
return $this->hasMany(Loan::class,'user_id')
->where('loan_type_id','!=',LoanType::where('name','=','Loan')->first()->id)
;
}
public function notes()
{
return $this->hasMany(Note::class,'user_id');
}
}

View File

@ -0,0 +1,128 @@
<?php
namespace App\Policies;
use App\Models\Brand;
use App\Models\Permission;
use App\Models\User;
use Illuminate\Auth\Access\HandlesAuthorization;
use Illuminate\Auth\Access\Response;
use Illuminate\Support\Facades\Auth;
class BrandPolicy
{
use HandlesAuthorization;
/**
* Create a new policy instance.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Determine whether the user can view any models.
*
* @return Response
*/
public function viewAny(): Response
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','brands_viewAny'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can view any models.
*
* @return Response
*/
public function viewAny_deleted(): Response
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','brands_viewAny_deleted'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can view the model.
*
* @param Brand $Brand
* @param User $model
* @return Response
*/
public function view(): Response
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','brands_view'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can create models.
*
* @return Response
*/
public function create(): Response
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','brands_create'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can update the model.
*
* @param Brand $Brand
* @return Response
*/
public function edit(): Response
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','brands_edit'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can delete the model.
*
* @param Brand $Brand
* @return Response
*/
public function delete(): Response
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','brands_delete'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can restore the model.
*
* @param Brand $Brand
* @return Response|bool
*/
public function restore()
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','brands_restore'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can permanently delete the model.
*
* @param Brand $Brand
* @return Response|bool
*/
public function delete_force()
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','brands_delete_force'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
}

View File

@ -0,0 +1,123 @@
<?php
namespace App\Policies;
use App\Models\Building;
use App\Models\Permission;
use App\Models\Room;
use App\Models\User;
use Illuminate\Auth\Access\HandlesAuthorization;
use Illuminate\Auth\Access\Response;
use Illuminate\Support\Facades\Auth;
class BuildingPolicy
{
use HandlesAuthorization;
/**
* Create a new policy instance.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Determine whether the user can view any models.
*
* @return Response
*/
public function viewAny(): Response
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','buildings_viewAny'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can view any models.
*
* @return Response
*/
public function viewAny_deleted(): Response
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','buildings_viewAny_deleted'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can view the model.
*
* @return Response
*/
public function view(): Response
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','buildings_view'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can create models.
*
* @return Response
*/
public function create(): Response
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','buildings_create'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can update the model.
*
* @return Response
*/
public function edit(): Response
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','buildings_edit'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can delete the model.
*
* @return Response
*/
public function delete(): Response
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','buildings_delete'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can restore the model.
*
* @return Response|bool
*/
public function restore()
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','buildings_restore'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can permanently delete the model.
*
* @return Response|bool
*/
public function delete_force()
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','buildings_delete_force'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
}

View File

@ -0,0 +1,121 @@
<?php
namespace App\Policies;
use App\Models\CabelCategory;
use App\Models\Permission;
use Illuminate\Auth\Access\HandlesAuthorization;
use Illuminate\Auth\Access\Response;
use Illuminate\Support\Facades\Auth;
class CabelCategoryPolicy
{
use HandlesAuthorization;
/**
* Create a new policy instance.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Determine whether the user can view any models.
*
* @return Response
*/
public function viewAny(): Response
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','cabelCategories_viewAny'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can view any models.
*
* @return Response
*/
public function viewAny_deleted(): Response
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','cabelCategories_viewAny_deleted'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can view the model.
*
* @return Response
*/
public function view(): Response
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','cabelCategories_view'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can create models.
*
* @return Response
*/
public function create(): Response
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','cabelCategories_create'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can update the model.
*
* @return Response
*/
public function edit(): Response
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','cabelCategories_edit'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can delete the model.
*
* @return Response
*/
public function delete(): Response
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','cabelCategories_delete'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can restore the model.
*
* @return Response|bool
*/
public function restore()
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','cabelCategories_restore'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can permanently delete the model.
*
* @return Response|bool
*/
public function delete_force()
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','cabelCategories_delete_force'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
}

View File

@ -0,0 +1,146 @@
<?php
namespace App\Policies;
use App\Models\Cabel;
use App\Models\Permission;
use App\Models\User;
use Illuminate\Auth\Access\HandlesAuthorization;
use Illuminate\Auth\Access\Response;
use Illuminate\Support\Facades\Auth;
class CabelPolicy
{
use HandlesAuthorization;
/**
* Create a new policy instance.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Determine whether the user can view any models.
*
* @return Response
*/
public function viewAny(): Response
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','cabels_viewAny'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can view any models.
*
* @return Response
*/
public function viewAny_deleted(): Response
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','cabels_viewAny_deleted'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can view the model.
*
* @return Response
*/
public function view(): Response
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','cabels_view'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can create models.
*
* @return Response
*/
public function create(): Response
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','cabels_create'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can update the model.
*
* @return Response
*/
public function edit(): Response
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','cabels_edit'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can delete the model.
*
* @return Response
*/
public function delete(): Response
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','cabels_delete'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can delete the model.
*
* @return Response
*/
public function delete_force(): Response
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','cabels_delete_force'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can restore the model.
*
* @return Response|bool
*/
public function restore()
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','cabels_restore'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can add to the pool.
*
* @return Response|bool
*/
public function amount_add()
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','cabels_amount_add'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can remove from the pool.
*
* @return Response|bool
*/
public function amount_remove()
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','cabels_amount_remove'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
}

View File

@ -0,0 +1,122 @@
<?php
namespace App\Policies;
use App\Models\ProductCategory;
use App\Models\Permission;
use App\Models\User;
use Illuminate\Auth\Access\HandlesAuthorization;
use Illuminate\Auth\Access\Response;
use Illuminate\Support\Facades\Auth;
class CategoryPolicy
{
use HandlesAuthorization;
/**
* Create a new policy instance.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Determine whether the user can view any models.
*
* @return Response
*/
public function viewAny(): Response
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','categories_viewAny'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can view any models.
*
* @return Response
*/
public function viewAny_deleted(): Response
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','categories_viewAny_deleted'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can view the model.
*
* @return Response
*/
public function view(): Response
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','categories_view'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can create models.
*
* @return Response
*/
public function create(): Response
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','categories_create'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can update the model.
*
* @return Response
*/
public function edit(): Response
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','categories_edit'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can delete the model.
*
* @return Response
*/
public function delete(): Response
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','categories_delete'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can restore the model.
*
* @return Response|bool
*/
public function restore()
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','categories_restore'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can permanently delete the model.
*
* @return Response|bool
*/
public function delete_force()
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','categories_delete_force'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
}

View File

@ -0,0 +1,85 @@
<?php
namespace App\Policies;
use App\Models\Permission;
use App\Models\User;
use Illuminate\Auth\Access\HandlesAuthorization;
use Illuminate\Auth\Access\Response;
use Illuminate\Support\Facades\Auth;
class LoanPolicy
{
use HandlesAuthorization;
/**
* Create a new policy instance.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Determine whether the user can view any models.
*
* @return Response
*/
public function viewAny(): Response
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','loans_viewAny'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can create models.
*
* @return Response
*/
public function create_user(): Response
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','loans_create_user'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can create models.
*
* @return Response
*/
public function create_laptop(): Response
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','loans_create_laptop'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can update the model.
*
* @return Response
*/
public function adjust(): Response
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','loans_adjust'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can delete the model.
*
* @return Response
*/
public function return(): Response
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','loans_return'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
}

View File

@ -0,0 +1,123 @@
<?php
namespace App\Policies;
use App\Models\Productmodel;
use App\Models\Permission;
use App\Models\User;
use Illuminate\Auth\Access\HandlesAuthorization;
use Illuminate\Auth\Access\Response;
use Illuminate\Support\Facades\Auth;
class ModelPolicy
{
use HandlesAuthorization;
/**
* Create a new policy instance.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Determine whether the user can view any models.
*
* @return Response
*/
public function viewAny(): Response
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','models_viewAny'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can view any models.
*
* @return Response
*/
public function viewAny_deleted(): Response
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','models_viewAny_deleted'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can view the model.
*
* @return Response
*/
public function view(): Response
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','models_view'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can create models.
*
* @return Response
*/
public function create(): Response
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','models_create'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can update the model.
*
* @return Response
*/
public function edit(): Response
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','models_edit'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can delete the model.
*
* @return Response
*/
public function delete(): Response
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','models_delete'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can permanently delete the model.
*
* @return Response|bool
*/
public function delete_force()
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','models_delete_force'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can restore the model.
*
* @return Response|bool
*/
public function restore()
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','models_restore'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
}

121
app/Policies/NotePolicy.php Normal file
View File

@ -0,0 +1,121 @@
<?php
namespace App\Policies;
use App\Models\Permission;
use Illuminate\Auth\Access\HandlesAuthorization;
use Illuminate\Auth\Access\Response;
use Illuminate\Support\Facades\Auth;
class NotePolicy
{
use HandlesAuthorization;
/**
* Create a new policy instance.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Determine whether the user can view any notes.
*
* @return Response
*/
public function viewAny(): Response
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','notes_viewAny'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can view any notes.
*
* @return Response
*/
public function viewAny_deleted(): Response
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','notes_viewAny_deleted'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can view the model.
*
* @return Response
*/
public function view(): Response
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','notes_view'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can create notes.
*
* @return Response
*/
public function create(): Response
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','notes_create'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can update the model.
*
* @return Response
*/
public function edit(): Response
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','notes_edit'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can delete the model.
*
* @return Response
*/
public function delete(): Response
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','notes_delete'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can permanently delete the model.
*
* @return Response|bool
*/
public function delete_force()
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','notes_delete_force'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can restore the model.
*
* @return Response|bool
*/
public function restore()
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','notes_restore'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
}

View File

@ -0,0 +1,45 @@
<?php
namespace App\Policies;
use App\Models\Permission;
use App\Models\User;
use Illuminate\Auth\Access\HandlesAuthorization;
use Illuminate\Auth\Access\Response;
use Illuminate\Support\Facades\Auth;
class OtherPolicy
{
use HandlesAuthorization;
/**
* Create a new policy instance.
*
* @return void
*/
public function __construct()
{
//
}
public function logs()
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','logs_viewAny'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
public function home_page()
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','home_page'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
public function statistics()
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','statistics'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
}

View File

@ -0,0 +1,61 @@
<?php
namespace App\Policies;
use App\Models\Permission;
use App\Models\User;
use Illuminate\Auth\Access\HandlesAuthorization;
use Illuminate\Auth\Access\Response;
use Illuminate\Support\Facades\Auth;
class PDFPolicy
{
use HandlesAuthorization;
/**
* Create a new policy instance.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Determine whether the user can view any models.
*
* @return Response
*/
public function viewAny(): Response
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','pdf_viewAny'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can update the model.
*
* @return Response
*/
public function view(): Response
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','pdf_view'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can delete the model.
*
* @return Response
*/
public function delete(): Response
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','pdf_delete'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
}

View File

@ -0,0 +1,144 @@
<?php
namespace App\Policies;
use App\Models\Permission;
use App\Models\User;
use Illuminate\Auth\Access\HandlesAuthorization;
use Illuminate\Auth\Access\Response;
use Illuminate\Support\Facades\Auth;
class ProductPolicy
{
use HandlesAuthorization;
/**
* Create a new policy instance.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Determine whether the user can view any models.
*
* @return Response
*/
public function viewAny(): Response
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','products_viewAny'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can view any models.
*
* @return Response
*/
public function viewAny_deleted(): Response
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','products_viewAny_deleted'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can view the model.
*
* @return Response
*/
public function view(): Response
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','products_view'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can create models.
*
* @return Response
*/
public function create(): Response
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','products_create'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can update the model.
*
* @return Response
*/
public function edit(): Response
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','products_edit'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can delete the model.
*
* @return Response
*/
public function delete(): Response
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','products_delete'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can restore the model.
*
* @return Response|bool
*/
public function restore()
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','products_restore'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can permanently delete the model.
*
* @return Response|bool
*/
public function delete_force()
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','products_delete_force'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can add to the pool.
*
* @return Response|bool
*/
public function amount_add()
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','products_amount_add'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can remove from the pool.
*
* @return Response|bool
*/
public function amount_remove()
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','products_amount_remove'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
}

View File

@ -0,0 +1,119 @@
<?php
namespace App\Policies;
use App\Models\Permission;
use App\Models\User;
use Illuminate\Auth\Access\HandlesAuthorization;
use Illuminate\Auth\Access\Response;
use Illuminate\Support\Facades\Auth;
class ReservationPolicy
{
use HandlesAuthorization;
/**
* Create a new policy instance.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Determine whether the user can view any models.
*
* @return Response
*/
public function viewAny(): Response
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','reservations_viewAny'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can create models.
*
* @return Response
*/
public function create(): Response
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','reservations_create'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can update the model.
*
* @return Response
*/
public function extend(): Response
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','reservations_extend'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can delete the model.
*
* @return Response
*/
public function return(): Response
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','reservations_return'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can validate the model.
*
* @return Response
*/
public function validate(): Response
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','reservations_validate'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can cancel the model.
*
* @return Response
*/
public function cancel(): Response
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','reservations_cancel'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can delete the model.
*
* @return Response
*/
public function pickup(): Response
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','reservations_pickup'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can delete the model.
*
* @return Response
*/
public function setup(): Response
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','reservations_setup'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
}

127
app/Policies/RolePolicy.php Normal file
View File

@ -0,0 +1,127 @@
<?php
namespace App\Policies;
use App\Models\Permission;
use Illuminate\Auth\Access\HandlesAuthorization;
use Illuminate\Auth\Access\Response;
use Illuminate\Support\Facades\Auth;
class RolePolicy
{
use HandlesAuthorization;
/**
* Create a new policy instance.
*
* @return void
*/
public function __construct()
{
//
}
public function viewAny(): Response
{
//ConsoleLogger::DebugToConsole("users Policy - viewAny - returns: ".$user->role->permissions->contains(Permission::firstWhere('name', '=', 'user_view_any')));
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','roles_viewAny'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
public function viewAny_deleted(): Response
{
//ConsoleLogger::DebugToConsole("users Policy - viewAny - returns: ".$user->role->permissions->contains(Permission::firstWhere('name', '=', 'user_view_any')));
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','roles_viewAny_deleted'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can view the model.
*
* @return Response
*/
public function view(): Response
{
//ConsoleLogger::DebugToConsole("users Policy - View - returns: ".$user->role->permissions->contains(Permission::firstWhere('name', '=', 'user_view')));
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','roles_view'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can create models.
*
* @return Response
*/
public function create(): Response
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','roles_create'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can update the model.
*
* @return Response
*/
public function edit(): Response
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','roles_edit'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can delete the model.
*
* @return Response
*/
public function delete(): Response
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','roles_delete'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can restore the model.
*
* @return Response|bool
*/
public function restore()
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','roles_restore'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can permanently delete the model.
*
* @return Response|bool
*/
public function delete_force()
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','roles_delete_force'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can permanently delete the model.
*
* @return Response|bool
*/
public function edit_permissions()
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','roles_edit_permissions'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
}

123
app/Policies/RoomPolicy.php Normal file
View File

@ -0,0 +1,123 @@
<?php
namespace App\Policies;
use App\Models\Permission;
use App\Models\Room;
use App\Models\User;
use Illuminate\Auth\Access\HandlesAuthorization;
use Illuminate\Auth\Access\Response;
use Illuminate\Support\Facades\Auth;
class RoomPolicy
{
use HandlesAuthorization;
/**
* Create a new policy instance.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Determine whether the user can view any models.
*
* @return Response
*/
public function viewAny(): Response
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','rooms_viewAny'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can view any models.
*
* @return Response
*/
public function viewAny_deleted(): Response
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','rooms_viewAny_deleted'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can view the model.
*
* @return Response
*/
public function view(): Response
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','rooms_view'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can create models.
*
* @return Response
*/
public function create(): Response
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','rooms_create'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can update the model.
*
* @return Response
*/
public function edit(): Response
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','rooms_edit'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can delete the model.
*
* @return Response
*/
public function delete(): Response
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','rooms_delete'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can restore the model.
*
* @return Response|bool
*/
public function restore()
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','rooms_restore'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can permanently delete the model.
*
* @return Response|bool
*/
public function delete_force()
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','rooms_delete_force'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
}

View File

@ -0,0 +1,125 @@
<?php
namespace App\Policies;
use App\Models\Permission;
use App\Models\Room;
use App\Models\User;
use Illuminate\Auth\Access\HandlesAuthorization;
use Illuminate\Auth\Access\Response;
use Illuminate\Support\Facades\Auth;
class SubcategoryPolicy
{
use HandlesAuthorization;
/**
* Create a new policy instance.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Determine whether the user can view any models.
*
* @return Response
*/
public function viewAny(): Response
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','subcategories_viewAny'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can view any models.
*
* @return Response
*/
public function viewAny_deleted(): Response
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','subcategories_viewAny_deleted'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can view the model.
*
* @return Response
*/
public function view(): Response
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','subcategories_view'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can create models.
*
* @return Response
*/
public function create(): Response
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','subcategories_create'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can update the model.
*
* @return Response
*/
public function edit(): Response
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','subcategories_edit'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can delete the model.
*
* @return Response
*/
public function delete(): Response
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','subcategories_delete'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can restore the model.
*
* @return Response|bool
*/
public function restore()
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','subcategories_restore'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can permanently delete the model.
*
* @return Response|bool
*/
public function delete_force()
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','subcategories_delete_force'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
}

156
app/Policies/UserPolicy.php Normal file
View File

@ -0,0 +1,156 @@
<?php
namespace App\Policies;
use App\Models\Permission;
use App\Models\User;
use Illuminate\Auth\Access\HandlesAuthorization;
use Illuminate\Auth\Access\Response;
use Illuminate\Support\Facades\Auth;
class UserPolicy
{
use HandlesAuthorization;
/**
* Create a new policy instance.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Determine whether the user can view any models.
*
* @return Response
*/
public function viewAny(): Response
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'users_viewAny'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can view any models.
*
* @return Response
*/
public function viewAny_deleted(): Response
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'users_viewAny_deleted'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can view the model.
*
* @param User $user
* @param User $model
* @return Response
*/
public function view(User $user): Response
{
return ($user->id === Auth::user()->id
or Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'users_view')))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can create models.
*
* @return Response
*/
public function create(): Response
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'users_create'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can update the model.
*
* @param User $user
* @return Response
*/
public function edit(User $user): Response
{
return ($user->id === Auth::user()->id
or Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'users_edit')))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can delete the model.
*
* @param User $user
* @return Response
*/
public function delete(User $user): Response
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'users_delete'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can restore the model.
*
* @param User $user
* @return Response|bool
*/
public function restore(User $user)
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'users_restore'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can permanently delete the model.
*
* @param User $user
* @return Response|bool
*/
public function delete_force(User $user)
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'users_delete_force'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can permanently delete the model.
*
* @param User $user
* @return Response|bool
*/
public function edit_username(User $user)
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'users_edit_username'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can permanently delete the model.
*
* @param User $user
* @return Response|bool
*/
public function edit_role(User $user)
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name', '=', 'users_edit_role'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
}

View File

@ -0,0 +1,31 @@
<?php
namespace App\Providers;
use Illuminate\Pagination\Paginator;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*
* @return void
*/
public function register()
{
//
}
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
Paginator::useBootstrap();
Schema::defaultStringLength(191);
}
}

View File

@ -0,0 +1,222 @@
<?php
namespace App\Providers;
// use Illuminate\Support\Facades\Gate;
use App\Models\Brand;
use App\Models\Building;
use App\Models\Cabel;
use App\Models\Cabelcategory;
use App\Models\Note;
use App\Models\Product;
use App\Models\ProductCategory;
use App\Models\ProductModel;
use App\Models\ProductSubcategory;
use App\Models\Role;
use App\Models\Room;
use App\Models\User;
use App\Policies\BrandPolicy;
use App\Policies\BuildingPolicy;
use App\Policies\CabelcategoryPolicy;
use App\Policies\CabelPolicy;
use App\Policies\CategoryPolicy;
use App\Policies\LoanPolicy;
use App\Policies\ModelPolicy;
use App\Policies\NotePolicy;
use App\Policies\OtherPolicy;
use App\Policies\PDFPolicy;
use App\Policies\ProductPolicy;
use App\Policies\ReservationPolicy;
use App\Policies\RolePolicy;
use App\Policies\RoomPolicy;
use App\Policies\SubcategoryPolicy;
use App\Policies\UserPolicy;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Gate;
class AuthServiceProvider extends ServiceProvider
{
/**
* The model to policy mappings for the application.
*
* @var array<class-string, class-string>
*/
protected $policies = [
// 'App\Models\models' => 'App\Policies\ModelPolicy',
Role::class => RolePolicy::class,
User::class => UserPolicy::class,
Building::class => BuildingPolicy::class,
Room::class => RoomPolicy::class,
Brand::class => BrandPolicy::class,
ProductModel::class => ModelPolicy::class,
ProductCategory::class => CategoryPolicy::class,
ProductSubcategory::class => SubcategoryPolicy::class,
Product::class => ProductPolicy::class,
Cabel::class => CabelPolicy::class,
Cabelcategory::class => CabelcategoryPolicy::class,
Note::class => NotePolicy::class,
];
/**
* Register any authentication / authorization services.
*
* @return void
*/
public function boot()
{
$this->registerPolicies();
// users Policy
Gate::define('users_viewAny', [UserPolicy::class,'viewAny']);
Gate::define('users_viewAny_deleted', [UserPolicy::class,'viewAny_deleted']);
Gate::define('users_view', [UserPolicy::class,'view']);
Gate::define('users_edit', [UserPolicy::class,'edit']);
Gate::define('users_edit_role', [UserPolicy::class,'edit_role']);
Gate::define('users_edit_username', [UserPolicy::class,'edit_username']);
Gate::define('users_delete', [UserPolicy::class,'delete']);
Gate::define('users_delete_force', [UserPolicy::class,'delete_force']);
Gate::define('users_restore', [UserPolicy::class,'restore']);
// buildings Policy
Gate::define('buildings_viewAny', [BuildingPolicy::class,'viewAny']);
Gate::define('buildings_viewAny_deleted', [BuildingPolicy::class,'viewAny_deleted']);
Gate::define('buildings_view', [BuildingPolicy::class,'view']);
Gate::define('buildings_create', [BuildingPolicy::class,'create']);
Gate::define('buildings_edit', [BuildingPolicy::class,'edit']);
Gate::define('buildings_delete', [BuildingPolicy::class,'delete']);
Gate::define('buildings_delete_force', [BuildingPolicy::class,'delete_force']);
Gate::define('buildings_restore', [BuildingPolicy::class,'restore']);
// rooms Policy
Gate::define('rooms_viewAny', [RoomPolicy::class,'viewAny']);
Gate::define('rooms_viewAny_deleted', [RoomPolicy::class,'viewAny_deleted']);
Gate::define('rooms_view', [RoomPolicy::class,'view']);
Gate::define('rooms_create', [RoomPolicy::class,'create']);
Gate::define('rooms_edit', [RoomPolicy::class,'edit']);
Gate::define('rooms_delete', [RoomPolicy::class,'delete']);
Gate::define('rooms_delete_force', [RoomPolicy::class,'delete_force']);
Gate::define('rooms_restore', [RoomPolicy::class,'restore']);
//PDF
Gate::define('pdf_viewAny',[PDFPolicy::class,'viewAny']);
Gate::define('pdf_view',[PDFPolicy::class,'view']);
Gate::define('pdf_delete',[PDFPolicy::class,'delete']);
// roles Policy
Gate::define('roles_viewAny', [RolePolicy::class, 'viewAny']);
Gate::define('roles_viewAny_deleted', [RolePolicy::class, 'viewAny_deleted']);
Gate::define('roles_view', [RolePolicy::class, 'view']);
Gate::define('roles_create', [RolePolicy::class, 'create']);
Gate::define('roles_edit', [RolePolicy::class, 'edit']);
Gate::define('roles_edit_permissions', [RolePolicy::class, 'edit_permissions']);
Gate::define('roles_delete', [RolePolicy::class, 'delete']);
Gate::define('roles_delete_force', [RolePolicy::class, 'delete_force']);
Gate::define('roles_restore', [RolePolicy::class, 'restore']);
// brands Policy
Gate::define('brands_viewAny', [BrandPolicy::class, 'viewAny']);
Gate::define('brands_viewAny_deleted', [BrandPolicy::class, 'viewAny_deleted']);
Gate::define('brands_view', [BrandPolicy::class, 'view']);
Gate::define('brands_create', [BrandPolicy::class, 'create']);
Gate::define('brands_edit', [BrandPolicy::class, 'edit']);
Gate::define('brands_delete', [BrandPolicy::class, 'delete']);
Gate::define('brands_delete_force', [BrandPolicy::class, 'delete_force']);
Gate::define('brands_restore', [BrandPolicy::class, 'restore']);
// models Policy
Gate::define('models_viewAny', [ModelPolicy::class, 'viewAny']);
Gate::define('models_viewAny_deleted', [ModelPolicy::class, 'viewAny_deleted']);
Gate::define('models_view', [ModelPolicy::class, 'view']);
Gate::define('models_create', [ModelPolicy::class, 'create']);
Gate::define('models_edit', [ModelPolicy::class, 'edit']);
Gate::define('models_delete', [ModelPolicy::class, 'delete']);
Gate::define('models_delete_force', [ModelPolicy::class, 'delete_force']);
Gate::define('models_restore', [ModelPolicy::class, 'restore']);
// categories Policy
Gate::define('categories_viewAny', [CategoryPolicy::class, 'viewAny']);
Gate::define('categories_viewAny_deleted', [CategoryPolicy::class, 'viewAny_deleted']);
Gate::define('categories_view', [CategoryPolicy::class, 'view']);
Gate::define('categories_create', [CategoryPolicy::class, 'create']);
Gate::define('categories_edit', [CategoryPolicy::class, 'edit']);
Gate::define('categories_delete', [CategoryPolicy::class, 'delete']);
Gate::define('categories_delete_force', [CategoryPolicy::class, 'delete_force']);
Gate::define('categories_restore', [CategoryPolicy::class, 'restore']);
// subcategories Policy
Gate::define('subcategories_viewAny', [SubcategoryPolicy::class, 'viewAny']);
Gate::define('subcategories_viewAny_deleted', [SubcategoryPolicy::class, 'viewAny_deleted']);
Gate::define('subcategories_view', [SubcategoryPolicy::class, 'view']);
Gate::define('subcategories_create', [SubcategoryPolicy::class, 'create']);
Gate::define('subcategories_edit', [SubcategoryPolicy::class, 'edit']);
Gate::define('subcategories_delete', [SubcategoryPolicy::class, 'delete']);
Gate::define('subcategories_delete_force', [SubcategoryPolicy::class, 'delete_force']);
Gate::define('subcategories_restore', [SubcategoryPolicy::class, 'restore']);
// products Policy
Gate::define('products_viewAny', [ProductPolicy::class, 'viewAny']);
Gate::define('products_viewAny_deleted', [ProductPolicy::class, 'viewAny_deleted']);
Gate::define('products_view', [ProductPolicy::class, 'view']);
Gate::define('products_create', [ProductPolicy::class, 'create']);
Gate::define('products_edit', [ProductPolicy::class, 'edit']);
Gate::define('products_delete', [ProductPolicy::class, 'delete']);
Gate::define('products_delete_force', [ProductPolicy::class, 'delete_force']);
Gate::define('products_restore', [ProductPolicy::class, 'restore']);
Gate::define('products_amount_add', [ProductPolicy::class, 'amount_add']);
Gate::define('products_amount_remove', [ProductPolicy::class, 'amount_remove']);
// cabel categories Policy
Gate::define('cabelCategories_viewAny',[CabelcategoryPolicy::class,'viewAny']);
Gate::define('cabelCategories_viewAny_deleted',[CabelcategoryPolicy::class,'viewAny_deleted']);
Gate::define('cabelCategories_view',[CabelcategoryPolicy::class,'view']);
Gate::define('cabelCategories_create',[CabelcategoryPolicy::class,'create']);
Gate::define('cabelCategories_edit',[CabelcategoryPolicy::class,'edit']);
Gate::define('cabelCategories_delete',[CabelcategoryPolicy::class,'delete']);
Gate::define('cabelCategories_delete_force',[CabelcategoryPolicy::class,'delete_force']);
Gate::define('cabelCategories_restore',[CabelcategoryPolicy::class,'restore']);
// cabels Policy
Gate::define('cabels_viewAny',[CabelPolicy::class,'viewAny']);
Gate::define('cabels_viewAny_deleted',[CabelPolicy::class,'viewAny_deleted']);
Gate::define('cabels_view',[CabelPolicy::class,'view']);
Gate::define('cabels_create',[CabelPolicy::class,'create']);
Gate::define('cabels_edit',[CabelPolicy::class,'edit']);
Gate::define('cabels_delete',[CabelPolicy::class,'delete']);
Gate::define('cabels_delete_force',[CabelPolicy::class,'delete_force']);
Gate::define('cabels_restore',[CabelPolicy::class,'restore']);
Gate::define('cabels_amount_add',[CabelPolicy::class,'amount_add']);
Gate::define('cabels_amount_remove',[CabelPolicy::class,'amount_remove']);
// loans Policy
Gate::define('loans_viewAny',[LoanPolicy::class,'viewAny']);
Gate::define('loans_create_user',[LoanPolicy::class,'create_user']);
Gate::define('loans_create_laptop',[LoanPolicy::class,'create_laptop']);
Gate::define('loans_adjust',[LoanPolicy::class,'adjust']);
Gate::define('loans_return',[LoanPolicy::class,'return']);
// reservations
Gate::define('reservations_viewAny',[ReservationPolicy::class,'viewAny']);
Gate::define('reservations_create',[ReservationPolicy::class,'create']);
Gate::define('reservations_validate',[ReservationPolicy::class,'validate']);
Gate::define('reservations_cancel',[ReservationPolicy::class,'cancel']);
Gate::define('reservations_setup',[ReservationPolicy::class,'setup']);
Gate::define('reservations_pickup',[ReservationPolicy::class,'pickup']);
Gate::define('reservations_extend',[ReservationPolicy::class,'extend']);
Gate::define('reservations_return',[ReservationPolicy::class,'return']);
// notes
Gate::define('notes_viewAny',[NotePolicy::class,'viewAny']);
Gate::define('notes_viewAny_deleted',[NotePolicy::class,'viewAny_deleted']);
Gate::define('notes_view',[NotePolicy::class,'view']);
Gate::define('notes_create',[NotePolicy::class,'create']);
Gate::define('notes_edit',[NotePolicy::class,'edit']);
Gate::define('notes_delete',[NotePolicy::class,'delete']);
Gate::define('notes_delete_force',[NotePolicy::class,'delete_force']);
Gate::define('notes_restore',[NotePolicy::class,'restore']);
// Other
Gate::define('home_page',[OtherPolicy::class,'home_page']);
Gate::define('logs_viewAny',[OtherPolicy::class,'logs']);
Gate::define('statistics',[OtherPolicy::class,'statistics']);
}
}

View File

@ -0,0 +1,21 @@
<?php
namespace App\Providers;
use Illuminate\Support\Facades\Broadcast;
use Illuminate\Support\ServiceProvider;
class BroadcastServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
Broadcast::routes();
require base_path('routes/channels.php');
}
}

View File

@ -0,0 +1,42 @@
<?php
namespace App\Providers;
use Illuminate\Auth\Events\Registered;
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Event;
class EventServiceProvider extends ServiceProvider
{
/**
* The event to listener mappings for the application.
*
* @var array<class-string, array<int, class-string>>
*/
protected $listen = [
Registered::class => [
SendEmailVerificationNotification::class,
],
];
/**
* Register any events for your application.
*
* @return void
*/
public function boot()
{
//
}
/**
* Determine if events and listeners should be automatically discovered.
*
* @return bool
*/
public function shouldDiscoverEvents()
{
return false;
}
}

View File

@ -0,0 +1,52 @@
<?php
namespace App\Providers;
use Illuminate\Cache\RateLimiting\Limit;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\RateLimiter;
use Illuminate\Support\Facades\Route;
class RouteServiceProvider extends ServiceProvider
{
/**
* The path to the "home" route for your application.
*
* Typically, users are redirected here after authentication.
*
* @var string
*/
public const HOME = '/home';
/**
* Define your route model bindings, pattern filters, and other route configuration.
*
* @return void
*/
public function boot()
{
$this->configureRateLimiting();
$this->routes(function () {
Route::middleware('api')
->prefix('api')
->group(base_path('routes/api.php'));
Route::middleware('web')
->group(base_path('routes/web.php'));
});
}
/**
* Configure the rate limiters for the application.
*
* @return void
*/
protected function configureRateLimiting()
{
RateLimiter::for('api', function (Request $request) {
return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip());
});
}
}

53
artisan Normal file
View File

@ -0,0 +1,53 @@
#!/usr/bin/env php
<?php
define('LARAVEL_START', microtime(true));
/*
|--------------------------------------------------------------------------
| 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 of our classes manually. It's great to relax.
|
*/
require __DIR__.'/vendor/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);

55
bootstrap/app.php Normal file
View File

@ -0,0 +1,55 @@
<?php
/*
|--------------------------------------------------------------------------
| Create The Application
|--------------------------------------------------------------------------
|
| The first thing we will do is create a new Laravel application instance
| which serves as the "glue" for all the components of Laravel, and is
| the IoC container for the system binding all of the various parts.
|
*/
$app = new Illuminate\Foundation\Application(
$_ENV['APP_BASE_PATH'] ?? dirname(__DIR__)
);
/*
|--------------------------------------------------------------------------
| Bind Important Interfaces
|--------------------------------------------------------------------------
|
| Next, we need to bind some important interfaces into the container so
| we will be able to resolve them when needed. The kernels serve the
| incoming requests to this application from both the web and CLI.
|
*/
$app->singleton(
Illuminate\Contracts\Http\Kernel::class,
App\Http\Kernel::class
);
$app->singleton(
Illuminate\Contracts\Console\Kernel::class,
App\Console\Kernel::class
);
$app->singleton(
Illuminate\Contracts\Debug\ExceptionHandler::class,
App\Exceptions\Handler::class
);
/*
|--------------------------------------------------------------------------
| Return The Application
|--------------------------------------------------------------------------
|
| This script returns the application instance. The instance is given to
| the calling script so we can separate the building of the instances
| from the actual running of the application and sending responses.
|
*/
return $app;

2
bootstrap/cache/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
*
!.gitignore

69
composer.json Normal file
View File

@ -0,0 +1,69 @@
{
"name": "laravel/laravel",
"type": "project",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"require": {
"php": "^8.0.2",
"barryvdh/laravel-dompdf": "^2.0",
"directorytree/ldaprecord-laravel": "^2.6",
"guzzlehttp/guzzle": "^7.2",
"laravel/framework": "^9.19",
"laravel/sanctum": "^3.0",
"laravel/tinker": "^2.7",
"mailjet/laravel-mailjet": "^3.0",
"ext-pdo": "*"
},
"require-dev": {
"fakerphp/faker": "^1.9.1",
"laravel/pint": "^1.0",
"laravel/sail": "^1.0.1",
"mockery/mockery": "^1.4.4",
"nunomaduro/collision": "^6.1",
"phpunit/phpunit": "^9.5.10",
"spatie/laravel-ignition": "^1.0"
},
"autoload": {
"psr-4": {
"App\\": "app/",
"Database\\Factories\\": "database/factories/",
"Database\\Seeders\\": "database/seeders/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"scripts": {
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"@php artisan package:discover --ansi"
],
"post-update-cmd": [
"@php artisan vendor:publish --tag=laravel-assets --ansi --force"
],
"post-root-package-install": [
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"@php artisan key:generate --ansi"
]
},
"extra": {
"laravel": {
"dont-discover": []
}
},
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true,
"allow-plugins": {
"pestphp/pest-plugin": true
}
},
"minimum-stability": "dev",
"prefer-stable": true
}

8566
composer.lock generated Normal file

File diff suppressed because it is too large Load Diff

239
config/app.php Normal file
View File

@ -0,0 +1,239 @@
<?php
use Illuminate\Support\Facades\Facade;
return [
/*
|--------------------------------------------------------------------------
| Application Name
|--------------------------------------------------------------------------
|
| This value is the name of your application. This value is used when the
| framework needs to place the application's name in a notification or
| any other location as required by the application or its packages.
|
*/
'name' => env('APP_NAME', 'Laravel'),
/*
|--------------------------------------------------------------------------
| Application Environment
|--------------------------------------------------------------------------
|
| This value determines the "environment" your application is currently
| running in. This may determine how you prefer to configure various
| services the application utilizes. Set this in your ".env" file.
|
*/
'env' => env('APP_ENV', 'production'),
/*
|--------------------------------------------------------------------------
| Application Debug Mode
|--------------------------------------------------------------------------
|
| When your application is in debug mode, detailed error messages with
| stack traces will be shown on every error that occurs within your
| application. If disabled, a simple generic error page is shown.
|
*/
'debug' => (bool) env('APP_DEBUG', false),
/*
|--------------------------------------------------------------------------
| Application URL
|--------------------------------------------------------------------------
|
| This URL is used by the console to properly generate URLs when using
| the Artisan command line tool. You should set this to the root of
| your application so that it is used when running Artisan tasks.
|
*/
'url' => env('APP_URL', 'http://localhost'),
'asset_url' => env('ASSET_URL'),
/*
|--------------------------------------------------------------------------
| Application Timezone
|--------------------------------------------------------------------------
|
| Here you may specify the default timezone for your application, which
| will be used by the PHP date and date-time functions. We have gone
| ahead and set this to a sensible default for you out of the box.
|
*/
'timezone' => 'Europe/Copenhagen',
/*
|--------------------------------------------------------------------------
| Application Locale Configuration
|--------------------------------------------------------------------------
|
| The application locale determines the default locale that will be used
| by the translation service provider. You are free to set this value
| to any of the locales which will be supported by the application.
|
*/
'locale' => 'da',
/*
|--------------------------------------------------------------------------
| Application Fallback Locale
|--------------------------------------------------------------------------
|
| The fallback locale determines the locale to use when the current one
| is not available. You may change the value to correspond to any of
| the language folders that are provided through your application.
|
*/
'fallback_locale' => 'en',
/*
|--------------------------------------------------------------------------
| Faker Locale
|--------------------------------------------------------------------------
|
| This locale will be used by the Faker PHP library when generating fake
| data for your database seeds. For example, this will be used to get
| localized telephone numbers, street address information and more.
|
*/
'faker_locale' => 'en_US',
/*
|--------------------------------------------------------------------------
| Encryption Key
|--------------------------------------------------------------------------
|
| This key is used by the Illuminate encrypter service and should be set
| to a random, 32 character string, otherwise these encrypted strings
| will not be safe. Please do this before deploying an application!
|
*/
'key' => env('APP_KEY'),
'cipher' => 'AES-256-CBC',
/*
|--------------------------------------------------------------------------
| Maintenance Mode Driver
|--------------------------------------------------------------------------
|
| These configuration options determine the driver used to determine and
| manage Laravel's "maintenance mode" status. The "cache" driver will
| allow maintenance mode to be controlled across multiple machines.
|
| Supported drivers: "file", "cache"
|
*/
'maintenance' => [
'driver' => 'file',
// 'store' => 'redis',
],
/*
|--------------------------------------------------------------------------
| Autoloaded Service Providers
|--------------------------------------------------------------------------
|
| The service providers listed here will be automatically loaded on the
| request to your application. Feel free to add your own services to
| this array to grant expanded functionality to your applications.
|
*/
'providers' => [
/*
* Custom Service Providers
*/
Mailjet\LaravelMailjet\MailjetServiceProvider::class,
/*
* Laravel Framework Service Providers...
*/
Illuminate\Auth\AuthServiceProvider::class,
Illuminate\Broadcasting\BroadcastServiceProvider::class,
Illuminate\Bus\BusServiceProvider::class,
Illuminate\Cache\CacheServiceProvider::class,
Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
Illuminate\Cookie\CookieServiceProvider::class,
Illuminate\Database\DatabaseServiceProvider::class,
Illuminate\Encryption\EncryptionServiceProvider::class,
Illuminate\Filesystem\FilesystemServiceProvider::class,
Illuminate\Foundation\Providers\FoundationServiceProvider::class,
Illuminate\Hashing\HashServiceProvider::class,
Illuminate\Mail\MailServiceProvider::class,
Illuminate\Notifications\NotificationServiceProvider::class,
Illuminate\Pagination\PaginationServiceProvider::class,
Illuminate\Pipeline\PipelineServiceProvider::class,
Illuminate\Queue\QueueServiceProvider::class,
Illuminate\Redis\RedisServiceProvider::class,
Illuminate\Auth\Passwords\PasswordResetServiceProvider::class,
Illuminate\Session\SessionServiceProvider::class,
Illuminate\Translation\TranslationServiceProvider::class,
Illuminate\Validation\ValidationServiceProvider::class,
Illuminate\View\ViewServiceProvider::class,
/*
* Package Service Providers...
*/
/*
* Application Service Providers...
*/
App\Providers\AppServiceProvider::class,
App\Providers\AuthServiceProvider::class,
// App\Providers\BroadcastServiceProvider::class,
App\Providers\EventServiceProvider::class,
App\Providers\RouteServiceProvider::class,
],
/*
|--------------------------------------------------------------------------
| Class Aliases
|--------------------------------------------------------------------------
|
| This array of class aliases will be registered when this application
| is started. However, feel free to register as many as you wish as
| the aliases are "lazy" loaded so they don't hinder performance.
|
*/
'aliases' => Facade::defaultAliases()->merge([
// 'ExampleClass' => App\Example\ExampleClass::class,
'Mailjet' => Mailjet\LaravelMailjet\Facades\Mailjet::class,
'Logger' => \App\Helpers\Logger::class,
'PaginationHelper' => \App\Helpers\PaginationHelper::class,
])->toArray(),
/*
|--------------------------------------------------------------------------
| Custom Vars
|--------------------------------------------------------------------------
| Custom ENV variables
|
*/
'barcode_mode' => env('BARCODE_MODE'),
'login_mode' => env('LOGIN_MODE'),
'mail_username' => env('MAIL_USERNAME'),
'mail_password' => env('MAIL_PASSWORD'),
'mail_from_address' => env('MAIL_FROM_ADDRESS'),
'mail_from_name' => env('MAIL_FROM_NAME'),
'app_url' => env('APP_URL'),
];

136
config/auth.php Normal file
View File

@ -0,0 +1,136 @@
<?php
use App\Models\LoanerType;
use App\Models\User;
return [
/*
|--------------------------------------------------------------------------
| Authentication Defaults
|--------------------------------------------------------------------------
|
| This option controls the default authentication "guard" and password
| reset options for your application. You may change these defaults
| as required, but they're a perfect start for most applications.
|
*/
'defaults' => [
'guard' => 'nadUser',
'passwords' => 'users',
],
/*
|--------------------------------------------------------------------------
| Authentication Guards
|--------------------------------------------------------------------------
|
| Next, you may define every authentication guard for your application.
| Of course, a great default configuration has been defined for you
| here which uses session storage and the Eloquent user provider.
|
| All authentication drivers have a user provider. This defines how the
| users are actually retrieved out of your database or other storage
| mechanisms used by this application to persist your user's data.
|
| Supported: "session"
|
*/
'guards' => [
'nadUser' => [
'driver' => 'session',
'provider' => 'nadUser',
],
'adUser' => [
'driver' => 'session',
'provider' => 'ldap',
],
],
/*
|--------------------------------------------------------------------------
| User Providers
|--------------------------------------------------------------------------
|
| All authentication drivers have a user provider. This defines how the
| users are actually retrieved out of your database or other storage
| mechanisms used by this application to persist your user's data.
|
| If you have multiple user tables or models you may configure multiple
| sources which represent each model / table. These sources may then
| be assigned to any extra authentication guards you have defined.
|
| Supported: "database", "eloquent"
|
*/
'providers' => [
'nadUser' => [
'driver' => 'eloquent',
'model' => User::class,
],
'ldap' => [
'driver' => 'ldap', // Was 'eloquent'.
'model' => \LdapRecord\Models\ActiveDirectory\User::class,
'rules' => [],
'database' => [
'model' => User::class,
'sync_passwords' => true,
'sync_attributes' => [
'username' => 'samaccountname',
'name' => 'cn',
'loaner_type_id' => LoanerType::firstWhere('name','=','adUser')->id,
//'role_id' => 2 //Role::firstWhere('name','=','elev')->id
],
'password' => 'password',
],
]
// 'users' => [
// 'driver' => 'database',
// 'table' => 'users',
// ],
],
/*
|--------------------------------------------------------------------------
| Resetting Passwords
|--------------------------------------------------------------------------
|
| You may specify multiple password reset configurations if you have more
| than one user table or model in the application and you want to have
| separate password reset settings based on the specific user types.
|
| The expire time is the number of minutes that each reset token will be
| considered valid. This security feature keeps tokens short-lived so
| they have less time to be guessed. You may change this as needed.
|
*/
'passwords' => [
'users' => [
'provider' => 'users',
'table' => 'password_resets',
'expire' => 60,
'throttle' => 60,
],
],
/*
|--------------------------------------------------------------------------
| Password Confirmation Timeout
|--------------------------------------------------------------------------
|
| Here you may define the amount of seconds before a password confirmation
| times out and the user is prompted to re-enter their password via the
| confirmation screen. By default, the timeout lasts for three hours.
|
*/
'password_timeout' => 10800,
];

70
config/broadcasting.php Normal file
View File

@ -0,0 +1,70 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Broadcaster
|--------------------------------------------------------------------------
|
| This option controls the default broadcaster that will be used by the
| framework when an event needs to be broadcast. You may set this to
| any of the connections defined in the "connections" array below.
|
| Supported: "pusher", "ably", "redis", "log", "null"
|
*/
'default' => env('BROADCAST_DRIVER', 'null'),
/*
|--------------------------------------------------------------------------
| Broadcast Connections
|--------------------------------------------------------------------------
|
| Here you may define all of the broadcast connections that will be used
| to broadcast events to other systems or over websockets. Samples of
| each available type of connection are provided inside this array.
|
*/
'connections' => [
'pusher' => [
'driver' => 'pusher',
'key' => env('PUSHER_APP_KEY'),
'secret' => env('PUSHER_APP_SECRET'),
'app_id' => env('PUSHER_APP_ID'),
'options' => [
'host' => env('PUSHER_HOST', 'api-'.env('PUSHER_APP_CLUSTER', 'mt1').'.pusher.com') ?: 'api-'.env('PUSHER_APP_CLUSTER', 'mt1').'.pusher.com',
'port' => env('PUSHER_PORT', 443),
'scheme' => env('PUSHER_SCHEME', 'https'),
'encrypted' => true,
'useTLS' => env('PUSHER_SCHEME', 'https') === 'https',
],
'client_options' => [
// Guzzle client options: https://docs.guzzlephp.org/en/stable/request-options.html
],
],
'ably' => [
'driver' => 'ably',
'key' => env('ABLY_KEY'),
],
'redis' => [
'driver' => 'redis',
'connection' => 'default',
],
'log' => [
'driver' => 'log',
],
'null' => [
'driver' => 'null',
],
],
];

110
config/cache.php Normal file
View File

@ -0,0 +1,110 @@
<?php
use Illuminate\Support\Str;
return [
/*
|--------------------------------------------------------------------------
| Default Cache Store
|--------------------------------------------------------------------------
|
| This option controls the default cache connection that gets used while
| using this caching library. This connection is used when another is
| not explicitly specified when executing a given caching function.
|
*/
'default' => env('CACHE_DRIVER', 'file'),
/*
|--------------------------------------------------------------------------
| Cache Stores
|--------------------------------------------------------------------------
|
| Here you may define all of the cache "stores" for your application as
| well as their drivers. You may even define multiple stores for the
| same cache driver to group types of items stored in your caches.
|
| Supported drivers: "apc", "array", "database", "file",
| "memcached", "redis", "dynamodb", "octane", "null"
|
*/
'stores' => [
'apc' => [
'driver' => 'apc',
],
'array' => [
'driver' => 'array',
'serialize' => false,
],
'database' => [
'driver' => 'database',
'table' => 'cache',
'connection' => null,
'lock_connection' => null,
],
'file' => [
'driver' => 'file',
'path' => storage_path('framework/cache/data'),
],
'memcached' => [
'driver' => 'memcached',
'persistent_id' => env('MEMCACHED_PERSISTENT_ID'),
'sasl' => [
env('MEMCACHED_USERNAME'),
env('MEMCACHED_PASSWORD'),
],
'options' => [
// Memcached::OPT_CONNECT_TIMEOUT => 2000,
],
'servers' => [
[
'host' => env('MEMCACHED_HOST', '127.0.0.1'),
'port' => env('MEMCACHED_PORT', 11211),
'weight' => 100,
],
],
],
'redis' => [
'driver' => 'redis',
'connection' => 'cache',
'lock_connection' => 'default',
],
'dynamodb' => [
'driver' => 'dynamodb',
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
'table' => env('DYNAMODB_CACHE_TABLE', 'cache'),
'endpoint' => env('DYNAMODB_ENDPOINT'),
],
'octane' => [
'driver' => 'octane',
],
],
/*
|--------------------------------------------------------------------------
| Cache Key Prefix
|--------------------------------------------------------------------------
|
| When utilizing the APC, database, memcached, Redis, or DynamoDB cache
| stores there might be other applications using the same cache. For
| that reason, you may prefix every cache key to avoid collisions.
|
*/
'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_cache_'),
];

34
config/cors.php Normal file
View File

@ -0,0 +1,34 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Cross-Origin Resource Sharing (CORS) Configuration
|--------------------------------------------------------------------------
|
| Here you may configure your settings for cross-origin resource sharing
| or "CORS". This determines what cross-origin operations may execute
| in web browsers. You are free to adjust these settings as needed.
|
| To learn more: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS
|
*/
'paths' => ['api/*', 'sanctum/csrf-cookie'],
'allowed_methods' => ['*'],
'allowed_origins' => ['*'],
'allowed_origins_patterns' => [],
'allowed_headers' => ['*'],
'exposed_headers' => [],
'max_age' => 0,
'supports_credentials' => false,
];

151
config/database.php Normal file
View File

@ -0,0 +1,151 @@
<?php
use Illuminate\Support\Str;
return [
/*
|--------------------------------------------------------------------------
| Default Database Connection Name
|--------------------------------------------------------------------------
|
| Here you may specify which of the database connections below you wish
| to use as your default connection for all database work. Of course
| you may use many connections at once using the Database library.
|
*/
'default' => env('DB_CONNECTION', 'mysql'),
/*
|--------------------------------------------------------------------------
| Database Connections
|--------------------------------------------------------------------------
|
| Here are each of the database connections setup for your application.
| Of course, examples of configuring each database platform that is
| supported by Laravel is shown below to make development simple.
|
|
| All database work in Laravel is done through the PHP PDO facilities
| so make sure you have the driver for your particular database of
| choice installed on your machine before you begin development.
|
*/
'connections' => [
'sqlite' => [
'driver' => 'sqlite',
'url' => env('DATABASE_URL'),
'database' => env('DB_DATABASE', database_path('database.sqlite')),
'prefix' => '',
'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),
],
'mysql' => [
'driver' => 'mysql',
'url' => env('DATABASE_URL'),
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'prefix_indexes' => true,
'strict' => false,
'engine' => 'InnoDB',
'options' => extension_loaded('pdo_mysql') ? array_filter([
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
]) : [],
],
'pgsql' => [
'driver' => 'pgsql',
'url' => env('DATABASE_URL'),
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '5432'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'prefix' => '',
'prefix_indexes' => true,
'search_path' => 'public',
'sslmode' => 'prefer',
],
'sqlsrv' => [
'driver' => 'sqlsrv',
'url' => env('DATABASE_URL'),
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '1433'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'prefix' => '',
'prefix_indexes' => true,
// 'encrypt' => env('DB_ENCRYPT', 'yes'),
// 'trust_server_certificate' => env('DB_TRUST_SERVER_CERTIFICATE', 'false'),
],
],
/*
|--------------------------------------------------------------------------
| Migration Repository Table
|--------------------------------------------------------------------------
|
| This table keeps track of all the migrations that have already run for
| your application. Using this information, we can determine which of
| the migrations on disk haven't actually been run in the database.
|
*/
'migrations' => 'migrations',
/*
|--------------------------------------------------------------------------
| Redis Databases
|--------------------------------------------------------------------------
|
| Redis is an open source, fast, and advanced key-value store that also
| provides a richer body of commands than a typical key-value system
| such as APC or Memcached. Laravel makes it easy to dig right in.
|
*/
'redis' => [
'client' => env('REDIS_CLIENT', 'phpredis'),
'options' => [
'cluster' => env('REDIS_CLUSTER', 'redis'),
'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'),
],
'default' => [
'url' => env('REDIS_URL'),
'host' => env('REDIS_HOST', '127.0.0.1'),
'username' => env('REDIS_USERNAME'),
'password' => env('REDIS_PASSWORD'),
'port' => env('REDIS_PORT', '6379'),
'database' => env('REDIS_DB', '0'),
],
'cache' => [
'url' => env('REDIS_URL'),
'host' => env('REDIS_HOST', '127.0.0.1'),
'username' => env('REDIS_USERNAME'),
'password' => env('REDIS_PASSWORD'),
'port' => env('REDIS_PORT', '6379'),
'database' => env('REDIS_CACHE_DB', '1'),
],
],
];

284
config/dompdf.php Normal file
View File

@ -0,0 +1,284 @@
<?php
return array(
/*
|--------------------------------------------------------------------------
| Settings
|--------------------------------------------------------------------------
|
| Set some default values. It is possible to add all defines that can be set
| in dompdf_config.inc.php. You can also override the entire config file.
|
*/
'show_warnings' => false, // Throw an Exception on warnings from dompdf
'public_path' => null, // Override the public path if needed
/*
* Dejavu Sans font is missing glyphs for converted entities, turn it off if you need to show and £.
*/
'convert_entities' => true,
'options' => array(
/**
* The location of the DOMPDF font directory
*
* The location of the directory where DOMPDF will store fonts and font metrics
* Note: This directory must exist and be writable by the webserver process.
* *Please note the trailing slash.*
*
* Notes regarding fonts:
* Additional .afm font metrics can be added by executing load_font.php from command line.
*
* Only the original "Base 14 fonts" are present on all pdf viewers. Additional fonts must
* be embedded in the pdf file or the PDF may not display correctly. This can significantly
* increase file size unless font subsetting is enabled. Before embedding a font please
* review your rights under the font license.
*
* Any font specification in the source HTML is translated to the closest font available
* in the font directory.
*
* The pdf standard "Base 14 fonts" are:
* Courier, Courier-Bold, Courier-BoldOblique, Courier-Oblique,
* Helvetica, Helvetica-Bold, Helvetica-BoldOblique, Helvetica-Oblique,
* Times-Roman, Times-Bold, Times-BoldItalic, Times-Italic,
* Symbol, ZapfDingbats.
*/
"font_dir" => storage_path('fonts'), // advised by dompdf (https://github.com/dompdf/dompdf/pull/782)
/**
* The location of the DOMPDF font cache directory
*
* This directory contains the cached font metrics for the fonts used by DOMPDF.
* This directory can be the same as DOMPDF_FONT_DIR
*
* Note: This directory must exist and be writable by the webserver process.
*/
"font_cache" => storage_path('fonts'),
/**
* The location of a temporary directory.
*
* The directory specified must be writeable by the webserver process.
* The temporary directory is required to download remote images and when
* using the PFDLib back end.
*/
"temp_dir" => sys_get_temp_dir(),
/**
* ==== IMPORTANT ====
*
* dompdf's "chroot": Prevents dompdf from accessing system files or other
* files on the webserver. All local files opened by dompdf must be in a
* subdirectory of this directory. DO NOT set it to '/' since this could
* allow an attacker to use dompdf to read any files on the server. This
* should be an absolute path.
* This is only checked on command line call by dompdf.php, but not by
* direct class use like:
* $dompdf = new DOMPDF(); $dompdf->load_html($htmldata); $dompdf->render(); $pdfdata = $dompdf->output();
*/
"chroot" => realpath(base_path()),
/**
* Protocol whitelist
*
* Protocols and PHP wrappers allowed in URIs, and the validation rules
* that determine if a resouce may be loaded. Full support is not guaranteed
* for the protocols/wrappers specified
* by this array.
*
* @var array
*/
'allowed_protocols' => [
"file://" => ["rules" => []],
"http://" => ["rules" => []],
"https://" => ["rules" => []]
],
/**
* @var string
*/
'log_output_file' => null,
/**
* Whether to enable font subsetting or not.
*/
"enable_font_subsetting" => false,
/**
* The PDF rendering backend to use
*
* Valid settings are 'PDFLib', 'CPDF' (the bundled R&OS PDF class), 'GD' and
* 'auto'. 'auto' will look for PDFLib and use it if found, or if not it will
* fall back on CPDF. 'GD' renders PDFs to graphic files. {@link
* Canvas_Factory} ultimately determines which rendering class to instantiate
* based on this setting.
*
* Both PDFLib & CPDF rendering backends provide sufficient rendering
* capabilities for dompdf, however additional features (e.g. object,
* image and font support, etc.) differ between backends. Please see
* {@link PDFLib_Adapter} for more information on the PDFLib backend
* and {@link CPDF_Adapter} and lib/class.pdf.php for more information
* on CPDF. Also see the documentation for each backend at the links
* below.
*
* The GD rendering backend is a little different than PDFLib and
* CPDF. Several features of CPDF and PDFLib are not supported or do
* not make any sense when creating image files. For example,
* multiple pages are not supported, nor are PDF 'objects'. Have a
* look at {@link GD_Adapter} for more information. GD support is
* experimental, so use it at your own risk.
*
* @link http://www.pdflib.com
* @link http://www.ros.co.nz/pdf
* @link http://www.php.net/image
*/
"pdf_backend" => "CPDF",
/**
* PDFlib license key
*
* If you are using a licensed, commercial version of PDFlib, specify
* your license key here. If you are using PDFlib-Lite or are evaluating
* the commercial version of PDFlib, comment out this setting.
*
* @link http://www.pdflib.com
*
* If pdflib present in web server and auto or selected explicitely above,
* a real license code must exist!
*/
//"DOMPDF_PDFLIB_LICENSE" => "your license key here",
/**
* html target media view which should be rendered into pdf.
* List of types and parsing rules for future extensions:
* http://www.w3.org/TR/REC-html40/types.html
* screen, tty, tv, projection, handheld, print, braille, aural, all
* Note: aural is deprecated in CSS 2.1 because it is replaced by speech in CSS 3.
* Note, even though the generated pdf file is intended for print output,
* the desired content might be different (e.g. screen or projection view of html file).
* Therefore allow specification of content here.
*/
"default_media_type" => "screen",
/**
* The default paper size.
*
* North America standard is "letter"; other countries generally "a4"
*
* @see CPDF_Adapter::PAPER_SIZES for valid sizes ('letter', 'legal', 'A4', etc.)
*/
"default_paper_size" => "a4",
/**
* The default paper orientation.
*
* The orientation of the page (portrait or landscape).
*
* @var string
*/
'default_paper_orientation' => "portrait",
/**
* The default font family
*
* Used if no suitable fonts can be found. This must exist in the font folder.
* @var string
*/
"default_font" => "serif",
/**
* Image DPI setting
*
* This setting determines the default DPI setting for images and fonts. The
* DPI may be overridden for inline images by explictly setting the
* image's width & height style attributes (i.e. if the image's native
* width is 600 pixels and you specify the image's width as 72 points,
* the image will have a DPI of 600 in the rendered PDF. The DPI of
* background images can not be overridden and is controlled entirely
* via this parameter.
*
* For the purposes of DOMPDF, pixels per inch (PPI) = dots per inch (DPI).
* If a size in html is given as px (or without unit as image size),
* this tells the corresponding size in pt.
* This adjusts the relative sizes to be similar to the rendering of the
* html page in a reference browser.
*
* In pdf, always 1 pt = 1/72 inch
*
* Rendering resolution of various browsers in px per inch:
* Windows Firefox and Internet Explorer:
* SystemControl->Display properties->FontResolution: Default:96, largefonts:120, custom:?
* Linux Firefox:
* about:config *resolution: Default:96
* (xorg screen dimension in mm and Desktop font dpi settings are ignored)
*
* Take care about extra font/image zoom factor of browser.
*
* In images, <img> size in pixel attribute, img css style, are overriding
* the real image dimension in px for rendering.
*
* @var int
*/
"dpi" => 96,
/**
* Enable inline PHP
*
* If this setting is set to true then DOMPDF will automatically evaluate
* inline PHP contained within <script type="text/php"> ... </script> tags.
*
* Enabling this for documents you do not trust (e.g. arbitrary remote html
* pages) is a security risk. Set this option to false if you wish to process
* untrusted documents.
*
* @var bool
*/
"enable_php" => false,
/**
* Enable inline Javascript
*
* If this setting is set to true then DOMPDF will automatically insert
* JavaScript code contained within <script type="text/javascript"> ... </script> tags.
*
* @var bool
*/
"enable_javascript" => true,
/**
* Enable remote file access
*
* If this setting is set to true, DOMPDF will access remote sites for
* images and CSS files as required.
* This is required for part of test case www/test/image_variants.html through www/examples.php
*
* Attention!
* This can be a security risk, in particular in combination with DOMPDF_ENABLE_PHP and
* allowing remote access to dompdf.php or on allowing remote html code to be passed to
* $dompdf = new DOMPDF(, $dompdf->load_html(...,
* This allows anonymous users to download legally doubtful internet content which on
* tracing back appears to being downloaded by your server, or allows malicious php code
* in remote html pages to be executed by your server with your account privileges.
*
* @var bool
*/
"enable_remote" => true,
/**
* A ratio applied to the fonts height to be more like browsers' line height
*/
"font_height_ratio" => 1.1,
/**
* Use the HTML5 Lib parser
*
* @deprecated This feature is now always on in dompdf 2.x
* @var bool
*/
"enable_html5_parser" => true,
),
);

76
config/filesystems.php Normal file
View File

@ -0,0 +1,76 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Filesystem Disk
|--------------------------------------------------------------------------
|
| Here you may specify the default filesystem disk that should be used
| by the framework. The "local" disk, as well as a variety of cloud
| based disks are available to your application. Just store away!
|
*/
'default' => env('FILESYSTEM_DISK', 'local'),
/*
|--------------------------------------------------------------------------
| Filesystem Disks
|--------------------------------------------------------------------------
|
| Here you may configure as many filesystem "disks" as you wish, and you
| may even configure multiple disks of the same driver. Defaults have
| been set up for each driver as an example of the required values.
|
| Supported Drivers: "local", "ftp", "sftp", "s3"
|
*/
'disks' => [
'local' => [
'driver' => 'local',
'root' => storage_path('app'),
'throw' => false,
],
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
'throw' => false,
],
's3' => [
'driver' => 's3',
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION'),
'bucket' => env('AWS_BUCKET'),
'url' => env('AWS_URL'),
'endpoint' => env('AWS_ENDPOINT'),
'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
'throw' => false,
],
],
/*
|--------------------------------------------------------------------------
| Symbolic Links
|--------------------------------------------------------------------------
|
| Here you may configure the symbolic links that will be created when the
| `storage:link` Artisan command is executed. The array keys should be
| the locations of the links and the values should be their targets.
|
*/
'links' => [
public_path('storage') => storage_path('app/public'),
],
];

52
config/hashing.php Normal file
View File

@ -0,0 +1,52 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Hash Driver
|--------------------------------------------------------------------------
|
| This option controls the default hash driver that will be used to hash
| passwords for your application. By default, the bcrypt algorithm is
| used; however, you remain free to modify this option if you wish.
|
| Supported: "bcrypt", "argon", "argon2id"
|
*/
'driver' => 'bcrypt',
/*
|--------------------------------------------------------------------------
| Bcrypt Options
|--------------------------------------------------------------------------
|
| Here you may specify the configuration options that should be used when
| passwords are hashed using the Bcrypt algorithm. This will allow you
| to control the amount of time it takes to hash the given password.
|
*/
'bcrypt' => [
'rounds' => env('BCRYPT_ROUNDS', 10),
],
/*
|--------------------------------------------------------------------------
| Argon Options
|--------------------------------------------------------------------------
|
| Here you may specify the configuration options that should be used when
| passwords are hashed using the Argon algorithm. These will allow you
| to control the amount of time it takes to hash the given password.
|
*/
'argon' => [
'memory' => 65536,
'threads' => 1,
'time' => 4,
],
];

73
config/ldap.php Normal file
View File

@ -0,0 +1,73 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Default LDAP Connection Name
|--------------------------------------------------------------------------
|
| Here you may specify which of the LDAP connections below you wish
| to use as your default connection for all LDAP operations. Of
| course you may add as many connections you'd like below.
|
*/
'default' => env('LDAP_CONNECTION', 'default'),
/*
|--------------------------------------------------------------------------
| LDAP Connections
|--------------------------------------------------------------------------
|
| Below you may configure each LDAP connection your application requires
| access to. Be sure to include a valid base DN - otherwise you may
| not receive any results when performing LDAP search operations.
|
*/
'connections' => [
'default' => [
'hosts' => [env('LDAP_HOST', '172.16.1.187')],
'username' => env('LDAP_USERNAME', 'CN=Ldap Con,OU=OU_ServerAccounts,OU=OU_Zone9,OU=OU_IT-SKP,OU=OU_Main,DC=ITSKP-ODENSE,DC=dk'),
'password' => env('LDAP_PASSWORD', 'SKPlager1!'),
'port' => env('LDAP_PORT', 389),
'base_dn' => env('LDAP_BASE_DN', 'dc=ITSKP-ODENSE,dc=dk'),
'timeout' => env('LDAP_TIMEOUT', 5),
'use_ssl' => env('LDAP_SSL', false),
'use_tls' => env('LDAP_TLS', false),
],
],
/*
|--------------------------------------------------------------------------
| LDAP Logging
|--------------------------------------------------------------------------
|
| When LDAP logging is enabled, all LDAP search and authentication
| operations are logged using the default application logging
| driver. This can assist in debugging issues and more.
|
*/
'logging' => env('LDAP_LOGGING', true),
/*
|--------------------------------------------------------------------------
| LDAP Cache
|--------------------------------------------------------------------------
|
| LDAP caching enables the ability of caching search results using the
| query builder. This is great for running expensive operations that
| may take many seconds to complete, such as a pagination request.
|
*/
'cache' => [
'enabled' => env('LDAP_CACHE', false),
'driver' => env('CACHE_DRIVER', 'file'),
],
];

122
config/logging.php Normal file
View File

@ -0,0 +1,122 @@
<?php
use Monolog\Handler\NullHandler;
use Monolog\Handler\StreamHandler;
use Monolog\Handler\SyslogUdpHandler;
return [
/*
|--------------------------------------------------------------------------
| Default Log Channel
|--------------------------------------------------------------------------
|
| This option defines the default log channel that gets used when writing
| messages to the logs. The name specified in this option should match
| one of the channels defined in the "channels" configuration array.
|
*/
'default' => env('LOG_CHANNEL', 'stack'),
/*
|--------------------------------------------------------------------------
| Deprecations Log Channel
|--------------------------------------------------------------------------
|
| This option controls the log channel that should be used to log warnings
| regarding deprecated PHP and library features. This allows you to get
| your application ready for upcoming major versions of dependencies.
|
*/
'deprecations' => [
'channel' => env('LOG_DEPRECATIONS_CHANNEL', 'null'),
'trace' => false,
],
/*
|--------------------------------------------------------------------------
| Log Channels
|--------------------------------------------------------------------------
|
| Here you may configure the log channels for your application. Out of
| the box, Laravel uses the Monolog PHP logging library. This gives
| you a variety of powerful log handlers / formatters to utilize.
|
| Available Drivers: "single", "daily", "slack", "syslog",
| "errorlog", "monolog",
| "custom", "stack"
|
*/
'channels' => [
'stack' => [
'driver' => 'stack',
'channels' => ['single'],
'ignore_exceptions' => false,
],
'single' => [
'driver' => 'single',
'path' => storage_path('logs/laravel.log'),
'level' => env('LOG_LEVEL', 'debug'),
],
'daily' => [
'driver' => 'daily',
'path' => storage_path('logs/laravel.log'),
'level' => env('LOG_LEVEL', 'debug'),
'days' => 14,
],
'slack' => [
'driver' => 'slack',
'url' => env('LOG_SLACK_WEBHOOK_URL'),
'username' => 'Laravel Log',
'emoji' => ':boom:',
'level' => env('LOG_LEVEL', 'critical'),
],
'papertrail' => [
'driver' => 'monolog',
'level' => env('LOG_LEVEL', 'debug'),
'handler' => env('LOG_PAPERTRAIL_HANDLER', SyslogUdpHandler::class),
'handler_with' => [
'host' => env('PAPERTRAIL_URL'),
'port' => env('PAPERTRAIL_PORT'),
'connectionString' => 'tls://'.env('PAPERTRAIL_URL').':'.env('PAPERTRAIL_PORT'),
],
],
'stderr' => [
'driver' => 'monolog',
'level' => env('LOG_LEVEL', 'debug'),
'handler' => StreamHandler::class,
'formatter' => env('LOG_STDERR_FORMATTER'),
'with' => [
'stream' => 'php://stderr',
],
],
'syslog' => [
'driver' => 'syslog',
'level' => env('LOG_LEVEL', 'debug'),
],
'errorlog' => [
'driver' => 'errorlog',
'level' => env('LOG_LEVEL', 'debug'),
],
'null' => [
'driver' => 'monolog',
'handler' => NullHandler::class,
],
'emergency' => [
'path' => storage_path('logs/laravel.log'),
],
],
];

163
config/mail.php Normal file
View File

@ -0,0 +1,163 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Mailer
|--------------------------------------------------------------------------
|
| This option controls the default mailer that is used to send any email
| messages sent by your application. Alternative mailers may be setup
| and used as needed; however, this mailer will be used by default.
|
*/
'default' => env('MAIL_MAILER', 'smtp'),
/*
|--------------------------------------------------------------------------
| Mailer Configurations
|--------------------------------------------------------------------------
|
| Here you may configure all of the mailers used by your application plus
| their respective settings. Several examples have been configured for
| you and you are free to add your own as your application requires.
|
| Laravel supports a variety of mail "transport" drivers to be used while
| sending an e-mail. You will specify which one you are using for your
| mailers below. You are free to add additional mailers as required.
|
| Supported: "smtp", "sendmail", "mailgun", "ses",
| "postmark", "log", "array", "failover"
|
*/
'mailers' => [
'smtp' => [
'transport' => 'smtp',
'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
'port' => env('MAIL_PORT', 587),
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'timeout' => null,
'local_domain' => env('MAIL_EHLO_DOMAIN'),
],
'ses' => [
'transport' => 'ses',
],
'mailgun' => [
'transport' => 'mailgun',
],
'postmark' => [
'transport' => 'postmark',
],
'mailjet' => [
'transport' => 'mailjet',
'key' => env('MAILJET_APIKEY'),
'secret' => env('MAILJET_APISECRET'),
'transactional' => [
'call' => true,
'options' => [
'url' => 'api.mailjet.com',
'version' => 'v3.1',
'call' => true,
'secured' => true
]
],
'common' => [
'call' => true,
'options' => [
'url' => 'api.mailjet.com',
'version' => 'v3',
'call' => true,
'secured' => true
]
]
],
'sendmail' => [
'transport' => 'sendmail',
'path' => env('MAIL_SENDMAIL_PATH', '/usr/sbin/sendmail -bs -i'),
],
'log' => [
'transport' => 'log',
'channel' => env('MAIL_LOG_CHANNEL'),
],
'array' => [
'transport' => 'array',
],
'failover' => [
'transport' => 'failover',
'mailers' => [
'smtp',
'log',
],
],
],
/*
|--------------------------------------------------------------------------
| Global "From" Address
|--------------------------------------------------------------------------
|
| You may wish for all e-mails sent by your application to be sent from
| the same address. Here, you may specify a name and address that is
| used globally for all e-mails that are sent by your application.
|
*/
'from' => [
'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'),
'name' => env('MAIL_FROM_NAME', 'Example'),
],
/*
|--------------------------------------------------------------------------
| Markdown Mail Settings
|--------------------------------------------------------------------------
|
| If you are using Markdown based email rendering, you may configure your
| theme and component paths here, allowing you to customize the design
| of the emails. Or, you may simply stick with the Laravel defaults!
|
*/
'markdown' => [
'theme' => 'default',
'paths' => [
resource_path('views/vendor/mail'),
],
],
];

93
config/queue.php Normal file
View File

@ -0,0 +1,93 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Queue Connection Name
|--------------------------------------------------------------------------
|
| Laravel's queue API supports an assortment of back-ends via a single
| API, giving you convenient access to each back-end using the same
| syntax for every one. Here you may define a default connection.
|
*/
'default' => env('QUEUE_CONNECTION', 'sync'),
/*
|--------------------------------------------------------------------------
| Queue Connections
|--------------------------------------------------------------------------
|
| Here you may configure the connection information for each server that
| is used by your application. A default configuration has been added
| for each back-end shipped with Laravel. You are free to add more.
|
| Drivers: "sync", "database", "beanstalkd", "sqs", "redis", "null"
|
*/
'connections' => [
'sync' => [
'driver' => 'sync',
],
'database' => [
'driver' => 'database',
'table' => 'jobs',
'queue' => 'default',
'retry_after' => 90,
'after_commit' => false,
],
'beanstalkd' => [
'driver' => 'beanstalkd',
'host' => 'localhost',
'queue' => 'default',
'retry_after' => 90,
'block_for' => 0,
'after_commit' => false,
],
'sqs' => [
'driver' => 'sqs',
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'),
'queue' => env('SQS_QUEUE', 'default'),
'suffix' => env('SQS_SUFFIX'),
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
'after_commit' => false,
],
'redis' => [
'driver' => 'redis',
'connection' => 'default',
'queue' => env('REDIS_QUEUE', 'default'),
'retry_after' => 90,
'block_for' => null,
'after_commit' => false,
],
],
/*
|--------------------------------------------------------------------------
| Failed Queue Jobs
|--------------------------------------------------------------------------
|
| These options configure the behavior of failed queue job logging so you
| can control which database and table are used to store the jobs that
| have failed. You may change them to any database / table you wish.
|
*/
'failed' => [
'driver' => env('QUEUE_FAILED_DRIVER', 'database-uuids'),
'database' => env('DB_CONNECTION', 'mysql'),
'table' => 'failed_jobs',
],
];

67
config/sanctum.php Normal file
View File

@ -0,0 +1,67 @@
<?php
use Laravel\Sanctum\Sanctum;
return [
/*
|--------------------------------------------------------------------------
| Stateful Domains
|--------------------------------------------------------------------------
|
| Requests from the following domains / hosts will receive stateful API
| authentication cookies. Typically, these should include your local
| and production domains which access your API via a frontend SPA.
|
*/
'stateful' => explode(',', env('SANCTUM_STATEFUL_DOMAINS', sprintf(
'%s%s',
'localhost,localhost:3000,127.0.0.1,127.0.0.1:8000,::1',
Sanctum::currentApplicationUrlWithPort()
))),
/*
|--------------------------------------------------------------------------
| Sanctum Guards
|--------------------------------------------------------------------------
|
| This array contains the authentication guards that will be checked when
| Sanctum is trying to authenticate a request. If none of these guards
| are able to authenticate the request, Sanctum will use the bearer
| token that's present on an incoming request for authentication.
|
*/
'guard' => ['web'],
/*
|--------------------------------------------------------------------------
| Expiration Minutes
|--------------------------------------------------------------------------
|
| This value controls the number of minutes until an issued token will be
| considered expired. If this value is null, personal access tokens do
| not expire. This won't tweak the lifetime of first-party sessions.
|
*/
'expiration' => null,
/*
|--------------------------------------------------------------------------
| Sanctum Middleware
|--------------------------------------------------------------------------
|
| When authenticating your first-party SPA with Sanctum you may need to
| customize some of the middleware Sanctum uses while processing the
| request. You may change the middleware listed below as required.
|
*/
'middleware' => [
'verify_csrf_token' => App\Http\Middleware\VerifyCsrfToken::class,
'encrypt_cookies' => App\Http\Middleware\EncryptCookies::class,
],
];

Some files were not shown because too many files have changed in this diff Show More