Skip to content

Commit

Permalink
Merge branch '5.4.0' into remove_images
Browse files Browse the repository at this point in the history
  • Loading branch information
imanghafoori1 authored Mar 16, 2018
2 parents 28a0823 + 0ce145d commit 90125dd
Show file tree
Hide file tree
Showing 31 changed files with 220 additions and 163 deletions.
7 changes: 3 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@
"require": {
"php":">=5.6",
"barryvdh/laravel-dompdf": "0.8.*",
"doctrine/dbal": "~2.3",
"maatwebsite/excel": "~2.1.0",
"unisharp/laravel-filemanager": "1.7.*",
"intervention/imagecache": "2.*",
"doctrine/dbal": "~2.3",
"maatwebsite/excel": "~2.1.0",
"unisharp/laravel-filemanager": "1.7.7",
"imanghafoori/laravel-widgetize": "1.8.*"
},
"autoload": {
Expand Down
8 changes: 7 additions & 1 deletion docs/en/form-money.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,15 @@ Input text with auto money number format
```php
$this->form[] = ['label'=>'Price','name'=>'price','type'=>'money'];
```
### Custom Money Format
```php
$this->form[] = ['label'=>'Price','name'=>'price','type'=>'money', 'priceformat_parameters' => ['prefix' => 'Rp. ', 'thousandsSeparator' => '.', 'centsSeparator' => ',', 'centsLimit' => 2 ]];
// Rp. 1.000,00
```
Add `priceformat_parameters` attribute value with [JQuery Price Format parameters](http://flaviosilveira.com/Jquery-Price-Format/)

## What's Next
- [Form Input Type: number](./form-number.md)

## Table Of Contents
- [Back To Index](./index.md)
- [Back To Index](./index.md)
42 changes: 5 additions & 37 deletions src/CRUDBoosterServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,11 @@ public function boot()

if(!file_exists(app_path('Http/Controllers/AdminCmsUsersController.php'))) {
$this->publishes([__DIR__.'/userfiles/controllers/AdminCmsUsersController.php' => app_path('Http/Controllers/AdminCmsUsersController.php')],'cb_user_controller');
}
}

/* Symlink Fixed If Missing */
$this->symlinkFixed();
$this->publishes([
__DIR__.'/assets'=>public_path('vendor/crudbooster')
],'cb_asset');

require __DIR__.'/validations/validation.php';
require __DIR__.'/routes.php';
Expand Down Expand Up @@ -67,7 +68,6 @@ public function register()
$this->commands('crudboosterinstall');
$this->commands('crudboosterupdate');


$this->app->register('Barryvdh\DomPDF\ServiceProvider');
$this->app->register('Maatwebsite\Excel\ExcelServiceProvider');
$this->app->register('Unisharp\Laravelfilemanager\LaravelFilemanagerServiceProvider');
Expand All @@ -91,37 +91,5 @@ private function registerCrudboosterCommand()
$this->app->singleton('crudboosterupdate',function() {
return new CrudboosterUpdateCommand;
});
}

