first initial
This commit is contained in:
18
.editorconfig
Normal file
18
.editorconfig
Normal 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
|
||||||
52
.env.example
Normal file
52
.env.example
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
APP_NAME=Laravel
|
||||||
|
APP_ENV=local
|
||||||
|
APP_KEY=
|
||||||
|
APP_DEBUG=true
|
||||||
|
APP_URL=http://localhost
|
||||||
|
|
||||||
|
LOG_CHANNEL=stack
|
||||||
|
LOG_DEPRECATIONS_CHANNEL=null
|
||||||
|
LOG_LEVEL=debug
|
||||||
|
|
||||||
|
DB_CONNECTION=mysql
|
||||||
|
DB_HOST=127.0.0.1
|
||||||
|
DB_PORT=3306
|
||||||
|
DB_DATABASE=laravel
|
||||||
|
DB_USERNAME=root
|
||||||
|
DB_PASSWORD=
|
||||||
|
|
||||||
|
BROADCAST_DRIVER=log
|
||||||
|
CACHE_DRIVER=file
|
||||||
|
FILESYSTEM_DRIVER=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=smtp
|
||||||
|
MAIL_HOST=mailhog
|
||||||
|
MAIL_PORT=1025
|
||||||
|
MAIL_USERNAME=null
|
||||||
|
MAIL_PASSWORD=null
|
||||||
|
MAIL_ENCRYPTION=null
|
||||||
|
MAIL_FROM_ADDRESS=null
|
||||||
|
MAIL_FROM_NAME="${APP_NAME}"
|
||||||
|
|
||||||
|
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_APP_CLUSTER=mt1
|
||||||
|
|
||||||
|
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
|
||||||
|
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
|
||||||
10
.gitattributes
vendored
Normal file
10
.gitattributes
vendored
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
* 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
|
||||||
15
.gitignore
vendored
Normal file
15
.gitignore
vendored
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
/node_modules
|
||||||
|
/public/hot
|
||||||
|
/public/storage
|
||||||
|
/storage/*.key
|
||||||
|
/vendor
|
||||||
|
.env
|
||||||
|
.env.backup
|
||||||
|
.phpunit.result.cache
|
||||||
|
docker-compose.override.yml
|
||||||
|
Homestead.json
|
||||||
|
Homestead.yaml
|
||||||
|
npm-debug.log
|
||||||
|
yarn-error.log
|
||||||
|
/.idea
|
||||||
|
/.vscode
|
||||||
14
.styleci.yml
Normal file
14
.styleci.yml
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
php:
|
||||||
|
preset: laravel
|
||||||
|
version: 8
|
||||||
|
disabled:
|
||||||
|
- no_unused_imports
|
||||||
|
finder:
|
||||||
|
not-name:
|
||||||
|
- index.php
|
||||||
|
- server.php
|
||||||
|
js:
|
||||||
|
finder:
|
||||||
|
not-name:
|
||||||
|
- webpack.mix.js
|
||||||
|
css: true
|
||||||
64
README.md
Normal file
64
README.md
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
<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"></a></p>
|
||||||
|
|
||||||
|
<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.
|
||||||
|
|
||||||
|
If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains over 1500 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).
|
||||||
BIN
api_bengkel2/git.zip
Normal file
BIN
api_bengkel2/git.zip
Normal file
Binary file not shown.
32
app/Console/Kernel.php
Normal file
32
app/Console/Kernel.php
Normal 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');
|
||||||
|
}
|
||||||
|
}
|
||||||
51
app/Exceptions/Handler.php
Normal file
51
app/Exceptions/Handler.php
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Exceptions;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||||
|
use Throwable;
|
||||||
|
|
||||||
|
class Handler extends ExceptionHandler
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 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 for 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) {
|
||||||
|
//
|
||||||
|
});
|
||||||
|
|
||||||
|
$this->renderable(function (\Illuminate\Auth\AuthenticationException $e, $request) {
|
||||||
|
if ($request->is('api/*')) {
|
||||||
|
return response()->json([
|
||||||
|
'message' => 'Not authorized',
|
||||||
|
'status' => false,
|
||||||
|
'code' => 401
|
||||||
|
], 401);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
78
app/Exports/TransactionDealerExport.php
Normal file
78
app/Exports/TransactionDealerExport.php
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Exports;
|
||||||
|
|
||||||
|
use App\Models\Transaction;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||||
|
|
||||||
|
class TransactionDealerExport implements FromCollection
|
||||||
|
{
|
||||||
|
|
||||||
|
protected $dealer;
|
||||||
|
protected $month;
|
||||||
|
|
||||||
|
function __construct($request) {
|
||||||
|
$this->month = (isset($request->dealer)) ? $request->query('month') : date('m');
|
||||||
|
$this->dealer = (isset($request->dealer)) ? $request->query('dealer') : 'all';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Illuminate\Support\Collection
|
||||||
|
*/
|
||||||
|
public function collection()
|
||||||
|
{
|
||||||
|
$dealer_work_trx = DB::statement("SET @sql = NULL");
|
||||||
|
$sql = "SELECT IF(work_id IS NOT NULL, GROUP_CONCAT(DISTINCT CONCAT('SUM(IF(work_id = \"', work_id,'\", qty,\"\")) AS \"',CONCAT(w.name, '|',w.id),'\"')), 's.work_id') INTO @sql FROM transactions t JOIN works w ON w.id = t.work_id WHERE month(t.date) = '". $this->month ."' and year(t.date) = '". date('Y') ."' and t.deleted_at is null";
|
||||||
|
|
||||||
|
if(isset($this->dealer) && $this->dealer != 'all') {
|
||||||
|
$sql .= " and t.dealer_id = '". $this->dealer ."'";
|
||||||
|
}
|
||||||
|
|
||||||
|
$dealer_work_trx = DB::statement($sql);
|
||||||
|
|
||||||
|
if(isset($this->dealer) && $this->dealer != 'all') {
|
||||||
|
$dealer_work_trx = DB::statement("SET @sql = IF(@sql != 's.work_id' ,CONCAT(\"SELECT d.name as DEALER, d.id as dealer_id, \", @sql, \"FROM transactions s JOIN dealers d ON d.id = s.dealer_id WHERE month(s.date) = '". $this->month ."' and year(s.date) = '". date('Y') ."' and s.deleted_at is null and s.dealer_id = '". $this->dealer ."' GROUP BY s.dealer_id ORDER BY s.dealer_id ASC\"), CONCAT(\"SELECT d.name as DEALER \", \"FROM transactions s JOIN dealers d ON d.id = s.dealer_id WHERE month(s.date) = '". $this->month ."' and year(s.date) = '". date('Y') ."' and s.deleted_at is null and s.dealer_id = '". $this->dealer ."' GROUP BY s.`dealer_id` ORDER BY s.`dealer_id` ASC\"))");
|
||||||
|
}else{
|
||||||
|
$dealer_work_trx = DB::statement("SET @sql = IF(@sql != 's.work_id' ,CONCAT(\"SELECT d.name as DEALER, d.id as dealer_id, \", @sql, \"FROM transactions s JOIN dealers d ON d.id = s.dealer_id WHERE month(s.date) = '". $this->month ."' and year(s.date) = '". date('Y') ."' and s.deleted_at is null GROUP BY s.dealer_id ORDER BY s.dealer_id ASC\"), CONCAT(\"SELECT d.name as DEALER, d.id as dealer_id \", \"FROM transactions s JOIN dealers d ON d.id = s.dealer_id WHERE month(s.date) = '". $this->month ."' and year(s.date) = '". date('Y') ."' and s.deleted_at is null GROUP BY s.`dealer_id` ORDER BY s.`dealer_id` ASC\"))");
|
||||||
|
}
|
||||||
|
|
||||||
|
$dealer_work_trx = DB::statement("PREPARE stmt FROM @sql");
|
||||||
|
$dealer_work_trx = DB::select(DB::raw("EXECUTE stmt"));
|
||||||
|
DB::statement('DEALLOCATE PREPARE stmt');
|
||||||
|
|
||||||
|
$work_trx = [];
|
||||||
|
foreach($dealer_work_trx as $index => $dealer_work) {
|
||||||
|
$dealer_work_2 = (array) $dealer_work;
|
||||||
|
unset($dealer_work_2['dealer_id']);
|
||||||
|
$work_names = array_keys($dealer_work_2);
|
||||||
|
if($index == 0) {
|
||||||
|
$work_names_e = [];
|
||||||
|
foreach($work_names as $work) {
|
||||||
|
$arr_work = explode('|', $work);
|
||||||
|
$work_names_e[] = $arr_work[0];
|
||||||
|
}
|
||||||
|
$work_trx[] = $work_names_e;
|
||||||
|
$work_trx[] = array_values($dealer_work_2);
|
||||||
|
}else{
|
||||||
|
$work_trx[] = array_values($dealer_work_2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return collect($work_trx);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// public function headings(): array
|
||||||
|
// {
|
||||||
|
// return $this->theads;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// public function actions(Request $request)
|
||||||
|
// {
|
||||||
|
// return [
|
||||||
|
// (new DownloadExcel)->withHeadings('Tanggal', 'Mekanik', 'SA', 'No.Polisi', 'Warranty', 'Kategori', 'Qty')
|
||||||
|
// ];
|
||||||
|
// }
|
||||||
|
}
|
||||||
93
app/Exports/TransactionExport.php
Normal file
93
app/Exports/TransactionExport.php
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Exports;
|
||||||
|
|
||||||
|
use App\Models\Transaction;
|
||||||
|
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||||
|
|
||||||
|
class TransactionExport implements FromCollection, WithHeadings
|
||||||
|
{
|
||||||
|
|
||||||
|
protected $date_start;
|
||||||
|
protected $date_end;
|
||||||
|
protected $sa;
|
||||||
|
protected $mechanic;
|
||||||
|
protected $dealer;
|
||||||
|
|
||||||
|
function __construct($request) {
|
||||||
|
$this->date_start = $request->query('date_start');
|
||||||
|
$this->date_end = $request->query('date_end');
|
||||||
|
$this->sa = $request->query('sa');
|
||||||
|
$this->mechanic = $request->query('mechanic');
|
||||||
|
$this->dealer = $request->query('dealer');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Illuminate\Support\Collection
|
||||||
|
*/
|
||||||
|
public function collection()
|
||||||
|
{
|
||||||
|
$data = Transaction::leftJoin('users', 'users.id', '=', 'transactions.user_id')
|
||||||
|
->leftJoin('users as sa', 'sa.id', '=', 'transactions.user_sa_id')
|
||||||
|
->leftJoin('works as w', 'w.id', '=', 'transactions.work_id')
|
||||||
|
->leftJoin('categories as cat', 'cat.id', '=', 'w.category_id')
|
||||||
|
->leftJoin('dealers as d', 'd.id', '=', 'transactions.dealer_id')
|
||||||
|
->select('transactions.id', 'transactions.status', 'transactions.user_id as user_id', 'transactions.user_sa_id as user_sa_id', 'users.name as username', 'sa.name as sa_name', 'cat.name as category_name', 'w.name as workname', 'transactions.qty as qty', 'transactions.date as date', 'transactions.police_number as police_number', 'transactions.warranty as warranty', 'transactions.spk as spk', 'transactions.dealer_id', 'd.name as dealer_name');
|
||||||
|
|
||||||
|
if(isset($this->date_start) && $this->date_start != null) {
|
||||||
|
$data = $data->where('transactions.date', '>=', $this->date_start);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isset($this->date_end) && $this->date_end != null) {
|
||||||
|
$data = $data->where('transactions.date', '<=', $this->date_end);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isset($this->sa) && $this->sa != null) {
|
||||||
|
$data = $data->where('transactions.user_sa_id', $this->sa);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isset($this->mechanic) && $this->mechanic != null) {
|
||||||
|
$data = $data->where('transactions.user_id', $this->mechanic);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isset($this->dealer) && $this->dealer != null) {
|
||||||
|
$data = $data->where('transactions.dealer_id', $this->dealer);
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = $data->orderBy('date', 'DESC')->get();
|
||||||
|
|
||||||
|
$data2 = [];
|
||||||
|
foreach($data as $item) {
|
||||||
|
$data2[] = [
|
||||||
|
"date" => date('d-m-Y', strtotime($item['date'])),
|
||||||
|
"dealer" => $item['dealer_name'],
|
||||||
|
"spk" => $item['spk'],
|
||||||
|
"mechanic" => $item['username'],
|
||||||
|
"sa" => $item['sa_name'],
|
||||||
|
"police_number" => $item['police_number'],
|
||||||
|
"warranty" => $item['warranty'] == 1 ? 'Ya' : 'Tidak',
|
||||||
|
"category" => $item['category_name'],
|
||||||
|
"work" => $item['workname'],
|
||||||
|
"qty" => $item['qty']
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
$data2 = collect($data2);
|
||||||
|
|
||||||
|
return $data2;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function headings(): array
|
||||||
|
{
|
||||||
|
return ["Tanggal", "Dealer", "Spk","Mekanik", "SA", "No. Polisi", "Warranty", "Kategori", "Pekerjaan", "Qty"];
|
||||||
|
}
|
||||||
|
|
||||||
|
// public function actions(Request $request)
|
||||||
|
// {
|
||||||
|
// return [
|
||||||
|
// (new DownloadExcel)->withHeadings('Tanggal', 'Mekanik', 'SA', 'No.Polisi', 'Warranty', 'Kategori', 'Qty')
|
||||||
|
// ];
|
||||||
|
// }
|
||||||
|
}
|
||||||
90
app/Exports/TransactionSaExport.php
Normal file
90
app/Exports/TransactionSaExport.php
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Exports;
|
||||||
|
|
||||||
|
use App\Models\Transaction;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||||
|
|
||||||
|
class TransactionSaExport implements FromCollection
|
||||||
|
{
|
||||||
|
|
||||||
|
protected $dealer;
|
||||||
|
protected $month;
|
||||||
|
protected $sa;
|
||||||
|
|
||||||
|
function __construct($request) {
|
||||||
|
$this->month = (isset($request->month)) ? $request->query('month') : date('m');
|
||||||
|
$this->dealer = (isset($request->dealer)) ? $request->query('dealer') : 'all';
|
||||||
|
$this->sa = (isset($request->sa)) ? $request->query('sa') : 'all';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Illuminate\Support\Collection
|
||||||
|
*/
|
||||||
|
public function collection()
|
||||||
|
{
|
||||||
|
$sa_work_trx = DB::statement("SET @sql = NULL");
|
||||||
|
$sql = "SELECT IF(work_id IS NOT NULL, GROUP_CONCAT(DISTINCT CONCAT('SUM(IF(work_id = \"', work_id,'\", qty,\"\")) AS \"',CONCAT(w.name, '|',w.id),'\"')), 's.work_id') INTO @sql FROM transactions t JOIN works w ON w.id = t.work_id WHERE month(t.date) = '". $this->month ."' and year(t.date) = '". date('Y') ."' and t.deleted_at is null";
|
||||||
|
|
||||||
|
if(isset($this->dealer) && $this->dealer != 'all') {
|
||||||
|
$sql .= " and t.dealer_id = '". $this->dealer ."'";
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isset($this->sa) && $this->sa != 'all') {
|
||||||
|
$sql .= " and t.user_sa_id = '". $this->sa ."'";
|
||||||
|
}
|
||||||
|
|
||||||
|
$sa_work_trx = DB::statement($sql);
|
||||||
|
|
||||||
|
if(isset($this->dealer) && $this->dealer != 'all') {
|
||||||
|
if(isset($this->sa) && $this->sa != 'all') {
|
||||||
|
$sa_work_trx = DB::statement("SET @sql = IF(@sql != 's.work_id' ,CONCAT(\"SELECT sa.name as SA, sa.id as sa_id, \", @sql, \"FROM transactions s JOIN users sa ON sa.id = s.user_sa_id WHERE month(s.date) = '". $this->month ."' and year(s.date) = '". date('Y') ."' and s.deleted_at is null and s.dealer_id = '". $this->dealer ."' and s.user_sa_id = '". $this->sa ."' GROUP BY s.user_sa_id ORDER BY s.user_sa_id ASC\"), CONCAT(\"SELECT sa.name as SA, sa.id as sa_id \", \"FROM transactions s JOIN users sa ON sa.id = s.user_sa_id WHERE month(s.date) = '". $this->month ."' and year(s.date) = '". date('Y') ."' and s.deleted_at is null and s.dealer_id = '". $this->dealer ."' and s.user_sa_id = '". $this->sa ."' GROUP BY s.`user_sa_id` ORDER BY s.`user_sa_id` ASC\"))");
|
||||||
|
}else{
|
||||||
|
$sa_work_trx = DB::statement("SET @sql = IF(@sql != 's.work_id' ,CONCAT(\"SELECT sa.name as SA, sa.id as sa_id, \", @sql, \"FROM transactions s JOIN users sa ON sa.id = s.user_sa_id WHERE month(s.date) = '". $this->month ."' and year(s.date) = '". date('Y') ."' and s.deleted_at is null and s.dealer_id = '". $this->dealer ."' GROUP BY s.user_sa_id ORDER BY s.user_sa_id ASC\"), CONCAT(\"SELECT sa.name as SA, sa.id as sa_id \", \"FROM transactions s JOIN users sa ON sa.id = s.user_sa_id WHERE month(s.date) = '". $this->month ."' and year(s.date) = '". date('Y') ."' and s.deleted_at is null and s.dealer_id = '". $this->dealer ."' GROUP BY s.`user_sa_id` ORDER BY s.`user_sa_id` ASC\"))");
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
if(isset($this->sa) && $this->sa != 'all') {
|
||||||
|
$sa_work_trx = DB::statement("SET @sql = IF(@sql != 's.work_id' ,CONCAT(\"SELECT sa.name as SA, sa.id as sa_id, \", @sql, \"FROM transactions s JOIN users sa ON sa.id = s.user_sa_id WHERE month(s.date) = '". $this->month ."' and year(s.date) = '". date('Y') ."' and s.deleted_at is null and s.user_sa_id = '". $this->sa ."' GROUP BY s.user_sa_id ORDER BY s.user_sa_id ASC\"), CONCAT(\"SELECT sa.name as SA, sa.id as user_sa_id \", \"FROM transactions s JOIN dealers d ON d.id = s.user_sa_id WHERE month(s.date) = '". $this->month ."' and year(s.date) = '". date('Y') ."' and s.deleted_at is null and s.user_sa_id = '". $this->sa ."' GROUP BY s.`user_sa_id` ORDER BY s.`user_sa_id` ASC\"))");
|
||||||
|
}else{
|
||||||
|
$sa_work_trx = DB::statement("SET @sql = IF(@sql != 's.work_id' ,CONCAT(\"SELECT sa.name as SA, sa.id as sa_id, \", @sql, \"FROM transactions s JOIN users sa ON sa.id = s.user_sa_id WHERE month(s.date) = '". $this->month ."' and year(s.date) = '". date('Y') ."' and s.deleted_at is null GROUP BY s.user_sa_id ORDER BY s.user_sa_id ASC\"), CONCAT(\"SELECT sa.name as SA, sa.id as user_sa_id \", \"FROM transactions s JOIN dealers d ON d.id = s.user_sa_id WHERE month(s.date) = '". $this->month ."' and year(s.date) = '". date('Y') ."' and s.deleted_at is null GROUP BY s.`user_sa_id` ORDER BY s.`user_sa_id` ASC\"))");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$sa_work_trx = DB::statement("PREPARE stmt FROM @sql");
|
||||||
|
$sa_work_trx = DB::select(DB::raw("EXECUTE stmt"));
|
||||||
|
DB::statement('DEALLOCATE PREPARE stmt');
|
||||||
|
$work_trx = [];
|
||||||
|
foreach($sa_work_trx as $index => $sa_work) {
|
||||||
|
$sa_work_2 = (array) $sa_work;
|
||||||
|
unset($sa_work_2['sa_id']);
|
||||||
|
$work_names = array_keys($sa_work_2);
|
||||||
|
if($index == 0) {
|
||||||
|
$work_names_e = [];
|
||||||
|
foreach($work_names as $work) {
|
||||||
|
$arr_work = explode('|', $work);
|
||||||
|
$work_names_e[] = $arr_work[0];
|
||||||
|
}
|
||||||
|
$work_trx[] = $work_names_e;
|
||||||
|
$work_trx[] = array_values($sa_work_2);
|
||||||
|
}else{
|
||||||
|
$work_trx[] = array_values($sa_work_2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return collect($work_trx);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// public function headings(): array
|
||||||
|
// {
|
||||||
|
// return $this->theads;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// public function actions(Request $request)
|
||||||
|
// {
|
||||||
|
// return [
|
||||||
|
// (new DownloadExcel)->withHeadings('Tanggal', 'Mekanik', 'SA', 'No.Polisi', 'Warranty', 'Kategori', 'Qty')
|
||||||
|
// ];
|
||||||
|
// }
|
||||||
|
}
|
||||||
478
app/Http/Controllers/AdminController.php
Normal file
478
app/Http/Controllers/AdminController.php
Normal file
@@ -0,0 +1,478 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Models\Dealer;
|
||||||
|
use App\Models\Menu;
|
||||||
|
use App\Models\Transaction;
|
||||||
|
use App\Models\User;
|
||||||
|
use App\Models\Work;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Facades\Gate;
|
||||||
|
|
||||||
|
class AdminController extends Controller
|
||||||
|
{
|
||||||
|
public function cmp($a, $b){
|
||||||
|
$key = 'work_id';
|
||||||
|
if($a[$key] > $b[$key]){
|
||||||
|
return 1;
|
||||||
|
}else if($a[$key] < $b[$key]){
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dashboard(Request $request) {
|
||||||
|
abort_if(Gate::denies('view', Menu::where('link', 'dashboard')->first()), 403, 'Unauthorized User');
|
||||||
|
|
||||||
|
if(!isset($request->month)) {
|
||||||
|
$request['month'] = date('m');
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!isset($request->year)) {
|
||||||
|
$request['year'] = date('Y');
|
||||||
|
}
|
||||||
|
|
||||||
|
$month = $request->month;
|
||||||
|
$dealer = $request->dealer;
|
||||||
|
$year = $request->year;
|
||||||
|
$dealer_datas = Dealer::all();
|
||||||
|
$ajax_url = route('dashboard_data').'?month='.$month.'&year='.$year.'&dealer='.$dealer;
|
||||||
|
// dd($ajax_url);
|
||||||
|
return view('dashboard', compact('month','year', 'ajax_url', 'dealer', 'dealer_datas'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dashboard_data(Request $request) {
|
||||||
|
abort_if(Gate::denies('view', Menu::where('link', 'dashboard')->first()), 403, 'Unauthorized User');
|
||||||
|
if(!isset($request->month)) {
|
||||||
|
$request['month'] = date('m');
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!isset($request->year)) {
|
||||||
|
$request['year'] = date('Y');
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isset($request->{'amp;dealer'})) {
|
||||||
|
$request['dealer'] = $request->{'amp;dealer'};
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isset($request->{'amp;year'})) {
|
||||||
|
$request['year'] = $request->{'amp;year'};
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!isset($request->dealer)) {
|
||||||
|
$request['dealer'] = 'all';
|
||||||
|
}
|
||||||
|
|
||||||
|
$month = $request->month;
|
||||||
|
$dealer = $request->dealer;
|
||||||
|
$year = $request->year;
|
||||||
|
|
||||||
|
$dealer_work_trx = DB::statement("SET @sql = NULL");
|
||||||
|
$sql = "SELECT IF(work_id IS NOT NULL, GROUP_CONCAT(DISTINCT CONCAT('SUM(IF(work_id = \"', work_id,'\", qty,\"\")) AS \"',CONCAT(w.name, '|',w.id),'\"')), 's.work_id') INTO @sql FROM transactions t JOIN works w ON w.id = t.work_id WHERE month(t.date) = '". $month ."' and year(t.date) = '". $year ."' and t.deleted_at is null";
|
||||||
|
|
||||||
|
if(isset($request->dealer) && $request->dealer != 'all') {
|
||||||
|
$sql .= " and t.dealer_id = '". $dealer ."'";
|
||||||
|
}
|
||||||
|
|
||||||
|
$dealer_work_trx = DB::statement($sql);
|
||||||
|
|
||||||
|
if(isset($request->dealer) && $request->dealer != 'all') {
|
||||||
|
$dealer_work_trx = DB::statement("SET @sql = IF(@sql != 's.work_id' ,CONCAT(\"SELECT d.name as DEALER, d.id as dealer_id, \", @sql, \"FROM transactions s JOIN dealers d ON d.id = s.dealer_id WHERE month(s.date) = '". $month ."' and year(s.date) = '". $year ."' and s.deleted_at is null and s.dealer_id = '". $dealer ."' GROUP BY s.dealer_id ORDER BY s.dealer_id ASC\"), CONCAT(\"SELECT d.name as DEALER \", \"FROM transactions s JOIN dealers d ON d.id = s.dealer_id WHERE month(s.date) = '". $month ."' and year(s.date) = '". $year ."' and s.deleted_at is null and s.dealer_id = '". $dealer ."' GROUP BY s.`dealer_id` ORDER BY s.`dealer_id` ASC\"))");
|
||||||
|
}else{
|
||||||
|
$dealer_work_trx = DB::statement("SET @sql = IF(@sql != 's.work_id' ,CONCAT(\"SELECT d.name as DEALER, d.id as dealer_id, \", @sql, \"FROM transactions s JOIN dealers d ON d.id = s.dealer_id WHERE month(s.date) = '". $month ."' and year(s.date) = '". $year ."' and s.deleted_at is null GROUP BY s.dealer_id ORDER BY s.dealer_id ASC\"), CONCAT(\"SELECT d.name as DEALER, d.id as dealer_id \", \"FROM transactions s JOIN dealers d ON d.id = s.dealer_id WHERE month(s.date) = '". $month ."' and year(s.date) = '". $year ."' and s.deleted_at is null GROUP BY s.`dealer_id` ORDER BY s.`dealer_id` ASC\"))");
|
||||||
|
}
|
||||||
|
|
||||||
|
$dealer_work_trx = DB::statement("PREPARE stmt FROM @sql");
|
||||||
|
$dealer_work_trx = DB::select(DB::raw("EXECUTE stmt"));
|
||||||
|
DB::statement('DEALLOCATE PREPARE stmt');
|
||||||
|
// DD($dealer_work_trx);
|
||||||
|
$theads = ['DEALER'];
|
||||||
|
$dealer_names = [];
|
||||||
|
$dealer_trx = [];
|
||||||
|
$work_trx = [];
|
||||||
|
$work_ids = [];
|
||||||
|
|
||||||
|
foreach($dealer_work_trx as $index => $dealer_work) {
|
||||||
|
$dealer_work_2 = (array) $dealer_work;
|
||||||
|
unset($dealer_work_2['dealer_id']);
|
||||||
|
$work_trx[$dealer_work->dealer_id] = array_values($dealer_work_2);
|
||||||
|
unset($dealer_work_2['DEALER']);
|
||||||
|
$work_names = array_keys($dealer_work_2);
|
||||||
|
if($index == 0) {
|
||||||
|
foreach($work_names as $work) {
|
||||||
|
$arr_work = explode('|', $work);
|
||||||
|
$theads[] = $arr_work[0];
|
||||||
|
$work_ids[] = $arr_work[1];
|
||||||
|
$dealer_trx[$work] = [
|
||||||
|
'work_name' => $arr_work[0],
|
||||||
|
'qty' => [$dealer_work->{$work}]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
foreach($work_names as $work) {
|
||||||
|
$dealer_trx[$work]['qty'][] = $dealer_work->{$work};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$dealer_names[] = $dealer_work->DEALER;
|
||||||
|
}
|
||||||
|
// dd($dealer_trx);
|
||||||
|
$dealer_trx = array_values($dealer_trx);
|
||||||
|
$dealer = $request->dealer;
|
||||||
|
$month = $request->month;
|
||||||
|
|
||||||
|
$dealer_names = json_encode($dealer_names);
|
||||||
|
$dealer_trx = json_encode($dealer_trx);
|
||||||
|
|
||||||
|
$prev_mth_start = date('Y-m-d', strtotime(date($year.'-'. $request->month .'-1')." -1 month"));
|
||||||
|
$prev_mth = explode('-', $prev_mth_start);
|
||||||
|
if($request->month == date('m')) {
|
||||||
|
$prev_mth_end = $prev_mth[0].'-'.$prev_mth[1].'-'.date('d');
|
||||||
|
}else{
|
||||||
|
$prev_mth_end = $prev_mth[0].'-'.$prev_mth[1].'-'.date('t');
|
||||||
|
}
|
||||||
|
|
||||||
|
$prev_month_trx = [];
|
||||||
|
$now_month_trx = [];
|
||||||
|
foreach($work_ids as $work_id) {
|
||||||
|
$now_month = Transaction::select(DB::raw("SUM(qty) as qty"))->where('work_id', $work_id)->whereMonth('date', '=', $request->month)->whereYear('date', $year);
|
||||||
|
$prev_month = Transaction::select(DB::raw("SUM(qty) as qty"))->where('work_id', $work_id)->whereDate('date', '>=', $prev_mth_start)->whereDate('date', '<=', $prev_mth_end);
|
||||||
|
|
||||||
|
if(isset($request->dealer) && $request->dealer != 'all') {
|
||||||
|
$prev_month = $prev_month->where('dealer_id', $request->dealer);
|
||||||
|
$now_month = $now_month->where('dealer_id', $request->dealer);
|
||||||
|
}
|
||||||
|
|
||||||
|
$prev_month_trx[] = $prev_month->sum('qty');
|
||||||
|
$now_month_trx[] = $now_month->sum('qty');
|
||||||
|
}
|
||||||
|
|
||||||
|
$totals = [];
|
||||||
|
for($i = 0; $i < count($now_month_trx); $i++) {
|
||||||
|
$totals[] = [
|
||||||
|
"prev" => $prev_month_trx[$i],
|
||||||
|
"now" => $now_month_trx[$i],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('dashboard_data', compact('theads', 'work_trx', 'month', 'year', 'dealer_names', 'dealer_trx', 'dealer', 'totals'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dealer_work_trx(Request $request) {
|
||||||
|
$dealer_work_trx = Work::select(DB::raw('works.name AS work_name'), DB::raw("IFNULL(SUM(t.qty), 0) AS qty"), 'works.id AS work_id')->whereHas('transactions', function($q) use($request) {
|
||||||
|
if(isset($request->month)) {
|
||||||
|
$q = $q->whereMonth('date', '=', $request->month)->whereYear('date', date('Y'));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isset($request->dealer_filter) && $request->dealer_filter != 'all') {
|
||||||
|
$q = $q->where('dealer_id', $request->dealer_filter);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $q;
|
||||||
|
})->leftJoin('transactions AS t', function($q) use($request) {
|
||||||
|
$q->on('t.work_id', '=', 'works.id');
|
||||||
|
$q->on(DB::raw('MONTH(t.date)'), '=', DB::raw($request->month));
|
||||||
|
$q->on(DB::raw('YEAR(t.date)'), '=', DB::raw(date('Y')));
|
||||||
|
$q->on('t.dealer_id', '=', DB::raw($request->dealer));
|
||||||
|
})->groupBy('works.id')->orderBy('works.id', 'ASC')->get();
|
||||||
|
return response()->json($dealer_work_trx);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function get_dealer_has_transactions(Request $request) {
|
||||||
|
if(!isset($request->month)) {
|
||||||
|
$request['month'] = date('m');
|
||||||
|
}
|
||||||
|
|
||||||
|
$dealers = Dealer::whereHas('transactions', function($q) use($request) {
|
||||||
|
if(isset($request->month)) {
|
||||||
|
$q = $q->whereMonth('date', '=', $request->month)->whereYear('date', date('Y'));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if(isset($request->dealer) && $request->dealer != 'all') {
|
||||||
|
$dealers = $dealers->where('id', $request->dealer);
|
||||||
|
}
|
||||||
|
|
||||||
|
$dealers = $dealers->orderBy('id', 'ASC')->get();
|
||||||
|
|
||||||
|
return response()->json($dealers);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dashboard_data_old(Request $request) {
|
||||||
|
$trxs = [];
|
||||||
|
|
||||||
|
if(!isset($request->month)) {
|
||||||
|
$request['month'] = date('m');
|
||||||
|
}
|
||||||
|
|
||||||
|
$dealers = Dealer::whereHas('transactions', function($q) use($request) {
|
||||||
|
if(isset($request->month)) {
|
||||||
|
return $q->whereMonth('date', '=', $request->month)->whereYear('date', date('Y'));
|
||||||
|
}
|
||||||
|
})->orderBy('id', 'ASC')->get();
|
||||||
|
|
||||||
|
$works = Work::select('id', 'name')->whereHas('transactions', function($q) use($request) {
|
||||||
|
if(isset($request->month)) {
|
||||||
|
return $q->whereMonth('date', '=', $request->month)->whereYear('date', date('Y'));
|
||||||
|
}
|
||||||
|
})->orderBy('id', 'ASC')->get();
|
||||||
|
|
||||||
|
|
||||||
|
$works_count = $works->count();
|
||||||
|
$month_trxs_total = [];
|
||||||
|
$prev_month_trxs_total = [];
|
||||||
|
foreach ($dealers as $key => $dealer) {
|
||||||
|
foreach($works as $work1) {
|
||||||
|
$prev_mth_start = date('Y-m-d', strtotime(date('Y-'. $request->month .'-1')." -1 month"));
|
||||||
|
$prev_mth = explode('-', $prev_mth_start);
|
||||||
|
if($request->month == date('m')) {
|
||||||
|
$prev_mth_end = $prev_mth[0].'-'.$prev_mth[1].'-'.date('d');
|
||||||
|
}else{
|
||||||
|
$prev_mth_end = $prev_mth[0].'-'.$prev_mth[1].'-'.date('t');
|
||||||
|
}
|
||||||
|
|
||||||
|
// dd($prev_mth_end);
|
||||||
|
$yesterday_month_trx = Transaction::where('work_id', $work1->id)->where('dealer_id', $dealer->id)->whereDate('date', '>=', $prev_mth_start)->whereDate('date', '<=', $prev_mth_end)->sum('qty');
|
||||||
|
|
||||||
|
if(array_key_exists($work1->id, $prev_month_trxs_total)) {
|
||||||
|
$prev_month_trxs_total[$work1->id] += $yesterday_month_trx;
|
||||||
|
}else{
|
||||||
|
$prev_month_trxs_total[$work1->id] = $yesterday_month_trx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$dealer_works = [];
|
||||||
|
foreach ($works as $key2 => $work) {
|
||||||
|
$d = Transaction::where('dealer_id', $dealer->id)->where('work_id', $work->id);
|
||||||
|
|
||||||
|
if(isset($request->month)) {
|
||||||
|
$d = $d->whereMonth('date', '=', $request->month)->whereYear('date', date('Y'));
|
||||||
|
$month = $request->month;
|
||||||
|
}
|
||||||
|
|
||||||
|
$d = $d->sum('qty');
|
||||||
|
if($d) {
|
||||||
|
if(array_key_exists($work->id, $month_trxs_total)) {
|
||||||
|
$month_trxs_total[$work->id] += $d;
|
||||||
|
}else{
|
||||||
|
$month_trxs_total[$work->id] = $d;
|
||||||
|
}
|
||||||
|
$dealer_works[] = [
|
||||||
|
'work_id' => $work->id,
|
||||||
|
'work_name' => $work->name,
|
||||||
|
'dealer_id' => $dealer->id,
|
||||||
|
'qty' => $d,
|
||||||
|
];
|
||||||
|
}else{
|
||||||
|
$dealer_works[] = [
|
||||||
|
'work_id' => $work->id,
|
||||||
|
'work_name' => $work->name,
|
||||||
|
'dealer_id' => $dealer->id,
|
||||||
|
'qty' => 0,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$trxs[] = [
|
||||||
|
'dealer_id' => $dealer->id,
|
||||||
|
'dealer_name' => $dealer->name,
|
||||||
|
'works' => $dealer_works
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
$dealer_names = [];
|
||||||
|
$trx_data = [];
|
||||||
|
foreach($trxs as $trx) {
|
||||||
|
$dealer_names[] = $trx['dealer_name'];
|
||||||
|
$work_data2 = [];
|
||||||
|
foreach($trx['works'] as $work_data) {
|
||||||
|
if(array_key_exists($work_data['work_name'], $trx_data)) {
|
||||||
|
$trx_data[$work_data['work_name']]['qty'][] = $work_data['qty'];
|
||||||
|
}else{
|
||||||
|
$trx_data[$work_data['work_name']] = [
|
||||||
|
'work_name' => $work_data['work_name'],
|
||||||
|
'qty' => [$work_data['qty']]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$month_trxs_total = array_values($month_trxs_total);
|
||||||
|
$prev_month_trxs_total = array_values($prev_month_trxs_total);
|
||||||
|
|
||||||
|
$totals = [];
|
||||||
|
for($i = 0; $i < count($month_trxs_total); $i++) {
|
||||||
|
$totals[] = [
|
||||||
|
"prev" => $prev_month_trxs_total[$i],
|
||||||
|
"now" => $month_trxs_total[$i],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
$dealer_names = json_encode($dealer_names);
|
||||||
|
|
||||||
|
$trx_data = json_encode(array_values($trx_data));
|
||||||
|
$month = $request->month;
|
||||||
|
|
||||||
|
return view('dashboard_data', compact('works', 'works_count', 'trxs', 'month', 'dealer_names', 'trx_data', 'totals'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dealer_recap(Request $request, $id)
|
||||||
|
{
|
||||||
|
abort_if(Gate::denies('view', Menu::where('link', 'dashboard')->first()), 403, 'Unauthorized User');
|
||||||
|
|
||||||
|
if(!isset($request->month)) {
|
||||||
|
$request['month'] = date('m');
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!isset($request->year)) {
|
||||||
|
$request['year'] = date('Y');
|
||||||
|
}
|
||||||
|
|
||||||
|
$works = Work::select('id', 'name', 'shortname')->whereHas('transactions', function($q) use($request, $id) {
|
||||||
|
return $q->where('qty', '>', '0')->where('dealer_id', $id)->whereMonth('date', '=', $request->month)->whereYear('date', $request->year);
|
||||||
|
})->get();
|
||||||
|
|
||||||
|
$sas = User::select('id', 'name')->whereHas('sa_transactions', function($q) use($request, $id) {
|
||||||
|
return $q->where('dealer_id', $id)->whereMonth('date', '=', $request->month)->whereYear('date', $request->year);
|
||||||
|
})->get();
|
||||||
|
|
||||||
|
$dealer = Dealer::find($id);
|
||||||
|
|
||||||
|
$dates = Transaction::select(DB::raw('DATE(`date`) as date'))->where('dealer_id', $id)->whereMonth('date', $request->month)->whereYear('date', $request->year)->groupBy(DB::raw('DATE(`date`)'))->get()->toArray();
|
||||||
|
$dates = $this->array_value_recursive('date', $dates);
|
||||||
|
|
||||||
|
$trxs = [];
|
||||||
|
$month_trxs_total = [];
|
||||||
|
$yesterday_month_trxs_total = [];
|
||||||
|
foreach($works as $work1) {
|
||||||
|
$prev_mth_start = date('Y-m-d', strtotime(date($request->year.'-'. $request->month .'-1')." -1 month"));
|
||||||
|
$prev_mth = explode('-', $prev_mth_start);
|
||||||
|
if($request->month == date('m')) {
|
||||||
|
$prev_mth_end = $prev_mth[0].'-'.$prev_mth[1].'-'.date('d');
|
||||||
|
}else{
|
||||||
|
$prev_mth_end = $prev_mth[0].'-'.$prev_mth[1].'-'.date('t');
|
||||||
|
}
|
||||||
|
|
||||||
|
$yesterday_month_trx = Transaction::where('work_id', $work1->id)->where('dealer_id', $id)->whereDate('date', '>=', $prev_mth_start)->whereDate('date', '<=', $prev_mth_end)->sum('qty');
|
||||||
|
|
||||||
|
if(array_key_exists($work1->id, $yesterday_month_trxs_total)) {
|
||||||
|
$yesterday_month_trxs_total[$work1->id] += $yesterday_month_trx;
|
||||||
|
}else{
|
||||||
|
$yesterday_month_trxs_total[$work1->id] = $yesterday_month_trx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if($dates) {
|
||||||
|
foreach($dates as $key => $date) {
|
||||||
|
$date_works = [];
|
||||||
|
$share_works = [];
|
||||||
|
foreach ($works as $key2 => $work) {
|
||||||
|
$d = Transaction::where('work_id', $work->id)->where('dealer_id', $id)->whereDate('date', $date)->whereMonth('date', '=', $request->month)->whereYear('date', $request->year);
|
||||||
|
|
||||||
|
if($d) {
|
||||||
|
$d = $d->sum('qty');
|
||||||
|
if(array_key_exists($work->id, $month_trxs_total)) {
|
||||||
|
$month_trxs_total[$work->id] += $d;
|
||||||
|
}else{
|
||||||
|
$month_trxs_total[$work->id] = $d;
|
||||||
|
}
|
||||||
|
|
||||||
|
$date_works[] = [
|
||||||
|
'work_id' => $work->id,
|
||||||
|
'work_name' => $work->name,
|
||||||
|
'shortname' => $work->shortname,
|
||||||
|
'date' => $date,
|
||||||
|
'qty' => $d,
|
||||||
|
];
|
||||||
|
}else{
|
||||||
|
$date_works[] = [
|
||||||
|
'work_id' => $work->id,
|
||||||
|
'work_name' => $work->name,
|
||||||
|
'shortname' => $work->shortname,
|
||||||
|
'date' => $date,
|
||||||
|
'qty' => 0,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$trxs[] = [
|
||||||
|
'date' => date('d/m/Y', strtotime($date)),
|
||||||
|
'works' => $date_works
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$dealer_trxs = [];
|
||||||
|
foreach($sas as $key => $sa) {
|
||||||
|
$sa_works = [];
|
||||||
|
foreach ($works as $key2 => $work) {
|
||||||
|
$d = Transaction::where('user_sa_id', $sa->id)->where('work_id', $work->id)->where('dealer_id', $id);
|
||||||
|
|
||||||
|
$d = $d->whereMonth('date', '=', $request->month)->whereYear('date', $request->year);
|
||||||
|
$month = $request->month;
|
||||||
|
|
||||||
|
if($d) {
|
||||||
|
$d = $d->sum('qty');
|
||||||
|
$sa_works[] = [
|
||||||
|
'work_id' => $work->id,
|
||||||
|
'work_name' => $work->name,
|
||||||
|
'user_sa_id' => $sa->id,
|
||||||
|
'qty' => $d,
|
||||||
|
];
|
||||||
|
}else{
|
||||||
|
$sa_works[] = [
|
||||||
|
'work_id' => $work->id,
|
||||||
|
'work_name' => $work->name,
|
||||||
|
'user_sa_id' => $sa->id,
|
||||||
|
'qty' => 0,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$dealer_trxs[] = [
|
||||||
|
'user_sa_id' => $sa->id,
|
||||||
|
'sa_name' => $sa->name,
|
||||||
|
'works' => $sa_works
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
// $month_trxs_total = array_values($month_trxs_total);
|
||||||
|
// $yesterday_month_trxs_total = array_values($yesterday_month_trxs_total);
|
||||||
|
// dd(["month_trxs_total" => $month_trxs_total, "yesterday_month_trxs_total" => $yesterday_month_trxs_total, "works" => $works->toArray()]);
|
||||||
|
// dd($month_trxs_total);
|
||||||
|
// dd($yesterday_month_trxs_total);
|
||||||
|
$final_month_trxs_total = [];
|
||||||
|
$final_yesterday_month_trxs_total = [];
|
||||||
|
foreach($works as $work1) {
|
||||||
|
$final_month_trxs_total[$work1->id] = array_key_exists($work1->id, $month_trxs_total) ? $month_trxs_total[$work1->id] : 0;
|
||||||
|
$final_yesterday_month_trxs_total[$work1->id] = $yesterday_month_trxs_total[$work1->id];
|
||||||
|
}
|
||||||
|
// dd([$final_month_trxs_total, $final_yesterday_month_trxs_total]);
|
||||||
|
$month_trxs_total = array_values($final_month_trxs_total);
|
||||||
|
$yesterday_month_trxs_total = array_values($final_yesterday_month_trxs_total);
|
||||||
|
$totals = [];
|
||||||
|
for($i = 0; $i < count($month_trxs_total); $i++) {
|
||||||
|
$totals[] = [
|
||||||
|
"prev" => $yesterday_month_trxs_total[$i],
|
||||||
|
"now" => $month_trxs_total[$i],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
$works_count = count($works);
|
||||||
|
$month = $request->month;
|
||||||
|
$year = $request->year;
|
||||||
|
return view('dealer_recap', compact('totals', 'month', 'year', 'works', 'works_count', 'trxs', 'dealer', 'dealer_trxs'));
|
||||||
|
}
|
||||||
|
|
||||||
|
private function array_value_recursive($key, array $arr){
|
||||||
|
$val = array();
|
||||||
|
array_walk_recursive($arr, function($v, $k) use($key, &$val){
|
||||||
|
if($k == $key) array_push($val, $v);
|
||||||
|
});
|
||||||
|
|
||||||
|
return $val;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
1066
app/Http/Controllers/ApiController.php
Normal file
1066
app/Http/Controllers/ApiController.php
Normal file
File diff suppressed because it is too large
Load Diff
40
app/Http/Controllers/Auth/ConfirmPasswordController.php
Normal file
40
app/Http/Controllers/Auth/ConfirmPasswordController.php
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Auth;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Providers\RouteServiceProvider;
|
||||||
|
use Illuminate\Foundation\Auth\ConfirmsPasswords;
|
||||||
|
|
||||||
|
class ConfirmPasswordController extends Controller
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Confirm Password Controller
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This controller is responsible for handling password confirmations and
|
||||||
|
| uses a simple trait to include the behavior. You're free to explore
|
||||||
|
| this trait and override any functions that require customization.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
use ConfirmsPasswords;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Where to redirect users when the intended url fails.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $redirectTo = RouteServiceProvider::HOME;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new controller instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->middleware('auth');
|
||||||
|
}
|
||||||
|
}
|
||||||
22
app/Http/Controllers/Auth/ForgotPasswordController.php
Normal file
22
app/Http/Controllers/Auth/ForgotPasswordController.php
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Auth;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
|
||||||
|
|
||||||
|
class ForgotPasswordController extends Controller
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Password Reset Controller
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This controller is responsible for handling password reset emails and
|
||||||
|
| includes a trait which assists in sending these notifications from
|
||||||
|
| your application to your users. Feel free to explore this trait.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
use SendsPasswordResetEmails;
|
||||||
|
}
|
||||||
62
app/Http/Controllers/Auth/LoginController.php
Normal file
62
app/Http/Controllers/Auth/LoginController.php
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Auth;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\Privilege;
|
||||||
|
use App\Providers\RouteServiceProvider;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Foundation\Auth\AuthenticatesUsers;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
class LoginController extends Controller
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Login Controller
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This controller handles authenticating users for the application and
|
||||||
|
| redirecting them to your home screen. The controller uses a trait
|
||||||
|
| to conveniently provide its functionality to your applications.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
use AuthenticatesUsers;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Where to redirect users after login.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $redirectTo = RouteServiceProvider::HOME;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new controller instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->middleware('guest')->except('logout');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The user has been authenticated.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @param mixed $user
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
protected function authenticated(Request $request, $user)
|
||||||
|
{
|
||||||
|
$user = Privilege::where('menu_id', 10)->where('role_id', Auth::user()->role_id)->where('view', 1)->first();
|
||||||
|
|
||||||
|
if ($user != null) {
|
||||||
|
return redirect()->route('dashboard');
|
||||||
|
}else{
|
||||||
|
return redirect(RouteServiceProvider::HOME);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
73
app/Http/Controllers/Auth/RegisterController.php
Normal file
73
app/Http/Controllers/Auth/RegisterController.php
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Auth;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Providers\RouteServiceProvider;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Foundation\Auth\RegistersUsers;
|
||||||
|
use Illuminate\Support\Facades\Hash;
|
||||||
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
|
||||||
|
class RegisterController extends Controller
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Register Controller
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This controller handles the registration of new users as well as their
|
||||||
|
| validation and creation. By default this controller uses a trait to
|
||||||
|
| provide this functionality without requiring any additional code.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
use RegistersUsers;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Where to redirect users after registration.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $redirectTo = RouteServiceProvider::HOME;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new controller instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->middleware('guest');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a validator for an incoming registration request.
|
||||||
|
*
|
||||||
|
* @param array $data
|
||||||
|
* @return \Illuminate\Contracts\Validation\Validator
|
||||||
|
*/
|
||||||
|
protected function validator(array $data)
|
||||||
|
{
|
||||||
|
return Validator::make($data, [
|
||||||
|
'name' => ['required', 'string', 'max:255'],
|
||||||
|
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
|
||||||
|
'password' => ['required', 'string', 'min:8', 'confirmed'],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new user instance after a valid registration.
|
||||||
|
*
|
||||||
|
* @param array $data
|
||||||
|
* @return \App\Models\User
|
||||||
|
*/
|
||||||
|
protected function create(array $data)
|
||||||
|
{
|
||||||
|
return User::create([
|
||||||
|
'name' => $data['name'],
|
||||||
|
'email' => $data['email'],
|
||||||
|
'password' => Hash::make($data['password']),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
30
app/Http/Controllers/Auth/ResetPasswordController.php
Normal file
30
app/Http/Controllers/Auth/ResetPasswordController.php
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Auth;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Providers\RouteServiceProvider;
|
||||||
|
use Illuminate\Foundation\Auth\ResetsPasswords;
|
||||||
|
|
||||||
|
class ResetPasswordController extends Controller
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Password Reset Controller
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This controller is responsible for handling password reset requests
|
||||||
|
| and uses a simple trait to include this behavior. You're free to
|
||||||
|
| explore this trait and override any methods you wish to tweak.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
use ResetsPasswords;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Where to redirect users after resetting their password.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $redirectTo = RouteServiceProvider::HOME;
|
||||||
|
}
|
||||||
42
app/Http/Controllers/Auth/VerificationController.php
Normal file
42
app/Http/Controllers/Auth/VerificationController.php
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Auth;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Providers\RouteServiceProvider;
|
||||||
|
use Illuminate\Foundation\Auth\VerifiesEmails;
|
||||||
|
|
||||||
|
class VerificationController extends Controller
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Email Verification Controller
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This controller is responsible for handling email verification for any
|
||||||
|
| user that recently registered with the application. Emails may also
|
||||||
|
| be re-sent if the user didn't receive the original email message.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
use VerifiesEmails;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Where to redirect users after verification.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $redirectTo = RouteServiceProvider::HOME;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new controller instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->middleware('auth');
|
||||||
|
$this->middleware('signed')->only('verify');
|
||||||
|
$this->middleware('throttle:6,1')->only('verify', 'resend');
|
||||||
|
}
|
||||||
|
}
|
||||||
146
app/Http/Controllers/CategoryController.php
Normal file
146
app/Http/Controllers/CategoryController.php
Normal file
@@ -0,0 +1,146 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Models\Category;
|
||||||
|
use App\Models\Menu;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\Gate;
|
||||||
|
use Yajra\DataTables\DataTables;
|
||||||
|
|
||||||
|
class CategoryController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
$menu = Menu::where('link', 'category.index')->first();
|
||||||
|
abort_if(Gate::denies('view', $menu), 403, 'Unauthorized User');
|
||||||
|
|
||||||
|
if ($request->ajax()) {
|
||||||
|
$data = Category::all();
|
||||||
|
return DataTables::of($data)->addIndexColumn()
|
||||||
|
->addColumn('action', function($row) use ($menu) {
|
||||||
|
$btn = '';
|
||||||
|
|
||||||
|
if(Auth::user()->can('delete', $menu)) {
|
||||||
|
$btn .= '<button class="btn btn-danger btn-sm btn-bold" data-action="'. route('category.destroy', $row->id) .'" id="destroyCategory'. $row->id .'" onclick="destroyCategory('. $row->id .')"> Hapus </button>';
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Auth::user()->can('update', $menu)) {
|
||||||
|
$btn .= '<button class="btn btn-warning btn-sm btn-bold" id="editCategory'. $row->id .'" data-url="'. route('category.edit', $row->id) .'" data-action="'. route('category.update', $row->id) .'" onclick="editCategory('. $row->id .')"> Edit </button>';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $btn;
|
||||||
|
})
|
||||||
|
->rawColumns(['action'])
|
||||||
|
->make(true);
|
||||||
|
}
|
||||||
|
return view('back.master.category');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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)
|
||||||
|
{
|
||||||
|
$menu = Menu::where('link', 'category.index')->first();
|
||||||
|
abort_if(Gate::denies('create', $menu), 403, 'Unauthorized User');
|
||||||
|
Category::create($request->all());
|
||||||
|
|
||||||
|
$response = [
|
||||||
|
"status" => 200,
|
||||||
|
"message" => "Data created successfully"
|
||||||
|
];
|
||||||
|
|
||||||
|
return response()->json($response);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the specified resource.
|
||||||
|
*
|
||||||
|
* @param \App\Models\Category $category
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function show(Category $category)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
*
|
||||||
|
* @param \App\Models\Category $category
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function edit(Category $category)
|
||||||
|
{
|
||||||
|
$menu = Menu::where('link', 'category.index')->first();
|
||||||
|
abort_if(Gate::denies('view', $menu), 403, 'Unauthorized User');
|
||||||
|
$category = Category::find($category->id);
|
||||||
|
$response = [
|
||||||
|
'data' => $category,
|
||||||
|
'status' => 200,
|
||||||
|
'message' => 'get data successfully'
|
||||||
|
];
|
||||||
|
return response()->json($response);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @param \App\Models\Category $category
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function update(Request $request, Category $category)
|
||||||
|
{
|
||||||
|
$menu = Menu::where('link', 'category.index')->first();
|
||||||
|
abort_if(Gate::denies('update', $menu), 403, 'Unauthorized User');
|
||||||
|
Category::find($category->id)->update($request->all());
|
||||||
|
|
||||||
|
$response = [
|
||||||
|
"status" => 200,
|
||||||
|
"message" => "Data updated successfully"
|
||||||
|
];
|
||||||
|
|
||||||
|
return response()->json($response);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*
|
||||||
|
* @param \App\Models\Category $category
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function destroy(Category $category)
|
||||||
|
{
|
||||||
|
$menu = Menu::where('link', 'category.index')->first();
|
||||||
|
abort_if(Gate::denies('delete', $menu), 403, 'Unauthorized User');
|
||||||
|
Category::destroy($category->id);
|
||||||
|
|
||||||
|
$response = [
|
||||||
|
"status" => 200,
|
||||||
|
"message" => "Data deleted successfully"
|
||||||
|
];
|
||||||
|
|
||||||
|
return response()->json($response);
|
||||||
|
}
|
||||||
|
}
|
||||||
13
app/Http/Controllers/Controller.php
Normal file
13
app/Http/Controllers/Controller.php
Normal 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;
|
||||||
|
}
|
||||||
178
app/Http/Controllers/DealerController.php
Normal file
178
app/Http/Controllers/DealerController.php
Normal file
@@ -0,0 +1,178 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Models\Dealer;
|
||||||
|
use App\Models\Menu;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
// use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\Gate;
|
||||||
|
use Yajra\DataTables\DataTables;
|
||||||
|
|
||||||
|
class DealerController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
$menu = Menu::where('link', 'dealer.index')->first();
|
||||||
|
abort_if(Gate::denies('view', $menu), 403, 'Unauthorized User');
|
||||||
|
|
||||||
|
if ($request->ajax()) {
|
||||||
|
$data = Dealer::leftJoin('users as u', 'u.id', '=', 'pic')->select('u.name as pic_name', 'dealers.*');
|
||||||
|
return Datatables::of($data)->addIndexColumn()
|
||||||
|
->addColumn('action', function($row) use ($menu) {
|
||||||
|
$btn = '';
|
||||||
|
if($row->pic != null) {
|
||||||
|
|
||||||
|
if(Auth::user()->can('delete', $menu)) {
|
||||||
|
$btn .= '<button class="btn btn-danger btn-sm btn-bold" data-action="'. route('dealer.destroy', $row->id) .'" id="destroyDealer'. $row->id .'" onclick="destroyDealer('. $row->id .')"> Hapus </button>';
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Auth::user()->can('update', $menu)) {
|
||||||
|
$btn .= '<button class="btn btn-warning btn-sm btn-bold" id="editDealer'. $row->id .'" data-url="'. route('dealer.edit', $row->id) .'" data-action="'. route('dealer.update', $row->id) .'" onclick="editDealer('. $row->id .')"> Edit </button>';
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
if(Auth::user()->can('delete', $menu)) {
|
||||||
|
$btn .= '<button class="btn btn-danger btn-sm btn-bold" data-action="'. route('dealer.destroy', $row->id) .'" id="destroyDealer'. $row->id .'" onclick="destroyDealer('. $row->id .')"> Hapus </button>';
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Auth::user()->can('update', $menu)) {
|
||||||
|
$btn .= '<button class="btn btn-warning btn-sm btn-bold" id="editDealer'. $row->id .'" data-url="'. route('dealer.edit', $row->id) .'" data-action="'. route('dealer.update', $row->id) .'" onclick="editDealer('. $row->id .')"> Edit </button>
|
||||||
|
<button class="btn btn-success btn-sm btn-bold" data-action="'. route('dealer.picstore', $row->id) .'" id="addPic'. $row->id .'" data-url="'. route('dealer.edit', $row->id) .'" onclick="addPic('. $row->id .')"> Tambahkan PIC </button>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $btn;
|
||||||
|
})
|
||||||
|
->rawColumns(['action'])
|
||||||
|
->make(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
$mechanics = User::where('role_id', 3)->get();
|
||||||
|
return view('back.master.dealer', compact('mechanics'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function pic_store(Request $request, $id)
|
||||||
|
{
|
||||||
|
$menu = Menu::where('link', 'dealer.index')->first();
|
||||||
|
abort_if(Gate::denies('update', $menu), 403, 'Unauthorized User');
|
||||||
|
|
||||||
|
Dealer::find($id)->update([
|
||||||
|
'pic' => $request->pic
|
||||||
|
]);
|
||||||
|
|
||||||
|
$response = [
|
||||||
|
"status" => 200,
|
||||||
|
"message" => "Data updated successfully"
|
||||||
|
];
|
||||||
|
|
||||||
|
return response()->json($response);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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)
|
||||||
|
{
|
||||||
|
$menu = Menu::where('link', 'dealer.index')->first();
|
||||||
|
abort_if(Gate::denies('create', $menu), 403, 'Unauthorized User');
|
||||||
|
Dealer::create($request->all());
|
||||||
|
|
||||||
|
$response = [
|
||||||
|
"status" => 200,
|
||||||
|
"message" => "Data created successfully"
|
||||||
|
];
|
||||||
|
|
||||||
|
return response()->json($response);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the specified resource.
|
||||||
|
*
|
||||||
|
* @param \App\Models\Dealer $dealer
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function show(Dealer $dealer)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
*
|
||||||
|
* @param \App\Models\Dealer $dealer
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function edit(Dealer $dealer)
|
||||||
|
{
|
||||||
|
$menu = Menu::where('link', 'dealer.index')->first();
|
||||||
|
abort_if(Gate::denies('view', $menu), 403, 'Unauthorized User');
|
||||||
|
$dealer = Dealer::find($dealer->id);
|
||||||
|
$response = [
|
||||||
|
'data' => $dealer,
|
||||||
|
'status' => 200,
|
||||||
|
'message' => 'get data successfully'
|
||||||
|
];
|
||||||
|
return response()->json($response);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @param \App\Models\Dealer $dealer
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function update(Request $request, Dealer $dealer)
|
||||||
|
{
|
||||||
|
$menu = Menu::where('link', 'dealer.index')->first();
|
||||||
|
abort_if(Gate::denies('update', $menu), 403, 'Unauthorized User');
|
||||||
|
Dealer::find($dealer->id)->update($request->all());
|
||||||
|
|
||||||
|
$response = [
|
||||||
|
"status" => 200,
|
||||||
|
"message" => "Data updated successfully"
|
||||||
|
];
|
||||||
|
|
||||||
|
return response()->json($response);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*
|
||||||
|
* @param \App\Models\Dealer $dealer
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function destroy(Dealer $dealer)
|
||||||
|
{
|
||||||
|
$menu = Menu::where('link', 'dealer.index')->first();
|
||||||
|
abort_if(Gate::denies('delete', $menu), 403, 'Unauthorized User');
|
||||||
|
Dealer::destroy($dealer->id);
|
||||||
|
|
||||||
|
$response = [
|
||||||
|
"status" => 200,
|
||||||
|
"message" => "Data deleted successfully"
|
||||||
|
];
|
||||||
|
|
||||||
|
return response()->json($response);
|
||||||
|
}
|
||||||
|
}
|
||||||
28
app/Http/Controllers/HomeController.php
Normal file
28
app/Http/Controllers/HomeController.php
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class HomeController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Create a new controller instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->middleware('auth');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the application dashboard.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Contracts\Support\Renderable
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
return view('home');
|
||||||
|
}
|
||||||
|
}
|
||||||
565
app/Http/Controllers/ReportController.php
Normal file
565
app/Http/Controllers/ReportController.php
Normal file
@@ -0,0 +1,565 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Exports\TransactionDealerExport;
|
||||||
|
use App\Exports\TransactionExport;
|
||||||
|
use App\Exports\TransactionSaExport;
|
||||||
|
use App\Models\Dealer;
|
||||||
|
use App\Models\Menu;
|
||||||
|
use App\Models\Transaction;
|
||||||
|
use App\Models\User;
|
||||||
|
use App\Models\Work;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Facades\Gate;
|
||||||
|
use Yajra\DataTables\Facades\DataTables;
|
||||||
|
use Maatwebsite\Excel\Facades\Excel;
|
||||||
|
|
||||||
|
class ReportController extends Controller
|
||||||
|
{
|
||||||
|
public function transaction_sa_old2(Request $request)
|
||||||
|
{
|
||||||
|
$menu = Menu::where('link', 'report.transaction_sa')->first();
|
||||||
|
abort_if(Gate::denies('view', $menu), 403, 'Unauthorized User');
|
||||||
|
|
||||||
|
if(!isset($request->month)) {
|
||||||
|
$request['month'] = date('m');
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!isset($request->dealer)) {
|
||||||
|
$request['dealer'] = 'all';
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!isset($request->sa)) {
|
||||||
|
$request['sa'] = 'all';
|
||||||
|
}
|
||||||
|
|
||||||
|
$works = Work::select('id', 'name')->whereHas('transactions', function($q) use($request) {
|
||||||
|
if(isset($request->month)) {
|
||||||
|
$q = $q->whereMonth('date', '=', $request->month)->whereYear('date', date('Y'));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isset($request->dealer) && $request->dealer != 'all') {
|
||||||
|
$q = $q->where('dealer_id', '=', $request->dealer);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isset($request->sa) && $request->sa != 'all') {
|
||||||
|
$q = $q->where('user_sa_id', '=', $request->sa);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $q;
|
||||||
|
})->orderBy('id', 'ASC')->get();
|
||||||
|
|
||||||
|
$dealer_datas = Dealer::orderBy('id', 'ASC')->get();
|
||||||
|
$sa_datas = User::select('id', 'name')->where('role_id', 4)->get();
|
||||||
|
$sa = $request->sa;
|
||||||
|
$dealer = $request->dealer;
|
||||||
|
$month = $request->month;
|
||||||
|
|
||||||
|
return view('back.report.transaction_sa', compact('dealer_datas', 'sa_datas', 'month', 'works', 'sa', 'dealer'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function transaction_sa(Request $request)
|
||||||
|
{
|
||||||
|
$menu = Menu::where('link', 'report.transaction_sa')->first();
|
||||||
|
abort_if(Gate::denies('view', $menu), 403, 'Unauthorized User');
|
||||||
|
|
||||||
|
if(!isset($request->month)) {
|
||||||
|
$request['month'] = date('m');
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!isset($request->year)) {
|
||||||
|
$request['year'] = date('Y');
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!isset($request->dealer)) {
|
||||||
|
$request['dealer'] = '20';
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!isset($request->sa)) {
|
||||||
|
$request['sa'] = 'all';
|
||||||
|
}
|
||||||
|
|
||||||
|
$dealer_datas = Dealer::orderBy('id', 'ASC')->get();
|
||||||
|
$sa_datas = User::select('id', 'name')->where('role_id', 4)->get();
|
||||||
|
|
||||||
|
$sa = $request->sa;
|
||||||
|
$dealer = $request->dealer;
|
||||||
|
$month = $request->month;
|
||||||
|
$year = $request->year;
|
||||||
|
|
||||||
|
$ajax_url = route('report.transaction_sa_data').'?month='.$month.'&year='.$year.'&dealer='.$dealer.'&sa='.$sa;
|
||||||
|
|
||||||
|
return view('back.report.transaction_sa', compact('dealer_datas', 'sa_datas', 'month', 'year', 'sa', 'dealer', 'ajax_url'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function transaction_sa_data(Request $request) {
|
||||||
|
abort_if(Gate::denies('view', Menu::where('link', 'dashboard')->first()), 403, 'Unauthorized User');
|
||||||
|
if(!isset($request->month)) {
|
||||||
|
$request['month'] = date('m');
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!isset($request->year)) {
|
||||||
|
$request['year'] = date('Y');
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isset($request->{'amp;dealer'})) {
|
||||||
|
$request['dealer'] = $request->{'amp;dealer'};
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isset($request->{'amp;sa'})) {
|
||||||
|
$request['sa'] = $request->{'amp;sa'};
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isset($request->{'amp;year'})) {
|
||||||
|
$request['year'] = $request->{'amp;year'};
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!isset($request->dealer)) {
|
||||||
|
$request['dealer'] = 'all';
|
||||||
|
}
|
||||||
|
|
||||||
|
$month = $request->month;
|
||||||
|
$dealer = $request->dealer;
|
||||||
|
$sa = $request->sa;
|
||||||
|
$year = $request->year;
|
||||||
|
|
||||||
|
$dealer_work_trx = DB::statement("SET @sql = NULL");
|
||||||
|
$sql = "SELECT IF(work_id IS NOT NULL, GROUP_CONCAT(DISTINCT CONCAT('SUM(IF(work_id = \"', work_id,'\", qty,\"\")) AS \"',CONCAT(w.name, '|',w.id),'\"')), 's.work_id') INTO @sql FROM transactions t JOIN works w ON w.id = t.work_id WHERE month(t.date) = '". $month ."' and year(t.date) = '". $year ."' and t.deleted_at is null";
|
||||||
|
|
||||||
|
if(isset($request->dealer) && $request->dealer != 'all') {
|
||||||
|
$sql .= " and t.dealer_id = '". $dealer ."'";
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isset($request->sa) && $request->sa != 'all') {
|
||||||
|
$sql .= " and t.user_sa_id = '". $sa ."'";
|
||||||
|
}
|
||||||
|
|
||||||
|
$sa_work_trx = DB::statement($sql);
|
||||||
|
|
||||||
|
if(isset($request->dealer) && $request->dealer != 'all') {
|
||||||
|
if(isset($request->sa) && $request->sa != 'all') {
|
||||||
|
$sa_work_trx = DB::statement("SET @sql = IF(@sql != 's.work_id' ,CONCAT(\"SELECT sa.name as SA, sa.id as sa_id, \", @sql, \"FROM transactions s JOIN users sa ON sa.id = s.user_sa_id WHERE month(s.date) = '". $month ."' and year(s.date) = '". $year ."' and s.deleted_at is null and s.dealer_id = '". $dealer ."' and s.user_sa_id = '". $sa ."' GROUP BY s.user_sa_id ORDER BY s.user_sa_id ASC\"), CONCAT(\"SELECT sa.name as SA, sa.id as sa_id \", \"FROM transactions s JOIN users sa ON sa.id = s.user_sa_id WHERE month(s.date) = '". $month ."' and year(s.date) = '". $year ."' and s.deleted_at is null and s.dealer_id = '". $dealer ."' and s.user_sa_id = '". $sa ."' GROUP BY s.`user_sa_id` ORDER BY s.`user_sa_id` ASC\"))");
|
||||||
|
}else{
|
||||||
|
$sa_work_trx = DB::statement("SET @sql = IF(@sql != 's.work_id' ,CONCAT(\"SELECT sa.name as SA, sa.id as sa_id, \", @sql, \"FROM transactions s JOIN users sa ON sa.id = s.user_sa_id WHERE month(s.date) = '". $month ."' and year(s.date) = '". $year ."' and s.deleted_at is null and s.dealer_id = '". $dealer ."' GROUP BY s.user_sa_id ORDER BY s.user_sa_id ASC\"), CONCAT(\"SELECT sa.name as SA, sa.id as sa_id \", \"FROM transactions s JOIN users sa ON sa.id = s.user_sa_id WHERE month(s.date) = '". $month ."' and year(s.date) = '". $year ."' and s.deleted_at is null and s.dealer_id = '". $dealer ."' GROUP BY s.`user_sa_id` ORDER BY s.`user_sa_id` ASC\"))");
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
if(isset($request->sa) && $request->sa != 'all') {
|
||||||
|
$sa_work_trx = DB::statement("SET @sql = IF(@sql != 's.work_id' ,CONCAT(\"SELECT sa.name as SA, sa.id as sa_id, \", @sql, \"FROM transactions s JOIN users sa ON sa.id = s.user_sa_id WHERE month(s.date) = '". $month ."' and year(s.date) = '". $year ."' and s.deleted_at is null and s.user_sa_id = '". $sa ."' GROUP BY s.user_sa_id ORDER BY s.user_sa_id ASC\"), CONCAT(\"SELECT sa.name as SA, sa.id as user_sa_id \", \"FROM transactions s JOIN dealers d ON d.id = s.user_sa_id WHERE month(s.date) = '". $month ."' and year(s.date) = '". $year ."' and s.deleted_at is null and s.user_sa_id = '". $sa ."' GROUP BY s.`user_sa_id` ORDER BY s.`user_sa_id` ASC\"))");
|
||||||
|
}else{
|
||||||
|
$sa_work_trx = DB::statement("SET @sql = IF(@sql != 's.work_id' ,CONCAT(\"SELECT sa.name as SA, sa.id as sa_id, \", @sql, \"FROM transactions s JOIN users sa ON sa.id = s.user_sa_id WHERE month(s.date) = '". $month ."' and year(s.date) = '". $year ."' and s.deleted_at is null GROUP BY s.user_sa_id ORDER BY s.user_sa_id ASC\"), CONCAT(\"SELECT sa.name as SA, sa.id as user_sa_id \", \"FROM transactions s JOIN dealers d ON d.id = s.user_sa_id WHERE month(s.date) = '". $month ."' and year(s.date) = '". $year ."' and s.deleted_at is null GROUP BY s.`user_sa_id` ORDER BY s.`user_sa_id` ASC\"))");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$sa_work_trx = DB::statement("PREPARE stmt FROM @sql");
|
||||||
|
$sa_work_trx = DB::select(DB::raw("EXECUTE stmt"));
|
||||||
|
DB::statement('DEALLOCATE PREPARE stmt');
|
||||||
|
$theads = ['SA'];
|
||||||
|
$sa_names = [];
|
||||||
|
$sa_trx = [];
|
||||||
|
$work_trx = [];
|
||||||
|
$work_ids = [];
|
||||||
|
|
||||||
|
foreach($sa_work_trx as $index => $sa_work) {
|
||||||
|
$sa_work_2 = (array) $sa_work;
|
||||||
|
unset($sa_work_2['sa_id']);
|
||||||
|
$work_trx[$sa_work->sa_id] = array_values($sa_work_2);
|
||||||
|
unset($sa_work_2['SA']);
|
||||||
|
$work_names = array_keys($sa_work_2);
|
||||||
|
if($index == 0) {
|
||||||
|
foreach($work_names as $work) {
|
||||||
|
$arr_work = explode('|', $work);
|
||||||
|
$theads[] = $arr_work[0];
|
||||||
|
$work_ids[] = $arr_work[1];
|
||||||
|
$sa_trx[$work] = [
|
||||||
|
'work_name' => $arr_work[0],
|
||||||
|
'qty' => []
|
||||||
|
];
|
||||||
|
|
||||||
|
if($sa_work->{$work} > 0) {
|
||||||
|
$sa_trx[$work]['qty'][] = $sa_work->{$work};
|
||||||
|
}else{
|
||||||
|
$sa_trx[$work]['qty'][] = "N/A";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
foreach($work_names as $work) {
|
||||||
|
if($sa_work->{$work} > 0) {
|
||||||
|
$sa_trx[$work]['qty'][] = $sa_work->{$work};
|
||||||
|
}else{
|
||||||
|
$sa_trx[$work]['qty'][] = "N/A";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$sa_names[] = $sa_work->SA;
|
||||||
|
}
|
||||||
|
|
||||||
|
$sa_trx = array_values($sa_trx);
|
||||||
|
$dealer = $request->dealer;
|
||||||
|
$month = $request->month;
|
||||||
|
$sa = $request->sa;
|
||||||
|
$year = $request->year;
|
||||||
|
|
||||||
|
$sa_names = json_encode($sa_names);
|
||||||
|
$sa_trx = json_encode($sa_trx);
|
||||||
|
|
||||||
|
return view('back.report.transaction_sa_data', compact('theads', 'work_trx', 'month', 'sa_names', 'sa_trx', 'dealer', 'sa', 'year'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function transaction_sa_old(Request $request)
|
||||||
|
{
|
||||||
|
$menu = Menu::where('link', 'report.transaction_sa')->first();
|
||||||
|
abort_if(Gate::denies('view', $menu), 403, 'Unauthorized User');
|
||||||
|
|
||||||
|
if(!isset($request->month)) {
|
||||||
|
$request['month'] = date('m');
|
||||||
|
}
|
||||||
|
|
||||||
|
$works = Work::select('id', 'name')->whereHas('transactions', function($q) use($request) {
|
||||||
|
if(isset($request->month)) {
|
||||||
|
$q->whereMonth('date', '=', $request->month);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isset($request->dealer) && $request->dealer != 'all') {
|
||||||
|
$q->where('dealer_id', '=', $request->dealer);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isset($request->sa) && $request->sa != 'all') {
|
||||||
|
$q->where('user_sa_id', '=', $request->sa);
|
||||||
|
}
|
||||||
|
})->get();
|
||||||
|
|
||||||
|
$sas = User::select('id', 'name')->where('role_id', 4)->get();
|
||||||
|
|
||||||
|
$trxs = [];
|
||||||
|
foreach($sas as $key => $sa) {
|
||||||
|
$sa_works = [];
|
||||||
|
foreach ($works as $key2 => $work) {
|
||||||
|
$d = Transaction::where('user_sa_id', $sa->id)->where('work_id', $work->id);
|
||||||
|
|
||||||
|
if(isset($request->month)) {
|
||||||
|
$d = $d->whereMonth('date', '=', $request->month);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isset($request->dealer) && $request->dealer != 'all') {
|
||||||
|
$d = $d->where('dealer_id', '=', $request->dealer);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isset($request->sa) && $request->sa != 'all') {
|
||||||
|
$d = $d->where('user_sa_id', '=', $request->sa);
|
||||||
|
}
|
||||||
|
|
||||||
|
$d = $d->sum('qty');
|
||||||
|
if($d) {
|
||||||
|
$sa_works[] = [
|
||||||
|
'work_id' => $work->id,
|
||||||
|
'work_name' => $work->name,
|
||||||
|
'user_sa_id' => $sa->id,
|
||||||
|
'qty' => $d,
|
||||||
|
];
|
||||||
|
}else{
|
||||||
|
$sa_works[] = [
|
||||||
|
'work_id' => $work->id,
|
||||||
|
'work_name' => $work->name,
|
||||||
|
'user_sa_id' => $sa->id,
|
||||||
|
'qty' => 0,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$trxs[] = [
|
||||||
|
'user_sa_id' => $sa->id,
|
||||||
|
'sa_name' => $sa->name,
|
||||||
|
'works' => $sa_works
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
$sa_names = [];
|
||||||
|
$trx_data = [];
|
||||||
|
foreach($trxs as $trx) {
|
||||||
|
$sa_names[] = $trx['sa_name'];
|
||||||
|
$work_data2 = [];
|
||||||
|
foreach($trx['works'] as $work_data) {
|
||||||
|
if(array_key_exists($work_data['work_name'], $trx_data)) {
|
||||||
|
$trx_data[$work_data['work_name']]['qty'][] = $work_data['qty'];
|
||||||
|
}else{
|
||||||
|
$trx_data[$work_data['work_name']] = [
|
||||||
|
'work_name' => $work_data['work_name'],
|
||||||
|
'qty' => [$work_data['qty']]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$sa_names = json_encode($sa_names);
|
||||||
|
$trx_data = json_encode(array_values($trx_data));
|
||||||
|
// dd($trx_data);
|
||||||
|
$work_count = count($works);
|
||||||
|
$month = $request->month;
|
||||||
|
$dealer_id = $request->dealer;
|
||||||
|
$sa_id = $request->sa;
|
||||||
|
$dealers = Dealer::all();
|
||||||
|
$sas = User::where('role_id', 4)->get();
|
||||||
|
|
||||||
|
|
||||||
|
return view('back.report.transaction_sa', compact('sas', 'dealers', 'dealer_id', 'sa_id', 'month', 'trxs', 'works', 'work_count', 'sa_names', 'trx_data'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function sa_work_trx(Request $request) {
|
||||||
|
$sa_work_trx = Work::select(DB::raw('works.name AS work_name'), DB::raw("IFNULL(SUM(t.qty), 0) AS qty"), 'works.id AS work_id')->whereHas('transactions', function($q) use($request) {
|
||||||
|
if(isset($request->month)) {
|
||||||
|
$q = $q->whereMonth('date', '=', $request->month)->whereYear('date', date('Y'));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isset($request->dealer) && $request->dealer != 'all') {
|
||||||
|
$q = $q->where('dealer_id', '=', $request->dealer);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isset($request->sa_filter) && $request->sa_filter != 'all') {
|
||||||
|
$q = $q->where('user_sa_id', '=', $request->sa_filter);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $q;
|
||||||
|
})->leftJoin('transactions AS t', function($q) use($request) {
|
||||||
|
$q->on('t.work_id', '=', 'works.id');
|
||||||
|
$q->on(DB::raw('MONTH(t.date)'), '=', DB::raw($request->month));
|
||||||
|
$q->on(DB::raw('YEAR(t.date)'), '=', DB::raw(date('Y')));
|
||||||
|
$q->on('t.user_sa_id', '=', DB::raw($request->sa));
|
||||||
|
if(isset($request->dealer) && $request->dealer != 'all') {
|
||||||
|
$q->on('t.dealer_id', '=', DB::raw($request->dealer));
|
||||||
|
}
|
||||||
|
if(isset($request->sa_filter) && $request->sa_filter != 'all') {
|
||||||
|
$q->on('t.user_sa_id', '=', DB::raw($request->sa_filter));
|
||||||
|
}
|
||||||
|
})->groupBy('works.id')->orderBy('works.id', 'ASC')->get();
|
||||||
|
return response()->json($sa_work_trx);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function get_sa_has_transactions(Request $request) {
|
||||||
|
if(!isset($request->month)) {
|
||||||
|
$request['month'] = date('m');
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!isset($request->dealer)) {
|
||||||
|
$request['dealer'] = 'all';
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!isset($request->sa)) {
|
||||||
|
$request['sa'] = 'all';
|
||||||
|
}
|
||||||
|
|
||||||
|
$sas = User::where('role_id', 4)->whereHas('sa_transactions', function($q) use($request) {
|
||||||
|
if(isset($request->month)) {
|
||||||
|
$q = $q->whereMonth('date', '=', $request->month)->whereYear('date', date('Y'));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isset($request->dealer) && $request->dealer != 'all') {
|
||||||
|
$q->where('dealer_id', '=', $request->dealer);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if(isset($request->sa) && $request->sa != 'all') {
|
||||||
|
$sas = $sas->where('id', $request->sa);
|
||||||
|
}
|
||||||
|
|
||||||
|
$sas = $sas->orderBy('id', 'ASC')->get();
|
||||||
|
|
||||||
|
return response()->json($sas);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function transaction_dealer(Request $request)
|
||||||
|
{
|
||||||
|
$menu = Menu::where('link', 'report.transaction_dealer')->first();
|
||||||
|
abort_if(Gate::denies('view', $menu), 403, 'Unauthorized User');
|
||||||
|
|
||||||
|
if(!isset($request->month)) {
|
||||||
|
$request['month'] = date('m');
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!isset($request->year)) {
|
||||||
|
$request['year'] = date('Y');
|
||||||
|
}
|
||||||
|
|
||||||
|
$year = $request->year;
|
||||||
|
$month = $request->month;
|
||||||
|
$dealer = $request->dealer;
|
||||||
|
$dealer_datas = Dealer::all();
|
||||||
|
$ajax_url = route('dashboard_data').'?month='.$month.'&year='.$year.'&dealer='.$dealer;
|
||||||
|
return view('dashboard', compact('month', 'ajax_url', 'dealer', 'dealer_datas', 'year'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function transaction(Request $request)
|
||||||
|
{
|
||||||
|
$menu = Menu::where('link', 'report.transaction')->first();
|
||||||
|
abort_if(Gate::denies('view', $menu), 403, 'Unauthorized User');
|
||||||
|
|
||||||
|
$sas = User::where('role_id', 4)->get();
|
||||||
|
$mechanics = User::where('role_id', 3)->get();
|
||||||
|
$dealers = Dealer::all();
|
||||||
|
$works = Work::all();
|
||||||
|
|
||||||
|
return view('back.report.transaction', compact('sas', 'mechanics', 'dealers', 'works'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function transaction_data(Request $request)
|
||||||
|
{
|
||||||
|
$menu = Menu::where('link', 'report.transaction')->first();
|
||||||
|
abort_if(Gate::denies('view', $menu), 403, 'Unauthorized User');
|
||||||
|
|
||||||
|
if ($request->ajax()) {
|
||||||
|
$data = Transaction::leftJoin('users', 'users.id', '=', 'transactions.user_id')
|
||||||
|
->leftJoin('users as sa', 'sa.id', '=', 'transactions.user_sa_id')
|
||||||
|
->leftJoin('works as w', 'w.id', '=', 'transactions.work_id')
|
||||||
|
->leftJoin('categories as cat', 'cat.id', '=', 'w.category_id')
|
||||||
|
->leftJoin('dealers as d', 'd.id', '=', 'transactions.dealer_id')
|
||||||
|
->select('transactions.id', 'transactions.status', 'transactions.user_id as user_id', 'transactions.user_sa_id as user_sa_id', 'users.name as username', 'sa.name as sa_name', 'cat.name as category_name', 'w.name as workname', 'transactions.qty as qty', 'transactions.date as date', 'transactions.police_number as police_number', 'transactions.warranty as warranty', 'transactions.spk as spk', 'transactions.dealer_id', 'd.name as dealer_name');
|
||||||
|
|
||||||
|
if(isset($request->date_start)) {
|
||||||
|
$data->where('transactions.date', '>=', $request->date_start);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isset($request->date_end)) {
|
||||||
|
$data->where('transactions.date', '<=', $request->date_end);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isset($request->sa)) {
|
||||||
|
$data->where('transactions.user_sa_id', $request->sa);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isset($request->mechanic)) {
|
||||||
|
$data->where('transactions.user_id', $request->mechanic);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isset($request->dealer)) {
|
||||||
|
$data->where('transactions.dealer_id', $request->dealer);
|
||||||
|
}
|
||||||
|
|
||||||
|
$data->orderBy('date', 'DESC');
|
||||||
|
return DataTables::of($data)->addIndexColumn()
|
||||||
|
->addColumn('action', function($row) use ($menu) {
|
||||||
|
$btn = '';
|
||||||
|
if($row->status == 1) {
|
||||||
|
if(Auth::user()->can('delete', $menu)) {
|
||||||
|
$btn .= ' <button class="btn btn-danger btn-sm btn-bold" data-action="'. route('report.transaction.destroy', $row->id) .'" id="destroyTransaction'. $row->id .'" onclick="destroyTransaction('. $row->id .')"> Hapus </button>';
|
||||||
|
}
|
||||||
|
$btn .= '<span class="badge badge-success">Closed</span>';
|
||||||
|
}else{
|
||||||
|
if(Auth::user()->can('delete', $menu)) {
|
||||||
|
$btn .= '<button class="btn btn-danger btn-sm btn-bold" data-action="'. route('report.transaction.destroy', $row->id) .'" id="destroyTransaction'. $row->id .'" onclick="destroyTransaction('. $row->id .')"> Hapus </button>';
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Auth::user()->can('update', $menu)) {
|
||||||
|
$btn .= '<button class="btn btn-info btn-sm btn-bold" data-url="'. route('report.transaction.edit', $row->id) .'" data-action="'. route('report.transaction.update', $row->id) .'" onclick="editTransaction('. $row->id .')" id="editTransaction'. $row->id .'"> Edit </button>
|
||||||
|
<button class="btn btn-warning btn-sm btn-bold" id="closeTransaction'. $row->id .'" data-url="'. route('report.transaction.close', $row->id) .'" onclick="closeTransaction('. $row->id .')"> Close </button>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $btn;
|
||||||
|
})
|
||||||
|
->rawColumns(['action'])
|
||||||
|
->make(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function export(Request $request)
|
||||||
|
{
|
||||||
|
return Excel::download(new TransactionExport($request), date('dmY_').'pekerjaan.xlsx');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dealer_export(Request $request)
|
||||||
|
{
|
||||||
|
return Excel::download(new TransactionDealerExport($request), date('dmY_').'dealer.xlsx');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function sa_export(Request $request)
|
||||||
|
{
|
||||||
|
return Excel::download(new TransactionSaExport($request), date('dmY_').'sa.xlsx');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
$transaction = Transaction::find($id);
|
||||||
|
$response = [
|
||||||
|
'data' => $transaction,
|
||||||
|
'status' => 200,
|
||||||
|
'message' => 'get data successfully'
|
||||||
|
];
|
||||||
|
return response()->json($response);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(Request $request, $id)
|
||||||
|
{
|
||||||
|
$menu = Menu::where('link', 'report.transaction')->first();
|
||||||
|
abort_if(Gate::denies('update', $menu), 403, 'Unauthorized User');
|
||||||
|
|
||||||
|
Transaction::find($id)->update([
|
||||||
|
"spk" => $request->spk,
|
||||||
|
"date" => $request->date,
|
||||||
|
"police_number" => $request->police_number,
|
||||||
|
"work_id" => $request->work_id,
|
||||||
|
"dealer_id" => $request->dealer_id,
|
||||||
|
"qty" => $request->qty,
|
||||||
|
"warranty" => $request->warranty,
|
||||||
|
"user_sa_id" => $request->sa_id,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$response = [
|
||||||
|
"status" => 200,
|
||||||
|
"message" => "Data updated successfully"
|
||||||
|
];
|
||||||
|
|
||||||
|
return response()->json($response);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function close_transaction($id)
|
||||||
|
{
|
||||||
|
$menu = Menu::where('link', 'report.transaction')->first();
|
||||||
|
abort_if(Gate::denies('update', $menu), 403, 'Unauthorized User');
|
||||||
|
|
||||||
|
Transaction::find($id)->update([
|
||||||
|
'status' => 1
|
||||||
|
]);
|
||||||
|
|
||||||
|
$response = [
|
||||||
|
'message' => 'Data updated successfully',
|
||||||
|
'status' => 200
|
||||||
|
];
|
||||||
|
|
||||||
|
return response()->json($response);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function bulk_close_transaction(Request $request)
|
||||||
|
{
|
||||||
|
$menu = Menu::where('link', 'report.transaction')->first();
|
||||||
|
abort_if(Gate::denies('update', $menu), 403, 'Unauthorized User');
|
||||||
|
|
||||||
|
Transaction::whereIn('id', $request->selected)->update([
|
||||||
|
'status' => 1
|
||||||
|
]);
|
||||||
|
|
||||||
|
$response = [
|
||||||
|
'message' => 'Data updated successfully',
|
||||||
|
'status' => 200
|
||||||
|
];
|
||||||
|
|
||||||
|
return response()->json($response);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy_transaction($id)
|
||||||
|
{
|
||||||
|
$menu = Menu::where('link', 'report.transaction')->first();
|
||||||
|
abort_if(Gate::denies('delete', $menu), 403, 'Unauthorized User');
|
||||||
|
|
||||||
|
Transaction::destroy($id);
|
||||||
|
|
||||||
|
$response = [
|
||||||
|
'message' => 'Data deleted successfully',
|
||||||
|
'status' => 200
|
||||||
|
];
|
||||||
|
|
||||||
|
return response()->json($response);
|
||||||
|
}
|
||||||
|
}
|
||||||
120
app/Http/Controllers/RolePrivilegeController.php
Normal file
120
app/Http/Controllers/RolePrivilegeController.php
Normal file
@@ -0,0 +1,120 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Models\Menu;
|
||||||
|
use App\Models\Privilege;
|
||||||
|
use App\Models\Role;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Gate;
|
||||||
|
|
||||||
|
class RolePrivilegeController extends Controller
|
||||||
|
{
|
||||||
|
public function index() {
|
||||||
|
$menu = Menu::where('link', 'roleprivileges.index')->first();
|
||||||
|
abort_if(Gate::denies('view', $menu), 403, 'Unauthorized User');
|
||||||
|
$roles = Role::all();
|
||||||
|
$menus = Menu::all();
|
||||||
|
$users = User::all();
|
||||||
|
return view('back.roleprivileges', compact('roles', 'users', 'menus'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(Request $request) {
|
||||||
|
$menu = Menu::where('link', 'roleprivileges.index')->first();
|
||||||
|
abort_if(Gate::denies('create', $menu), 403, 'Unauthorized User');
|
||||||
|
$request->validate([
|
||||||
|
'role' => 'required',
|
||||||
|
'privileges' => 'required'
|
||||||
|
]);
|
||||||
|
|
||||||
|
|
||||||
|
$role = Role::create(['name' => $request->role]);
|
||||||
|
if($request->has('privileges')) {
|
||||||
|
$role_privileges = [];
|
||||||
|
foreach ($request->privileges as $submenu_id => $privilege) {
|
||||||
|
$privilege['menu_id'] = $submenu_id;
|
||||||
|
$privilege['role_id'] = $role->id;
|
||||||
|
$privilege['created_at'] = date('Y-m-d H:i:s');
|
||||||
|
$role_privileges[] = $privilege;
|
||||||
|
}
|
||||||
|
|
||||||
|
Privilege::insert($role_privileges);
|
||||||
|
}
|
||||||
|
|
||||||
|
return redirect()->back()->with('success', 'Berhasil tambah Role & Priveleges');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function edit($id) {
|
||||||
|
$menu = Menu::where('link', 'roleprivileges.index')->first();
|
||||||
|
abort_if(Gate::denies('view', $menu), 403, 'Unauthorized User');
|
||||||
|
$menus = Menu::all();
|
||||||
|
$user_menus = [];
|
||||||
|
|
||||||
|
$role = Role::find($id);
|
||||||
|
foreach($menus as $menu) {
|
||||||
|
$privilege = Privilege::where('menu_id', $menu->id)->where('role_id', $id)->first();
|
||||||
|
$menu_privilege = [
|
||||||
|
'create' => 0,
|
||||||
|
'update' => 0,
|
||||||
|
'delete' => 0,
|
||||||
|
'view' => 0,
|
||||||
|
'menu_id' => $menu->id,
|
||||||
|
'name' => $menu->name,
|
||||||
|
];
|
||||||
|
|
||||||
|
if($privilege) {
|
||||||
|
$menu_privilege = [
|
||||||
|
'create' => (int) $privilege->create,
|
||||||
|
'update' => (int) $privilege->update,
|
||||||
|
'delete' => (int) $privilege->delete,
|
||||||
|
'view' => (int) $privilege->view,
|
||||||
|
'menu_id' => $menu->id,
|
||||||
|
'name' => $menu->name,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
$user_menus[] = $menu_privilege;
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'role' => $role,
|
||||||
|
'role_privileges' => $user_menus,
|
||||||
|
];
|
||||||
|
|
||||||
|
return response()->json($data, 200);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(Request $request, $id) {
|
||||||
|
$menu = Menu::where('link', 'roleprivileges.index')->first();
|
||||||
|
abort_if(Gate::denies('update', $menu), 403, 'Unauthorized User');
|
||||||
|
$request->validate([
|
||||||
|
'role' => 'required',
|
||||||
|
'privileges' => 'required'
|
||||||
|
]);
|
||||||
|
|
||||||
|
Role::find($id)->update(['name' => $request->role]);
|
||||||
|
if($request->has('privileges')) {
|
||||||
|
Privilege::where('role_id', $id)->delete();
|
||||||
|
$role_privileges = [];
|
||||||
|
foreach ($request->privileges as $menu_id => $privilege) {
|
||||||
|
$privilege['menu_id'] = $menu_id;
|
||||||
|
$privilege['role_id'] = $id;
|
||||||
|
$privilege['created_at'] = date('Y-m-d H:i:s');
|
||||||
|
$privilege['updated_at'] = date('Y-m-d H:i:s');
|
||||||
|
$role_privileges[] = $privilege;
|
||||||
|
}
|
||||||
|
|
||||||
|
Privilege::insert($role_privileges);
|
||||||
|
}
|
||||||
|
|
||||||
|
return redirect()->back()->with('success', 'Berhasil ubah Role & Priveleges');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function delete($id) {
|
||||||
|
Privilege::where('role_id', $id)->delete();
|
||||||
|
Role::destroy($id);
|
||||||
|
User::where('role_id', $id)->update(['role_id' => 0]);
|
||||||
|
return redirect()->back()->with('success', 'Berhasil Hapus Role');
|
||||||
|
}
|
||||||
|
}
|
||||||
757
app/Http/Controllers/TransactionController.php
Normal file
757
app/Http/Controllers/TransactionController.php
Normal file
@@ -0,0 +1,757 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Models\Category;
|
||||||
|
use App\Models\Dealer;
|
||||||
|
use App\Models\Transaction;
|
||||||
|
use App\Models\User;
|
||||||
|
use App\Models\Work;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Carbon;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
|
||||||
|
class TransactionController extends Controller
|
||||||
|
{
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
$work_works = Work::leftJoin('categories as c', 'c.id', '=', 'works.category_id')->select('c.name as category_name', 'works.*')->where('c.name', 'LIKE', '%kerja%')->get();
|
||||||
|
$wash_work = Work::leftJoin('categories as c', 'c.id', '=', 'works.category_id')->select('c.name as category_name', 'works.*')->where('c.name', 'LIKE', '%cuci%')->first();
|
||||||
|
$user_sas = User::where('role_id', 4)->where('dealer_id', Auth::user()->dealer_id)->get();
|
||||||
|
$count_transaction_users = Transaction::where("user_id", Auth::user()->id)->count();
|
||||||
|
$count_transaction_dealers = Transaction::leftJoin('users', 'users.id', '=', 'transactions.user_id')->where('users.dealer_id', Auth::user()->dealer_id)->count();
|
||||||
|
$mechanic = User::leftJoin('dealers as d', 'd.id', '=', 'users.dealer_id')
|
||||||
|
->select('d.name as dealer_name', 'd.id as dealer_id', 'users.name', 'users.id', 'users.role', 'users.email', 'd.dealer_code', 'd.address')
|
||||||
|
->where('users.id', Auth::user()->id)->first();
|
||||||
|
$now = Carbon::now()->translatedFormat('d F Y');
|
||||||
|
return view('transaction.index', compact('now', 'wash_work', 'work_works', 'user_sas', 'count_transaction_users', 'count_transaction_dealers', 'mechanic'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function workcategory($category_id)
|
||||||
|
{
|
||||||
|
$works = Work::where('category_id', $category_id)->get();
|
||||||
|
$response = [
|
||||||
|
"message" => "get work category successfully",
|
||||||
|
"data" => $works,
|
||||||
|
"status" => 200
|
||||||
|
];
|
||||||
|
|
||||||
|
return response()->json($response);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function lists(Request $request)
|
||||||
|
{
|
||||||
|
if(!isset($request->date_start)) {
|
||||||
|
$request['date_start'] = date('Y-m-d');
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!isset($request->date_end)) {
|
||||||
|
$request['date_end'] = date('Y-m-d');
|
||||||
|
}
|
||||||
|
|
||||||
|
$transaction_dealers = Transaction::leftJoin('users', 'users.id', '=', 'transactions.user_id')
|
||||||
|
->leftJoin('users as sa', 'sa.id', '=', 'transactions.user_sa_id')
|
||||||
|
->leftJoin('works as w', 'w.id', '=', 'transactions.work_id')
|
||||||
|
->leftJoin('categories as cat', 'cat.id', '=', 'w.category_id')
|
||||||
|
->select('transactions.id as transaction_id', 'transactions.status', 'transactions.user_id as user_id', 'transactions.user_sa_id as user_sa_id', 'users.name as username', 'sa.name as sa_name', 'cat.name as category_name', 'w.name as workname', 'transactions.qty as qty', 'transactions.date as date', 'transactions.police_number as police_number', 'transactions.warranty as warranty', 'transactions.spk as spk')
|
||||||
|
->where('users.dealer_id', Auth::user()->dealer_id);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$transaction_works = Work::select('id', 'name', 'shortname')->whereHas('transactions', function($q) {
|
||||||
|
return $q->whereDate('date', '=', date('Y-m-d'))->where('dealer_id', Auth::user()->dealer_id);
|
||||||
|
})->get();
|
||||||
|
|
||||||
|
$tm1 = [];
|
||||||
|
foreach($transaction_works as $index => $work) {
|
||||||
|
$transaction_sas = Transaction::leftJoin('users as sa', 'sa.id', '=', 'transactions.user_sa_id')
|
||||||
|
->select(DB::raw('SUM(transactions.qty) as qty'), 'sa.name as sa_name')
|
||||||
|
->where('sa.dealer_id', Auth::user()->dealer_id)
|
||||||
|
->where('work_id', $work->id)
|
||||||
|
->whereDate('transactions.date', '=', date('Y-m-d'))->groupBy('transactions.user_sa_id')->get();
|
||||||
|
foreach($transaction_sas as $sa) {
|
||||||
|
$tm1[$work['shortname']]['data'][] = $sa['sa_name'].":".$sa['qty'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$month_share_data = Transaction::select(DB::raw('SUM(qty) as qty'), 'u.name')->join('users AS u', 'u.id', '=', 'transactions.user_sa_id')->where('transactions.dealer_id', Auth::user()->dealer->id)->whereMonth('date', date('m'))->whereYear('date', date('Y'))->where('work_id', $work->id)->groupBy('user_sa_id')->get();
|
||||||
|
$tm1[$work['shortname']]['total_title'] = "*[PERIODE 1 - ". Carbon::now()->translatedFormat('d F Y') ."]*\n\n";
|
||||||
|
|
||||||
|
$sum_month_share_trx = 0;
|
||||||
|
$tm_month = [];
|
||||||
|
foreach($month_share_data as $m_trx) {
|
||||||
|
$tm_month[] = $m_trx->name.":".$m_trx->qty." Unit\n";
|
||||||
|
$sum_month_share_trx += $m_trx->qty;
|
||||||
|
}
|
||||||
|
|
||||||
|
$tm1[$work['shortname']]['total_body'] = $tm_month;
|
||||||
|
$tm1[$work['shortname']]['total_total'] = "*TOTAL : ". $sum_month_share_trx." Unit*";
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isset($request->date_start)) {
|
||||||
|
$transaction_dealers = $transaction_dealers->where('transactions.date', '>=', date('Y-m-d', strtotime($request->date_start)));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isset($request->date_end)){
|
||||||
|
$transaction_dealers = $transaction_dealers->where('transactions.date', '<=', date('Y-m-d', strtotime($request->date_end)));
|
||||||
|
}
|
||||||
|
|
||||||
|
$transaction_dealers = $transaction_dealers->orderBy('date', 'DESC')->paginate(6);
|
||||||
|
|
||||||
|
$date_start = $request->date_start;
|
||||||
|
$date_end = $request->date_end;
|
||||||
|
|
||||||
|
$transaction_mechanics = ["today_date"=> Carbon::now()->translatedFormat('d F Y'), "data"=>$tm1];
|
||||||
|
$mechanic = User::leftJoin('dealers as d', 'd.id', '=', 'users.dealer_id')
|
||||||
|
->select('d.name as dealer_name', 'users.name', 'users.id', 'users.role', 'users.email', 'd.dealer_code', 'd.address')
|
||||||
|
->where('users.id', Auth::user()->id)->first();
|
||||||
|
|
||||||
|
$sas = User::where('role_id', 4)->get();
|
||||||
|
$dealers = Dealer::all();
|
||||||
|
$works = Work::all();
|
||||||
|
return view('transaction.lists', compact('transaction_dealers', 'transaction_mechanics', 'mechanic', 'sas', 'dealers', 'works', 'date_start', 'date_end'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function cmp($a, $b){
|
||||||
|
$key = 'work_id';
|
||||||
|
if($a[$key] > $b[$key]){
|
||||||
|
return 1;
|
||||||
|
}else if($a[$key] < $b[$key]){
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function cmp2($a, $b){
|
||||||
|
$key = 'id';
|
||||||
|
if($a[$key] > $b[$key]){
|
||||||
|
return 1;
|
||||||
|
}else if($a[$key] < $b[$key]){
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function recap_old(Request $request)
|
||||||
|
{
|
||||||
|
$id = Auth::user()->dealer_id;
|
||||||
|
$works = Work::all();
|
||||||
|
$dealer = Dealer::find($id);
|
||||||
|
$works_count = Work::count();
|
||||||
|
|
||||||
|
$mechanic = User::leftJoin('dealers as d', 'd.id', '=', 'users.dealer_id')
|
||||||
|
->select('d.name as dealer_name', 'users.name', 'users.id', 'users.role', 'users.email', 'd.dealer_code', 'd.address')
|
||||||
|
->where('users.id', Auth::user()->id)->first();
|
||||||
|
$d = Transaction::leftJoin('works as w', 'w.id', '=', 'transactions.work_id')->select('transactions.*', 'w.name as work_name', 'w.shortname as shortname')->where('dealer_id', $id);
|
||||||
|
|
||||||
|
|
||||||
|
if(isset($request->date_start)) {
|
||||||
|
$d = $d->where('transactions.date', '>=', date('Y-m-d', strtotime($request->date_start)));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isset($request->date_end)){
|
||||||
|
$d = $d->where('transactions.date', '<=', date('Y-m-d', strtotime($request->date_end)));
|
||||||
|
}
|
||||||
|
|
||||||
|
$d = $d->get()->toArray();
|
||||||
|
|
||||||
|
$works2 = [];
|
||||||
|
foreach($d as $d2) {
|
||||||
|
$w1 = Work::find($d2['work_id']);
|
||||||
|
$works2[$d2['work_id']] = $w1;
|
||||||
|
}
|
||||||
|
usort($works2, array($this, 'cmp2'));
|
||||||
|
$works = $works2;
|
||||||
|
$dw = [];
|
||||||
|
foreach($d as $dw2) {
|
||||||
|
$dw[$dw2['date']][] = $dw2;
|
||||||
|
}
|
||||||
|
$works_count = count($works);
|
||||||
|
$dw9 = [];
|
||||||
|
$sharedw = [];
|
||||||
|
foreach($dw as $key => $dw3) {
|
||||||
|
$dw5 = [];
|
||||||
|
foreach($dw3 as $dw4) {
|
||||||
|
if(array_key_exists($dw4['work_id'], $dw5)) {
|
||||||
|
$dw5[$dw4['work_id']]['qty'] += $dw4['qty'];
|
||||||
|
}else{
|
||||||
|
$dw5[$dw4['work_id']] = $dw4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
usort($dw5, array($this, 'cmp'));
|
||||||
|
$dw7 = [];
|
||||||
|
foreach($dw5 as $dw6) {
|
||||||
|
$dw7[$dw6['work_id']] = $dw6;
|
||||||
|
$sharedw[$key][] = [
|
||||||
|
"work_id" => $dw6['work_id'],
|
||||||
|
"shortname" => $dw6['shortname'],
|
||||||
|
"qty" => $dw6['qty'],
|
||||||
|
"date" => date('d/m/Y', strtotime($dw6['date'])),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$dw8 = [];
|
||||||
|
for($i = 0; $i < count($works2); $i++) {
|
||||||
|
if(array_key_exists($works2[$i]['id'], $dw7)) {
|
||||||
|
$dw8[$works2[$i]['id']] = [
|
||||||
|
"work_id" => $dw7[$works2[$i]['id']]['work_id'],
|
||||||
|
"qty" => $dw7[$works2[$i]['id']]['qty'],
|
||||||
|
"work_name" => $dw7[$works2[$i]['id']]['work_name'],
|
||||||
|
"date" => date('d/m/Y', strtotime($dw7[$works2[$i]['id']]['date']))
|
||||||
|
];
|
||||||
|
}else{
|
||||||
|
$dw8[$works2[$i]['id']] = [
|
||||||
|
"work_id" => $works2[$i]['id'],
|
||||||
|
"qty" => 0,
|
||||||
|
"work_name" => '-',
|
||||||
|
"date" => '-'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$dw9[$key] = [
|
||||||
|
'date' => $key,
|
||||||
|
'works' => $dw8
|
||||||
|
];
|
||||||
|
}
|
||||||
|
// $works =
|
||||||
|
$trxs = $dw9;
|
||||||
|
$dwd = [];
|
||||||
|
foreach($d as $dwd2) {
|
||||||
|
$dwd[$dwd2['user_sa_id']][] = $dwd2;
|
||||||
|
}
|
||||||
|
|
||||||
|
$dwd9 = [];
|
||||||
|
foreach($dwd as $key2 => $dwd3) {
|
||||||
|
$dwd5 = [];
|
||||||
|
|
||||||
|
foreach($dwd3 as $dwd4) {
|
||||||
|
if(array_key_exists($dwd4['work_id'], $dwd5)) {
|
||||||
|
$dwd5[$dwd4['work_id']]['qty'] += $dwd4['qty'];
|
||||||
|
}else{
|
||||||
|
$dwd5[$dwd4['work_id']] = $dwd4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
usort($dwd5, array($this, 'cmp'));
|
||||||
|
$dwd7 = [];
|
||||||
|
foreach($dwd5 as $dwd6) {
|
||||||
|
$dwd7[$dwd6['work_id']] = $dwd6;
|
||||||
|
}
|
||||||
|
|
||||||
|
$dwd8 = [];
|
||||||
|
for($i = 0; $i < count($works); $i++) {
|
||||||
|
if(array_key_exists($works[$i]['id'], $dwd7)) {
|
||||||
|
$dwd8[$works[$i]['id']] = [
|
||||||
|
"work_id" => $dwd7[$works[$i]['id']]['work_id'],
|
||||||
|
"qty" => $dwd7[$works[$i]['id']]['qty'],
|
||||||
|
"work_name" => $dwd7[$works[$i]['id']]['work_name'],
|
||||||
|
"date" => date('d/m/Y', strtotime($dwd7[$works[$i]['id']]['date']))
|
||||||
|
];
|
||||||
|
}else{
|
||||||
|
$dwd8[$works[$i]['id']] = [
|
||||||
|
"work_id" => $works[$i]['id'],
|
||||||
|
"qty" => 0,
|
||||||
|
"work_name" => '-',
|
||||||
|
"date" => '-'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$sa_name = User::find($key2);
|
||||||
|
$dwd9[$sa_name->name] = [
|
||||||
|
'sa_name' => $sa_name->name,
|
||||||
|
'works' => $dwd8
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
$dealer_trxs = $dwd9;
|
||||||
|
|
||||||
|
return view('transaction.recap_old', compact('works', 'works_count', 'trxs', 'dealer_trxs','dealer', 'sharedw', 'mechanic'));
|
||||||
|
}
|
||||||
|
|
||||||
|
private function array_value_recursive($key, array $arr){
|
||||||
|
$val = array();
|
||||||
|
array_walk_recursive($arr, function($v, $k) use($key, &$val){
|
||||||
|
if($k == $key) array_push($val, $v);
|
||||||
|
});
|
||||||
|
|
||||||
|
return $val;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function recap2(Request $request)
|
||||||
|
{
|
||||||
|
if(!isset($request->month)) {
|
||||||
|
$request['month'] = date('m');
|
||||||
|
}
|
||||||
|
|
||||||
|
$id = Auth::user()->dealer_id;
|
||||||
|
$works = Work::select('id', 'name', 'shortname')->whereHas('transactions', function($q) use($request, $id) {
|
||||||
|
if(isset($request->month)) {
|
||||||
|
return $q->whereMonth('date', '=', $request->month)->whereYear('date', date('Y'))->where('dealer_id', $id);
|
||||||
|
}
|
||||||
|
})->get();
|
||||||
|
|
||||||
|
$sas = User::select('id', 'name')->whereHas('sa_transactions', function($q) use($request, $id) {
|
||||||
|
if(isset($request->month)) {
|
||||||
|
return $q->whereMonth('date', '=', $request->month)->whereYear('date', date('Y'))->where('dealer_id', $id);
|
||||||
|
}
|
||||||
|
})->get();
|
||||||
|
|
||||||
|
$dealer = Dealer::find($id);
|
||||||
|
$mechanic = User::leftJoin('dealers as d', 'd.id', '=', 'users.dealer_id')
|
||||||
|
->select('d.name as dealer_name', 'users.name', 'users.id', 'users.role', 'users.email', 'd.dealer_code', 'd.address')
|
||||||
|
->where('users.id', Auth::user()->id)->first();
|
||||||
|
|
||||||
|
$dates = Transaction::select(DB::raw('DATE(`date`) as date'))->where('dealer_id', $id)->whereMonth('date', $request->month)->whereYear('date', date('Y'))->groupBy(DB::raw('DATE(`date`)'))->get()->toArray();
|
||||||
|
$dates = $this->array_value_recursive('date', $dates);
|
||||||
|
|
||||||
|
$month_trxs = [];
|
||||||
|
$month_trxs_total = [];
|
||||||
|
$yesterday_month_trxs_total = [];
|
||||||
|
foreach($works as $work1) {
|
||||||
|
$prev_mth_start = date('Y-m-d', strtotime(date('Y-'. $request->month .'-1')." -1 month"));
|
||||||
|
$prev_mth = explode('-', $prev_mth_start);
|
||||||
|
$prev_mth_end = $prev_mth[0].'-'.$prev_mth[1].'-'.date('d');
|
||||||
|
|
||||||
|
$yesterday_month_trx = Transaction::where('work_id', $work1->id)->where('dealer_id', $id)->whereDate('date', '>=', $prev_mth_start)->whereDate('date', '<=', $prev_mth_end)->sum('qty');
|
||||||
|
|
||||||
|
if(array_key_exists($work1->id, $yesterday_month_trxs_total)) {
|
||||||
|
$yesterday_month_trxs_total[$work1->id] += $yesterday_month_trx;
|
||||||
|
}else{
|
||||||
|
$yesterday_month_trxs_total[$work1->id] = $yesterday_month_trx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if($dates) {
|
||||||
|
foreach($dates as $key => $date) {
|
||||||
|
$date_works = [];
|
||||||
|
$share_works = [];
|
||||||
|
foreach ($works as $key2 => $work) {
|
||||||
|
$d = Transaction::where('work_id', $work->id)->where('dealer_id', $id)->whereDate('date', $date);
|
||||||
|
|
||||||
|
if(isset($request->month)) {
|
||||||
|
$d = $d->whereMonth('date', '=', $request->month)->whereYear('date', date('Y'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$d = $d->sum('qty');
|
||||||
|
|
||||||
|
if($d) {
|
||||||
|
if(array_key_exists($work->id, $month_trxs_total)) {
|
||||||
|
$month_trxs_total[$work->id] += $d;
|
||||||
|
}else{
|
||||||
|
$month_trxs_total[$work->id] = $d;
|
||||||
|
}
|
||||||
|
$date_works[] = [
|
||||||
|
'work_id' => $work->id,
|
||||||
|
'work_name' => $work->name,
|
||||||
|
'shortname' => $work->shortname,
|
||||||
|
'date' => $date,
|
||||||
|
'qty' => $d,
|
||||||
|
];
|
||||||
|
}else{
|
||||||
|
$date_works[] = [
|
||||||
|
'work_id' => $work->id,
|
||||||
|
'work_name' => $work->name,
|
||||||
|
'shortname' => $work->shortname,
|
||||||
|
'date' => $date,
|
||||||
|
'qty' => 0,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$month_trxs[] = [
|
||||||
|
'date' => date('d/m/Y', strtotime($date)),
|
||||||
|
'works' => $date_works
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$trxs = [];
|
||||||
|
foreach($sas as $key => $sa) {
|
||||||
|
$sa_works = [];
|
||||||
|
foreach ($works as $key2 => $work) {
|
||||||
|
$d = Transaction::where('user_sa_id', $sa->id)->where('work_id', $work->id)->where('dealer_id', $id);
|
||||||
|
|
||||||
|
if(isset($request->month)) {
|
||||||
|
$d = $d->whereMonth('date', '=', $request->month)->whereYear('date', date('Y'));
|
||||||
|
$month = $request->month;
|
||||||
|
}
|
||||||
|
|
||||||
|
$d = $d->sum('qty');
|
||||||
|
if($d) {
|
||||||
|
$sa_works[] = [
|
||||||
|
'work_id' => $work->id,
|
||||||
|
'work_name' => $work->name,
|
||||||
|
'user_sa_id' => $sa->id,
|
||||||
|
'qty' => $d,
|
||||||
|
];
|
||||||
|
}else{
|
||||||
|
$sa_works[] = [
|
||||||
|
'work_id' => $work->id,
|
||||||
|
'work_name' => $work->name,
|
||||||
|
'user_sa_id' => $sa->id,
|
||||||
|
'qty' => 0,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$trxs[] = [
|
||||||
|
'user_sa_id' => $sa->id,
|
||||||
|
'sa_name' => $sa->name,
|
||||||
|
'works' => $sa_works
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
$sa_names = [];
|
||||||
|
$trx_data = [];
|
||||||
|
foreach($trxs as $trx) {
|
||||||
|
$sa_names[] = $trx['sa_name'];
|
||||||
|
$work_data2 = [];
|
||||||
|
foreach($trx['works'] as $work_data) {
|
||||||
|
if(array_key_exists($work_data['work_name'], $trx_data)) {
|
||||||
|
$trx_data[$work_data['work_name']]['qty'][] = $work_data['qty'];
|
||||||
|
}else{
|
||||||
|
$trx_data[$work_data['work_name']] = [
|
||||||
|
'work_name' => $work_data['work_name'],
|
||||||
|
'qty' => [$work_data['qty']]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$sa_names = json_encode($sa_names);
|
||||||
|
$trx_data = json_encode(array_values($trx_data));
|
||||||
|
$works_count = count($works);
|
||||||
|
$share = $month_trxs;
|
||||||
|
$month = $request->month;
|
||||||
|
dd($share);
|
||||||
|
|
||||||
|
return view('transaction.recap', compact('month_trxs_total', 'yesterday_month_trxs_total', 'month', 'trx_data', 'sa_names', 'works', 'works_count', 'trxs', 'month_trxs','dealer', 'share', 'mechanic'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function recap(Request $request)
|
||||||
|
{
|
||||||
|
if(!isset($request->month)) {
|
||||||
|
$request['month'] = date('m');
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!isset($request->year)) {
|
||||||
|
$request['year'] = date('Y');
|
||||||
|
}
|
||||||
|
|
||||||
|
$id = Auth::user()->dealer_id;
|
||||||
|
$works = Work::select('id', 'name', 'shortname')->whereHas('transactions', function($q) use($request, $id) {
|
||||||
|
if(isset($request->month)) {
|
||||||
|
return $q->whereMonth('date', '=', $request->month)->whereYear('date', $request->year)->where('dealer_id', $id);
|
||||||
|
}
|
||||||
|
})->get();
|
||||||
|
|
||||||
|
$sas = User::select('id', 'name')->whereHas('sa_transactions', function($q) use($request, $id) {
|
||||||
|
if(isset($request->month)) {
|
||||||
|
return $q->whereMonth('date', '=', $request->month)->whereYear('date', $request->year)->where('dealer_id', $id);
|
||||||
|
}
|
||||||
|
})->get();
|
||||||
|
|
||||||
|
$dealer = Dealer::find($id);
|
||||||
|
$mechanic = User::leftJoin('dealers as d', 'd.id', '=', 'users.dealer_id')
|
||||||
|
->select('d.name as dealer_name', 'users.name', 'users.id', 'users.role', 'users.email', 'd.dealer_code', 'd.address')
|
||||||
|
->where('users.id', Auth::user()->id)->first();
|
||||||
|
|
||||||
|
$dates = Transaction::select(DB::raw('DATE(`date`) as date'))->where('dealer_id', $id)->whereMonth('date', $request->month)->whereYear('date', $request->year)->groupBy(DB::raw('DATE(`date`)'))->get()->toArray();
|
||||||
|
// print_r($dates);die;
|
||||||
|
$dates = $this->array_value_recursive('date', $dates);
|
||||||
|
|
||||||
|
$month_trxs = [];
|
||||||
|
$month_trxs_total = [];
|
||||||
|
$yesterday_month_trxs_total = [];
|
||||||
|
foreach($works as $work1) {
|
||||||
|
$prev_mth_start = date('Y-m-d', strtotime(date($request->year.'-'. $request->month .'-1')." -1 month"));
|
||||||
|
$prev_mth = explode('-', $prev_mth_start);
|
||||||
|
if($request->month == date('m')) {
|
||||||
|
$prev_mth_end = $prev_mth[0].'-'.$prev_mth[1].'-'.date('d');
|
||||||
|
}else{
|
||||||
|
$prev_mth_end = $prev_mth[0].'-'.$prev_mth[1].'-'.date('t');
|
||||||
|
}
|
||||||
|
|
||||||
|
// dd($prev_mth_end);
|
||||||
|
$yesterday_month_trx = Transaction::where('work_id', $work1->id)->where('dealer_id', $id)->whereDate('date', '>=', $prev_mth_start)->whereDate('date', '<=', $prev_mth_end)->sum('qty');
|
||||||
|
|
||||||
|
if(array_key_exists($work1->id, $yesterday_month_trxs_total)) {
|
||||||
|
$yesterday_month_trxs_total[$work1->id] += $yesterday_month_trx;
|
||||||
|
}else{
|
||||||
|
$yesterday_month_trxs_total[$work1->id] = $yesterday_month_trx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if($dates) {
|
||||||
|
foreach($dates as $key => $date) {
|
||||||
|
$date_works = [];
|
||||||
|
$share_works = [];
|
||||||
|
foreach ($works as $key2 => $work) {
|
||||||
|
$d = Transaction::where('work_id', $work->id)->where('dealer_id', $id)->whereDate('date', $date);
|
||||||
|
|
||||||
|
if(isset($request->month)) {
|
||||||
|
$d = $d->whereMonth('date', '=', $request->month)->whereYear('date', $request->year);
|
||||||
|
}
|
||||||
|
|
||||||
|
$d = $d->sum('qty');
|
||||||
|
|
||||||
|
if($d) {
|
||||||
|
if(array_key_exists($work->id, $month_trxs_total)) {
|
||||||
|
$month_trxs_total[$work->id] += $d;
|
||||||
|
}else{
|
||||||
|
$month_trxs_total[$work->id] = $d;
|
||||||
|
}
|
||||||
|
$date_works[] = [
|
||||||
|
'work_id' => $work->id,
|
||||||
|
'work_name' => $work->name,
|
||||||
|
'shortname' => $work->shortname,
|
||||||
|
'date' => $date,
|
||||||
|
'qty' => $d,
|
||||||
|
];
|
||||||
|
}else{
|
||||||
|
$date_works[] = [
|
||||||
|
'work_id' => $work->id,
|
||||||
|
'work_name' => $work->name,
|
||||||
|
'shortname' => $work->shortname,
|
||||||
|
'date' => $date,
|
||||||
|
'qty' => 0,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$month_trxs[] = [
|
||||||
|
'date' => date('d/m/Y', strtotime($date)),
|
||||||
|
'works' => $date_works
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this_month_trxs = Transaction::select(DB::raw('SUM(qty) as qty'), 'u.name')->join('users AS u', 'u.id', '=', 'transactions.user_sa_id')->where('transactions.dealer_id', $id)->whereMonth('date', date('m'))->whereYear('date', $request->year)->groupBy('user_sa_id')->get();
|
||||||
|
$today_trxs = Transaction::select(DB::raw('SUM(qty) as qty'), 'u.name')->join('users AS u', 'u.id', '=', 'transactions.user_sa_id')->where('transactions.dealer_id', $id)->whereDate('date', date('Y-m-d'))->groupBy('user_sa_id')->get();
|
||||||
|
|
||||||
|
$trxs = [];
|
||||||
|
foreach($sas as $key => $sa) {
|
||||||
|
$sa_works = [];
|
||||||
|
foreach ($works as $key2 => $work) {
|
||||||
|
$d = Transaction::where('user_sa_id', $sa->id)->where('work_id', $work->id)->where('dealer_id', $id);
|
||||||
|
|
||||||
|
if(isset($request->month)) {
|
||||||
|
$d = $d->whereMonth('date', '=', $request->month)->whereYear('date', $request->year);
|
||||||
|
$month = $request->month;
|
||||||
|
}
|
||||||
|
|
||||||
|
$d = $d->sum('qty');
|
||||||
|
if($d) {
|
||||||
|
$sa_works[] = [
|
||||||
|
'work_id' => $work->id,
|
||||||
|
'work_name' => $work->name,
|
||||||
|
'user_sa_id' => $sa->id,
|
||||||
|
'qty' => $d,
|
||||||
|
];
|
||||||
|
}else{
|
||||||
|
$sa_works[] = [
|
||||||
|
'work_id' => $work->id,
|
||||||
|
'work_name' => $work->name,
|
||||||
|
'user_sa_id' => $sa->id,
|
||||||
|
'qty' => 0,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$trxs[] = [
|
||||||
|
'user_sa_id' => $sa->id,
|
||||||
|
'sa_name' => $sa->name,
|
||||||
|
'works' => $sa_works
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
$sa_names = [];
|
||||||
|
$trx_data = [];
|
||||||
|
foreach($trxs as $trx) {
|
||||||
|
$sa_names[] = $trx['sa_name'];
|
||||||
|
$work_data2 = [];
|
||||||
|
foreach($trx['works'] as $work_data) {
|
||||||
|
if(array_key_exists($work_data['work_name'], $trx_data)) {
|
||||||
|
$trx_data[$work_data['work_name']]['qty'][] = $work_data['qty'];
|
||||||
|
}else{
|
||||||
|
$trx_data[$work_data['work_name']] = [
|
||||||
|
'work_name' => $work_data['work_name'],
|
||||||
|
'qty' => [$work_data['qty']]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// dd($works);
|
||||||
|
// dd([$month_trxs_total, $yesterday_month_trxs_total]);
|
||||||
|
$final_month_trxs_total = [];
|
||||||
|
$final_yesterday_month_trxs_total = [];
|
||||||
|
foreach($works as $work1) {
|
||||||
|
$final_month_trxs_total[$work1->id] = $month_trxs_total[$work1->id];
|
||||||
|
$final_yesterday_month_trxs_total[$work1->id] = $yesterday_month_trxs_total[$work1->id];
|
||||||
|
}
|
||||||
|
// dd([$final_month_trxs_total, $final_yesterday_month_trxs_total]);
|
||||||
|
$month_trxs_total = array_values($final_month_trxs_total);
|
||||||
|
$yesterday_month_trxs_total = array_values($final_yesterday_month_trxs_total);
|
||||||
|
|
||||||
|
$totals = [];
|
||||||
|
for($i = 0; $i < count($month_trxs_total); $i++) {
|
||||||
|
$totals[] = [
|
||||||
|
"prev" => $yesterday_month_trxs_total[$i],
|
||||||
|
"now" => $month_trxs_total[$i],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
$sa_names = json_encode($sa_names);
|
||||||
|
$trx_data = json_encode(array_values($trx_data));
|
||||||
|
$works_count = count($works);
|
||||||
|
$share = ["this_month_trxs" => $this_month_trxs, "today_trxs" => $today_trxs, 'today_date' => Carbon::now()->translatedFormat('d F Y')];
|
||||||
|
$month = $request->month;
|
||||||
|
$year = $request->year;
|
||||||
|
|
||||||
|
return view('transaction.recap', compact('totals', 'month', 'year', 'trx_data', 'sa_names', 'works', 'works_count', 'trxs', 'month_trxs','dealer', 'share', 'mechanic'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
Transaction::find($id)->delete();
|
||||||
|
|
||||||
|
$response = [
|
||||||
|
'message' => 'Data deleted successfully',
|
||||||
|
'status' => 200
|
||||||
|
];
|
||||||
|
|
||||||
|
return redirect()->back();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
$request['quantity'] = array_filter($request['quantity'], function($value) { return !is_null($value) && $value !== ''; });
|
||||||
|
$request->validate([
|
||||||
|
'work_id.*' => ['required', 'integer'],
|
||||||
|
'quantity.*' => ['required', 'integer'],
|
||||||
|
'spk_no' => ['required', function($attribute, $value, $fail) use($request) {
|
||||||
|
$date = explode('/', $request->date);
|
||||||
|
$date = $date[2].'-'.$date[0].'-'.$date[1];
|
||||||
|
|
||||||
|
if(!$request->work_id) {
|
||||||
|
$fail('Pekerjaan harus diisi');
|
||||||
|
}else{
|
||||||
|
$error_work = '';
|
||||||
|
foreach($request->work_id as $work_id) {
|
||||||
|
$check = Transaction::with(['work'])->where('work_id', $work_id)->where('date', $date)->where('spk', $value)->where('police_number', $request->police_number)->orderBy('id', 'DESC')->whereDate('created_at', date('Y-m-d'))->limit(1)->first();
|
||||||
|
if($check) {
|
||||||
|
$error_work .= $check->work->name.', ';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if($error_work) {
|
||||||
|
$fail('SPK ini sudah digunakan untuk pekerjaan '. $error_work .' sebelumnya');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}],
|
||||||
|
'police_number' => ['required', function($attribute, $value, $fail) use($request) {
|
||||||
|
$date = explode('/', $request->date);
|
||||||
|
$date = $date[2].'-'.$date[0].'-'.$date[1];
|
||||||
|
|
||||||
|
if(!$request->work_id) {
|
||||||
|
$fail('Pekerjaan harus diisi');
|
||||||
|
}else{
|
||||||
|
$error_work = '';
|
||||||
|
foreach($request->work_id as $work_id) {
|
||||||
|
$check = Transaction::with(['work'])->where('work_id', $work_id)->where('date', $date)->where('spk', $request->spk_no)->where('police_number', $value)->orderBy('id', 'DESC')->whereDate('created_at', date('Y-m-d'))->limit(1)->first();
|
||||||
|
if($check) {
|
||||||
|
$error_work .= $check->work->name.', ';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if($error_work) {
|
||||||
|
$fail('No Polisi ini sudah digunakan untuk pekerjaan '. $error_work .' sebelumnya');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}],
|
||||||
|
'warranty' => ['required'],
|
||||||
|
'date' => ['required', function($attribute, $value, $fail) use($request) {
|
||||||
|
$date = explode('/', $value);
|
||||||
|
$date = $date[2].'-'.$date[0].'-'.$date[1];
|
||||||
|
|
||||||
|
if(!$request->work_id) {
|
||||||
|
$fail('Pekerjaan harus diisi');
|
||||||
|
}else{
|
||||||
|
$error_work = '';
|
||||||
|
foreach($request->work_id as $work_id) {
|
||||||
|
$check = Transaction::with(['work'])->where('work_id', $work_id)->where('date', $date)->where('spk', $request->spk_no)->where('police_number', $request->police_number)->orderBy('id', 'DESC')->whereDate('created_at', date('Y-m-d'))->limit(1)->first();
|
||||||
|
if($check) {
|
||||||
|
$error_work .= $check->work->name.', ';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if($error_work) {
|
||||||
|
$fail('Tanggal ini sudah digunakan untuk pekerjaan '. $error_work .' sebelumnya');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}],
|
||||||
|
'category' => ['required'],
|
||||||
|
'user_sa_id' => ['required', 'integer'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$request['date'] = explode('/', $request->date);
|
||||||
|
$request['date'] = $request['date'][2].'-'.$request['date'][0].'-'.$request['date'][1];
|
||||||
|
|
||||||
|
$data = [];
|
||||||
|
for($i = 0; $i < count($request->work_id); $i++) {
|
||||||
|
$data[] = [
|
||||||
|
"user_id" => $request->mechanic_id,
|
||||||
|
"dealer_id" => $request->dealer_id,
|
||||||
|
"form" => $request->form,
|
||||||
|
"work_id" => $request->work_id[$i],
|
||||||
|
"qty" => $request->quantity[$i],
|
||||||
|
"spk" => $request->spk_no,
|
||||||
|
"police_number" => $request->police_number,
|
||||||
|
"warranty" => $request->warranty,
|
||||||
|
"user_sa_id" => $request->user_sa_id,
|
||||||
|
"date" => $request->date,
|
||||||
|
"created_at" => date('Y-m-d H:i:s')
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
Transaction::insert($data);
|
||||||
|
return redirect()->back()->with('success', 'Berhasil input pekerjaan');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
$transaction = Transaction::find($id);
|
||||||
|
$response = [
|
||||||
|
'data' => $transaction,
|
||||||
|
'status' => 200,
|
||||||
|
'message' => 'get data successfully'
|
||||||
|
];
|
||||||
|
return response()->json($response);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(Request $request, $id)
|
||||||
|
{
|
||||||
|
Transaction::find($id)->update([
|
||||||
|
"spk" => $request->spk,
|
||||||
|
"date" => $request->date,
|
||||||
|
"police_number" => $request->police_number,
|
||||||
|
"work_id" => $request->work_id,
|
||||||
|
"qty" => $request->qty,
|
||||||
|
"warranty" => $request->warranty,
|
||||||
|
"user_sa_id" => $request->sa_id,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$response = [
|
||||||
|
"status" => 200,
|
||||||
|
"message" => "Data updated successfully"
|
||||||
|
];
|
||||||
|
|
||||||
|
return response()->json($response);
|
||||||
|
}
|
||||||
|
}
|
||||||
119
app/Http/Controllers/UserController.php
Normal file
119
app/Http/Controllers/UserController.php
Normal file
@@ -0,0 +1,119 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Models\Dealer;
|
||||||
|
use App\Models\Menu;
|
||||||
|
use App\Models\Role;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\Gate;
|
||||||
|
use Yajra\DataTables\Facades\DataTables;
|
||||||
|
|
||||||
|
class UserController extends Controller
|
||||||
|
{
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
$menu = Menu::where('link', 'user.index')->first();
|
||||||
|
abort_if(Gate::denies('view', $menu), 403, 'Unauthorized User');
|
||||||
|
if ($request->ajax()) {
|
||||||
|
$data = User::select('r.name as role_name', 'd.name as dealer_name', 'users.id', 'users.name', 'users.email')
|
||||||
|
->leftJoin('dealers as d', 'd.id', '=', 'users.dealer_id')
|
||||||
|
->join('roles as r', 'r.id', '=', 'users.role_id');
|
||||||
|
return DataTables::of($data)
|
||||||
|
->addIndexColumn()
|
||||||
|
->addColumn('action', function($row) use ($menu) {
|
||||||
|
$btn = '';
|
||||||
|
|
||||||
|
if(Auth::user()->can('delete', $menu)) {
|
||||||
|
$btn .= '<button class="btn btn-danger btn-sm btn-bold" data-action="'. route('user.destroy', $row->id) .'" id="destroyUser'. $row->id .'" onclick="destroyUser('. $row->id .')"> Hapus </button>';
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Auth::user()->can('update', $menu)) {
|
||||||
|
$btn .= '<button class="btn btn-warning btn-sm btn-bold" id="editUser'. $row->id .'" data-url="'. route('user.edit', $row->id) .'" data-action="'. route('user.update', $row->id) .'" onclick="editUser('. $row->id .')"> Edit </button>';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $btn;
|
||||||
|
})
|
||||||
|
->rawColumns(['action'])
|
||||||
|
->make();
|
||||||
|
}
|
||||||
|
|
||||||
|
$dealers = Dealer::all();
|
||||||
|
$roles = Role::all();
|
||||||
|
return view('back.users', compact('dealers', 'roles'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
$menu = Menu::where('link', 'user.index')->first();
|
||||||
|
abort_if(Gate::denies('create', $menu), 403, 'Unauthorized User');
|
||||||
|
User::create([
|
||||||
|
"name" => $request->name,
|
||||||
|
"dealer_id" => $request->dealer_id,
|
||||||
|
"role_id" => $request->role,
|
||||||
|
"email" => $request->email,
|
||||||
|
"password" => bcrypt($request->password)
|
||||||
|
]);
|
||||||
|
|
||||||
|
$response = [
|
||||||
|
"message" => "Data created succesfully",
|
||||||
|
"status" => 200
|
||||||
|
];
|
||||||
|
return response()->json($response);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
$menu = Menu::where('link', 'user.index')->first();
|
||||||
|
abort_if(Gate::denies('view', $menu), 403, 'Unauthorized User');
|
||||||
|
$user = User::find($id);
|
||||||
|
$response = [
|
||||||
|
"data" => $user,
|
||||||
|
"message" => "get data successfully",
|
||||||
|
"status" => 200
|
||||||
|
];
|
||||||
|
return response()->json($response);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @param \App\Models\Dealer $dealer
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function update(Request $request, $id)
|
||||||
|
{
|
||||||
|
$menu = Menu::where('link', 'user.index')->first();
|
||||||
|
abort_if(Gate::denies('update', $menu), 403, 'Unauthorized User');
|
||||||
|
User::find($id)
|
||||||
|
->update([
|
||||||
|
"name" => $request->name,
|
||||||
|
"dealer_id" => $request->dealer_id,
|
||||||
|
"role_id" => $request->role,
|
||||||
|
"email" => $request->email,
|
||||||
|
"password" => bcrypt($request->password)
|
||||||
|
]);
|
||||||
|
|
||||||
|
$response = [
|
||||||
|
"status" => 200,
|
||||||
|
"message" => "Data updated successfully"
|
||||||
|
];
|
||||||
|
|
||||||
|
return response()->json($response);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
$menu = Menu::where('link', 'user.index')->first();
|
||||||
|
abort_if(Gate::denies('delete', $menu), 403, 'Unauthorized User');
|
||||||
|
User::destroy($id);
|
||||||
|
$response = [
|
||||||
|
"message" => "Data deleted successfully",
|
||||||
|
"status" => 200
|
||||||
|
];
|
||||||
|
return response()->json($response);
|
||||||
|
}
|
||||||
|
}
|
||||||
148
app/Http/Controllers/WorkController.php
Normal file
148
app/Http/Controllers/WorkController.php
Normal file
@@ -0,0 +1,148 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Models\Category;
|
||||||
|
use App\Models\Menu;
|
||||||
|
use App\Models\Work;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Facades\Gate;
|
||||||
|
use Yajra\DataTables\DataTables;
|
||||||
|
|
||||||
|
class WorkController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
$menu = Menu::where('link', 'work.index')->first();
|
||||||
|
abort_if(Gate::denies('view', $menu), 403, 'Unauthorized User');
|
||||||
|
if ($request->ajax()) {
|
||||||
|
$data = DB::table('works as w')->leftJoin('categories as c', 'c.id', '=', 'w.category_id')->select('w.shortname as shortname', 'w.id as work_id', 'w.name as name', 'w.desc as desc', 'c.name as category_name', 'w.category_id as category_id');
|
||||||
|
return DataTables::of($data)->addIndexColumn()
|
||||||
|
->addColumn('action', function($row) use ($menu) {
|
||||||
|
$btn = '';
|
||||||
|
|
||||||
|
if(Auth::user()->can('delete', $menu)) {
|
||||||
|
$btn .= '<button class="btn btn-danger btn-sm btn-bold" data-action="'. route('work.destroy', $row->work_id) .'" id="destroyWork'. $row->work_id .'" onclick="destroyWork('. $row->work_id .')"> Hapus </button>';
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Auth::user()->can('update', $menu)) {
|
||||||
|
$btn .= '<button class="btn btn-warning btn-sm btn-bold" id="editWork'. $row->work_id .'" data-url="'. route('work.edit', $row->work_id) .'" data-action="'. route('work.update', $row->work_id) .'" onclick="editWork('. $row->work_id .')"> Edit </button>';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $btn;
|
||||||
|
})
|
||||||
|
->rawColumns(['action'])
|
||||||
|
->make(true);
|
||||||
|
}
|
||||||
|
$categories = Category::all();
|
||||||
|
return view('back.master.work', compact('categories'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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)
|
||||||
|
{
|
||||||
|
$menu = Menu::where('link', 'work.index')->first();
|
||||||
|
abort_if(Gate::denies('create', $menu), 403, 'Unauthorized User');
|
||||||
|
Work::create($request->all());
|
||||||
|
|
||||||
|
$response = [
|
||||||
|
"status" => 200,
|
||||||
|
"message" => "Data created successfully"
|
||||||
|
];
|
||||||
|
|
||||||
|
return response()->json($response);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the specified resource.
|
||||||
|
*
|
||||||
|
* @param \App\Models\Work $work
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function show(Work $work)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
*
|
||||||
|
* @param \App\Models\Work $work
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function edit(Work $work)
|
||||||
|
{
|
||||||
|
$menu = Menu::where('link', 'work.index')->first();
|
||||||
|
abort_if(Gate::denies('view', $menu), 403, 'Unauthorized User');
|
||||||
|
$work = Work::find($work->id);
|
||||||
|
$response = [
|
||||||
|
'data' => $work,
|
||||||
|
'status' => 200,
|
||||||
|
'message' => 'get data successfully'
|
||||||
|
];
|
||||||
|
return response()->json($response);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @param \App\Models\Work $work
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function update(Request $request, Work $work)
|
||||||
|
{
|
||||||
|
$menu = Menu::where('link', 'work.index')->first();
|
||||||
|
abort_if(Gate::denies('update', $menu), 403, 'Unauthorized User');
|
||||||
|
Work::find($work->id)->update($request->all());
|
||||||
|
|
||||||
|
$response = [
|
||||||
|
"status" => 200,
|
||||||
|
"message" => "Data updated successfully"
|
||||||
|
];
|
||||||
|
|
||||||
|
return response()->json($response);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*
|
||||||
|
* @param \App\Models\Work $work
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function destroy(Work $work)
|
||||||
|
{
|
||||||
|
$menu = Menu::where('link', 'work.index')->first();
|
||||||
|
abort_if(Gate::denies('delete', $menu), 403, 'Unauthorized User');
|
||||||
|
Work::destroy($work->id);
|
||||||
|
|
||||||
|
$response = [
|
||||||
|
"status" => 200,
|
||||||
|
"message" => "Data deleted successfully"
|
||||||
|
];
|
||||||
|
|
||||||
|
return response()->json($response);
|
||||||
|
}
|
||||||
|
}
|
||||||
69
app/Http/Kernel.php
Normal file
69
app/Http/Kernel.php
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
<?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,
|
||||||
|
\Fruitcake\Cors\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\Session\Middleware\AuthenticateSession::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,
|
||||||
|
'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' => \Illuminate\Routing\Middleware\ValidateSignature::class,
|
||||||
|
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
|
||||||
|
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
|
||||||
|
'adminRole' => \App\Http\Middleware\adminRole::class,
|
||||||
|
'mechanicRole' => \App\Http\Middleware\mechanicRole::class,
|
||||||
|
];
|
||||||
|
}
|
||||||
21
app/Http/Middleware/Authenticate.php
Normal file
21
app/Http/Middleware/Authenticate.php
Normal 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');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
17
app/Http/Middleware/EncryptCookies.php
Normal file
17
app/Http/Middleware/EncryptCookies.php
Normal 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 = [
|
||||||
|
//
|
||||||
|
];
|
||||||
|
}
|
||||||
17
app/Http/Middleware/PreventRequestsDuringMaintenance.php
Normal file
17
app/Http/Middleware/PreventRequestsDuringMaintenance.php
Normal 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 = [
|
||||||
|
//
|
||||||
|
];
|
||||||
|
}
|
||||||
38
app/Http/Middleware/RedirectIfAuthenticated.php
Normal file
38
app/Http/Middleware/RedirectIfAuthenticated.php
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use App\Models\Privilege;
|
||||||
|
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()) {
|
||||||
|
$user = Privilege::where('menu_id', 10)->where('role_id', Auth::user()->role_id)->where('view', 1)->first();
|
||||||
|
if ($user != null) {
|
||||||
|
return redirect('dashboard');
|
||||||
|
}else{
|
||||||
|
return redirect(RouteServiceProvider::HOME);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
}
|
||||||
19
app/Http/Middleware/TrimStrings.php
Normal file
19
app/Http/Middleware/TrimStrings.php
Normal 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',
|
||||||
|
];
|
||||||
|
}
|
||||||
20
app/Http/Middleware/TrustHosts.php
Normal file
20
app/Http/Middleware/TrustHosts.php
Normal 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(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
28
app/Http/Middleware/TrustProxies.php
Normal file
28
app/Http/Middleware/TrustProxies.php
Normal 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;
|
||||||
|
}
|
||||||
17
app/Http/Middleware/VerifyCsrfToken.php
Normal file
17
app/Http/Middleware/VerifyCsrfToken.php
Normal 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 = [
|
||||||
|
//
|
||||||
|
];
|
||||||
|
}
|
||||||
30
app/Http/Middleware/adminRole.php
Normal file
30
app/Http/Middleware/adminRole.php
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use App\Models\Privilege;
|
||||||
|
use Closure;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
class adminRole
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Handle an incoming request.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next
|
||||||
|
* @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
|
||||||
|
*/
|
||||||
|
public function handle(Request $request, Closure $next)
|
||||||
|
{
|
||||||
|
// check if user can access admin area
|
||||||
|
$user = Privilege::join('menus AS m', 'm.id', '=', 'privileges.menu_id')->where('m.link', 'adminarea')->where('role_id', Auth::user()->role_id)->where('view', 1)->get();
|
||||||
|
// dd($user);
|
||||||
|
if (!$user) {
|
||||||
|
abort(404);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
}
|
||||||
29
app/Http/Middleware/mechanicRole.php
Normal file
29
app/Http/Middleware/mechanicRole.php
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use App\Models\Privilege;
|
||||||
|
use Closure;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
class mechanicRole
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Handle an incoming request.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next
|
||||||
|
* @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
|
||||||
|
*/
|
||||||
|
public function handle(Request $request, Closure $next)
|
||||||
|
{
|
||||||
|
// check if user can access mechanic area
|
||||||
|
$user = Privilege::join('menus AS m', 'm.id', '=', 'privileges.menu_id')->where('m.link', 'mechanicarea')->where('role_id', Auth::user()->role_id)->where('view', 1)->get();
|
||||||
|
if (!$user) {
|
||||||
|
abort(404);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
}
|
||||||
15
app/Models/Category.php
Normal file
15
app/Models/Category.php
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
|
||||||
|
class Category extends Model
|
||||||
|
{
|
||||||
|
use HasFactory, SoftDeletes;
|
||||||
|
protected $fillable = [
|
||||||
|
"name", "form"
|
||||||
|
];
|
||||||
|
}
|
||||||
25
app/Models/Dealer.php
Normal file
25
app/Models/Dealer.php
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
|
||||||
|
class Dealer extends Model
|
||||||
|
{
|
||||||
|
use HasFactory, SoftDeletes;
|
||||||
|
protected $fillable = [
|
||||||
|
'dealer_code', 'name', 'address', 'pic'
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all of the transactions for the Dealer
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||||
|
*/
|
||||||
|
public function transactions()
|
||||||
|
{
|
||||||
|
return $this->hasMany(Transaction::class, 'dealer_id', 'id');
|
||||||
|
}
|
||||||
|
}
|
||||||
14
app/Models/Menu.php
Normal file
14
app/Models/Menu.php
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class Menu extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
protected $fillable = [
|
||||||
|
'name', 'link'
|
||||||
|
];
|
||||||
|
}
|
||||||
14
app/Models/Privilege.php
Normal file
14
app/Models/Privilege.php
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class Privilege extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
protected $fillable = [
|
||||||
|
'role_id', 'menu_id', 'create', 'update', 'view', 'delete'
|
||||||
|
];
|
||||||
|
}
|
||||||
14
app/Models/Role.php
Normal file
14
app/Models/Role.php
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class Role extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
protected $fillable = [
|
||||||
|
'name'
|
||||||
|
];
|
||||||
|
}
|
||||||
25
app/Models/Transaction.php
Normal file
25
app/Models/Transaction.php
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
|
||||||
|
class Transaction extends Model
|
||||||
|
{
|
||||||
|
use HasFactory, SoftDeletes;
|
||||||
|
protected $fillable = [
|
||||||
|
"user_id", "user_sa_id", "work_id", "form", "spk", "police_number", "warranty", "date", "qty", "status", "dealer_id"
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the work associated with the Transaction
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\HasOne
|
||||||
|
*/
|
||||||
|
public function work()
|
||||||
|
{
|
||||||
|
return $this->hasOne(Work::class, 'id', 'work_id');
|
||||||
|
}
|
||||||
|
}
|
||||||
78
app/Models/User.php
Normal file
78
app/Models/User.php
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||||
|
use Illuminate\Notifications\Notifiable;
|
||||||
|
use Laravel\Sanctum\HasApiTokens;
|
||||||
|
|
||||||
|
class User extends Authenticatable
|
||||||
|
{
|
||||||
|
use HasApiTokens, HasFactory, Notifiable, SoftDeletes;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes that are mass assignable.
|
||||||
|
*
|
||||||
|
* @var array<int, string>
|
||||||
|
*/
|
||||||
|
protected $fillable = [
|
||||||
|
'name',
|
||||||
|
'email',
|
||||||
|
'role',
|
||||||
|
'dealer_id',
|
||||||
|
'password',
|
||||||
|
'role_id'
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes that should be hidden for serialization.
|
||||||
|
*
|
||||||
|
* @var array<int, string>
|
||||||
|
*/
|
||||||
|
protected $hidden = [
|
||||||
|
'password',
|
||||||
|
'remember_token',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes that should be cast.
|
||||||
|
*
|
||||||
|
* @var array<string, string>
|
||||||
|
*/
|
||||||
|
protected $casts = [
|
||||||
|
'email_verified_at' => 'datetime',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all of the transactions for the User
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||||
|
*/
|
||||||
|
public function transactions()
|
||||||
|
{
|
||||||
|
return $this->hasMany(Transaction::class, 'user_id', 'id');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all of the sa_transactions for the User
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||||
|
*/
|
||||||
|
public function sa_transactions()
|
||||||
|
{
|
||||||
|
return $this->hasMany(Transaction::class, 'user_sa_id', 'id');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the dealer associated with the User
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\HasOne
|
||||||
|
*/
|
||||||
|
public function dealer()
|
||||||
|
{
|
||||||
|
return $this->hasOne(Dealer::class, 'id', 'dealer_id');
|
||||||
|
}
|
||||||
|
}
|
||||||
25
app/Models/Work.php
Normal file
25
app/Models/Work.php
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
|
||||||
|
class Work extends Model
|
||||||
|
{
|
||||||
|
use HasFactory, SoftDeletes;
|
||||||
|
protected $fillable = [
|
||||||
|
"category_id", "name", "desc", "shortname"
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all of the transactions for the Work
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||||
|
*/
|
||||||
|
public function transactions()
|
||||||
|
{
|
||||||
|
return $this->hasMany(Transaction::class, 'work_id', 'id');
|
||||||
|
}
|
||||||
|
}
|
||||||
38
app/Providers/AppServiceProvider.php
Normal file
38
app/Providers/AppServiceProvider.php
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Providers;
|
||||||
|
|
||||||
|
use App\Models\Menu;
|
||||||
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
use Illuminate\Support\Facades\View;
|
||||||
|
|
||||||
|
class AppServiceProvider extends ServiceProvider
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Register any application services.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function register()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bootstrap any application services.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function boot()
|
||||||
|
{
|
||||||
|
View::composer(['layouts.partials.sidebarMenu', 'dashboard', 'dealer_recap', 'back.*'], function ($view) {
|
||||||
|
$menuQuery = Menu::all();
|
||||||
|
$menus = [];
|
||||||
|
foreach($menuQuery as $menu) {
|
||||||
|
$menus[$menu->link] = $menu;
|
||||||
|
}
|
||||||
|
|
||||||
|
$view->with('menus', $menus);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
103
app/Providers/AuthServiceProvider.php
Normal file
103
app/Providers/AuthServiceProvider.php
Normal file
@@ -0,0 +1,103 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Providers;
|
||||||
|
|
||||||
|
use App\Models\Menu;
|
||||||
|
use App\Models\Privilege;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
|
||||||
|
use Illuminate\Support\Facades\Gate;
|
||||||
|
|
||||||
|
class AuthServiceProvider extends ServiceProvider
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The policy mappings for the application.
|
||||||
|
*
|
||||||
|
* @var array<class-string, class-string>
|
||||||
|
*/
|
||||||
|
protected $policies = [
|
||||||
|
// 'App\Models\Model' => 'App\Policies\ModelPolicy',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register any authentication / authorization services.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function boot()
|
||||||
|
{
|
||||||
|
$this->registerPolicies();
|
||||||
|
|
||||||
|
Gate::define(
|
||||||
|
'create',
|
||||||
|
function (User $user, Menu $menu) {
|
||||||
|
$role_id = $user->role_id;
|
||||||
|
$privilegeData = Privilege::where('role_id', $role_id)
|
||||||
|
->where('menu_id', $menu->id)
|
||||||
|
->where('create', 1)
|
||||||
|
->first();
|
||||||
|
|
||||||
|
$privilegeData ? $privilege = true : $privilege = false;
|
||||||
|
if($role_id == 0) {
|
||||||
|
$privilege = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $privilege;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
Gate::define(
|
||||||
|
'update',
|
||||||
|
function (User $user, Menu $menu) {
|
||||||
|
$role_id = $user->role_id;
|
||||||
|
$privilegeData = Privilege::where('role_id', $role_id)
|
||||||
|
->where('menu_id', $menu->id)
|
||||||
|
->where('update', 1)
|
||||||
|
->first();
|
||||||
|
|
||||||
|
$privilegeData ? $privilege = true : $privilege = false;
|
||||||
|
if($role_id == 0) {
|
||||||
|
$privilege = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $privilege;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
Gate::define(
|
||||||
|
'delete',
|
||||||
|
function (User $user, Menu $menu) {
|
||||||
|
$role_id = $user->role_id;
|
||||||
|
$privilegeData = Privilege::where('role_id', $role_id)
|
||||||
|
->where('menu_id', $menu->id)
|
||||||
|
->where('delete', 1)
|
||||||
|
->first();
|
||||||
|
|
||||||
|
$privilegeData ? $privilege = true : $privilege = false;
|
||||||
|
if($role_id == 0) {
|
||||||
|
$privilege = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $privilege;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
Gate::define(
|
||||||
|
'view',
|
||||||
|
function (User $user, Menu $menu) {
|
||||||
|
$role_id = $user->role_id;
|
||||||
|
$privilegeData = Privilege::where('role_id', $role_id)
|
||||||
|
->where('menu_id', $menu->id)
|
||||||
|
->where('view', 1)
|
||||||
|
->first();
|
||||||
|
|
||||||
|
$privilegeData ? $privilege = true : $privilege = false;
|
||||||
|
if($role_id == 0) {
|
||||||
|
$privilege = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $privilege;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
21
app/Providers/BroadcastServiceProvider.php
Normal file
21
app/Providers/BroadcastServiceProvider.php
Normal 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');
|
||||||
|
}
|
||||||
|
}
|
||||||
32
app/Providers/EventServiceProvider.php
Normal file
32
app/Providers/EventServiceProvider.php
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
<?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 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()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
63
app/Providers/RouteServiceProvider.php
Normal file
63
app/Providers/RouteServiceProvider.php
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
<?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.
|
||||||
|
*
|
||||||
|
* This is used by Laravel authentication to redirect users after login.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public const HOME = '/';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The controller namespace for the application.
|
||||||
|
*
|
||||||
|
* When present, controller route declarations will automatically be prefixed with this namespace.
|
||||||
|
*
|
||||||
|
* @var string|null
|
||||||
|
*/
|
||||||
|
// protected $namespace = 'App\\Http\\Controllers';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Define your route model bindings, pattern filters, etc.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function boot()
|
||||||
|
{
|
||||||
|
$this->configureRateLimiting();
|
||||||
|
|
||||||
|
$this->routes(function () {
|
||||||
|
Route::prefix('api')
|
||||||
|
->middleware('api')
|
||||||
|
->namespace($this->namespace)
|
||||||
|
->group(base_path('routes/api.php'));
|
||||||
|
|
||||||
|
Route::middleware('web')
|
||||||
|
->namespace($this->namespace)
|
||||||
|
->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(optional($request->user())->id ?: $request->ip());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
53
artisan
Normal file
53
artisan
Normal 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);
|
||||||
BIN
bengkell.zip
Normal file
BIN
bengkell.zip
Normal file
Binary file not shown.
55
bootstrap/app.php
Normal file
55
bootstrap/app.php
Normal 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
2
bootstrap/cache/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
*
|
||||||
|
!.gitignore
|
||||||
70
composer.json
Normal file
70
composer.json
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
{
|
||||||
|
"name": "laravel/laravel",
|
||||||
|
"type": "project",
|
||||||
|
"description": "The Laravel Framework.",
|
||||||
|
"keywords": ["framework", "laravel"],
|
||||||
|
"license": "MIT",
|
||||||
|
"require": {
|
||||||
|
"php": "^7.3|^8.0",
|
||||||
|
"doctrine/dbal": "^3.3",
|
||||||
|
"fruitcake/laravel-cors": "^2.0",
|
||||||
|
"guzzlehttp/guzzle": "^7.0.1",
|
||||||
|
"laravel/framework": "^8.75",
|
||||||
|
"laravel/sanctum": "^2.11",
|
||||||
|
"laravel/tinker": "^2.5",
|
||||||
|
"laravel/ui": "^3.4",
|
||||||
|
"maatwebsite/excel": "^3.1",
|
||||||
|
"yajra/laravel-datatables-oracle": "^9.20"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"facade/ignition": "^2.5",
|
||||||
|
"fakerphp/faker": "^1.9.1",
|
||||||
|
"laravel/sail": "^1.0.1",
|
||||||
|
"mockery/mockery": "^1.4.4",
|
||||||
|
"nunomaduro/collision": "^5.10",
|
||||||
|
"phpunit/phpunit": "^9.5.10"
|
||||||
|
},
|
||||||
|
"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"
|
||||||
|
],
|
||||||
|
"dev": "npm run development",
|
||||||
|
"development": "npx mix",
|
||||||
|
"watch": "npx mix watch",
|
||||||
|
"production": "npx mix --production"
|
||||||
|
},
|
||||||
|
"extra": {
|
||||||
|
"laravel": {
|
||||||
|
"dont-discover": []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"config": {
|
||||||
|
"optimize-autoloader": true,
|
||||||
|
"preferred-install": "dist",
|
||||||
|
"sort-packages": true
|
||||||
|
},
|
||||||
|
"minimum-stability": "dev",
|
||||||
|
"prefer-stable": true
|
||||||
|
}
|
||||||
8928
composer.lock
generated
Normal file
8928
composer.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
237
config/app.php
Normal file
237
config/app.php
Normal file
@@ -0,0 +1,237 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
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', null),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| 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' => 'Asia/Jakarta',
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| 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' => 'id',
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| 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',
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| 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' => [
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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...
|
||||||
|
*/
|
||||||
|
Yajra\DataTables\DataTablesServiceProvider::class,
|
||||||
|
Maatwebsite\Excel\ExcelServiceProvider::class,
|
||||||
|
/*
|
||||||
|
* 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' => [
|
||||||
|
|
||||||
|
'App' => Illuminate\Support\Facades\App::class,
|
||||||
|
'Arr' => Illuminate\Support\Arr::class,
|
||||||
|
'Artisan' => Illuminate\Support\Facades\Artisan::class,
|
||||||
|
'Auth' => Illuminate\Support\Facades\Auth::class,
|
||||||
|
'Blade' => Illuminate\Support\Facades\Blade::class,
|
||||||
|
'Broadcast' => Illuminate\Support\Facades\Broadcast::class,
|
||||||
|
'Bus' => Illuminate\Support\Facades\Bus::class,
|
||||||
|
'Cache' => Illuminate\Support\Facades\Cache::class,
|
||||||
|
'Config' => Illuminate\Support\Facades\Config::class,
|
||||||
|
'Cookie' => Illuminate\Support\Facades\Cookie::class,
|
||||||
|
'Crypt' => Illuminate\Support\Facades\Crypt::class,
|
||||||
|
'Date' => Illuminate\Support\Facades\Date::class,
|
||||||
|
'DB' => Illuminate\Support\Facades\DB::class,
|
||||||
|
'Eloquent' => Illuminate\Database\Eloquent\Model::class,
|
||||||
|
'Event' => Illuminate\Support\Facades\Event::class,
|
||||||
|
'File' => Illuminate\Support\Facades\File::class,
|
||||||
|
'Gate' => Illuminate\Support\Facades\Gate::class,
|
||||||
|
'Hash' => Illuminate\Support\Facades\Hash::class,
|
||||||
|
'Http' => Illuminate\Support\Facades\Http::class,
|
||||||
|
'Js' => Illuminate\Support\Js::class,
|
||||||
|
'Lang' => Illuminate\Support\Facades\Lang::class,
|
||||||
|
'Log' => Illuminate\Support\Facades\Log::class,
|
||||||
|
'Mail' => Illuminate\Support\Facades\Mail::class,
|
||||||
|
'Notification' => Illuminate\Support\Facades\Notification::class,
|
||||||
|
'Password' => Illuminate\Support\Facades\Password::class,
|
||||||
|
'Queue' => Illuminate\Support\Facades\Queue::class,
|
||||||
|
'RateLimiter' => Illuminate\Support\Facades\RateLimiter::class,
|
||||||
|
'Redirect' => Illuminate\Support\Facades\Redirect::class,
|
||||||
|
// 'Redis' => Illuminate\Support\Facades\Redis::class,
|
||||||
|
'Request' => Illuminate\Support\Facades\Request::class,
|
||||||
|
'Response' => Illuminate\Support\Facades\Response::class,
|
||||||
|
'Route' => Illuminate\Support\Facades\Route::class,
|
||||||
|
'Schema' => Illuminate\Support\Facades\Schema::class,
|
||||||
|
'Session' => Illuminate\Support\Facades\Session::class,
|
||||||
|
'Storage' => Illuminate\Support\Facades\Storage::class,
|
||||||
|
'Str' => Illuminate\Support\Str::class,
|
||||||
|
'URL' => Illuminate\Support\Facades\URL::class,
|
||||||
|
'Validator' => Illuminate\Support\Facades\Validator::class,
|
||||||
|
'View' => Illuminate\Support\Facades\View::class,
|
||||||
|
'Excel' => Maatwebsite\Excel\Facades\Excel::class,
|
||||||
|
|
||||||
|
],
|
||||||
|
|
||||||
|
];
|
||||||
111
config/auth.php
Normal file
111
config/auth.php
Normal file
@@ -0,0 +1,111 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
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' => 'web',
|
||||||
|
'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' => [
|
||||||
|
'web' => [
|
||||||
|
'driver' => 'session',
|
||||||
|
'provider' => 'users',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| 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' => [
|
||||||
|
'users' => [
|
||||||
|
'driver' => 'eloquent',
|
||||||
|
'model' => App\Models\User::class,
|
||||||
|
],
|
||||||
|
|
||||||
|
// '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,
|
||||||
|
|
||||||
|
];
|
||||||
64
config/broadcasting.php
Normal file
64
config/broadcasting.php
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
<?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' => [
|
||||||
|
'cluster' => env('PUSHER_APP_CLUSTER'),
|
||||||
|
'useTLS' => true,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
|
||||||
|
'ably' => [
|
||||||
|
'driver' => 'ably',
|
||||||
|
'key' => env('ABLY_KEY'),
|
||||||
|
],
|
||||||
|
|
||||||
|
'redis' => [
|
||||||
|
'driver' => 'redis',
|
||||||
|
'connection' => 'default',
|
||||||
|
],
|
||||||
|
|
||||||
|
'log' => [
|
||||||
|
'driver' => 'log',
|
||||||
|
],
|
||||||
|
|
||||||
|
'null' => [
|
||||||
|
'driver' => 'null',
|
||||||
|
],
|
||||||
|
|
||||||
|
],
|
||||||
|
|
||||||
|
];
|
||||||
110
config/cache.php
Normal file
110
config/cache.php
Normal 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 a RAM based store such as APC or Memcached, there might
|
||||||
|
| be other applications utilizing the same cache. So, we'll specify a
|
||||||
|
| value to get prefixed to all our keys so we can avoid collisions.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_cache'),
|
||||||
|
|
||||||
|
];
|
||||||
34
config/cors.php
Normal file
34
config/cors.php
Normal 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,
|
||||||
|
|
||||||
|
];
|
||||||
147
config/database.php
Normal file
147
config/database.php
Normal file
@@ -0,0 +1,147 @@
|
|||||||
|
<?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' => null,
|
||||||
|
'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,
|
||||||
|
'schema' => '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,
|
||||||
|
],
|
||||||
|
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| 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'),
|
||||||
|
'password' => env('REDIS_PASSWORD', null),
|
||||||
|
'port' => env('REDIS_PORT', '6379'),
|
||||||
|
'database' => env('REDIS_DB', '0'),
|
||||||
|
],
|
||||||
|
|
||||||
|
'cache' => [
|
||||||
|
'url' => env('REDIS_URL'),
|
||||||
|
'host' => env('REDIS_HOST', '127.0.0.1'),
|
||||||
|
'password' => env('REDIS_PASSWORD', null),
|
||||||
|
'port' => env('REDIS_PORT', '6379'),
|
||||||
|
'database' => env('REDIS_CACHE_DB', '1'),
|
||||||
|
],
|
||||||
|
|
||||||
|
],
|
||||||
|
|
||||||
|
];
|
||||||
122
config/datatables.php
Normal file
122
config/datatables.php
Normal file
@@ -0,0 +1,122 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
/*
|
||||||
|
* DataTables search options.
|
||||||
|
*/
|
||||||
|
'search' => [
|
||||||
|
/*
|
||||||
|
* Smart search will enclose search keyword with wildcard string "%keyword%".
|
||||||
|
* SQL: column LIKE "%keyword%"
|
||||||
|
*/
|
||||||
|
'smart' => true,
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Multi-term search will explode search keyword using spaces resulting into multiple term search.
|
||||||
|
*/
|
||||||
|
'multi_term' => true,
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Case insensitive will search the keyword in lower case format.
|
||||||
|
* SQL: LOWER(column) LIKE LOWER(keyword)
|
||||||
|
*/
|
||||||
|
'case_insensitive' => true,
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Wild card will add "%" in between every characters of the keyword.
|
||||||
|
* SQL: column LIKE "%k%e%y%w%o%r%d%"
|
||||||
|
*/
|
||||||
|
'use_wildcards' => false,
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Perform a search which starts with the given keyword.
|
||||||
|
* SQL: column LIKE "keyword%"
|
||||||
|
*/
|
||||||
|
'starts_with' => false,
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
* DataTables internal index id response column name.
|
||||||
|
*/
|
||||||
|
'index_column' => 'DT_RowIndex',
|
||||||
|
|
||||||
|
/*
|
||||||
|
* List of available builders for DataTables.
|
||||||
|
* This is where you can register your custom dataTables builder.
|
||||||
|
*/
|
||||||
|
'engines' => [
|
||||||
|
'eloquent' => Yajra\DataTables\EloquentDataTable::class,
|
||||||
|
'query' => Yajra\DataTables\QueryDataTable::class,
|
||||||
|
'collection' => Yajra\DataTables\CollectionDataTable::class,
|
||||||
|
'resource' => Yajra\DataTables\ApiResourceDataTable::class,
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
* DataTables accepted builder to engine mapping.
|
||||||
|
* This is where you can override which engine a builder should use
|
||||||
|
* Note, only change this if you know what you are doing!
|
||||||
|
*/
|
||||||
|
'builders' => [
|
||||||
|
//Illuminate\Database\Eloquent\Relations\Relation::class => 'eloquent',
|
||||||
|
//Illuminate\Database\Eloquent\Builder::class => 'eloquent',
|
||||||
|
//Illuminate\Database\Query\Builder::class => 'query',
|
||||||
|
//Illuminate\Support\Collection::class => 'collection',
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Nulls last sql pattern for PostgreSQL & Oracle.
|
||||||
|
* For MySQL, use 'CASE WHEN :column IS NULL THEN 1 ELSE 0 END, :column :direction'
|
||||||
|
*/
|
||||||
|
'nulls_last_sql' => ':column :direction NULLS LAST',
|
||||||
|
|
||||||
|
/*
|
||||||
|
* User friendly message to be displayed on user if error occurs.
|
||||||
|
* Possible values:
|
||||||
|
* null - The exception message will be used on error response.
|
||||||
|
* 'throw' - Throws a \Yajra\DataTables\Exceptions\Exception. Use your custom error handler if needed.
|
||||||
|
* 'custom message' - Any friendly message to be displayed to the user. You can also use translation key.
|
||||||
|
*/
|
||||||
|
'error' => env('DATATABLES_ERROR', null),
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Default columns definition of dataTable utility functions.
|
||||||
|
*/
|
||||||
|
'columns' => [
|
||||||
|
/*
|
||||||
|
* List of columns hidden/removed on json response.
|
||||||
|
*/
|
||||||
|
'excess' => ['rn', 'row_num'],
|
||||||
|
|
||||||
|
/*
|
||||||
|
* List of columns to be escaped. If set to *, all columns are escape.
|
||||||
|
* Note: You can set the value to empty array to disable XSS protection.
|
||||||
|
*/
|
||||||
|
'escape' => '*',
|
||||||
|
|
||||||
|
/*
|
||||||
|
* List of columns that are allowed to display html content.
|
||||||
|
* Note: Adding columns to list will make us available to XSS attacks.
|
||||||
|
*/
|
||||||
|
'raw' => ['action'],
|
||||||
|
|
||||||
|
/*
|
||||||
|
* List of columns are forbidden from being searched/sorted.
|
||||||
|
*/
|
||||||
|
'blacklist' => ['password', 'remember_token'],
|
||||||
|
|
||||||
|
/*
|
||||||
|
* List of columns that are only allowed fo search/sort.
|
||||||
|
* If set to *, all columns are allowed.
|
||||||
|
*/
|
||||||
|
'whitelist' => '*',
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
* JsonResponse header and options config.
|
||||||
|
*/
|
||||||
|
'json' => [
|
||||||
|
'header' => [],
|
||||||
|
'options' => 0,
|
||||||
|
],
|
||||||
|
|
||||||
|
];
|
||||||
332
config/excel.php
Normal file
332
config/excel.php
Normal file
@@ -0,0 +1,332 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Maatwebsite\Excel\Excel;
|
||||||
|
|
||||||
|
return [
|
||||||
|
'exports' => [
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Chunk size
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| When using FromQuery, the query is automatically chunked.
|
||||||
|
| Here you can specify how big the chunk should be.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
'chunk_size' => 1000,
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Pre-calculate formulas during export
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
'pre_calculate_formulas' => false,
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Enable strict null comparison
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| When enabling strict null comparison empty cells ('') will
|
||||||
|
| be added to the sheet.
|
||||||
|
*/
|
||||||
|
'strict_null_comparison' => false,
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| CSV Settings
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Configure e.g. delimiter, enclosure and line ending for CSV exports.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
'csv' => [
|
||||||
|
'delimiter' => ',',
|
||||||
|
'enclosure' => '"',
|
||||||
|
'line_ending' => PHP_EOL,
|
||||||
|
'use_bom' => false,
|
||||||
|
'include_separator_line' => false,
|
||||||
|
'excel_compatibility' => false,
|
||||||
|
'output_encoding' => '',
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Worksheet properties
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Configure e.g. default title, creator, subject,...
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
'properties' => [
|
||||||
|
'creator' => '',
|
||||||
|
'lastModifiedBy' => '',
|
||||||
|
'title' => '',
|
||||||
|
'description' => '',
|
||||||
|
'subject' => '',
|
||||||
|
'keywords' => '',
|
||||||
|
'category' => '',
|
||||||
|
'manager' => '',
|
||||||
|
'company' => '',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
|
||||||
|
'imports' => [
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Read Only
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| When dealing with imports, you might only be interested in the
|
||||||
|
| data that the sheet exists. By default we ignore all styles,
|
||||||
|
| however if you want to do some logic based on style data
|
||||||
|
| you can enable it by setting read_only to false.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
'read_only' => true,
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Ignore Empty
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| When dealing with imports, you might be interested in ignoring
|
||||||
|
| rows that have null values or empty strings. By default rows
|
||||||
|
| containing empty strings or empty values are not ignored but can be
|
||||||
|
| ignored by enabling the setting ignore_empty to true.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
'ignore_empty' => false,
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Heading Row Formatter
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Configure the heading row formatter.
|
||||||
|
| Available options: none|slug|custom
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
'heading_row' => [
|
||||||
|
'formatter' => 'slug',
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| CSV Settings
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Configure e.g. delimiter, enclosure and line ending for CSV imports.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
'csv' => [
|
||||||
|
'delimiter' => null,
|
||||||
|
'enclosure' => '"',
|
||||||
|
'escape_character' => '\\',
|
||||||
|
'contiguous' => false,
|
||||||
|
'input_encoding' => 'UTF-8',
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Worksheet properties
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Configure e.g. default title, creator, subject,...
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
'properties' => [
|
||||||
|
'creator' => '',
|
||||||
|
'lastModifiedBy' => '',
|
||||||
|
'title' => '',
|
||||||
|
'description' => '',
|
||||||
|
'subject' => '',
|
||||||
|
'keywords' => '',
|
||||||
|
'category' => '',
|
||||||
|
'manager' => '',
|
||||||
|
'company' => '',
|
||||||
|
],
|
||||||
|
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Extension detector
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Configure here which writer/reader type should be used when the package
|
||||||
|
| needs to guess the correct type based on the extension alone.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
'extension_detector' => [
|
||||||
|
'xlsx' => Excel::XLSX,
|
||||||
|
'xlsm' => Excel::XLSX,
|
||||||
|
'xltx' => Excel::XLSX,
|
||||||
|
'xltm' => Excel::XLSX,
|
||||||
|
'xls' => Excel::XLS,
|
||||||
|
'xlt' => Excel::XLS,
|
||||||
|
'ods' => Excel::ODS,
|
||||||
|
'ots' => Excel::ODS,
|
||||||
|
'slk' => Excel::SLK,
|
||||||
|
'xml' => Excel::XML,
|
||||||
|
'gnumeric' => Excel::GNUMERIC,
|
||||||
|
'htm' => Excel::HTML,
|
||||||
|
'html' => Excel::HTML,
|
||||||
|
'csv' => Excel::CSV,
|
||||||
|
'tsv' => Excel::TSV,
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| PDF Extension
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Configure here which Pdf driver should be used by default.
|
||||||
|
| Available options: Excel::MPDF | Excel::TCPDF | Excel::DOMPDF
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
'pdf' => Excel::DOMPDF,
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Value Binder
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| PhpSpreadsheet offers a way to hook into the process of a value being
|
||||||
|
| written to a cell. In there some assumptions are made on how the
|
||||||
|
| value should be formatted. If you want to change those defaults,
|
||||||
|
| you can implement your own default value binder.
|
||||||
|
|
|
||||||
|
| Possible value binders:
|
||||||
|
|
|
||||||
|
| [x] Maatwebsite\Excel\DefaultValueBinder::class
|
||||||
|
| [x] PhpOffice\PhpSpreadsheet\Cell\StringValueBinder::class
|
||||||
|
| [x] PhpOffice\PhpSpreadsheet\Cell\AdvancedValueBinder::class
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
'value_binder' => [
|
||||||
|
'default' => Maatwebsite\Excel\DefaultValueBinder::class,
|
||||||
|
],
|
||||||
|
|
||||||
|
'cache' => [
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Default cell caching driver
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| By default PhpSpreadsheet keeps all cell values in memory, however when
|
||||||
|
| dealing with large files, this might result into memory issues. If you
|
||||||
|
| want to mitigate that, you can configure a cell caching driver here.
|
||||||
|
| When using the illuminate driver, it will store each value in a the
|
||||||
|
| cache store. This can slow down the process, because it needs to
|
||||||
|
| store each value. You can use the "batch" store if you want to
|
||||||
|
| only persist to the store when the memory limit is reached.
|
||||||
|
|
|
||||||
|
| Drivers: memory|illuminate|batch
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
'driver' => 'memory',
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Batch memory caching
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| When dealing with the "batch" caching driver, it will only
|
||||||
|
| persist to the store when the memory limit is reached.
|
||||||
|
| Here you can tweak the memory limit to your liking.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
'batch' => [
|
||||||
|
'memory_limit' => 60000,
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Illuminate cache
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| When using the "illuminate" caching driver, it will automatically use
|
||||||
|
| your default cache store. However if you prefer to have the cell
|
||||||
|
| cache on a separate store, you can configure the store name here.
|
||||||
|
| You can use any store defined in your cache config. When leaving
|
||||||
|
| at "null" it will use the default store.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
'illuminate' => [
|
||||||
|
'store' => null,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Transaction Handler
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| By default the import is wrapped in a transaction. This is useful
|
||||||
|
| for when an import may fail and you want to retry it. With the
|
||||||
|
| transactions, the previous import gets rolled-back.
|
||||||
|
|
|
||||||
|
| You can disable the transaction handler by setting this to null.
|
||||||
|
| Or you can choose a custom made transaction handler here.
|
||||||
|
|
|
||||||
|
| Supported handlers: null|db
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
'transactions' => [
|
||||||
|
'handler' => 'db',
|
||||||
|
'db' => [
|
||||||
|
'connection' => null,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
|
||||||
|
'temporary_files' => [
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Local Temporary Path
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| When exporting and importing files, we use a temporary file, before
|
||||||
|
| storing reading or downloading. Here you can customize that path.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
'local_path' => storage_path('framework/cache/laravel-excel'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Remote Temporary Disk
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| When dealing with a multi server setup with queues in which you
|
||||||
|
| cannot rely on having a shared local temporary path, you might
|
||||||
|
| want to store the temporary file on a shared disk. During the
|
||||||
|
| queue executing, we'll retrieve the temporary file from that
|
||||||
|
| location instead. When left to null, it will always use
|
||||||
|
| the local path. This setting only has effect when using
|
||||||
|
| in conjunction with queued imports and exports.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
'remote_disk' => null,
|
||||||
|
'remote_prefix' => null,
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Force Resync
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| When dealing with a multi server setup as above, it's possible
|
||||||
|
| for the clean up that occurs after entire queue has been run to only
|
||||||
|
| cleanup the server that the last AfterImportJob runs on. The rest of the server
|
||||||
|
| would still have the local temporary file stored on it. In this case your
|
||||||
|
| local storage limits can be exceeded and future imports won't be processed.
|
||||||
|
| To mitigate this you can set this config value to be true, so that after every
|
||||||
|
| queued chunk is processed the local temporary file is deleted on the server that
|
||||||
|
| processed it.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
'force_resync_remote' => null,
|
||||||
|
],
|
||||||
|
];
|
||||||
80
config/filesystems.php
Normal file
80
config/filesystems.php
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
<?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_DRIVER', '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 setup for each driver as an example of the required options.
|
||||||
|
|
|
||||||
|
| Supported Drivers: "local", "ftp", "sftp", "s3"
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'disks' => [
|
||||||
|
|
||||||
|
'local' => [
|
||||||
|
'driver' => 'local',
|
||||||
|
'root' => storage_path('app'),
|
||||||
|
],
|
||||||
|
|
||||||
|
'public' => [
|
||||||
|
'driver' => 'local',
|
||||||
|
'root' => storage_path('app/public'),
|
||||||
|
'url' => env('APP_URL').'/storage',
|
||||||
|
'visibility' => 'public',
|
||||||
|
],
|
||||||
|
|
||||||
|
'report' => [
|
||||||
|
'driver' => 'local',
|
||||||
|
'root' => storage_path('app/public/report/'),
|
||||||
|
'url' => env('APP_URL').'/storage',
|
||||||
|
'visibility' => 'public',
|
||||||
|
],
|
||||||
|
|
||||||
|
'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),
|
||||||
|
],
|
||||||
|
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| 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
52
config/hashing.php
Normal 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,
|
||||||
|
],
|
||||||
|
|
||||||
|
];
|
||||||
118
config/logging.php
Normal file
118
config/logging.php
Normal file
@@ -0,0 +1,118 @@
|
|||||||
|
<?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' => env('LOG_DEPRECATIONS_CHANNEL', 'null'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| 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' => SyslogUdpHandler::class,
|
||||||
|
'handler_with' => [
|
||||||
|
'host' => env('PAPERTRAIL_URL'),
|
||||||
|
'port' => 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'),
|
||||||
|
],
|
||||||
|
],
|
||||||
|
|
||||||
|
];
|
||||||
118
config/mail.php
Normal file
118
config/mail.php
Normal file
@@ -0,0 +1,118 @@
|
|||||||
|
<?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,
|
||||||
|
'auth_mode' => null,
|
||||||
|
],
|
||||||
|
|
||||||
|
'ses' => [
|
||||||
|
'transport' => 'ses',
|
||||||
|
],
|
||||||
|
|
||||||
|
'mailgun' => [
|
||||||
|
'transport' => 'mailgun',
|
||||||
|
],
|
||||||
|
|
||||||
|
'postmark' => [
|
||||||
|
'transport' => 'postmark',
|
||||||
|
],
|
||||||
|
|
||||||
|
'sendmail' => [
|
||||||
|
'transport' => 'sendmail',
|
||||||
|
'path' => env('MAIL_SENDMAIL_PATH', '/usr/sbin/sendmail -t -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
93
config/queue.php
Normal 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',
|
||||||
|
],
|
||||||
|
|
||||||
|
];
|
||||||
65
config/sanctum.php
Normal file
65
config/sanctum.php
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
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',
|
||||||
|
env('APP_URL') ? ','.parse_url(env('APP_URL'), PHP_URL_HOST) : ''
|
||||||
|
))),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| 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,
|
||||||
|
],
|
||||||
|
|
||||||
|
];
|
||||||
33
config/services.php
Normal file
33
config/services.php
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Third Party Services
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This file is for storing the credentials for third party services such
|
||||||
|
| as Mailgun, Postmark, AWS and more. This file provides the de facto
|
||||||
|
| location for this type of information, allowing packages to have
|
||||||
|
| a conventional file to locate the various service credentials.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'mailgun' => [
|
||||||
|
'domain' => env('MAILGUN_DOMAIN'),
|
||||||
|
'secret' => env('MAILGUN_SECRET'),
|
||||||
|
'endpoint' => env('MAILGUN_ENDPOINT', 'api.mailgun.net'),
|
||||||
|
],
|
||||||
|
|
||||||
|
'postmark' => [
|
||||||
|
'token' => env('POSTMARK_TOKEN'),
|
||||||
|
],
|
||||||
|
|
||||||
|
'ses' => [
|
||||||
|
'key' => env('AWS_ACCESS_KEY_ID'),
|
||||||
|
'secret' => env('AWS_SECRET_ACCESS_KEY'),
|
||||||
|
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
|
||||||
|
],
|
||||||
|
|
||||||
|
];
|
||||||
201
config/session.php
Normal file
201
config/session.php
Normal file
@@ -0,0 +1,201 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Default Session Driver
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This option controls the default session "driver" that will be used on
|
||||||
|
| requests. By default, we will use the lightweight native driver but
|
||||||
|
| you may specify any of the other wonderful drivers provided here.
|
||||||
|
|
|
||||||
|
| Supported: "file", "cookie", "database", "apc",
|
||||||
|
| "memcached", "redis", "dynamodb", "array"
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'driver' => env('SESSION_DRIVER', 'file'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Session Lifetime
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Here you may specify the number of minutes that you wish the session
|
||||||
|
| to be allowed to remain idle before it expires. If you want them
|
||||||
|
| to immediately expire on the browser closing, set that option.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'lifetime' => env('SESSION_LIFETIME', 120),
|
||||||
|
|
||||||
|
'expire_on_close' => false,
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Session Encryption
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This option allows you to easily specify that all of your session data
|
||||||
|
| should be encrypted before it is stored. All encryption will be run
|
||||||
|
| automatically by Laravel and you can use the Session like normal.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'encrypt' => false,
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Session File Location
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| When using the native session driver, we need a location where session
|
||||||
|
| files may be stored. A default has been set for you but a different
|
||||||
|
| location may be specified. This is only needed for file sessions.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'files' => storage_path('framework/sessions'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Session Database Connection
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| When using the "database" or "redis" session drivers, you may specify a
|
||||||
|
| connection that should be used to manage these sessions. This should
|
||||||
|
| correspond to a connection in your database configuration options.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'connection' => env('SESSION_CONNECTION', null),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Session Database Table
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| When using the "database" session driver, you may specify the table we
|
||||||
|
| should use to manage the sessions. Of course, a sensible default is
|
||||||
|
| provided for you; however, you are free to change this as needed.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'table' => 'sessions',
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Session Cache Store
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| While using one of the framework's cache driven session backends you may
|
||||||
|
| list a cache store that should be used for these sessions. This value
|
||||||
|
| must match with one of the application's configured cache "stores".
|
||||||
|
|
|
||||||
|
| Affects: "apc", "dynamodb", "memcached", "redis"
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'store' => env('SESSION_STORE', null),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Session Sweeping Lottery
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Some session drivers must manually sweep their storage location to get
|
||||||
|
| rid of old sessions from storage. Here are the chances that it will
|
||||||
|
| happen on a given request. By default, the odds are 2 out of 100.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'lottery' => [2, 100],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Session Cookie Name
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Here you may change the name of the cookie used to identify a session
|
||||||
|
| instance by ID. The name specified here will get used every time a
|
||||||
|
| new session cookie is created by the framework for every driver.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'cookie' => env(
|
||||||
|
'SESSION_COOKIE',
|
||||||
|
Str::slug(env('APP_NAME', 'laravel'), '_').'_session'
|
||||||
|
),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Session Cookie Path
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| The session cookie path determines the path for which the cookie will
|
||||||
|
| be regarded as available. Typically, this will be the root path of
|
||||||
|
| your application but you are free to change this when necessary.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'path' => '/',
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Session Cookie Domain
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Here you may change the domain of the cookie used to identify a session
|
||||||
|
| in your application. This will determine which domains the cookie is
|
||||||
|
| available to in your application. A sensible default has been set.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'domain' => env('SESSION_DOMAIN', null),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| HTTPS Only Cookies
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| By setting this option to true, session cookies will only be sent back
|
||||||
|
| to the server if the browser has a HTTPS connection. This will keep
|
||||||
|
| the cookie from being sent to you when it can't be done securely.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'secure' => env('SESSION_SECURE_COOKIE'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| HTTP Access Only
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Setting this value to true will prevent JavaScript from accessing the
|
||||||
|
| value of the cookie and the cookie will only be accessible through
|
||||||
|
| the HTTP protocol. You are free to modify this option if needed.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'http_only' => true,
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Same-Site Cookies
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This option determines how your cookies behave when cross-site requests
|
||||||
|
| take place, and can be used to mitigate CSRF attacks. By default, we
|
||||||
|
| will set this value to "lax" since this is a secure default value.
|
||||||
|
|
|
||||||
|
| Supported: "lax", "strict", "none", null
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'same_site' => 'lax',
|
||||||
|
|
||||||
|
];
|
||||||
36
config/view.php
Normal file
36
config/view.php
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| View Storage Paths
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Most templating systems load templates from disk. Here you may specify
|
||||||
|
| an array of paths that should be checked for your views. Of course
|
||||||
|
| the usual Laravel view path has already been registered for you.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'paths' => [
|
||||||
|
resource_path('views'),
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Compiled View Path
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This option determines where all the compiled Blade templates will be
|
||||||
|
| stored for your application. Typically, this is within the storage
|
||||||
|
| directory. However, as usual, you are free to change this value.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'compiled' => env(
|
||||||
|
'VIEW_COMPILED_PATH',
|
||||||
|
realpath(storage_path('framework/views'))
|
||||||
|
),
|
||||||
|
|
||||||
|
];
|
||||||
1
database/.gitignore
vendored
Normal file
1
database/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
*.sqlite*
|
||||||
39
database/factories/UserFactory.php
Normal file
39
database/factories/UserFactory.php
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Factories;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
class UserFactory extends Factory
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Define the model's default state.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function definition()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'name' => $this->faker->name(),
|
||||||
|
'email' => $this->faker->unique()->safeEmail(),
|
||||||
|
'email_verified_at' => now(),
|
||||||
|
'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password
|
||||||
|
'remember_token' => Str::random(10),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicate that the model's email address should be unverified.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||||
|
*/
|
||||||
|
public function unverified()
|
||||||
|
{
|
||||||
|
return $this->state(function (array $attributes) {
|
||||||
|
return [
|
||||||
|
'email_verified_at' => null,
|
||||||
|
];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('password_resets', function (Blueprint $table) {
|
||||||
|
$table->string('email')->index();
|
||||||
|
$table->string('token');
|
||||||
|
$table->timestamp('created_at')->nullable();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('password_resets');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class CreateFailedJobsTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('failed_jobs', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->string('uuid')->unique();
|
||||||
|
$table->text('connection');
|
||||||
|
$table->text('queue');
|
||||||
|
$table->longText('payload');
|
||||||
|
$table->longText('exception');
|
||||||
|
$table->timestamp('failed_at')->useCurrent();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('failed_jobs');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class CreatePersonalAccessTokensTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('personal_access_tokens', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->morphs('tokenable');
|
||||||
|
$table->string('name');
|
||||||
|
$table->string('token', 64)->unique();
|
||||||
|
$table->text('abilities')->nullable();
|
||||||
|
$table->timestamp('last_used_at')->nullable();
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('personal_access_tokens');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class CreateDealersTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('dealers', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->string('dealer_code')->unique();
|
||||||
|
$table->string('name');
|
||||||
|
$table->text('address');
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('dealers');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class CreateCategoriesTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('categories', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->string('name');
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('categories');
|
||||||
|
}
|
||||||
|
}
|
||||||
33
database/migrations/2022_05_20_100335_create_works_table.php
Normal file
33
database/migrations/2022_05_20_100335_create_works_table.php
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class CreateWorksTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('works', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->string('name');
|
||||||
|
$table->text('desc');
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('works');
|
||||||
|
}
|
||||||
|
}
|
||||||
39
database/migrations/2022_05_20_100340_create_users_table.php
Normal file
39
database/migrations/2022_05_20_100340_create_users_table.php
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class CreateUsersTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('users', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->string('name');
|
||||||
|
$table->bigInteger('dealer_id')->unsigned();
|
||||||
|
$table->foreign('dealer_id')->references('id')->on('dealers')->onDelete('cascade');
|
||||||
|
$table->enum('role', ['admin', 'sa', 'mechanic']);
|
||||||
|
$table->string('email')->unique();
|
||||||
|
$table->timestamp('email_verified_at')->nullable();
|
||||||
|
$table->string('password');
|
||||||
|
$table->rememberToken();
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('users');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class CreateTransactionsTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('transactions', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->bigInteger('user_id')->unsigned();
|
||||||
|
$table->bigInteger('user_sa_id')->unsigned();
|
||||||
|
$table->bigInteger('work_id')->unsigned();
|
||||||
|
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
|
||||||
|
$table->foreign('user_sa_id')->references('id')->on('users');
|
||||||
|
$table->string('spk');
|
||||||
|
$table->string('police_number');
|
||||||
|
$table->tinyInteger('warranty');
|
||||||
|
$table->dateTime('tanggal');
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('transactions');
|
||||||
|
}
|
||||||
|
}
|
||||||
33
database/migrations/2022_05_25_024641_update_works_table.php
Normal file
33
database/migrations/2022_05_25_024641_update_works_table.php
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class UpdateWorksTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::table('works', function($table) {
|
||||||
|
$table->bigInteger('category_id')->unsigned();
|
||||||
|
$table->foreign('category_id')->references('id')->on('categories')->onDelete('cascade');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('works', function($table) {
|
||||||
|
$table->dropColumn('category_id');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class UpdateCategoriesTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::table('categories', function (Blueprint $table) {
|
||||||
|
$table->enum('form', ['work', 'wash']);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('categories', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('form');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class UpdateTransactionTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::table('transactions', function (Blueprint $table) {
|
||||||
|
$table->enum('form', ['work', 'wash']);
|
||||||
|
$table->bigInteger('qty')->unsigned();
|
||||||
|
$table->renameColumn('tanggal', 'date');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('transactions', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('form');
|
||||||
|
$table->dropColumn('qty');
|
||||||
|
$table->renameColumn('date', 'tanggal');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class UpdateTableWorksAddShortnameField extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::table('works', function (Blueprint $table) {
|
||||||
|
$table->string("shortname");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('works', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('shortname');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class UpdateDealersTableAddPicField extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::table('dealers', function (Blueprint $table) {
|
||||||
|
$table->bigInteger("pic")->unsigned()->nullable();
|
||||||
|
$table->foreign('pic')->references('id')->on('users')->onDelete('cascade');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('dealers', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('pic');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class UpdateTransactionsTableAddStatusColumn extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::table('transactions', function (Blueprint $table) {
|
||||||
|
$table->tinyInteger('status')->default('0');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('transactions', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('status');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class UpdateTransactionTableAddDealerId extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::table('transactions', function (Blueprint $table) {
|
||||||
|
$table->bigInteger('dealer_id')->unsigned();
|
||||||
|
$table->foreign('dealer_id')->references('id')->on('dealers')->onDelete('cascade');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('transactions', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('dealer_id');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class AddDeletedAtAtUsersTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::table('users', function (Blueprint $table) {
|
||||||
|
$table->softDeletes();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('users', function (Blueprint $table) {
|
||||||
|
$table->dropSoftDeletes();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class AddDeletedAtAtDealersTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::table('dealers', function (Blueprint $table) {
|
||||||
|
$table->softDeletes();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('dealers', function (Blueprint $table) {
|
||||||
|
$table->dropSoftDeletes();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class AddDeletedAtAtCategoriesTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::table('categories', function (Blueprint $table) {
|
||||||
|
$table->softDeletes();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('categories', function (Blueprint $table) {
|
||||||
|
$table->dropSoftDeletes();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class AddDeletedAtAtWorksTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::table('works', function (Blueprint $table) {
|
||||||
|
$table->softDeletes();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('works', function (Blueprint $table) {
|
||||||
|
$table->dropSoftDeletes();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class AddDeletedAtAtTransactionsTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::table('transactions', function (Blueprint $table) {
|
||||||
|
$table->softDeletes();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('transactions', function (Blueprint $table) {
|
||||||
|
$table->dropSoftDeletes();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
33
database/migrations/2023_08_11_140743_create_roles_table.php
Normal file
33
database/migrations/2023_08_11_140743_create_roles_table.php
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class CreateRolesTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('roles', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->string('name');
|
||||||
|
$table->softDeletes();
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('roles');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class CreatePrivilegesTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('privileges', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->string('name');
|
||||||
|
$table->bigInteger('role_id')->unsigned();
|
||||||
|
$table->foreign('role_id')->references('id')->on('roles');
|
||||||
|
$table->tinyInteger('create');
|
||||||
|
$table->tinyInteger('update');
|
||||||
|
$table->tinyInteger('delete');
|
||||||
|
$table->tinyInteger('view');
|
||||||
|
$table->softDeletes();
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('privileges');
|
||||||
|
}
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user