-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e3ee6ef
commit 50df646
Showing
25 changed files
with
1,616 additions
and
181 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,164 @@ | ||
<?php | ||
|
||
/* | ||
+---------------------------------------------------------------------------+ | ||
| Laralum Developer Data Fetcher | | ||
+---------------------------------------------------------------------------+ | ||
| | | ||
| * Requires: | | ||
| | | ||
| $row - The row information | | ||
| | | ||
| * Available variables: | | ||
| | | ||
| $data - The table settings | | ||
| $table - The table name +-------------+ | ||
| $hidden: Columns that will not be displayed in the edit form, and they won't be updated +----------------------------+ | ||
| $empty: Columns that will not have their current value when editing them (eg: password field is hidden in the model) | | ||
| $confirmed: fields that will need to be confirmed twice +-+ | ||
| $encrypted: Fields that will be encrypted using: Crypt::encrypt(); when they are saved and decrypted when editing them +---------------------------+ | ||
| $hashed: Fields that will be hashed when they are saved in the database, will be empty on editing, and if saved as empty they will not be modified | | ||
| $masked: Fields that will be displayed as a type='password', so their content when beeing modified won't be visible +------------------------------+ | ||
| $default_random: Fields that if no data is set, they will be randomly generated (10 characters) +-------------------+ | ||
| $su_hidden: Columns that will be added to the hidden array if the user is su +------------------+ | ||
| $columns: the row columns +--+ | ||
| $fields: get the available fields | | ||
| | | ||
+---------------------------------------------------------------------------+ | ||
| | | ||
| This file creates the variables nessesary to make | | ||
| the dynamic field edition avialable to all the controllers | | ||
| regardless of it's differences. | | ||
| | | ||
+---------------------------------------------------------------------------+ | ||
*/ | ||
|
||
require('../app/Http/Controllers/Admin/Data/DevData.php'); | ||
|
||
|
||
|
||
|
||
if(array_key_exists($name, $data)) { | ||
$data = $data[$name]; | ||
if(!array_key_exists('create', $data)){ | ||
$data['create'] = []; | ||
} | ||
if(!array_key_exists('edit', $data)){ | ||
$data['edit'] = []; | ||
} | ||
} else { | ||
$data = ['create' => [], 'edit' => []]; | ||
} | ||
|
||
|
||
|
||
|
||
# Get the table data | ||
$table = $name; | ||
|
||
|
||
|
||
if(array_key_exists('allow', $data['create'])) { | ||
$allow = $data['create']['allow']; | ||
} else { | ||
$allow = true; | ||
} | ||
|
||
$su_hidden = []; | ||
$empty = []; | ||
|
||
if(array_key_exists('hidden', $data['create'])) { | ||
$hidden = $data['create']['hidden']; | ||
} else { | ||
$hidden = []; | ||
} | ||
|
||
if(array_key_exists('default_random', $data['create'])) { | ||
$default_random = $data['create']['default_random']; | ||
} else { | ||
$default_random = []; | ||
} | ||
|
||
if(array_key_exists('confirmed', $data['create'])) { | ||
$confirmed = $data['create']['confirmed']; | ||
} else { | ||
$confirmed = []; | ||
} | ||
|
||
if(array_key_exists('encrypted', $data['create'])) { | ||
$encrypted = $data['create']['encrypted']; | ||
} else { | ||
$encrypted = []; | ||
} | ||
|
||
if(array_key_exists('hashed', $data['create'])) { | ||
$hashed = $data['create']['hashed']; | ||
} else { | ||
$hashed = []; | ||
} | ||
|
||
if(array_key_exists('masked', $data['create'])) { | ||
$masked = $data['create']['masked']; | ||
} else { | ||
$masked = []; | ||
} | ||
|
||
if(array_key_exists('validator', $data['create'])) { | ||
$validator = $data['create']['validator']; | ||
} else { | ||
$validator = []; | ||
} | ||
|
||
if(array_key_exists('code', $data['edit'])) { | ||
$code = $data['edit']['code']; | ||
} else { | ||
$code = []; | ||
} | ||
|
||
if(array_key_exists('wysiwyg', $data['create'])) { | ||
$wysiwyg = $data['create']['wysiwyg']; | ||
} else { | ||
$wysiwyg = []; | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
# Get the row table columns | ||
$columns = Schema::getColumnListing($table); | ||
|
||
# Add su_hidden to hidden if the row is su | ||
if(Schema::hasColumn($table, 'su') and $row->su) { | ||
# Add the su_hidden fields to the hiden variable | ||
foreach($su_hidden as $su_hid) { | ||
array_push($hidden, $su_hid); | ||
} | ||
} | ||
|
||
# Gets the fields available to edit / update | ||
$final_columns = []; | ||
foreach($columns as $column) { | ||
$add = true; | ||
foreach($hidden as $hide) { | ||
if($column == $hide) { | ||
$add = false; | ||
} | ||
} | ||
if($add) { | ||
array_push($final_columns, $column); | ||
} | ||
} | ||
$fields = $final_columns; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
<?php | ||
|
||
/* | ||
+---------------------------------------------------------------------------+ | ||
| Laralum Data Saver | | ||
+---------------------------------------------------------------------------+ | ||
| | | ||
| * Requires: | | ||
| | | ||
| $row - The row information | | ||
| $request - The form requrest information | | ||
| | | ||
+---------------------------------------------------------------------------+ | ||
| | | ||
| This files saves the new information to the database | | | ||
| | | ||
+---------------------------------------------------------------------------+ | ||
*/ | ||
|
||
include('DevGet.php'); | ||
|
||
# Validate The Request | ||
$this->validate($request, $validator); | ||
|
||
# Update the row | ||
foreach($fields as $field) { | ||
|
||
$save = true; | ||
|
||
# Check the field type | ||
$type = Schema::getColumnType($table, $field); | ||
|
||
# Get the value | ||
$value = $request->input($field); | ||
|
||
if($type == 'string' or $type == 'integer') { | ||
|
||
# Check if it's a default_random field | ||
foreach($default_random as $random) { | ||
if($random == $field) { | ||
if(!$value) { | ||
$value = str_random(10); | ||
} | ||
} | ||
} | ||
|
||
# Check if it's a hashed field | ||
foreach($hashed as $hash) { | ||
if($hash == $field) { | ||
if($value) { | ||
$value = Hash::make($value); | ||
} else { | ||
$save = false; | ||
} | ||
} | ||
} | ||
|
||
# Check if it's an encrypted field | ||
foreach($encrypted as $encrypt) { | ||
if($encrypt == $field) { | ||
$value = Crypt::encrypt($value); | ||
} | ||
} | ||
|
||
# Save it | ||
if($save) { | ||
$update[$field] = $value; | ||
} | ||
|
||
} elseif($type == 'boolean') { | ||
|
||
# Save it | ||
if($value) { | ||
$update[$field] = true; | ||
} else { | ||
$update[$field] = false; | ||
} | ||
|
||
} else { | ||
# Save it | ||
$update[$field] = $value; | ||
} | ||
} | ||
|
||
# Save the row | ||
DB::table($name)->insert($update); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
|
||
<?php | ||
/* | ||
+---------------------------------------------------------------------------+ | ||
| Laralum Developer Data Configuration | | ||
+---------------------------------------------------------------------------+ | ||
| | | ||
| * Available settings: | | ||
| | | ||
| hide_display: Hides the field when the table is displayed | | ||
| table: The table name +-------------+ | ||
| hidden: Columns that will not be displayed in the edit form, and they won't be updated +----------------------------+ | ||
| empty: Columns that will not have their current value when editing them (eg: password field is hidden in the model) | | ||
| confirmed: fields that will need to be confirmed twice +-+ | ||
| encrypted: Fields that will be encrypted using: Crypt::encrypt(); when they are saved and decrypted when editing them +---------------------------+ | ||
| hashed: Fields that will be hashed when they are saved in the database, will be empty on editing, and if saved as empty they will not be modified | | ||
| masked: Fields that will be displayed as a type='password', so their content when beeing modified won't be visible +------------------------------+ | ||
| default_random: Fields that if no data is set, they will be randomly generated (10 characters) +-------------------+ | ||
| su_hidden: Columns that will be added to the hidden array if the user is su +------------------+ | ||
| code: Fields that can be edited using a code editor +-+ | ||
| wysiwyg: Fields that can be edited using a wysiwyg editor | | ||
| validator: validator settings when executing: $this->validate(); | | ||
| allow: allows to create/edit the row | | ||
| delete: allows to delete the row | | ||
| | | ||
| Note: The first index indicates the table name | | ||
| | | ||
+---------------------------------------------------------------------------+ | ||
| | | ||
| This file allows you to setup all the information | | ||
| to be able to manage your app without problems | | ||
| | | ||
+---------------------------------------------------------------------------+ | ||
*/ | ||
|
||
if(!isset($row)){ | ||
# the row will be the user logged in if no row is set | ||
$row = Auth::user(); | ||
} | ||
|
||
$data = [ | ||
|
||
|
||
'users' => [ | ||
|
||
'hide_display' => ['password'], | ||
'delete' => false, | ||
'create' => [ | ||
'allowed' => true, | ||
'hidden' => ['id', 'su', 'active', 'banned', 'register_ip', 'activation_key', 'remember_token', 'created_at', 'updated_at'], | ||
'default_random' => ['password'], | ||
'confirmed' => ['password'], | ||
'encrypted' => [], | ||
'hashed' => ['password'], | ||
'masked' => ['password'], | ||
'code' => [], | ||
'wysiwyg' => [], | ||
'validator' => [ | ||
'name' => 'required|max:255', | ||
'email' => 'required|email|unique:users', | ||
'password' => 'confirmed|min:6', | ||
'country_code' => 'required', | ||
], | ||
], | ||
'edit' => [ | ||
'hidden' => ['id', 'su', 'email', 'register_ip', 'activation_key', 'remember_token', 'created_at', 'updated_at'], | ||
'su_hidden' => ['name', 'active', 'banned', 'password', 'country_code'], | ||
'empty' => ['password'], | ||
'default_random' => [], | ||
'confirmed' => ['password'], | ||
'encrypted' => [], | ||
'hashed' => ['password'], | ||
'masked' => ['password'], | ||
'code' => [], | ||
'wysiwyg' => [], | ||
'validator' => [ | ||
'name' => 'sometimes|required|max:255', | ||
'password' => 'sometimes|confirmed|min:6', | ||
'country_code' => 'sometimes|required', | ||
], | ||
], | ||
], | ||
|
||
'settings' => [ | ||
'create' => [ | ||
'allow' => false, | ||
], | ||
] | ||
]; |
Oops, something went wrong.