private function symlinkFixed() {
//Create vendor folder at public
if(!file_exists(public_path('vendor'))) {
mkdir(public_path('vendor'),0777);
}

//Create symlink for uploads path
//Deprecated for a while, because uploads now handled by FileController.php
// if(file_exists(public_path('uploads'))) {
// $uploadPath = public_path('uploads');
// if(realpath($uploadPath) == $uploadPath) {
// // rrmdir(public_path('uploads'));
// rename(public_path('uploads'),'uploads.old.'.str_random(5));
// app('files')->link(storage_path('app'), public_path('uploads'));
// }
// }else{
// app('files')->link(storage_path('app'), public_path('uploads'));
// }

//Crate symlink for assets
if(file_exists(public_path('vendor'.DIRECTORY_SEPARATOR.'crudbooster'))) {
$vendorpath = public_path('vendor'.DIRECTORY_SEPARATOR.'crudbooster');
if(realpath($vendorpath) == $vendorpath) {
// rrmdir(public_path('vendor'.DIRECTORY_SEPARATOR.'crudbooster'));
rename(public_path('vendor'.DIRECTORY_SEPARATOR.'crudbooster'),'crudbooster.old.'.str_random(5));
app('files')->link(__DIR__.'/assets',public_path('vendor/crudbooster'));
}
}else{
app('files')->link(__DIR__.'/assets',public_path('vendor/crudbooster'));
}
}
}
}
3 changes: 3 additions & 0 deletions src/assets/assets/adminlte/dist/css/AdminLTE.css
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,9 @@ a:focus {
.user-panel:after {
clear: both;
}
.user-panel > .image {
min-height: 45px;
}
.user-panel > .image > img {
width: 100%;
max-width: 45px;
Expand Down
2 changes: 1 addition & 1 deletion src/assets/assets/adminlte/dist/css/AdminLTE.min.css

Large diffs are not rendered by default.

16 changes: 10 additions & 6 deletions src/commands/CrudboosterInstallationCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,17 @@ public function handle()
}


if($this->confirm('Do you have setting the database configuration at .env ?')) {
if($this->confirm('Do you have setting the database configuration at .env ?')) {

if(!file_exists(public_path('vendor'))) {
mkdir(public_path('vendor'),0777);
}

$this->info('Publishing CRUDBooster needs file...');
$this->callSilent('vendor:publish');
$this->callSilent('vendor:publish',['--tag'=>'cb_migration','--force'=>true]);
$this->callSilent('vendor:publish',['--tag'=>'cb_lfm','--force'=>true]);
$this->callSilent('vendor:publish',['--tag'=>'cb_localization','--force'=>true]);
$this->call('vendor:publish');
$this->call('vendor:publish',['--tag'=>'cb_migration','--force'=>true]);
$this->call('vendor:publish',['--tag'=>'cb_lfm','--force'=>true]);
$this->call('vendor:publish',['--tag'=>'cb_localization','--force'=>true]);

$configLFM = config_path('lfm.php');
$configLFM = file_get_contents($configLFM);
Expand All @@ -82,7 +86,7 @@ public function handle()
if (!class_exists('CBSeeder')) {
require_once __DIR__.'/../database/seeds/CBSeeder.php';
}
$this->callSilent('db:seed',['--class' => 'CBSeeder']);
$this->call('db:seed',['--class' => 'CBSeeder']);
$this->call('config:clear');
$this->call('optimize');

Expand Down
16 changes: 10 additions & 6 deletions src/commands/CrudboosterUpdateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,17 @@ public function handle()
$this->header();
$this->checkRequirements();

$this->info('Updating: ');
$this->info('Updating: ');

if(!file_exists(public_path('vendor'))) {
mkdir(public_path('vendor'),0777);
}

$this->info('Publishing CRUDBooster needs file...');
$this->callSilent('vendor:publish');
$this->callSilent('vendor:publish',['--tag'=>'cb_migration','--force'=>true]);
$this->callSilent('vendor:publish',['--tag'=>'cb_lfm','--force'=>true]);
$this->callSilent('vendor:publish',['--tag'=>'cb_localization','--force'=>true]);
$this->call('vendor:publish');
$this->call('vendor:publish',['--tag'=>'cb_migration','--force'=>true]);
$this->call('vendor:publish',['--tag'=>'cb_lfm','--force'=>true]);
$this->call('vendor:publish',['--tag'=>'cb_localization','--force'=>true]);

$configLFM = config_path('lfm.php');
$configLFM = file_get_contents($configLFM);
Expand All @@ -70,7 +74,7 @@ public function handle()
if (!class_exists('CBSeeder')) {
require_once __DIR__.'/../database/seeds/CBSeeder.php';
}
$this->callSilent('db:seed',['--class' => 'CBSeeder']);
$this->call('db:seed',['--class' => 'CBSeeder']);

$this->info('Clearing Cache...');
Cache::flush();
Expand Down
10 changes: 7 additions & 3 deletions src/configs/crudbooster.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@

'ADMIN_PATH' =>'admin',

/*
To Allowed Specific User Agent Only
E.g : ['Android','OkHttp','Mozilla','Mac']
*/
'API_USER_AGENT_ALLOWED' => [],

'USER_TABLE' =>'cms_users',

'IMAGE_FIELDS_CANDIDATE' =>'image,picture,photo,photos,foto,gambar,thumbnail',
Expand Down Expand Up @@ -64,8 +70,6 @@

/*
* NOTE :
* As a default, CRUDBooster making a cache for the configuration with command `php artisan config:cache`. It means any changes that you've made,
* would not make an effect, until you run `php artisan config:cache` again.
*
* Make sure yo clear your config cache by using command : php artisan config:clear
*/
];
50 changes: 22 additions & 28 deletions src/controllers/ApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public function execute_api() {

$action_type = $row_api->aksi;
$table = $row_api->tabel;
$pk = CRUDBooster::pk($table);

$debug_mode_message = 'You are in debug mode !';

Expand Down Expand Up @@ -91,6 +92,7 @@ public function execute_api() {
@$parameters = unserialize( $row_api->parameters );
@$responses = unserialize( $row_api->responses );


/*
| ----------------------------------------------
| User Data Validation
Expand All @@ -111,15 +113,19 @@ public function execute_api() {
$used = $param['used'];
$format_validation = array();

if ( $used == 0 ) {
if( $used && !$required && $value == '' && !in_array($type, ['image','file'])) {
continue;
}

if ( $used == '0' ) {
continue;
}

if ( $param['config'] && substr( $param['config'], 0, 1 ) != '*' ) {
if ( $config && substr( $config, 0, 1 ) == '*' ) {
continue;
}

if ( $required ) {
if ( $required == '1' ) {
$format_validation[] = 'required';
}

Expand Down Expand Up @@ -159,13 +165,14 @@ public function execute_api() {

if ( $name == 'id' ) {
$table_exist = CRUDBooster::parseSqlTable( $table )['table'];
$format_validation[] = 'exists:' . $table_exist . ',id';
$table_exist_pk = CRUDBooster::pk($table_exist);
$format_validation[] = 'exists:' . $table_exist . ','.$table_exist_pk;
}

$input_validator[ $name ] = $value;
$data_validation[ $name ] = implode( '|', $format_validation );
$input_validator[ $name ] = trim($value);
if(count($format_validation)) $data_validation[ $name ] = implode( '|', $format_validation );
}

$validator = Validator::make( $input_validator, $data_validation );
if ( $validator->fails() ) {
$message = $validator->errors()->all();
Expand All @@ -188,7 +195,7 @@ public function execute_api() {

$limit = ( $posts['limit'] ) ?: 20;
$offset = ( $posts['offset'] ) ?: 0;
$orderby = ( $posts['orderby'] ) ?: $table . '.id,desc';
$orderby = ( $posts['orderby'] ) ?: $table . '.'.$pk.',desc';
$uploads_format_candidate = explode( ',', config( "crudbooster.UPLOAD_TYPES" ) );
$uploads_candidate = explode( ',', config( 'crudbooster.IMAGE_FIELDS_CANDIDATE' ) );
$password_candidate = explode( ',', config( 'crudbooster.PASSWORD_FIELDS_CANDIDATE' ) );
Expand All @@ -201,7 +208,7 @@ public function execute_api() {
if ( $action_type == 'list' || $action_type == 'detail' || $action_type == 'delete' ) {
$name_tmp = array();
$data = DB::table( $table );
$data->skip( $offset );
if($offset) $data->skip( $offset );
$data->take( $limit );
foreach ( $responses as $resp ) {
$name = $resp['name'];
Expand Down Expand Up @@ -241,8 +248,8 @@ public function execute_api() {
if ( CRUDBooster::isForeignKey( $name ) ) {
$jointable = CRUDBooster::getTableForeignKey( $name );
$jointable_field = CRUDBooster::getTableColumns( $jointable );

$data->leftjoin( $jointable, $jointable . '.id', '=', $table . '.' . $name );
$jointablePK = CRUDBooster::pk($jointable);
$data->leftjoin( $jointable, $jointable . '.'. $jointablePK , '=', $table . '.' . $name );
foreach ( $jointable_field as $jf ) {
$jf_alias = $jointable . '_' . $jf;
if ( in_array( $jf_alias, $responses_fields ) ) {
Expand Down Expand Up @@ -312,10 +319,6 @@ public function execute_api() {
continue;
}

if ( $param['config'] != '' && substr( $param['config'], 0, 1 ) != '*' ) {
$value = $param['config'];
}

if ( $required == '1' ) {
if ( CRUDBooster::isColumnExists( $table, $name ) ) {
$w->where( $table . '.' . $name, $value );
Expand Down Expand Up @@ -377,7 +380,7 @@ public function execute_api() {
$orderby_col = $orderby_raw[0];
$orderby_val = $orderby_raw[1];
} else {
$orderby_col = $table . '.id';
$orderby_col = $table . '.'.$pk;
$orderby_val = 'desc';
}

Expand Down Expand Up @@ -425,11 +428,6 @@ public function execute_api() {
$used = $param['used'];
$required = $param['required'];

if ( $param['config'] != '' && substr( $param['config'], 0, 1 ) != '*' ) {
$value = $param['config'];
}


if ( $required ) {
if ( $type == 'password' ) {
if ( ! Hash::check( $value, $rows->{$name} ) ) {
Expand Down Expand Up @@ -546,15 +544,11 @@ public function execute_api() {
continue;
}

if ( substr( $param['config'], 0, 1 ) != '*' ) {
$value = $param['config'];
}

if ( $type == 'file' || $type == 'image' ) {
if ( Request::hasFile( $name ) ) {
$file = Request::file( $name );
$ext = $file->getClientOriginalExtension();
$filePath = 'uploads/'.CRUDBooster::myId().'/'.date('Y-m');
$filePath = 'uploads/'.date('Y-m');

//Create Directory Monthly
Storage::makeDirectory($filePath);
Expand All @@ -574,7 +568,7 @@ public function execute_api() {
@$mime_type = $mime_type[1];
if($mime_type) {
if(in_array($mime_type, $uploads_format_candidate)) {
$filePath = 'uploads/'.CRUDBooster::myId().'/'.date('Y-m');
$filePath = 'uploads/'.date('Y-m');
Storage::makeDirectory($filePath);
$filename = md5(str_random(5)).'.'.$mime_type;
if(Storage::put($filePath.'/'.$filename,$filedata)) {
Expand Down Expand Up @@ -668,7 +662,7 @@ public function execute_api() {

$this->hook_after( $posts, $result );

return response()->json( $result, $result['api_http'] );
return response()->json( $result, 200 );
}

protected function isJSON( $theData ) {
Expand Down
Loading

0 comments on commit 90125dd

Please sign in to comment.