56 |
57 | @endsection
58 |
--------------------------------------------------------------------------------
/readme.md:
--------------------------------------------------------------------------------
1 | # Laravel PHP Framework
2 |
3 | [](https://travis-ci.org/laravel/framework)
4 | [](https://packagist.org/packages/laravel/framework)
5 | [](https://packagist.org/packages/laravel/framework)
6 | [](https://packagist.org/packages/laravel/framework)
7 | [](https://packagist.org/packages/laravel/framework)
8 |
9 | Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable, creative experience to be truly fulfilling. Laravel attempts to take the pain out of development by easing common tasks used in the majority of web projects, such as authentication, routing, sessions, queueing, and caching.
10 |
11 | Laravel is accessible, yet powerful, providing powerful tools needed for large, robust applications. A superb inversion of control container, expressive migration system, and tightly integrated unit testing support give you the tools you need to build any application with which you are tasked.
12 |
13 | ## Official Documentation
14 |
15 | Documentation for the framework can be found on the [Laravel website](http://laravel.com/docs).
16 |
17 | ## Contributing
18 |
19 | Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](http://laravel.com/docs/contributions).
20 |
21 | ## Security Vulnerabilities
22 |
23 | If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell at taylor@laravel.com. All security vulnerabilities will be promptly addressed.
24 |
25 | ## License
26 |
27 | The Laravel framework is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT)
28 |
--------------------------------------------------------------------------------
/public/index.php:
--------------------------------------------------------------------------------
1 |
8 | */
9 |
10 | /*
11 | |--------------------------------------------------------------------------
12 | | Register The Auto Loader
13 | |--------------------------------------------------------------------------
14 | |
15 | | Composer provides a convenient, automatically generated class loader for
16 | | our application. We just need to utilize it! We'll simply require it
17 | | into the script here so that we don't have to worry about manual
18 | | loading any of our classes later on. It feels nice to relax.
19 | |
20 | */
21 |
22 | require __DIR__.'/../bootstrap/autoload.php';
23 |
24 | /*
25 | |--------------------------------------------------------------------------
26 | | Turn On The Lights
27 | |--------------------------------------------------------------------------
28 | |
29 | | We need to illuminate PHP development, so let us turn on the lights.
30 | | This bootstraps the framework and gets it ready for use, then it
31 | | will load up this application so that we can run it and send
32 | | the responses back to the browser and delight our users.
33 | |
34 | */
35 |
36 | $app = require_once __DIR__.'/../bootstrap/app.php';
37 |
38 | /*
39 | |--------------------------------------------------------------------------
40 | | Run The Application
41 | |--------------------------------------------------------------------------
42 | |
43 | | Once we have the application, we can handle the incoming request
44 | | through the kernel, and send the associated response back to
45 | | the client's browser allowing them to enjoy the creative
46 | | and wonderful application we have prepared for them.
47 | |
48 | */
49 |
50 | $kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);
51 |
52 | $response = $kernel->handle(
53 | $request = Illuminate\Http\Request::capture()
54 | );
55 |
56 | $response->send();
57 |
58 | $kernel->terminate($request, $response);
59 |
--------------------------------------------------------------------------------
/resources/views/store/book.blade.php:
--------------------------------------------------------------------------------
1 | @extends('layouts.app')
2 |
3 | @section('content')
4 |
5 |
6 |
{{$book->title}}
7 |
8 |
9 |
10 |
{{$book->author->name}}
11 |
12 |
13 |
14 | {{$book->description}}
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
25 | 60% Complete
26 |
27 |
28 |
This book is {{$book->percent_complete}}% complete
29 |
30 |
31 |
32 |
33 |
51 |
52 |
53 | @endsection
54 |
--------------------------------------------------------------------------------
/public/vendor/folklore/image/js/image.js:
--------------------------------------------------------------------------------
1 | (function (root, factory) {
2 | if (typeof define === 'function' && define.amd) {
3 | // AMD. Register as an anonymous module.
4 | define([], factory);
5 | } else if (typeof exports === 'object') {
6 | // Node. Does not work with strict CommonJS, but
7 | // only CommonJS-like environments that support module.exports,
8 | // like Node.
9 | module.exports = factory();
10 | } else {
11 | // Browser globals (root is window)
12 | if(typeof(root.Folklore) === 'undefined') {
13 | root.Folklore = {};
14 | }
15 | root.Folklore.Image = factory();
16 | }
17 | }(this, function () {
18 |
19 | 'use strict';
20 |
21 | var URL_PARAMETER = '-image({options})';
22 |
23 | // Build a image formatted URL
24 | function url(src, width, height, options) {
25 |
26 | // Don't allow empty strings
27 | if (!src || !src.length) return;
28 |
29 | //If width parameter is an array, use it as options
30 | if(width instanceof Object)
31 | {
32 | options = width;
33 | width = null;
34 | height = null;
35 | }
36 |
37 | //Get size
38 | if (!width) width = '_';
39 | if (!height) height = '_';
40 |
41 | // Produce the image option
42 | var params = [];
43 |
44 | //Add size if presents
45 | if(width != '_' || height != '_') {
46 | params.push(width+'x'+height);
47 | }
48 |
49 | // Add options.
50 | if (options && options instanceof Object) {
51 | var val, key;
52 | for (key in options) {
53 | val = options[key];
54 | if (val === true || val === null) {
55 | params.push(key);
56 | }
57 | else if (val instanceof Array) {
58 | params.push(key+'('+val.join(',')+')');
59 | }
60 | else {
61 | params.push(key+'('+val+')');
62 | }
63 | }
64 | }
65 |
66 | params = params.join('-');
67 | var parameter = URL_PARAMETER.replace('{options}',params);
68 |
69 | // Break the path apart and put back together again
70 | return src.replace(/^(.+)(\.[a-z]+)$/i, "$1"+parameter+"$2");
71 |
72 | }
73 |
74 | // Expose public methods.
75 | return {
76 | url: url
77 | };
78 | }));
79 |
--------------------------------------------------------------------------------
/resources/views/auth/passwords/email.blade.php:
--------------------------------------------------------------------------------
1 | @extends('layouts.app')
2 |
3 |
4 | @section('content')
5 |
70 | @endsection
71 |
--------------------------------------------------------------------------------
/app/Services/BookService.php:
--------------------------------------------------------------------------------
1 | parser = $parser;
30 | $this->dumper = $dumper;
31 | }
32 |
33 | public function storeCover(BookInterface $book, $cover)
34 | {
35 | Storage::disk('book_local')->put("{$book->id}/Resources/Templates/ebook/cover.jpg",
36 | File::get($cover));
37 | Storage::disk('book_local')->put("{$book->id}/Resources/Templates/cover.jpg",
38 | File::get($cover));
39 |
40 | $print_path = storage_path("books/{$book->id}/Resources/Templates/print");
41 |
42 | if (!is_dir($print_path)) {
43 | mkdir($print_path, 0775, true);
44 | }
45 |
46 | $img = new \Imagick(storage_path("books/{$book->id}/Resources/Templates/ebook/cover.jpg"));
47 | $img->setImageFormat("pdf");
48 | $img->writeImage(storage_path("books/{$book->id}/Resources/Templates/print/cover.pdf"));
49 |
50 | $thumbnail = \Image::open(storage_path("books/{$book->id}/Resources/Templates/ebook/cover.jpg"))
51 | ->thumbnail(new Box(356, 522));
52 | $thumbnail->save(public_path("books/thumbs/{$book->id}.jpg"));
53 |
54 | $thumbnail = \Image::open(storage_path("books/{$book->id}/Resources/Templates/ebook/cover.jpg"))
55 | ->thumbnail(new Box(138, 230));
56 | $thumbnail->save(public_path("books/thumbs/{$book->id}_small.jpg"));
57 | }
58 |
59 | public function export(BookInterface $book)
60 | {
61 | $this->exportContent($book);
62 | $config = $this->parser->parse(file_get_contents(storage_path('books/template/config.yml')));
63 | $config['book']['title'] = $book->title;
64 | $config['book']['author'] = $book->author->name;
65 |
66 | file_put_contents(storage_path("books/{$book->id}/Contents/dedication.md"), $book->dedication);
67 |
68 | foreach ($this->getChapters($book) as $chapter) {
69 | $ch['element'] = "chapter";
70 | $ch['number'] = $chapter->order;
71 | $ch['content'] = $chapter->order . ".md";
72 | array_push($config['book']['contents'], $ch);
73 | }
74 |
75 | $yml = $this->dumper->dump($config, 4);
76 |
77 | file_put_contents(storage_path("books/{$book->id}/config.yml"), $yml);
78 | }
79 |
80 | public function compress(BookInterface $book)
81 | {
82 | if (is_dir(storage_path("books/{$book->id}/Output"))) {
83 | ExtendedZip::zipTree(storage_path("books/{$book->id}/Output"),
84 | storage_path("books/{$book->id}/book.zip"),
85 | ExtendedZip::CREATE
86 | );
87 | }
88 | }
89 |
90 | private function getChapters(BookInterface $book)
91 | {
92 | return $book->chapters()->orderBy('order', 'asc')->get();
93 | }
94 |
95 | private function exportContent(BookInterface $book)
96 | {
97 | if (!is_dir(storage_path("books/{$book->id}/Contents/"))) {
98 | mkdir(storage_path("books/{$book->id}/Contents/"), 0775, true);
99 | }
100 | foreach ($this->getChapters($book) as $chapter) {
101 | file_put_contents(storage_path("books/{$book->id}/Contents/{$chapter->order}.md"), $chapter->content);
102 | }
103 | }
104 |
105 | }
--------------------------------------------------------------------------------
/app/Http/Controllers/Admin/BooksController.php:
--------------------------------------------------------------------------------
1 | user()->can('book_manage_all')) {
21 | $books = Book::all();
22 | } else {
23 | $books = Book::whereUserId(auth()->user()->id)->get();
24 | }
25 |
26 | return view('admin.books.index', compact('books'));
27 | }
28 |
29 | public function create()
30 | {
31 | $categories = Category::lists('name', 'id');
32 | return view('admin.books.create', compact('categories'));
33 | }
34 |
35 | public function store(Request $request)
36 | {
37 | $input = $request->all();
38 | $input['user_id'] = auth()->user()->id;
39 | Book::create($input);
40 | return redirect()->route('admin.books.index');
41 | }
42 |
43 | public function edit($id)
44 | {
45 | $book = Book::find($id);
46 |
47 | if (Gate::denies('manage', $book)) {
48 | abort(403, 'You dont own this book');
49 | }
50 |
51 | $categories = Category::lists('name', 'id');
52 | return view('admin.books.edit', compact('book', 'categories'));
53 | }
54 |
55 | public function update(Request $request, $id)
56 | {
57 | $book = Book::find($id);
58 |
59 | if (Gate::denies('manage', $book)) {
60 | abort(403, 'You dont own this book');
61 | }
62 |
63 | $book->update($request->all());
64 | return redirect()->route('admin.books.index');
65 | }
66 |
67 | public function destroy($id)
68 | {
69 | $book = Book::find($id);
70 |
71 | if (Gate::denies('manage', $book)) {
72 | abort(403, 'You dont own this book');
73 | }
74 |
75 | $book->delete();
76 | return redirect()->route('admin.books.index');
77 | }
78 |
79 | public function cover($id)
80 | {
81 | $book = Book::find($id);
82 |
83 | if (Gate::denies('manage', $book)) {
84 | abort(403, 'You dont own this book');
85 | }
86 |
87 | return view('admin.books.cover', compact('book'));
88 | }
89 |
90 | public function coverStore(Request $request, $id)
91 | {
92 | $book = Book::find($id);
93 |
94 | if (Gate::denies('manage', $book)) {
95 | abort(403, 'You dont own this book');
96 | }
97 |
98 | $bookService = app()->make(BookService::class);
99 | $bookService->storeCover($book, $request->file('file'));
100 |
101 | return redirect()->back();
102 | }
103 |
104 | public function export($id)
105 | {
106 | $book = Book::find($id);
107 |
108 | if (Gate::denies('manage', $book)) {
109 | abort(403, 'You dont own this book');
110 | }
111 |
112 | Event::fire(new GenerateBook($book));
113 |
114 | return redirect()->route('admin.books.index');
115 | }
116 |
117 | public function download($id)
118 | {
119 | $book = Book::find($id);
120 |
121 | if (Gate::denies('manage', $book)) {
122 | abort(403, 'You dont own this book');
123 | }
124 |
125 | if(file_exists(storage_path("books/{$book->id}/book.zip"))) {
126 | return response()->download(storage_path("books/{$book->id}/book.zip"));
127 | }
128 |
129 | return redirect()->route('admin.books.index');
130 | }
131 | }
132 |
--------------------------------------------------------------------------------
/database/seeds/UsersRolesPermissionsSeeder.php:
--------------------------------------------------------------------------------
1 | create([
15 | 'name' => 'Admin da Silva',
16 | 'email' => 'admin@admin.com',
17 | 'password' => bcrypt(123456)
18 | ]);
19 |
20 | $roleAdmin = factory(\CodePub\Models\Role::class)->create([
21 | 'name' => 'Admin',
22 | 'description' => 'System Administrator'
23 | ]);
24 |
25 | $user->addRole($roleAdmin);
26 |
27 | $userManager = factory(\CodePub\Models\User::class)->create([
28 | 'name' => 'Manager da Silva',
29 | 'email' => 'manager@admin.com',
30 | 'password' => bcrypt(123456)
31 | ]);
32 |
33 | $roleManager = factory(\CodePub\Models\Role::class)->create([
34 | 'name' => 'Manager',
35 | 'description' => 'System Manager'
36 | ]);
37 |
38 | $userManager->addRole($roleManager);
39 |
40 | $userSupervisor = factory(\CodePub\Models\User::class)->create([
41 | 'name' => 'Supervisor da Silva',
42 | 'email' => 'supervisor@admin.com',
43 | 'password' => bcrypt(123456)
44 | ]);
45 |
46 | $roleSupervisor = factory(\CodePub\Models\Role::class)->create([
47 | 'name' => 'Supervisor',
48 | 'description' => 'System Supervisor'
49 | ]);
50 |
51 | $userSupervisor->addRole($roleSupervisor);
52 |
53 |
54 | $userList = factory(\CodePub\Models\Permission::class)->create([
55 | 'name'=>'user_list',
56 | 'description' => 'Can list all users'
57 | ]);
58 |
59 | $userAdd = factory(\CodePub\Models\Permission::class)->create([
60 | 'name'=>'user_add',
61 | 'description' => 'Can add users'
62 | ]);
63 |
64 | $userEdit = factory(\CodePub\Models\Permission::class)->create([
65 | 'name'=>'user_edit',
66 | 'description' => 'Can edit users'
67 | ]);
68 |
69 | $userDestroy = factory(\CodePub\Models\Permission::class)->create([
70 | 'name'=>'user_destroy',
71 | 'description' => 'Can destroy an user'
72 | ]);
73 |
74 | $userViewRoles = factory(\CodePub\Models\Permission::class)->create([
75 | 'name'=>'user_view_roles',
76 | 'description' => 'Can view the users roles'
77 | ]);
78 |
79 | $userAddRole = factory(\CodePub\Models\Permission::class)->create([
80 | 'name'=>'user_add_role',
81 | 'description' => 'Can add a new role for an user'
82 | ]);
83 |
84 | $userRevokeRole = factory(\CodePub\Models\Permission::class)->create([
85 | 'name'=>'user_revoke_role',
86 | 'description' => 'Can revoke a role for an user'
87 | ]);
88 |
89 | $managePermissions = factory(\CodePub\Models\Permission::class)->create([
90 | 'name'=>'permission_admin',
91 | 'description' => 'Can admin all permissions'
92 | ]);
93 |
94 | $AdminRoles = factory(\CodePub\Models\Permission::class)->create([
95 | 'name'=>'role_admin',
96 | 'description' => 'Can admin all roles'
97 | ]);
98 |
99 | $roleManager->addPermission($userList);
100 | $roleManager->addPermission($userEdit);
101 | $roleManager->addPermission($userAdd);
102 | $roleManager->addPermission($userViewRoles);
103 |
104 | $roleSupervisor->addPermission($userList);
105 | $roleSupervisor->addPermission($userViewRoles);
106 | }
107 | }
108 |
--------------------------------------------------------------------------------
/config/auth.php:
--------------------------------------------------------------------------------
1 | [
17 | 'guard' => 'web',
18 | 'passwords' => 'users',
19 | ],
20 |
21 | /*
22 | |--------------------------------------------------------------------------
23 | | Authentication Guards
24 | |--------------------------------------------------------------------------
25 | |
26 | | Next, you may define every authentication guard for your application.
27 | | Of course, a great default configuration has been defined for you
28 | | here which uses session storage and the Eloquent user provider.
29 | |
30 | | All authentication drivers have a user provider. This defines how the
31 | | users are actually retrieved out of your database or other storage
32 | | mechanisms used by this application to persist your user's data.
33 | |
34 | | Supported: "session", "token"
35 | |
36 | */
37 |
38 | 'guards' => [
39 | 'web' => [
40 | 'driver' => 'session',
41 | 'provider' => 'users',
42 | ],
43 |
44 | 'api' => [
45 | 'driver' => 'token',
46 | 'provider' => 'users',
47 | ],
48 | ],
49 |
50 | /*
51 | |--------------------------------------------------------------------------
52 | | User Providers
53 | |--------------------------------------------------------------------------
54 | |
55 | | All authentication drivers have a user provider. This defines how the
56 | | users are actually retrieved out of your database or other storage
57 | | mechanisms used by this application to persist your user's data.
58 | |
59 | | If you have multiple user tables or models you may configure multiple
60 | | sources which represent each model / table. These sources may then
61 | | be assigned to any extra authentication guards you have defined.
62 | |
63 | | Supported: "database", "eloquent"
64 | |
65 | */
66 |
67 | 'providers' => [
68 | 'users' => [
69 | 'driver' => 'eloquent',
70 | 'model' => CodePub\Models\User::class,
71 | ],
72 |
73 | // 'users' => [
74 | // 'driver' => 'database',
75 | // 'table' => 'users',
76 | // ],
77 | ],
78 |
79 | /*
80 | |--------------------------------------------------------------------------
81 | | Resetting Passwords
82 | |--------------------------------------------------------------------------
83 | |
84 | | Here you may set the options for resetting passwords including the view
85 | | that is your password reset e-mail. You may also set the name of the
86 | | table that maintains all of the reset tokens for your application.
87 | |
88 | | You may specify multiple password reset configurations if you have more
89 | | than one user table or model in the application and you want to have
90 | | separate password reset settings based on the specific user types.
91 | |
92 | | The expire time is the number of minutes that the reset token should be
93 | | considered valid. This security feature keeps tokens short-lived so
94 | | they have less time to be guessed. You may change this as needed.
95 | |
96 | */
97 |
98 | 'passwords' => [
99 | 'users' => [
100 | 'provider' => 'users',
101 | 'email' => 'auth.emails.password',
102 | 'table' => 'password_resets',
103 | 'expire' => 60,
104 | ],
105 | ],
106 |
107 | ];
108 |
--------------------------------------------------------------------------------
/resources/views/auth/register.blade.php:
--------------------------------------------------------------------------------
1 | @extends('layouts.app')
2 |
3 | @section('content')
4 |
5 |
6 |
7 |
8 |
Register
9 |
10 |
77 |
78 |
79 |
80 |
81 |
82 | @endsection
83 |
--------------------------------------------------------------------------------
/config/image.php:
--------------------------------------------------------------------------------
1 | 'gd',
19 |
20 | /*
21 | |--------------------------------------------------------------------------
22 | | Host
23 | |--------------------------------------------------------------------------
24 | |
25 | | The http host where the image are served. Used by the Image::url() method
26 | | to generate the right URL.
27 | |
28 | */
29 | 'host' => '',
30 |
31 | /*
32 | |--------------------------------------------------------------------------
33 | | Source directories
34 | |--------------------------------------------------------------------------
35 | |
36 | | A list a directories to look for images
37 | |
38 | */
39 | 'src_dirs' => array(
40 | public_path()
41 | ),
42 |
43 | /*
44 | |--------------------------------------------------------------------------
45 | | URL parameter
46 | |--------------------------------------------------------------------------
47 | |
48 | | The URL parameter that will be appended to your image filename containing
49 | | all the options for image manipulation. You have to put {options} where
50 | | you want options to be placed. Keep in mind that this parameter is used
51 | | in an url so all characters should be URL safe.
52 | |
53 | | Default: -image({options})
54 | |
55 | | Example: /uploads/photo-image(300x300-grayscale).jpg
56 | |
57 | */
58 | 'url_parameter' => '-image({options})',
59 |
60 | /*
61 | |--------------------------------------------------------------------------
62 | | URL parameter separator
63 | |--------------------------------------------------------------------------
64 | |
65 | | The URL parameter separator is used to build the parameters string
66 | | that will replace {options} in url_parameter
67 | |
68 | | Default: -
69 | |
70 | | Example: /uploads/photo-image(300x300-grayscale).jpg
71 | |
72 | */
73 | 'url_parameter_separator' => '-',
74 |
75 | /*
76 | |--------------------------------------------------------------------------
77 | | Serve image
78 | |--------------------------------------------------------------------------
79 | |
80 | | If true, a route will be added to catch image containing the
81 | | URL parameter above.
82 | |
83 | */
84 | 'serve_image' => true,
85 |
86 | /*
87 | |--------------------------------------------------------------------------
88 | | Serve custom Filters only
89 | |--------------------------------------------------------------------------
90 | |
91 | | Restrict options in url to custom filters only. This prevent direct
92 | | manipulation of the image.
93 | |
94 | */
95 | 'serve_custom_filters_only' => false,
96 |
97 | /*
98 | |--------------------------------------------------------------------------
99 | | Write image
100 | |--------------------------------------------------------------------------
101 | |
102 | | When serving an image, write the manipulated image in the same directory
103 | | as the original image so the next request will serve this static file
104 | |
105 | */
106 | 'write_image' => false,
107 |
108 | /*
109 | |--------------------------------------------------------------------------
110 | | Write path
111 | |--------------------------------------------------------------------------
112 | |
113 | | By default, the manipulated images are saved in the same path as the
114 | | as the original image, you can override this path here
115 | |
116 | */
117 | 'write_path' => null,
118 |
119 | /*
120 | |--------------------------------------------------------------------------
121 | | Memory limit
122 | |--------------------------------------------------------------------------
123 | |
124 | | When manipulating an image, the memory limit is increased to this value
125 | |
126 | */
127 | 'memory_limit' => '128M'
128 |
129 | );
130 |
--------------------------------------------------------------------------------
/config/mail.php:
--------------------------------------------------------------------------------
1 | env('MAIL_DRIVER', 'smtp'),
19 |
20 | /*
21 | |--------------------------------------------------------------------------
22 | | SMTP Host Address
23 | |--------------------------------------------------------------------------
24 | |
25 | | Here you may provide the host address of the SMTP server used by your
26 | | applications. A default option is provided that is compatible with
27 | | the Mailgun mail service which will provide reliable deliveries.
28 | |
29 | */
30 |
31 | 'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
32 |
33 | /*
34 | |--------------------------------------------------------------------------
35 | | SMTP Host Port
36 | |--------------------------------------------------------------------------
37 | |
38 | | This is the SMTP port used by your application to deliver e-mails to
39 | | users of the application. Like the host we have set this value to
40 | | stay compatible with the Mailgun e-mail application by default.
41 | |
42 | */
43 |
44 | 'port' => env('MAIL_PORT', 587),
45 |
46 | /*
47 | |--------------------------------------------------------------------------
48 | | Global "From" Address
49 | |--------------------------------------------------------------------------
50 | |
51 | | You may wish for all e-mails sent by your application to be sent from
52 | | the same address. Here, you may specify a name and address that is
53 | | used globally for all e-mails that are sent by your application.
54 | |
55 | */
56 |
57 | 'from' => ['address' => null, 'name' => null],
58 |
59 | /*
60 | |--------------------------------------------------------------------------
61 | | E-Mail Encryption Protocol
62 | |--------------------------------------------------------------------------
63 | |
64 | | Here you may specify the encryption protocol that should be used when
65 | | the application send e-mail messages. A sensible default using the
66 | | transport layer security protocol should provide great security.
67 | |
68 | */
69 |
70 | 'encryption' => env('MAIL_ENCRYPTION', 'tls'),
71 |
72 | /*
73 | |--------------------------------------------------------------------------
74 | | SMTP Server Username
75 | |--------------------------------------------------------------------------
76 | |
77 | | If your SMTP server requires a username for authentication, you should
78 | | set it here. This will get used to authenticate with your server on
79 | | connection. You may also set the "password" value below this one.
80 | |
81 | */
82 |
83 | 'username' => env('MAIL_USERNAME'),
84 |
85 | /*
86 | |--------------------------------------------------------------------------
87 | | SMTP Server Password
88 | |--------------------------------------------------------------------------
89 | |
90 | | Here you may set the password required by your SMTP server to send out
91 | | messages from your application. This will be given to the server on
92 | | connection so that the application will be able to send messages.
93 | |
94 | */
95 |
96 | 'password' => env('MAIL_PASSWORD'),
97 |
98 | /*
99 | |--------------------------------------------------------------------------
100 | | Sendmail System Path
101 | |--------------------------------------------------------------------------
102 | |
103 | | When using the "sendmail" driver to send e-mails, we will need to know
104 | | the path to where Sendmail lives on this server. A default path has
105 | | been provided here, which will work well on most of your systems.
106 | |
107 | */
108 |
109 | 'sendmail' => '/usr/sbin/sendmail -bs',
110 |
111 | ];
112 |
--------------------------------------------------------------------------------
/config/database.php:
--------------------------------------------------------------------------------
1 | PDO::FETCH_CLASS,
17 |
18 | /*
19 | |--------------------------------------------------------------------------
20 | | Default Database Connection Name
21 | |--------------------------------------------------------------------------
22 | |
23 | | Here you may specify which of the database connections below you wish
24 | | to use as your default connection for all database work. Of course
25 | | you may use many connections at once using the Database library.
26 | |
27 | */
28 |
29 | 'default' => env('DB_CONNECTION', 'mysql'),
30 |
31 | /*
32 | |--------------------------------------------------------------------------
33 | | Database Connections
34 | |--------------------------------------------------------------------------
35 | |
36 | | Here are each of the database connections setup for your application.
37 | | Of course, examples of configuring each database platform that is
38 | | supported by Laravel is shown below to make development simple.
39 | |
40 | |
41 | | All database work in Laravel is done through the PHP PDO facilities
42 | | so make sure you have the driver for your particular database of
43 | | choice installed on your machine before you begin development.
44 | |
45 | */
46 |
47 | 'connections' => [
48 |
49 | 'sqlite' => [
50 | 'driver' => 'sqlite',
51 | 'database' => database_path('database.sqlite'),
52 | 'prefix' => '',
53 | ],
54 |
55 | 'mysql' => [
56 | 'driver' => 'mysql',
57 | 'host' => env('DB_HOST', 'localhost'),
58 | 'database' => env('DB_DATABASE', 'forge'),
59 | 'username' => env('DB_USERNAME', 'forge'),
60 | 'password' => env('DB_PASSWORD', ''),
61 | 'charset' => 'utf8',
62 | 'collation' => 'utf8_unicode_ci',
63 | 'prefix' => '',
64 | 'strict' => false,
65 | 'engine' => null,
66 | ],
67 |
68 | 'pgsql' => [
69 | 'driver' => 'pgsql',
70 | 'host' => env('DB_HOST', 'localhost'),
71 | 'database' => env('DB_DATABASE', 'forge'),
72 | 'username' => env('DB_USERNAME', 'forge'),
73 | 'password' => env('DB_PASSWORD', ''),
74 | 'charset' => 'utf8',
75 | 'prefix' => '',
76 | 'schema' => 'public',
77 | ],
78 |
79 | 'sqlsrv' => [
80 | 'driver' => 'sqlsrv',
81 | 'host' => env('DB_HOST', 'localhost'),
82 | 'database' => env('DB_DATABASE', 'forge'),
83 | 'username' => env('DB_USERNAME', 'forge'),
84 | 'password' => env('DB_PASSWORD', ''),
85 | 'charset' => 'utf8',
86 | 'prefix' => '',
87 | ],
88 |
89 | ],
90 |
91 | /*
92 | |--------------------------------------------------------------------------
93 | | Migration Repository Table
94 | |--------------------------------------------------------------------------
95 | |
96 | | This table keeps track of all the migrations that have already run for
97 | | your application. Using this information, we can determine which of
98 | | the migrations on disk haven't actually been run in the database.
99 | |
100 | */
101 |
102 | 'migrations' => 'migrations',
103 |
104 | /*
105 | |--------------------------------------------------------------------------
106 | | Redis Databases
107 | |--------------------------------------------------------------------------
108 | |
109 | | Redis is an open source, fast, and advanced key-value store that also
110 | | provides a richer set of commands than a typical key-value systems
111 | | such as APC or Memcached. Laravel makes it easy to dig right in.
112 | |
113 | */
114 |
115 | 'redis' => [
116 |
117 | 'cluster' => false,
118 |
119 | 'default' => [
120 | 'host' => env('REDIS_HOST', 'localhost'),
121 | 'password' => env('REDIS_PASSWORD', null),
122 | 'port' => env('REDIS_PORT', 6379),
123 | 'database' => 0,
124 | ],
125 |
126 | ],
127 |
128 | ];
129 |
--------------------------------------------------------------------------------
/resources/views/layouts/app.blade.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 | CodePub
12 |
13 |
14 |
103 |
104 | @yield('banner')
105 |
106 | @yield('menu')
107 |
108 |
109 | @yield('content')
110 |
111 |
112 |
113 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
--------------------------------------------------------------------------------
/config/session.php:
--------------------------------------------------------------------------------
1 | env('SESSION_DRIVER', 'file'),
20 |
21 | /*
22 | |--------------------------------------------------------------------------
23 | | Session Lifetime
24 | |--------------------------------------------------------------------------
25 | |
26 | | Here you may specify the number of minutes that you wish the session
27 | | to be allowed to remain idle before it expires. If you want them
28 | | to immediately expire on the browser closing, set that option.
29 | |
30 | */
31 |
32 | 'lifetime' => 120,
33 |
34 | 'expire_on_close' => false,
35 |
36 | /*
37 | |--------------------------------------------------------------------------
38 | | Session Encryption
39 | |--------------------------------------------------------------------------
40 | |
41 | | This option allows you to easily specify that all of your session data
42 | | should be encrypted before it is stored. All encryption will be run
43 | | automatically by Laravel and you can use the Session like normal.
44 | |
45 | */
46 |
47 | 'encrypt' => false,
48 |
49 | /*
50 | |--------------------------------------------------------------------------
51 | | Session File Location
52 | |--------------------------------------------------------------------------
53 | |
54 | | When using the native session driver, we need a location where session
55 | | files may be stored. A default has been set for you but a different
56 | | location may be specified. This is only needed for file sessions.
57 | |
58 | */
59 |
60 | 'files' => storage_path('framework/sessions'),
61 |
62 | /*
63 | |--------------------------------------------------------------------------
64 | | Session Database Connection
65 | |--------------------------------------------------------------------------
66 | |
67 | | When using the "database" or "redis" session drivers, you may specify a
68 | | connection that should be used to manage these sessions. This should
69 | | correspond to a connection in your database configuration options.
70 | |
71 | */
72 |
73 | 'connection' => null,
74 |
75 | /*
76 | |--------------------------------------------------------------------------
77 | | Session Database Table
78 | |--------------------------------------------------------------------------
79 | |
80 | | When using the "database" session driver, you may specify the table we
81 | | should use to manage the sessions. Of course, a sensible default is
82 | | provided for you; however, you are free to change this as needed.
83 | |
84 | */
85 |
86 | 'table' => 'sessions',
87 |
88 | /*
89 | |--------------------------------------------------------------------------
90 | | Session Sweeping Lottery
91 | |--------------------------------------------------------------------------
92 | |
93 | | Some session drivers must manually sweep their storage location to get
94 | | rid of old sessions from storage. Here are the chances that it will
95 | | happen on a given request. By default, the odds are 2 out of 100.
96 | |
97 | */
98 |
99 | 'lottery' => [2, 100],
100 |
101 | /*
102 | |--------------------------------------------------------------------------
103 | | Session Cookie Name
104 | |--------------------------------------------------------------------------
105 | |
106 | | Here you may change the name of the cookie used to identify a session
107 | | instance by ID. The name specified here will get used every time a
108 | | new session cookie is created by the framework for every driver.
109 | |
110 | */
111 |
112 | 'cookie' => 'laravel_session',
113 |
114 | /*
115 | |--------------------------------------------------------------------------
116 | | Session Cookie Path
117 | |--------------------------------------------------------------------------
118 | |
119 | | The session cookie path determines the path for which the cookie will
120 | | be regarded as available. Typically, this will be the root path of
121 | | your application but you are free to change this when necessary.
122 | |
123 | */
124 |
125 | 'path' => '/',
126 |
127 | /*
128 | |--------------------------------------------------------------------------
129 | | Session Cookie Domain
130 | |--------------------------------------------------------------------------
131 | |
132 | | Here you may change the domain of the cookie used to identify a session
133 | | in your application. This will determine which domains the cookie is
134 | | available to in your application. A sensible default has been set.
135 | |
136 | */
137 |
138 | 'domain' => null,
139 |
140 | /*
141 | |--------------------------------------------------------------------------
142 | | HTTPS Only Cookies
143 | |--------------------------------------------------------------------------
144 | |
145 | | By setting this option to true, session cookies will only be sent back
146 | | to the server if the browser has a HTTPS connection. This will keep
147 | | the cookie from being sent to you if it can not be done securely.
148 | |
149 | */
150 |
151 | 'secure' => false,
152 |
153 | ];
154 |
--------------------------------------------------------------------------------
/resources/lang/en/validation.php:
--------------------------------------------------------------------------------
1 | 'The :attribute must be accepted.',
17 | 'active_url' => 'The :attribute is not a valid URL.',
18 | 'after' => 'The :attribute must be a date after :date.',
19 | 'alpha' => 'The :attribute may only contain letters.',
20 | 'alpha_dash' => 'The :attribute may only contain letters, numbers, and dashes.',
21 | 'alpha_num' => 'The :attribute may only contain letters and numbers.',
22 | 'array' => 'The :attribute must be an array.',
23 | 'before' => 'The :attribute must be a date before :date.',
24 | 'between' => [
25 | 'numeric' => 'The :attribute must be between :min and :max.',
26 | 'file' => 'The :attribute must be between :min and :max kilobytes.',
27 | 'string' => 'The :attribute must be between :min and :max characters.',
28 | 'array' => 'The :attribute must have between :min and :max items.',
29 | ],
30 | 'boolean' => 'The :attribute field must be true or false.',
31 | 'confirmed' => 'The :attribute confirmation does not match.',
32 | 'date' => 'The :attribute is not a valid date.',
33 | 'date_format' => 'The :attribute does not match the format :format.',
34 | 'different' => 'The :attribute and :other must be different.',
35 | 'digits' => 'The :attribute must be :digits digits.',
36 | 'digits_between' => 'The :attribute must be between :min and :max digits.',
37 | 'email' => 'The :attribute must be a valid email address.',
38 | 'exists' => 'The selected :attribute is invalid.',
39 | 'filled' => 'The :attribute field is required.',
40 | 'image' => 'The :attribute must be an image.',
41 | 'in' => 'The selected :attribute is invalid.',
42 | 'integer' => 'The :attribute must be an integer.',
43 | 'ip' => 'The :attribute must be a valid IP address.',
44 | 'json' => 'The :attribute must be a valid JSON string.',
45 | 'max' => [
46 | 'numeric' => 'The :attribute may not be greater than :max.',
47 | 'file' => 'The :attribute may not be greater than :max kilobytes.',
48 | 'string' => 'The :attribute may not be greater than :max characters.',
49 | 'array' => 'The :attribute may not have more than :max items.',
50 | ],
51 | 'mimes' => 'The :attribute must be a file of type: :values.',
52 | 'min' => [
53 | 'numeric' => 'The :attribute must be at least :min.',
54 | 'file' => 'The :attribute must be at least :min kilobytes.',
55 | 'string' => 'The :attribute must be at least :min characters.',
56 | 'array' => 'The :attribute must have at least :min items.',
57 | ],
58 | 'not_in' => 'The selected :attribute is invalid.',
59 | 'numeric' => 'The :attribute must be a number.',
60 | 'regex' => 'The :attribute format is invalid.',
61 | 'required' => 'The :attribute field is required.',
62 | 'required_if' => 'The :attribute field is required when :other is :value.',
63 | 'required_unless' => 'The :attribute field is required unless :other is in :values.',
64 | 'required_with' => 'The :attribute field is required when :values is present.',
65 | 'required_with_all' => 'The :attribute field is required when :values is present.',
66 | 'required_without' => 'The :attribute field is required when :values is not present.',
67 | 'required_without_all' => 'The :attribute field is required when none of :values are present.',
68 | 'same' => 'The :attribute and :other must match.',
69 | 'size' => [
70 | 'numeric' => 'The :attribute must be :size.',
71 | 'file' => 'The :attribute must be :size kilobytes.',
72 | 'string' => 'The :attribute must be :size characters.',
73 | 'array' => 'The :attribute must contain :size items.',
74 | ],
75 | 'string' => 'The :attribute must be a string.',
76 | 'timezone' => 'The :attribute must be a valid zone.',
77 | 'unique' => 'The :attribute has already been taken.',
78 | 'url' => 'The :attribute format is invalid.',
79 |
80 | /*
81 | |--------------------------------------------------------------------------
82 | | Custom Validation Language Lines
83 | |--------------------------------------------------------------------------
84 | |
85 | | Here you may specify custom validation messages for attributes using the
86 | | convention "attribute.rule" to name the lines. This makes it quick to
87 | | specify a specific custom language line for a given attribute rule.
88 | |
89 | */
90 |
91 | 'custom' => [
92 | 'attribute-name' => [
93 | 'rule-name' => 'custom-message',
94 | ],
95 | ],
96 |
97 | /*
98 | |--------------------------------------------------------------------------
99 | | Custom Validation Attributes
100 | |--------------------------------------------------------------------------
101 | |
102 | | The following language lines are used to swap attribute place-holders
103 | | with something more reader friendly such as E-Mail Address instead
104 | | of "email". This simply helps us make messages a little cleaner.
105 | |
106 | */
107 |
108 | 'attributes' => [],
109 |
110 | ];
111 |
--------------------------------------------------------------------------------
/app/Http/routes.php:
--------------------------------------------------------------------------------
1 | ['web']], function () {
4 | Route::auth();
5 | Route::get('/', ['uses' => 'StoreController@index', 'as' => 'store']);
6 | Route::get('/book/{slug}', ['uses' => 'StoreController@view', 'as' => 'store.view']);
7 | Route::get('/category/{id}', ['uses' => 'StoreController@category', 'as' => 'store.category']);
8 | Route::get('/search', ['uses' => 'StoreController@search', 'as' => 'store.search']);
9 |
10 | Route::group(['middleware' => ['auth']], function () {
11 | Route::get('/checkout/{id}', ['uses' => 'StoreController@checkout', 'as' => 'store.checkout']);
12 | Route::post('/checkout/process/{id}', ['uses' => 'StoreController@process', 'as' => 'store.process']);
13 | Route::get('/orders', ['uses' => 'StoreController@orders', 'as' => 'store.orders']);
14 | Route::get('/download/{id}', ['uses' => 'StoreController@download', 'as' => 'store.download']);
15 | });
16 |
17 |
18 | });
19 |
20 |
21 | Route::group(['prefix' => 'admin', 'as' => 'admin.', 'middleware' => 'web'], function () {
22 |
23 | Route::get('roles', ['as' => 'roles.index', 'uses' => 'Admin\RolesController@index']);
24 | Route::get('roles/new', ['as' => 'roles.create', 'uses' => 'Admin\RolesController@create']);
25 | Route::post('roles/store', ['as' => 'roles.store', 'uses' => 'Admin\RolesController@store']);
26 | Route::get('roles/edit/{id}', ['as' => 'roles.edit', 'uses' => 'Admin\RolesController@edit']);
27 | Route::put('roles/update/{id}', ['as' => 'roles.update', 'uses' => 'Admin\RolesController@update']);
28 | Route::get('roles/destroy/{id}', ['as' => 'roles.destroy', 'uses' => 'Admin\RolesController@destroy']);
29 | Route::get('roles/permissions/{id}', ['as' => 'roles.permissions', 'uses' => 'Admin\RolesController@permissions']);
30 | Route::post('roles/permissions/{id}/store', ['as' => 'roles.permissions.store', 'uses' => 'Admin\RolesController@storePermission']);
31 | Route::get('roles/permissions/{id}/revoke/{permission_id}', ['as' => 'roles.permissions.revoke', 'uses' => 'Admin\RolesController@revokePermission']);
32 |
33 | Route::get('permissions', ['as' => 'permissions.index', 'uses' => 'Admin\PermissionsController@index']);
34 | Route::get('permissions/new', ['as' => 'permissions.create', 'uses' => 'Admin\PermissionsController@create']);
35 | Route::post('permissions/store', ['as' => 'permissions.store', 'uses' => 'Admin\PermissionsController@store']);
36 | Route::get('permissions/edit/{id}', ['as' => 'permissions.edit', 'uses' => 'Admin\PermissionsController@edit']);
37 | Route::put('permissions/update/{id}', ['as' => 'permissions.update', 'uses' => 'Admin\PermissionsController@update']);
38 | Route::get('permissions/destroy/{id}', ['as' => 'permissions.destroy', 'uses' => 'Admin\PermissionsController@destroy']);
39 |
40 | Route::get('users', ['as' => 'users.index', 'uses' => 'Admin\UsersController@index']);
41 | Route::get('users/new', ['as' => 'users.create', 'uses' => 'Admin\UsersController@create']);
42 | Route::post('users/store', ['as' => 'users.store', 'uses' => 'Admin\UsersController@store']);
43 | Route::get('users/edit/{id}', ['as' => 'users.edit', 'uses' => 'Admin\UsersController@edit']);
44 | Route::put('users/update/{id}', ['as' => 'users.update', 'uses' => 'Admin\UsersController@update']);
45 | Route::get('users/destroy/{id}', ['as' => 'users.destroy', 'uses' => 'Admin\UsersController@destroy']);
46 | Route::get('users/roles/{id}', ['as' => 'users.roles', 'uses' => 'Admin\UsersController@roles']);
47 | Route::post('users/roles/{id}/store', ['as' => 'users.roles.store', 'uses' => 'Admin\UsersController@storeRole']);
48 | Route::get('users/roles/{id}/revoke/{role_id}', ['as' => 'users.roles.revoke', 'uses' => 'Admin\UsersController@revokeRole']);
49 |
50 | Route::get('categories', ['as' => 'categories.index', 'uses' => 'Admin\CategoriesController@index']);
51 | Route::get('categories/new', ['as' => 'categories.create', 'uses' => 'Admin\CategoriesController@create']);
52 | Route::post('categories/store', ['as' => 'categories.store', 'uses' => 'Admin\CategoriesController@store']);
53 | Route::get('categories/edit/{id}', ['as' => 'categories.edit', 'uses' => 'Admin\CategoriesController@edit']);
54 | Route::put('categories/update/{id}', ['as' => 'categories.update', 'uses' => 'Admin\CategoriesController@update']);
55 | Route::get('categories/destroy/{id}', ['as' => 'categories.destroy', 'uses' => 'Admin\CategoriesController@destroy']);
56 |
57 | Route::get('books', ['as' => 'books.index', 'uses' => 'Admin\BooksController@index']);
58 | Route::get('books/new', ['as' => 'books.create', 'uses' => 'Admin\BooksController@create']);
59 | Route::post('books/store', ['as' => 'books.store', 'uses' => 'Admin\BooksController@store']);
60 | Route::get('books/edit/{id}', ['as' => 'books.edit', 'uses' => 'Admin\BooksController@edit']);
61 | Route::put('books/update/{id}', ['as' => 'books.update', 'uses' => 'Admin\BooksController@update']);
62 | Route::get('books/destroy/{id}', ['as' => 'books.destroy', 'uses' => 'Admin\BooksController@destroy']);
63 | Route::get('books/cover/{id}', ['as' => 'books.cover', 'uses' => 'Admin\BooksController@cover']);
64 | Route::post('books/cover/{id}', ['as' => 'books.cover.store', 'uses' => 'Admin\BooksController@coverStore']);
65 | Route::get('books/export/{id}', ['as' => 'books.export', 'uses' => 'Admin\BooksController@export']);
66 | Route::get('books/download/{id}', ['as' => 'books.download', 'uses' => 'Admin\BooksController@download']);
67 |
68 |
69 | Route::group(['prefix' => 'books', 'as' => 'books.'], function () {
70 | Route::get('{id}/chapters', ['as' => 'chapters.index', 'uses' => 'Admin\ChaptersController@index']);
71 | Route::get('{id}/chapters/create', ['as' => 'chapters.create', 'uses' => 'Admin\ChaptersController@create']);
72 | Route::post('{id}/chapters/store', ['as' => 'chapters.store', 'uses' => 'Admin\ChaptersController@store']);
73 | Route::get('{id}/chapters/edit/{chapter_id}', ['as' => 'chapters.edit', 'uses' => 'Admin\ChaptersController@edit']);
74 | Route::put('{id}/chapters/update/{chapter_id}', ['as' => 'chapters.update', 'uses' => 'Admin\ChaptersController@update']);
75 | Route::get('{id}/chapters/destroy/{chapter_id}', ['as' => 'chapters.destroy', 'uses' => 'Admin\ChaptersController@destroy']);
76 | });
77 | });
78 |
79 |
--------------------------------------------------------------------------------