diff --git a/app/Http/Controllers/AddMemberController.php b/app/Http/Controllers/AddMemberController.php new file mode 100644 index 0000000000000000000000000000000000000000..51854e9cfe72d855b5f5c8dc190166a8ae6f8e21 --- /dev/null +++ b/app/Http/Controllers/AddMemberController.php @@ -0,0 +1,156 @@ +<?php + +namespace App\Http\Controllers; + +use Illuminate\Http\Request; +use Illuminate\Support\Facades\Storage; +use Illuminate\Support\Collection; +use Excel; +use DB; +use App\Member; + +class AddMemberController extends Controller +{ + + public function __construct() + { + $this->middleware('admin'); + } + + /** + * Display a listing of the resource. + * + * @return \Illuminate\Http\Response + */ + public function index() + { + return view('admin.addmember'); + } + + /** + * 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 importCSV(Request $request) + { + $array_members = collect(); + if ($request->hasFile('list_members')) { + $extension = $request->file('list_members')->getClientOriginalExtension(); + if ($extension === 'csv') { + $path = $request->file('list_members')->getRealPath(); + $data = Excel::load($path, function($reader) {})->get(); + if (!empty($data)) { + foreach ($data as $key=>$value) { + $member = Member::create([ + 'nim' => $value->nim, + 'name' => $value->name, + 'email' => $value->email, + 'phone_number' => $value->phone_number, + 'interest' => 'none', + 'company' => 'none', + ]); + $member->save(); + + $member = Member::where('email', $value->email)->first(); + $array_members->push($member); + } + } + } + } + + $members = Member::orderBy('name','asc')->paginate(30); + return view('members.list')->with('members', $members)->with('success', 'Members Imported'); + } + + public function importMember(Request $request) + { + $this->validate($request, [ + 'email' => + array( + 'required', + 'regex:/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}/'), + 'phone_number' => + array( + 'required', + 'regex:/^[0-9]+$/'), + 'nim' => + array( + 'required', + 'regex:/^[0-9]+$/'), + 'name' => 'required' + ]); + $array_members = collect(); + + $member = Member::create([ + 'nim' => $request->input('nim'), + 'name' => $request->input('name'), + 'email' => $request->input('email'), + 'phone_number' => $request->input('phone_number'), + 'interest' => 'none', + 'company' => 'none' + ]); + $member->save(); + + $member = Member::where('email', $request->input('email'))->first(); + $array_members->push($member); + + $members = Member::orderBy('name','asc')->paginate(30); + return redirect('/members')->with('members', $members)->with('success', 'Member Added'); + } + + /** + * Display the specified resource. + * + * @param int $id + * @return \Illuminate\Http\Response + */ + public function show($id) + { + + } + + /** + * Show the form for editing the specified resource. + * + * @param int $id + * @return \Illuminate\Http\Response + */ + public function edit($id) + { + // + } + + /** + * Update the specified resource in storage. + * + * @param \Illuminate\Http\Request $request + * @param int $id + * @return \Illuminate\Http\Response + */ + public function update(Request $request, $id) + { + } + + /** + * Remove the specified resource from storage. + * + * @param int $id + * @return \Illuminate\Http\Response + */ + public function destroy($id) + { + // + } +} diff --git a/app/Http/Controllers/MembersController.php b/app/Http/Controllers/MembersController.php index 50b96c08ab8ffcf748d795216565a4548e24e920..f49c434d3b13da525ae644faded75916b871d011 100644 --- a/app/Http/Controllers/MembersController.php +++ b/app/Http/Controllers/MembersController.php @@ -91,7 +91,10 @@ class MembersController extends Controller array( 'required', 'regex:/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}/'), - 'phone_number' => 'required', + 'phone_number' => + array( + 'required', + 'regex:/^[0-9]+$/'), 'company' => 'required', 'interest' => 'required', 'profile_image' => 'image|nullable|max:1999' diff --git a/app/Member.php b/app/Member.php index e99cefff995ff940624a1731f7758655f8de4368..26c2e80ce350a5fb76696d4c87d4178bd274efb7 100644 --- a/app/Member.php +++ b/app/Member.php @@ -3,8 +3,18 @@ namespace App; use Illuminate\Database\Eloquent\Model; +use Illuminate\Notifications\Notifiable; class Member extends Model { - // + use Notifiable; + + /** + * The attributes that are mass assignable. + * + * @var array + */ + protected $fillable = [ + 'nim','name', 'email', 'phone_number', 'interest', 'company', + ]; } diff --git a/composer.json b/composer.json index 46733f1557278ffc67f0fc960f69deb6562a94ea..f8539e9163c35d603ca02e0a5ecb885cc0c49072 100644 --- a/composer.json +++ b/composer.json @@ -9,7 +9,8 @@ "fideloper/proxy": "~4.0", "laravel/framework": "5.6.*", "laravel/tinker": "~1.0", - "laravelcollective/html": "^5.4.0" + "laravelcollective/html": "^5.4.0", + "maatwebsite/excel": "~2.1.0" }, "require-dev": { "filp/whoops": "~2.0", diff --git a/composer.lock b/composer.lock index e54c6b0b6ca714be589bb2c366a63044d9e26289..06ff48d02a8e8a5139d48ed3705d10361ce19232 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "eee47e5816da11290628da12a27d841e", + "content-hash": "5b6fb45a2bf8d6ef9c5af64b2ba04c5b", "packages": [ { "name": "dnoegel/php-xdg-base-dir", @@ -453,6 +453,64 @@ ], "time": "2015-04-20T18:58:01+00:00" }, + { + "name": "jeremeamia/SuperClosure", + "version": "2.3.0", + "source": { + "type": "git", + "url": "https://github.com/jeremeamia/super_closure.git", + "reference": "443c3df3207f176a1b41576ee2a66968a507b3db" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/jeremeamia/super_closure/zipball/443c3df3207f176a1b41576ee2a66968a507b3db", + "reference": "443c3df3207f176a1b41576ee2a66968a507b3db", + "shasum": "" + }, + "require": { + "nikic/php-parser": "^1.2|^2.0|^3.0", + "php": ">=5.4", + "symfony/polyfill-php56": "^1.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.0|^5.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.3-dev" + } + }, + "autoload": { + "psr-4": { + "SuperClosure\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jeremy Lindblom", + "email": "jeremeamia@gmail.com", + "homepage": "https://github.com/jeremeamia", + "role": "Developer" + } + ], + "description": "Serialize Closure objects, including their context and binding", + "homepage": "https://github.com/jeremeamia/super_closure", + "keywords": [ + "closure", + "function", + "lambda", + "parser", + "serializable", + "serialize", + "tokenizer" + ], + "time": "2016-12-07T09:37:55+00:00" + }, { "name": "laravel/framework", "version": "v5.6.12", @@ -806,6 +864,84 @@ ], "time": "2018-03-01T10:27:04+00:00" }, + { + "name": "maatwebsite/excel", + "version": "2.1.27", + "source": { + "type": "git", + "url": "https://github.com/Maatwebsite/Laravel-Excel.git", + "reference": "ea758fe5a9d33e0d88b40f099d1df652a0c99d38" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Maatwebsite/Laravel-Excel/zipball/ea758fe5a9d33e0d88b40f099d1df652a0c99d38", + "reference": "ea758fe5a9d33e0d88b40f099d1df652a0c99d38", + "shasum": "" + }, + "require": { + "illuminate/cache": "5.0.*|5.1.*|5.2.*|5.3.*|5.4.*|5.5.*|5.6.*", + "illuminate/config": "5.0.*|5.1.*|5.2.*|5.3.*|5.4.*|5.5.*|5.6.*", + "illuminate/filesystem": "5.0.*|5.1.*|5.2.*|5.3.*|5.4.*|5.5.*|5.6.*", + "illuminate/support": "5.0.*|5.1.*|5.2.*|5.3.*|5.4.*|5.5.*|5.6.*", + "jeremeamia/superclosure": "^2.3", + "nesbot/carbon": "~1.0", + "php": ">=5.5", + "phpoffice/phpexcel": "^1.8.1", + "tijsverkoyen/css-to-inline-styles": "~2.0" + }, + "require-dev": { + "mockery/mockery": "~1.0", + "orchestra/testbench": "3.1.*|3.2.*|3.3.*|3.4.*|3.5.*|3.6.*", + "phpseclib/phpseclib": "~1.0", + "phpunit/phpunit": "~4.0" + }, + "suggest": { + "illuminate/http": "5.0.*|5.1.*|5.2.*|5.3.*|5.4.*|5.5.*|5.6.*", + "illuminate/queue": "5.0.*|5.1.*|5.2.*|5.3.*|5.4.*|5.5.*|5.6.*", + "illuminate/routing": "5.0.*|5.1.*|5.2.*|5.3.*|5.4.*|5.5.*|5.6.*", + "illuminate/view": "5.0.*|5.1.*|5.2.*|5.3.*|5.4.*|5.5.*|5.6.*" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "Maatwebsite\\Excel\\ExcelServiceProvider" + ], + "aliases": { + "Excel": "Maatwebsite\\Excel\\Facades\\Excel" + } + } + }, + "autoload": { + "classmap": [ + "src/Maatwebsite/Excel" + ], + "psr-0": { + "Maatwebsite\\Excel\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Maatwebsite.nl", + "email": "patrick@maatwebsite.nl" + } + ], + "description": "An eloquent way of importing and exporting Excel and CSV in Laravel 4 with the power of PHPExcel", + "keywords": [ + "PHPExcel", + "batch", + "csv", + "excel", + "export", + "import", + "laravel" + ], + "time": "2018-03-09T13:14:19+00:00" + }, { "name": "monolog/monolog", "version": "1.23.0", @@ -1036,6 +1172,64 @@ ], "time": "2017-09-27T21:40:39+00:00" }, + { + "name": "phpoffice/phpexcel", + "version": "1.8.1", + "source": { + "type": "git", + "url": "https://github.com/PHPOffice/PHPExcel.git", + "reference": "372c7cbb695a6f6f1e62649381aeaa37e7e70b32" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPOffice/PHPExcel/zipball/372c7cbb695a6f6f1e62649381aeaa37e7e70b32", + "reference": "372c7cbb695a6f6f1e62649381aeaa37e7e70b32", + "shasum": "" + }, + "require": { + "ext-xml": "*", + "ext-xmlwriter": "*", + "php": ">=5.2.0" + }, + "type": "library", + "autoload": { + "psr-0": { + "PHPExcel": "Classes/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL" + ], + "authors": [ + { + "name": "Maarten Balliauw", + "homepage": "http://blog.maartenballiauw.be" + }, + { + "name": "Mark Baker" + }, + { + "name": "Franck Lefevre", + "homepage": "http://blog.rootslabs.net" + }, + { + "name": "Erik Tilt" + } + ], + "description": "PHPExcel - OpenXML - Read, Create and Write Spreadsheet documents in PHP - Spreadsheet engine", + "homepage": "http://phpexcel.codeplex.com", + "keywords": [ + "OpenXML", + "excel", + "php", + "spreadsheet", + "xls", + "xlsx" + ], + "abandoned": "phpoffice/phpspreadsheet", + "time": "2015-05-01T07:00:55+00:00" + }, { "name": "psr/container", "version": "1.0.0", @@ -1874,6 +2068,62 @@ ], "time": "2018-01-30T19:27:44+00:00" }, + { + "name": "symfony/polyfill-php56", + "version": "v1.7.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php56.git", + "reference": "ebc999ce5f14204c5150b9bd15f8f04e621409d8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php56/zipball/ebc999ce5f14204c5150b9bd15f8f04e621409d8", + "reference": "ebc999ce5f14204c5150b9bd15f8f04e621409d8", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "symfony/polyfill-util": "~1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.7-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Php56\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 5.6+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "time": "2018-01-30T19:27:44+00:00" + }, { "name": "symfony/polyfill-php72", "version": "v1.7.0", @@ -1929,6 +2179,58 @@ ], "time": "2018-01-31T17:43:24+00:00" }, + { + "name": "symfony/polyfill-util", + "version": "v1.7.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-util.git", + "reference": "e17c808ec4228026d4f5a8832afa19be85979563" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-util/zipball/e17c808ec4228026d4f5a8832afa19be85979563", + "reference": "e17c808ec4228026d4f5a8832afa19be85979563", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.7-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Util\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony utilities for portability of PHP codes", + "homepage": "https://symfony.com", + "keywords": [ + "compat", + "compatibility", + "polyfill", + "shim" + ], + "time": "2018-01-31T18:08:44+00:00" + }, { "name": "symfony/process", "version": "v4.0.6", diff --git a/config/app.php b/config/app.php index 6644e8ceafffa40b91ee26831f368cc327f62d3f..d6a16399f352ce0d04b81d653cb05f5983ff9718 100644 --- a/config/app.php +++ b/config/app.php @@ -151,7 +151,7 @@ return [ /* * Package Service Providers... */ - + Maatwebsite\Excel\ExcelServiceProvider::class, /* * Application Service Providers... */ @@ -189,6 +189,7 @@ return [ 'DB' => Illuminate\Support\Facades\DB::class, 'Eloquent' => Illuminate\Database\Eloquent\Model::class, 'Event' => Illuminate\Support\Facades\Event::class, + 'Excel' => Maatwebsite\Excel\Facades\Excel::class, 'File' => Illuminate\Support\Facades\File::class, 'Gate' => Illuminate\Support\Facades\Gate::class, 'Hash' => Illuminate\Support\Facades\Hash::class, diff --git a/config/excel.php b/config/excel.php new file mode 100644 index 0000000000000000000000000000000000000000..bf19051a05f2ad1a3b4980eb81beb6dfc63bcc2d --- /dev/null +++ b/config/excel.php @@ -0,0 +1,704 @@ +<?php + +return array( + + 'cache' => [ + + /* + |-------------------------------------------------------------------------- + | Enable/Disable cell caching + |-------------------------------------------------------------------------- + */ + 'enable' => true, + + /* + |-------------------------------------------------------------------------- + | Caching driver + |-------------------------------------------------------------------------- + | + | Set the caching driver + | + | Available methods: + | memory|gzip|serialized|igbinary|discISAM|apc|memcache|temp|wincache|sqlite|sqlite3 + | + */ + 'driver' => 'memory', + + /* + |-------------------------------------------------------------------------- + | Cache settings + |-------------------------------------------------------------------------- + */ + 'settings' => [ + + 'memoryCacheSize' => '32MB', + 'cacheTime' => 600 + + ], + + /* + |-------------------------------------------------------------------------- + | Memcache settings + |-------------------------------------------------------------------------- + */ + 'memcache' => [ + + 'host' => 'localhost', + 'port' => 11211, + + ], + + /* + |-------------------------------------------------------------------------- + | Cache dir (for discISAM) + |-------------------------------------------------------------------------- + */ + + 'dir' => storage_path('cache') + ], + + 'properties' => [ + 'creator' => 'Maatwebsite', + 'lastModifiedBy' => 'Maatwebsite', + 'title' => 'Spreadsheet', + 'description' => 'Default spreadsheet export', + 'subject' => 'Spreadsheet export', + 'keywords' => 'maatwebsite, excel, export', + 'category' => 'Excel', + 'manager' => 'Maatwebsite', + 'company' => 'Maatwebsite', + ], + + /* + |-------------------------------------------------------------------------- + | Sheets settings + |-------------------------------------------------------------------------- + */ + 'sheets' => [ + + /* + |-------------------------------------------------------------------------- + | Default page setup + |-------------------------------------------------------------------------- + */ + 'pageSetup' => [ + 'orientation' => 'portrait', + 'paperSize' => '9', + 'scale' => '100', + 'fitToPage' => false, + 'fitToHeight' => true, + 'fitToWidth' => true, + 'columnsToRepeatAtLeft' => ['', ''], + 'rowsToRepeatAtTop' => [0, 0], + 'horizontalCentered' => false, + 'verticalCentered' => false, + 'printArea' => null, + 'firstPageNumber' => null, + ], + ], + + /* + |-------------------------------------------------------------------------- + | Creator + |-------------------------------------------------------------------------- + | + | The default creator of a new Excel file + | + */ + + 'creator' => 'Maatwebsite', + + 'csv' => [ + /* + |-------------------------------------------------------------------------- + | Delimiter + |-------------------------------------------------------------------------- + | + | The default delimiter which will be used to read out a CSV file + | + */ + + 'delimiter' => ',', + + /* + |-------------------------------------------------------------------------- + | Enclosure + |-------------------------------------------------------------------------- + */ + + 'enclosure' => '"', + + /* + |-------------------------------------------------------------------------- + | Line endings + |-------------------------------------------------------------------------- + */ + + 'line_ending' => "\r\n", + + /* + |-------------------------------------------------------------------------- + | setUseBom + |-------------------------------------------------------------------------- + */ + + 'use_bom' => false + ], + + 'export' => [ + + /* + |-------------------------------------------------------------------------- + | Autosize columns + |-------------------------------------------------------------------------- + | + | Disable/enable column autosize or set the autosizing for + | an array of columns ( array('A', 'B') ) + | + */ + 'autosize' => true, + + /* + |-------------------------------------------------------------------------- + | Autosize method + |-------------------------------------------------------------------------- + | + | --> PHPExcel_Shared_Font::AUTOSIZE_METHOD_APPROX + | The default is based on an estimate, which does its calculation based + | on the number of characters in the cell value (applying any calculation + | and format mask, and allowing for wordwrap and rotation) and with an + | "arbitrary" adjustment based on the font (Arial, Calibri or Verdana, + | defaulting to Calibri if any other font is used) and a proportional + | adjustment for the font size. + | + | --> PHPExcel_Shared_Font::AUTOSIZE_METHOD_EXACT + | The second method is more accurate, based on actual style formatting as + | well (bold, italic, etc), and is calculated by generating a gd2 imagettf + | bounding box and using its dimensions to determine the size; but this + | method is significantly slower, and its accuracy is still dependent on + | having the appropriate fonts installed. + | + */ + 'autosize-method' => PHPExcel_Shared_Font::AUTOSIZE_METHOD_APPROX, + + /* + |-------------------------------------------------------------------------- + | Auto generate table heading + |-------------------------------------------------------------------------- + | + | If set to true, the array indices (or model attribute names) + | will automatically be used as first row (table heading) + | + */ + 'generate_heading_by_indices' => true, + + /* + |-------------------------------------------------------------------------- + | Auto set alignment on merged cells + |-------------------------------------------------------------------------- + */ + 'merged_cell_alignment' => 'left', + + /* + |-------------------------------------------------------------------------- + | Pre-calculate formulas during export + |-------------------------------------------------------------------------- + */ + 'calculate' => false, + + /* + |-------------------------------------------------------------------------- + | Include Charts during export + |-------------------------------------------------------------------------- + */ + 'includeCharts' => false, + + /* + |-------------------------------------------------------------------------- + | Default sheet settings + |-------------------------------------------------------------------------- + */ + 'sheets' => [ + + /* + |-------------------------------------------------------------------------- + | Default page margin + |-------------------------------------------------------------------------- + | + | 1) When set to false, default margins will be used + | 2) It's possible to enter a single margin which will + | be used for all margins. + | 3) Alternatively you can pass an array with 4 margins + | Default order: array(top, right, bottom, left) + | + */ + 'page_margin' => false, + + /* + |-------------------------------------------------------------------------- + | Value in source array that stands for blank cell + |-------------------------------------------------------------------------- + */ + 'nullValue' => null, + + /* + |-------------------------------------------------------------------------- + | Insert array starting from this cell address as the top left coordinate + |-------------------------------------------------------------------------- + */ + 'startCell' => 'A1', + + /* + |-------------------------------------------------------------------------- + | Apply strict comparison when testing for null values in the array + |-------------------------------------------------------------------------- + */ + 'strictNullComparison' => false + ], + + /* + |-------------------------------------------------------------------------- + | Store settings + |-------------------------------------------------------------------------- + */ + + 'store' => [ + + /* + |-------------------------------------------------------------------------- + | Path + |-------------------------------------------------------------------------- + | + | The path we want to save excel file to + | + */ + 'path' => storage_path('exports'), + + /* + |-------------------------------------------------------------------------- + | Return info + |-------------------------------------------------------------------------- + | + | Whether we want to return information about the stored file or not + | + */ + 'returnInfo' => false + + ], + + /* + |-------------------------------------------------------------------------- + | PDF Settings + |-------------------------------------------------------------------------- + */ + 'pdf' => [ + + /* + |-------------------------------------------------------------------------- + | PDF Drivers + |-------------------------------------------------------------------------- + | Supported: DomPDF, tcPDF, mPDF + */ + 'driver' => 'DomPDF', + + /* + |-------------------------------------------------------------------------- + | PDF Driver settings + |-------------------------------------------------------------------------- + */ + 'drivers' => [ + + /* + |-------------------------------------------------------------------------- + | DomPDF settings + |-------------------------------------------------------------------------- + */ + 'DomPDF' => [ + 'path' => base_path('vendor/dompdf/dompdf/') + ], + + /* + |-------------------------------------------------------------------------- + | tcPDF settings + |-------------------------------------------------------------------------- + */ + 'tcPDF' => [ + 'path' => base_path('vendor/tecnick.com/tcpdf/') + ], + + /* + |-------------------------------------------------------------------------- + | mPDF settings + |-------------------------------------------------------------------------- + */ + 'mPDF' => [ + 'path' => base_path('vendor/mpdf/mpdf/') + ], + ] + ] + ], + + 'filters' => [ + /* + |-------------------------------------------------------------------------- + | Register read filters + |-------------------------------------------------------------------------- + */ + + 'registered' => [ + 'chunk' => 'Maatwebsite\Excel\Filters\ChunkReadFilter' + ], + + /* + |-------------------------------------------------------------------------- + | Enable certain filters for every file read + |-------------------------------------------------------------------------- + */ + + 'enabled' => [] + ], + + 'import' => [ + + /* + |-------------------------------------------------------------------------- + | Has heading + |-------------------------------------------------------------------------- + | + | The sheet has a heading (first) row which we can use as attribute names + | + | Options: true|false|slugged|slugged_with_count|ascii|numeric|hashed|hashed_with_lower|trans|original + | + */ + + 'heading' => 'slugged', + + /* + |-------------------------------------------------------------------------- + | First Row with data or heading of data + |-------------------------------------------------------------------------- + | + | If the heading row is not the first row, or the data doesn't start + | on the first row, here you can change the start row. + | + */ + + 'startRow' => 1, + + /* + |-------------------------------------------------------------------------- + | Cell name word separator + |-------------------------------------------------------------------------- + | + | The default separator which is used for the cell names + | Note: only applies to 'heading' settings 'true' && 'slugged' + | + */ + + 'separator' => '_', + + /* + |-------------------------------------------------------------------------- + | Slug whitelisting + |-------------------------------------------------------------------------- + | + | Here you can whitelist certain characters in the slug. + | E.g. user.last_name will not remove . and _ + | Note: only applies to 'heading' settings 'true' && 'slugged' + | + */ + + 'slug_whitelist' => '._', + + /* + |-------------------------------------------------------------------------- + | Include Charts during import + |-------------------------------------------------------------------------- + */ + + 'includeCharts' => false, + + /* + |-------------------------------------------------------------------------- + | Sheet heading conversion + |-------------------------------------------------------------------------- + | + | Convert headings to ASCII + | Note: only applies to 'heading' settings 'true' && 'slugged' + | + */ + + 'to_ascii' => true, + + /* + |-------------------------------------------------------------------------- + | Import encoding + |-------------------------------------------------------------------------- + */ + + 'encoding' => [ + + 'input' => 'UTF-8', + 'output' => 'UTF-8' + + ], + + /* + |-------------------------------------------------------------------------- + | Calculate + |-------------------------------------------------------------------------- + | + | By default cells with formulas will be calculated. + | + */ + + 'calculate' => true, + + /* + |-------------------------------------------------------------------------- + | Ignore empty cells + |-------------------------------------------------------------------------- + | + | By default empty cells are not ignored + | + */ + + 'ignoreEmpty' => false, + + /* + |-------------------------------------------------------------------------- + | Force sheet collection + |-------------------------------------------------------------------------- + | + | For a sheet collection even when there is only 1 sheets. + | When set to false and only 1 sheet found, the parsed file will return + | a row collection instead of a sheet collection. + | When set to true, it will return a sheet collection instead. + | + */ + 'force_sheets_collection' => false, + + /* + |-------------------------------------------------------------------------- + | Date format + |-------------------------------------------------------------------------- + | + | The format dates will be parsed to + | + */ + + 'dates' => [ + + /* + |-------------------------------------------------------------------------- + | Enable/disable date formatting + |-------------------------------------------------------------------------- + */ + 'enabled' => true, + + /* + |-------------------------------------------------------------------------- + | Default date format + |-------------------------------------------------------------------------- + | + | If set to false, a carbon object will return + | + */ + 'format' => false, + + /* + |-------------------------------------------------------------------------- + | Date columns + |-------------------------------------------------------------------------- + */ + 'columns' => [] + ], + + /* + |-------------------------------------------------------------------------- + | Import sheets by config + |-------------------------------------------------------------------------- + */ + 'sheets' => [ + + /* + |-------------------------------------------------------------------------- + | Example sheet + |-------------------------------------------------------------------------- + | + | Example sheet "test" will grab the firstname at cell A2 + | + */ + + 'test' => [ + + 'firstname' => 'A2' + + ] + + ] + ], + + 'views' => [ + + /* + |-------------------------------------------------------------------------- + | Styles + |-------------------------------------------------------------------------- + | + | The default styles which will be used when parsing a view + | + */ + + 'styles' => [ + + /* + |-------------------------------------------------------------------------- + | Table headings + |-------------------------------------------------------------------------- + */ + 'th' => [ + 'font' => [ + 'bold' => true, + 'size' => 12, + ] + ], + + /* + |-------------------------------------------------------------------------- + | Strong tags + |-------------------------------------------------------------------------- + */ + 'strong' => [ + 'font' => [ + 'bold' => true, + 'size' => 12, + ] + ], + + /* + |-------------------------------------------------------------------------- + | Bold tags + |-------------------------------------------------------------------------- + */ + 'b' => [ + 'font' => [ + 'bold' => true, + 'size' => 12, + ] + ], + + /* + |-------------------------------------------------------------------------- + | Italic tags + |-------------------------------------------------------------------------- + */ + 'i' => [ + 'font' => [ + 'italic' => true, + 'size' => 12, + ] + ], + + /* + |-------------------------------------------------------------------------- + | Heading 1 + |-------------------------------------------------------------------------- + */ + 'h1' => [ + 'font' => [ + 'bold' => true, + 'size' => 24, + ] + ], + + /* + |-------------------------------------------------------------------------- + | Heading 2 + |-------------------------------------------------------------------------- + */ + 'h2' => [ + 'font' => [ + 'bold' => true, + 'size' => 18, + ] + ], + + /* + |-------------------------------------------------------------------------- + | Heading 3 + |-------------------------------------------------------------------------- + */ + 'h3' => [ + 'font' => [ + 'bold' => true, + 'size' => 13.5, + ] + ], + + /* + |-------------------------------------------------------------------------- + | Heading 4 + |-------------------------------------------------------------------------- + */ + 'h4' => [ + 'font' => [ + 'bold' => true, + 'size' => 12, + ] + ], + + /* + |-------------------------------------------------------------------------- + | Heading 5 + |-------------------------------------------------------------------------- + */ + 'h5' => [ + 'font' => [ + 'bold' => true, + 'size' => 10, + ] + ], + + /* + |-------------------------------------------------------------------------- + | Heading 6 + |-------------------------------------------------------------------------- + */ + 'h6' => [ + 'font' => [ + 'bold' => true, + 'size' => 7.5, + ] + ], + + /* + |-------------------------------------------------------------------------- + | Hyperlinks + |-------------------------------------------------------------------------- + */ + 'a' => [ + 'font' => [ + 'underline' => true, + 'color' => ['argb' => 'FF0000FF'], + ] + ], + + /* + |-------------------------------------------------------------------------- + | Horizontal rules + |-------------------------------------------------------------------------- + */ + 'hr' => [ + 'borders' => [ + 'bottom' => [ + 'style' => 'thin', + 'color' => ['FF000000'] + ], + ] + ] + ] + + ] + +); diff --git a/database/migrations/2018_03_19_134312_profile_nim.php b/database/migrations/2018_03_19_134312_profile_nim.php new file mode 100644 index 0000000000000000000000000000000000000000..d426bba3df26c711157b72b62937f5a55bf8b592 --- /dev/null +++ b/database/migrations/2018_03_19_134312_profile_nim.php @@ -0,0 +1,32 @@ +<?php + +use Illuminate\Support\Facades\Schema; +use Illuminate\Database\Schema\Blueprint; +use Illuminate\Database\Migrations\Migration; + +class ProfileNim extends Migration +{ + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::table('members', function($table){ + $table->string('nim')->unique(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('members', function($table){ + $table->dropColumn('nim'); + }); + } +} diff --git a/resources/views/admin/addmember.blade.php b/resources/views/admin/addmember.blade.php new file mode 100644 index 0000000000000000000000000000000000000000..4603227f13f7668b97d3130db462585db0214eb3 --- /dev/null +++ b/resources/views/admin/addmember.blade.php @@ -0,0 +1,55 @@ +@extends('layouts.app') + +@section('title', 'Add Member') + +@section('content') + @include('inc.adminmenu') + <main role="main" class="col-7"> + <div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pb-2 mb-3"> + <h2 class="sub-title">Add Members</h2> + </div> + <div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pb-2 mb-3 border-bottom"> + {!! Form::open(['action' => ['AddMemberController@importCSV'], 'method' => 'POST', 'enctype' => 'multipart/form-data']) !!} + <div class="form-group"> + {{Form::label('list_members','Members')}} + {{Form::file('list_members')}} + </div> + {{Form::hidden('_method', 'POST')}} + {{Form::submit('Submit', ['class' => 'btn btn-primary'])}} + {!! Form::close() !!} + </div> + </main> + + <main role="main" class="col-7"> + <div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pb-2 mb-3"> + <h2 class="sub-title">Add Members</h2> + </div> + <div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pb-2 mb-3 border-bottom"> + {!! Form::open(['action' => ['AddMemberController@importMember'], 'method' => 'POST']) !!} + <div class="form-group"> + {{Form::label('nim','Student ID')}} + {{Form::text('nim', '', ['class' => 'form-control'])}} + + {{Form::label('email','Email')}} + {{Form::text('email', '', ['class' => 'form-control'])}} + + {{Form::label('phone_number','Phone Number')}} + {{Form::text('phone_number', '', ['class' => 'form-control'])}} + + {{Form::label('name','Name')}} + {{Form::text('name', '', ['class' => 'form-control'])}} + </div> + {{Form::hidden('_method', 'POST')}} + {{Form::submit('Submit', ['class' => 'btn btn-primary'])}} + {!! Form::close() !!} + </div> + </main> + + <link rel="stylesheet" type="text/css" href={{asset('css/file-upload.css')}} /> + <script src="js/file-upload.js"></script> + <script type="text/javascript"> + $(document).ready(function() { + $('.file-upload').file_upload(); + }); + </script> +@endsection \ No newline at end of file diff --git a/resources/views/admin/showmember.blade.php b/resources/views/admin/showmember.blade.php new file mode 100644 index 0000000000000000000000000000000000000000..d9ae8b1bb1ea82c1312fd2e0c43ac03429745375 --- /dev/null +++ b/resources/views/admin/showmember.blade.php @@ -0,0 +1,23 @@ +<!doctype html> +<html lang="{{ app()->getLocale() }}"> + <head> + <meta charset="utf-8"> + <meta http-equiv="X-UA-Compatible" content="IE=edge"> + <meta name="viewport" content="width=device-width, initial-scale=1"> + <link rel="stylesheet" href="{{asset('css/app.css')}}"> + <link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> + <title>@yield('title')</title> + </head> + <body> + <div class="container"> + @if (count($array_members) > 0) + @foreach($array_members as $member) + {{$member->name}} {{$member->email}} {{$member->phone_number}} {{$member->id}} + <br> + @endforeach + @else + no member added + @endif + </div> + </body> +</html> \ No newline at end of file diff --git a/resources/views/dashboard.blade.php b/resources/views/dashboard.blade.php index 838cce73a8f6861b3d2b5dfb6bce943a11c35141..989462dd071447e8bd265e360e61d0123b6ad3df 100644 --- a/resources/views/dashboard.blade.php +++ b/resources/views/dashboard.blade.php @@ -3,34 +3,8 @@ @section('title', 'Dashboard') @section('content') - <div class="container-fluid"> - <div class="row"> - <nav class="col-3 sidebar"> - <div class="sidebar-sticky"> - <ul class="nav flex-column"> - <li class="nav-item"> - <a class="nav-link active" href="/dashboard"> - <span data-feather="home"></span> - <i class="sideMenu">Dashboard</i><span class="sr-only">(current)</span> - </a> - </li> - <li class="nav-item"> - <a class="nav-link" href="/members"> - <span data-feather="users"></span> - <i class="sideMenu">Members List</i> - </a> - </li> - <li class="nav-item"> - <a class="nav-link" href="/dashboard"> - <span data-feather="file"></span> - <i class="sideMenu">TBD</i> - </a> - </li> - </ul> - </div> - </nav> - - <main role="main" class="col-7"> + @include('inc.adminmenu') + <main role="main" class="col-7"> <div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pb-2 mb-3 border-bottom"> <img src="{{URL::asset('storage/banner.jpg')}}" id="bannerMember"> </div> @@ -44,18 +18,11 @@ </div> </div> - <!-- Bootstrap core JavaScript - ================================================== --> - <!-- Placed at the end of the document so the pages load faster --> - <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script> - <script>window.jQuery || document.write('<script src="../../../../assets/js/vendor/jquery-slim.min.js"><\/script>')</script> - <script src="../../../../assets/js/vendor/popper.min.js"></script> - <script src="../../../../dist/js/bootstrap.min.js"></script> - - <!-- Icons --> - <script src="https://unpkg.com/feather-icons/dist/feather.min.js"></script> - <script> - feather.replace() - </script> -</html> + <!-- Bootstrap core JavaScript + ================================================== --> + <!-- Placed at the end of the document so the pages load faster --> + <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script> + <script>window.jQuery || document.write('<script src="../../../../assets/js/vendor/jquery-slim.min.js"><\/script>')</script> + <script src="../../../../assets/js/vendor/popper.min.js"></script> + <script src="../../../../dist/js/bootstrap.min.js"></script> @endsection diff --git a/resources/views/inc/adminmenu.blade.php b/resources/views/inc/adminmenu.blade.php new file mode 100644 index 0000000000000000000000000000000000000000..e983ccb4078e2b1364a5a0eaf9082272f77d4a2a --- /dev/null +++ b/resources/views/inc/adminmenu.blade.php @@ -0,0 +1,32 @@ +<div class="container-fluid"> + <div class="row"> + <nav class="col-3 sidebar"> + <div class="sidebar-sticky"> + <ul class="nav flex-column"> + <li class="nav-item"> + <a class="nav-link active" href="/dashboard"> + <span data-feather="home"></span> + <i class="sideMenu">Dashboard</i><span class="sr-only">(current)</span> + </a> + </li> + <li class="nav-item"> + <a class="nav-link" href="/members"> + <span data-feather="users"></span> + <i class="sideMenu">Members List</i> + </a> + </li> + <li class="nav-item"> + <a class="nav-link" href="/dashboard/#"> + <span data-feather="file"></span> + <i class="sideMenu">Articles</i> + </a> + </li> + </ul> + </div> + </nav> + + <!-- Icons --> + <script src="https://unpkg.com/feather-icons/dist/feather.min.js"></script> + <script> + feather.replace() + </script> \ No newline at end of file diff --git a/resources/views/inc/navbar.blade.php b/resources/views/inc/navbar.blade.php index 0f49e9b81fc035d3f23780a6edff52d0ee85aeb3..7e82af640067c1435edf6773fd8737dbbe6815fb 100644 --- a/resources/views/inc/navbar.blade.php +++ b/resources/views/inc/navbar.blade.php @@ -18,10 +18,10 @@ <li class="nav-item"> <a class="nav-link" href="/members">Members</a> </li> - @endif <li class="nav-item"> <a class="nav-link" href="#">Articles</a> </li> + @endif </ul> <!-- Right Side Of Navbar --> diff --git a/resources/views/members/list.blade.php b/resources/views/members/list.blade.php index 00ddad1c9edf12408ad61e9f52e4f2f944717d3d..18e358972e6c9a8a11e9e1abd583869a2c951248 100644 --- a/resources/views/members/list.blade.php +++ b/resources/views/members/list.blade.php @@ -52,11 +52,19 @@ @endif </main> </div> - </div> - - <!-- Icons --> - <script src="https://unpkg.com/feather-icons/dist/feather.min.js"></script> - <script> - feather.replace() - </script> + <div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pb-2 mb-3 border-bottom"> + <h1 class="h2">Members List</h1> + <a href="/addmember" class="btn btn-primary">Add Member</a> + </div> + @if(count($members) > 0) + @foreach($members as $member) + <div class="list-group-item"> + <h4><a href="/members/{{$member->id}}">{{$member->name}}</a></h4> + </div> + @endforeach + <ul class="pagination pull-right">{{$members->links()}}</ul> + @else + <p>No member.</p> + @endif + </main> @endsection \ No newline at end of file diff --git a/resources/views/users/profile.blade.php b/resources/views/users/profile.blade.php index b13c9ab27c45905404780fd0ed2e5fe32301b45f..ace7e141c252f3397b65416e02ce900b8db3f8c5 100644 --- a/resources/views/users/profile.blade.php +++ b/resources/views/users/profile.blade.php @@ -8,7 +8,7 @@ <div class="col-xs-12 col-sm-12 col-md-6 col-lg-6 col-xs-offset-0 col-sm-offset-0 col-md-offset-3 col-lg-offset-3 toppad" > <div class="panel panel-info"> <div class="panel-heading"> - <h3 class="panel-title">{{$user->name}}</h3> + <h3 class="panel-title">{{$user->name.' ('.$user->nim .')'}}</h3> </div> <div class="panel-body"> <div class="row"> diff --git a/routes/web.php b/routes/web.php index 3fd5d6e3535371a7b7d2e7f4e941f3b43a088370..249cb5e470f9d9435f8e1917ec14e62376da1333 100644 --- a/routes/web.php +++ b/routes/web.php @@ -17,6 +17,11 @@ Route::get('/', function () { Auth::routes(); Route::resource('members', 'MembersController'); +Route::post('/importcsv','AddMemberController@importCSV'); +Route::post('/importmember','AddMemberController@importMember'); + +Route::resource('profile', 'MembersController'); +Route::resource('addmember', 'AddMemberController'); Route::get('/dashboard', 'DashboardController@index'); Route::get('/add', function () { return view('addMember');