├── .editorconfig
├── .env.example
├── .gitattributes
├── .gitignore
├── .styleci.yml
├── app
├── Category.php
├── Console
│ └── Kernel.php
├── Exceptions
│ └── Handler.php
├── Http
│ ├── Controllers
│ │ ├── Admin
│ │ │ ├── CategoryController.php
│ │ │ ├── NotificationController.php
│ │ │ ├── OrdersController.php
│ │ │ ├── ProductController.php
│ │ │ ├── ProductPhotoController.php
│ │ │ └── StoreController.php
│ │ ├── Auth
│ │ │ ├── ForgotPasswordController.php
│ │ │ ├── LoginController.php
│ │ │ ├── RegisterController.php
│ │ │ ├── ResetPasswordController.php
│ │ │ └── VerificationController.php
│ │ ├── CartController.php
│ │ ├── CategoryController.php
│ │ ├── CheckoutController.php
│ │ ├── Controller.php
│ │ ├── HomeController.php
│ │ ├── StoreController.php
│ │ └── UserOrderController.php
│ ├── Kernel.php
│ ├── Middleware
│ │ ├── AccessControlStoreAdmin.php
│ │ ├── Authenticate.php
│ │ ├── CheckForMaintenanceMode.php
│ │ ├── EncryptCookies.php
│ │ ├── RedirectIfAuthenticated.php
│ │ ├── TrimStrings.php
│ │ ├── TrustProxies.php
│ │ ├── UserHasStoreMiddleware.php
│ │ └── VerifyCsrfToken.php
│ ├── Requests
│ │ ├── CategoryRequest.php
│ │ ├── ProductRequest.php
│ │ └── StoreRequest.php
│ └── Views
│ │ └── CategoryViewComposer.php
├── Mail
│ └── UserRegisteredEmail.php
├── Notifications
│ └── StoreReceiveNewOrder.php
├── Payment
│ └── PagSeguro
│ │ ├── CreditCard.php
│ │ └── Notification.php
├── Product.php
├── ProductPhoto.php
├── Providers
│ ├── AppServiceProvider.php
│ ├── AuthServiceProvider.php
│ ├── BroadcastServiceProvider.php
│ ├── ComposerServiceProvider.php
│ ├── EventServiceProvider.php
│ └── RouteServiceProvider.php
├── Store.php
├── Traits
│ ├── Slug.php
│ └── UploadTrait.php
├── User.php
└── UserOrder.php
├── artisan
├── bootstrap
├── app.php
└── cache
│ └── .gitignore
├── composer.json
├── composer.lock
├── config
├── app.php
├── auth.php
├── broadcasting.php
├── cache.php
├── database.php
├── filesystems.php
├── hashing.php
├── logging.php
├── mail.php
├── queue.php
├── services.php
├── session.php
└── view.php
├── database
├── .gitignore
├── factories
│ ├── CategoryFactory.php
│ ├── ProductFactory.php
│ ├── StoreFactory.php
│ └── UserFactory.php
├── migrations
│ ├── 2014_10_12_000000_create_users_table.php
│ ├── 2014_10_12_100000_create_password_resets_table.php
│ ├── 2019_08_19_000000_create_failed_jobs_table.php
│ ├── 2019_10_18_212717_create_table_store.php
│ ├── 2019_10_18_214944_create_products_table.php
│ ├── 2019_10_27_173536_create_categories_table.php
│ ├── 2019_10_27_173744_create_category_product_table.php
│ ├── 2019_12_04_201729_create_product_photos_table.php
│ ├── 2019_12_04_202057_alter_table_stores_add_column_logo.php
│ ├── 2019_12_28_140645_create_user_order_table.php
│ ├── 2020_02_07_183221_create_order_store_table.php
│ ├── 2020_02_09_153417_create_notifications_table.php
│ └── 2020_02_22_165158_alter_users_table.php
└── seeds
│ ├── DatabaseSeeder.php
│ ├── StoreTableSeeder.php
│ └── UsersTableSeeder.php
├── helpers
└── functions.php
├── package-lock.json
├── package.json
├── phpunit.xml
├── public
├── .htaccess
├── assets
│ ├── img
│ │ └── no-photo.jpg
│ └── js
│ │ └── jquery.ajax.js
├── css
│ └── app.css
├── favicon.ico
├── index.php
├── js
│ ├── app.js
│ ├── pagseguro_events.js
│ └── pagseguro_functions.js
├── mix-manifest.json
└── robots.txt
├── resources
├── js
│ ├── app.js
│ ├── bootstrap.js
│ ├── pagseguro_events.js
│ └── pagseguro_functions.js
├── lang
│ └── en
│ │ ├── auth.php
│ │ ├── pagination.php
│ │ ├── passwords.php
│ │ └── validation.php
├── sass
│ ├── _variables.scss
│ └── app.scss
└── views
│ ├── admin
│ ├── categories
│ │ ├── create.blade.php
│ │ ├── edit.blade.php
│ │ └── index.blade.php
│ ├── notifications.blade.php
│ ├── orders
│ │ └── index.blade.php
│ ├── products
│ │ ├── create.blade.php
│ │ ├── edit.blade.php
│ │ └── index.blade.php
│ └── stores
│ │ ├── create.blade.php
│ │ ├── edit.blade.php
│ │ └── index.blade.php
│ ├── auth
│ ├── login.blade.php
│ ├── passwords
│ │ ├── confirm.blade.php
│ │ ├── email.blade.php
│ │ └── reset.blade.php
│ ├── register.blade.php
│ └── verify.blade.php
│ ├── cart.blade.php
│ ├── category.blade.php
│ ├── checkout.blade.php
│ ├── emails
│ └── user-registered.blade.php
│ ├── layouts
│ ├── app.blade.php
│ └── front.blade.php
│ ├── single.blade.php
│ ├── store.blade.php
│ ├── thanks.blade.php
│ ├── user-orders.blade.php
│ └── welcome.blade.php
├── routes
├── api.php
├── channels.php
├── console.php
└── web.php
├── server.php
├── storage
├── app
│ ├── .gitignore
│ └── public
│ │ └── .gitignore
├── framework
│ ├── .gitignore
│ ├── cache
│ │ ├── .gitignore
│ │ └── data
│ │ │ └── .gitignore
│ ├── sessions
│ │ └── .gitignore
│ ├── testing
│ │ └── .gitignore
│ └── views
│ │ └── .gitignore
└── logs
│ └── .gitignore
├── tests
├── CreatesApplication.php
├── Feature
│ └── ExampleTest.php
├── TestCase.php
└── Unit
│ └── ExampleTest.php
└── webpack.mix.js
/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | charset = utf-8
5 | end_of_line = lf
6 | insert_final_newline = true
7 | indent_style = space
8 | indent_size = 4
9 | trim_trailing_whitespace = true
10 |
11 | [*.md]
12 | trim_trailing_whitespace = false
13 |
14 | [*.{yml,yaml}]
15 | indent_size = 2
16 |
--------------------------------------------------------------------------------
/.env.example:
--------------------------------------------------------------------------------
1 | APP_NAME=Laravel
2 | APP_ENV=local
3 | APP_KEY=
4 | APP_DEBUG=true
5 | APP_URL=http://localhost
6 |
7 | LOG_CHANNEL=stack
8 |
9 | DB_CONNECTION=mysql
10 | DB_HOST=127.0.0.1
11 | DB_PORT=3306
12 | DB_DATABASE=laravel
13 | DB_USERNAME=root
14 | DB_PASSWORD=
15 |
16 | BROADCAST_DRIVER=log
17 | CACHE_DRIVER=file
18 | QUEUE_CONNECTION=sync
19 | SESSION_DRIVER=file
20 | SESSION_LIFETIME=120
21 |
22 | REDIS_HOST=127.0.0.1
23 | REDIS_PASSWORD=null
24 | REDIS_PORT=6379
25 |
26 | MAIL_DRIVER=smtp
27 | MAIL_HOST=smtp.mailtrap.io
28 | MAIL_PORT=2525
29 | MAIL_USERNAME=null
30 | MAIL_PASSWORD=null
31 | MAIL_ENCRYPTION=null
32 |
33 | AWS_ACCESS_KEY_ID=
34 | AWS_SECRET_ACCESS_KEY=
35 | AWS_DEFAULT_REGION=us-east-1
36 | AWS_BUCKET=
37 |
38 | PUSHER_APP_ID=
39 | PUSHER_APP_KEY=
40 | PUSHER_APP_SECRET=
41 | PUSHER_APP_CLUSTER=mt1
42 |
43 | MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
44 | MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
45 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | * text=auto
2 | *.css linguist-vendored
3 | *.scss linguist-vendored
4 | *.js linguist-vendored
5 | CHANGELOG.md export-ignore
6 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /node_modules
2 | /public/hot
3 | /public/storage
4 | /storage/*.key
5 | /vendor
6 | .env
7 | .env.backup
8 | .phpunit.result.cache
9 | Homestead.json
10 | Homestead.yaml
11 | npm-debug.log
12 | yarn-error.log
13 | .idea/
14 | .DS_Store
15 |
--------------------------------------------------------------------------------
/.styleci.yml:
--------------------------------------------------------------------------------
1 | php:
2 | preset: laravel
3 | enabled:
4 | - alpha_ordered_imports
5 | disabled:
6 | - length_ordered_imports
7 | - unused_use
8 | finder:
9 | not-name:
10 | - index.php
11 | - server.php
12 | js:
13 | finder:
14 | not-name:
15 | - webpack.mix.js
16 | css: true
17 |
--------------------------------------------------------------------------------
/app/Category.php:
--------------------------------------------------------------------------------
1 | belongsToMany(Product::class);
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/app/Console/Kernel.php:
--------------------------------------------------------------------------------
1 | command('inspire')
28 | // ->hourly();
29 | }
30 |
31 | /**
32 | * Register the commands for the application.
33 | *
34 | * @return void
35 | */
36 | protected function commands()
37 | {
38 | $this->load(__DIR__.'/Commands');
39 |
40 | require base_path('routes/console.php');
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/app/Exceptions/Handler.php:
--------------------------------------------------------------------------------
1 | category = $category;
19 | }
20 |
21 | /**
22 | * Display a listing of the resource.
23 | *
24 | * @return \Illuminate\Http\Response
25 | */
26 | public function index()
27 | {
28 | $categories = $this->category->paginate(10);
29 |
30 | return view('admin.categories.index', compact('categories'));
31 | }
32 |
33 | /**
34 | * Show the form for creating a new resource.
35 | *
36 | * @return \Illuminate\Http\Response
37 | */
38 | public function create()
39 | {
40 | return view('admin.categories.create');
41 | }
42 |
43 | /**
44 | * Store a newly created resource in storage.
45 | *
46 | * @param CategoryRequest $request
47 | *
48 | * @return \Illuminate\Http\Response
49 | */
50 | public function store(CategoryRequest $request)
51 | {
52 | $data = $request->all();
53 |
54 | $category = $this->category->create($data);
55 |
56 | flash('Categoria Criado com Sucesso!')->success();
57 | return redirect()->route('admin.categories.index');
58 | }
59 |
60 | /**
61 | * Display the specified resource.
62 | *
63 | * @param int $id
64 | * @return \Illuminate\Http\Response
65 | */
66 | public function show($id)
67 | {
68 | //
69 | }
70 |
71 | /**
72 | * Show the form for editing the specified resource.
73 | *
74 | * @param int $category
75 | * @return \Illuminate\Http\Response
76 | */
77 | public function edit($category)
78 | {
79 | $category = $this->category->findOrFail($category);
80 |
81 | return view('admin.categories.edit', compact('category'));
82 | }
83 |
84 | /**
85 | * Update the specified resource in storage.
86 | *
87 | * @param CategoryRequest $request
88 | * @param int $category
89 | *
90 | * @return \Illuminate\Http\Response
91 | */
92 | public function update(CategoryRequest $request, $category)
93 | {
94 | $data = $request->all();
95 |
96 | $category = $this->category->find($category);
97 | $category->update($data);
98 |
99 | flash('Categoria Atualizada com Sucesso!')->success();
100 | return redirect()->route('admin.categories.index');
101 | }
102 |
103 | /**
104 | * Remove the specified resource from storage.
105 | *
106 | * @param int $category
107 | * @return \Illuminate\Http\Response
108 | */
109 | public function destroy($category)
110 | {
111 | $category = $this->category->find($category);
112 | $category->delete();
113 |
114 | flash('Categoria Removida com Sucesso!')->success();
115 | return redirect()->route('admin.categories.index');
116 | }
117 | }
118 |
--------------------------------------------------------------------------------
/app/Http/Controllers/Admin/NotificationController.php:
--------------------------------------------------------------------------------
1 | user()->unreadNotifications;
13 |
14 | return view('admin.notifications', compact('unreadNotifications'));
15 | }
16 |
17 | public function readAll()
18 | {
19 | $unreadNotifications = auth()->user()->unreadNotifications;
20 |
21 | $unreadNotifications->each(function($notification){
22 | $notification->markAsRead();
23 | });
24 |
25 | flash('Notificações lidas com sucesso!')->success();
26 | return redirect()->back();
27 | }
28 |
29 | public function read($notification)
30 | {
31 | $notification = auth()->user()->notifications()->find($notification);
32 | $notification->markAsRead();
33 |
34 | flash('Notificação lida com sucesso!')->success();
35 | return redirect()->back();
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/app/Http/Controllers/Admin/OrdersController.php:
--------------------------------------------------------------------------------
1 | order = $order;
16 | }
17 |
18 | public function index()
19 | {
20 | $orders = auth()->user()->store->orders()->paginate(15);
21 |
22 | return view('admin.orders.index', compact('orders'));
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/app/Http/Controllers/Admin/ProductController.php:
--------------------------------------------------------------------------------
1 | product = $product;
20 | }
21 |
22 | /**
23 | * Display a listing of the resource.
24 | *
25 | * @return \Illuminate\Http\Response
26 | */
27 | public function index()
28 | {
29 | $user = auth()->user();
30 |
31 | if(!$user->store()->exists()) {
32 | flash('É preciso criar uma loja para cadastrar produtos!')->warning();
33 | return redirect()->route('admin.stores.index');
34 | }
35 |
36 | $products = $user->store->products()->paginate(10);
37 |
38 | return view('admin.products.index', compact('products'));
39 | }
40 |
41 | /**
42 | * Show the form for creating a new resource.
43 | *
44 | * @return \Illuminate\Http\Response
45 | */
46 | public function create()
47 | {
48 | $categories = \App\Category::all(['id', 'name']);
49 |
50 | return view('admin.products.create', compact('categories'));
51 | }
52 |
53 | /**
54 | * Store a newly created resource in storage.
55 | *
56 | * @param \Illuminate\Http\Request $request
57 | * @return \Illuminate\Http\Response
58 | */
59 | public function store(ProductRequest $request)
60 | {
61 | $data = $request->all();
62 | $categories = $request->get('categories', null);
63 |
64 | $data['price'] = formatPriceToDatabase($data['price']);
65 |
66 | $store = auth()->user()->store;
67 | $product = $store->products()->create($data);
68 |
69 | $product->categories()->sync($categories);
70 |
71 | if($request->hasFile('photos')) {
72 | $images = $this->imageUpload($request->file('photos'), 'image');
73 |
74 | $product->photos()->createMany($images);
75 | }
76 |
77 | flash('Produto Criado com Sucesso!')->success();
78 | return redirect()->route('admin.products.index');
79 | }
80 |
81 | /**
82 | * Display the specified resource.
83 | *
84 | * @param int $id
85 | * @return \Illuminate\Http\Response
86 | */
87 | public function show($id)
88 | {
89 | }
90 |
91 | /**
92 | * Show the form for editing the specified resource.
93 | *
94 | * @param int $product
95 | * @return \Illuminate\Http\Response
96 | */
97 | public function edit($product)
98 | {
99 | $product = $this->product->findOrFail($product);
100 | $categories = \App\Category::all(['id', 'name']);
101 |
102 | return view('admin.products.edit', compact('product', 'categories'));
103 | }
104 |
105 | /**
106 | * Update the specified resource in storage.
107 | *
108 | * @param \Illuminate\Http\Request $request
109 | * @param int $product
110 | * @return \Illuminate\Http\Response
111 | */
112 | public function update(ProductRequest $request, $product)
113 | {
114 | $data = $request->all();
115 | $categories = $request->get('categories', null);
116 |
117 | $product = $this->product->find($product);
118 | $product->update($data);
119 |
120 | if(!is_null($categories))
121 | $product->categories()->sync($categories);
122 |
123 | if($request->hasFile('photos')) {
124 | $images = $this->imageUpload($request->file('photos'), 'image');
125 |
126 | $product->photos()->createMany($images);
127 | }
128 |
129 | flash('Produto Atualizado com Sucesso!')->success();
130 | return redirect()->route('admin.products.index');
131 | }
132 |
133 | /**
134 | * Remove the specified resource from storage.
135 | *
136 | * @param int $product
137 | * @return \Illuminate\Http\Response
138 | */
139 | public function destroy($product)
140 | {
141 | $product = $this->product->find($product);
142 | $product->delete();
143 |
144 | flash('Produto Removido com Sucesso!')->success();
145 | return redirect()->route('admin.products.index');
146 | }
147 | }
148 |
--------------------------------------------------------------------------------
/app/Http/Controllers/Admin/ProductPhotoController.php:
--------------------------------------------------------------------------------
1 | get('photoName');
15 |
16 | //Removo dos arquivos
17 | if(Storage::disk('public')->exists($photoName)) {
18 | Storage::disk('public')->delete($photoName);
19 | }
20 |
21 | //Removo a imagem do banco
22 | $removePhoto = ProductPhoto::where('image', $photoName);
23 |
24 | $productId = $removePhoto->first()->product_id;
25 |
26 | $removePhoto->delete();
27 |
28 | flash('Imagem removida com sucesso!')->success();
29 | return redirect()->route('admin.products.edit', ['product' => $productId]);
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/app/Http/Controllers/Admin/StoreController.php:
--------------------------------------------------------------------------------
1 | middleware('user.has.store')->only(['create', 'store']);
18 | }
19 |
20 | public function index()
21 | {
22 | $store = auth()->user()->store;
23 |
24 | return view('admin.stores.index', compact('store'));
25 | }
26 |
27 | public function create()
28 | {
29 | $users = \App\User::all(['id', 'name']);
30 |
31 | return view('admin.stores.create', compact('users'));
32 | }
33 |
34 | public function store(StoreRequest $request)
35 | {
36 | $data = $request->all();
37 | $user = auth()->user();
38 |
39 | if($request->hasFile('logo')) {
40 | $data['logo'] = $this->imageUpload($request->file('logo'));
41 | }
42 |
43 | $store = $user->store()->create($data);
44 |
45 | flash('Loja Criada com Sucesso')->success();
46 | return redirect()->route('admin.stores.index');
47 | }
48 |
49 | public function edit($store)
50 | {
51 | $store = \App\Store::find($store);
52 |
53 | return view('admin.stores.edit', compact('store'));
54 | }
55 |
56 | public function update(StoreRequest $request, $store)
57 | {
58 | $data = $request->all();
59 | $store = \App\Store::find($store);
60 |
61 | if($request->hasFile('logo')) {
62 | if(Storage::disk('public')->exists($store->logo)) {
63 | Storage::disk('public')->delete($store->logo);
64 | }
65 |
66 | $data['logo'] = $this->imageUpload($request->file('logo'));
67 | }
68 |
69 | $store->update($data);
70 |
71 | flash('Loja Atualizada com Sucesso')->success();
72 | return redirect()->route('admin.stores.index');
73 | }
74 |
75 | public function destroy($store)
76 | {
77 | $store = \App\Store::find($store);
78 | $store->delete();
79 |
80 | flash('Loja Removida com Sucesso')->success();
81 | return redirect()->route('admin.stores.index');
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/app/Http/Controllers/Auth/ForgotPasswordController.php:
--------------------------------------------------------------------------------
1 | middleware('guest');
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/app/Http/Controllers/Auth/LoginController.php:
--------------------------------------------------------------------------------
1 | middleware('guest')->except('logout');
39 | }
40 |
41 | protected function authenticated(Request $request, $user)
42 | {
43 | if($user->role == 'ROLE_OWNER')
44 | return redirect()->route('admin.stores.index');
45 |
46 | if($user->role == 'ROLE_USER' && session()->has('cart')) {
47 | return redirect()->route('checkout.index');
48 | } else {
49 | return redirect()->route('home');
50 | }
51 |
52 | return null;
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/app/Http/Controllers/Auth/RegisterController.php:
--------------------------------------------------------------------------------
1 | middleware('guest');
44 | }
45 |
46 | /**
47 | * Get a validator for an incoming registration request.
48 | *
49 | * @param array $data
50 | * @return \Illuminate\Contracts\Validation\Validator
51 | */
52 | protected function validator(array $data)
53 | {
54 | return Validator::make($data, [
55 | 'name' => ['required', 'string', 'max:255'],
56 | 'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
57 | 'password' => ['required', 'string', 'min:8', 'confirmed'],
58 | ]);
59 | }
60 |
61 | /**
62 | * Create a new user instance after a valid registration.
63 | *
64 | * @param array $data
65 | * @return \App\User
66 | */
67 | protected function create(array $data)
68 | {
69 | return User::create([
70 | 'name' => $data['name'],
71 | 'email' => $data['email'],
72 | 'password' => Hash::make($data['password']),
73 | 'role' => 'ROLE_USER'
74 | ]);
75 | }
76 |
77 | protected function registered(Request $request, $user)
78 | {
79 | Mail::to($user->email)->send(new UserRegisteredEmail($user));
80 |
81 | if($user->role == 'ROLE_OWNER')
82 | return redirect()->route('admin.stores.index');
83 |
84 | if($user->role == 'ROLE_USER' && session()->has('cart')) {
85 | return redirect()->route('checkout.index');
86 | } else {
87 | return redirect()->route('home');
88 | }
89 |
90 | return null;
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/app/Http/Controllers/Auth/ResetPasswordController.php:
--------------------------------------------------------------------------------
1 | middleware('guest');
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/app/Http/Controllers/Auth/VerificationController.php:
--------------------------------------------------------------------------------
1 | middleware('auth');
38 | $this->middleware('signed')->only('verify');
39 | $this->middleware('throttle:6,1')->only('verify', 'resend');
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/app/Http/Controllers/CartController.php:
--------------------------------------------------------------------------------
1 | has('cart') ? session()->get('cart') : [];
12 | return view('cart', compact('cart'));
13 | }
14 |
15 | public function add(Request $request)
16 | {
17 | $productData = $request->get('product');
18 |
19 | $product = \App\Product::whereSlug($productData['slug']);
20 |
21 | if(!$product->count() || $productData['amount'] <= 0)
22 | return redirect()->route('home');
23 |
24 | $product = array_merge($productData,
25 | $product->first(['id', 'name', 'price', 'store_id'])->toArray());
26 |
27 | if(session()->has('cart')) {
28 |
29 | $products = session()->get('cart');
30 | $productsSlugs = array_column($products, 'slug');
31 |
32 | if(in_array($product['slug'], $productsSlugs)) {
33 |
34 | $products = $this->productIncrement($product['slug'], $product['amount'], $products);
35 |
36 | session()->put('cart', $products);
37 |
38 | } else {
39 |
40 | session()->push('cart', $product);
41 |
42 | }
43 |
44 | } else {
45 | $products[] = $product;
46 |
47 | session()->put('cart', $products);
48 | }
49 |
50 | flash('Produto Adicionado no carrinho!')->success();
51 | return redirect()->route('product.single', ['slug' => $product['slug']]);
52 | }
53 |
54 | public function remove($slug)
55 | {
56 | if(!session()->has('cart'))
57 | return redirect()->route('cart.index');
58 |
59 | $products = session()->get('cart');
60 |
61 | $products = array_filter($products, function($line) use($slug){
62 | return $line['slug'] != $slug;
63 | });
64 |
65 | session()->put('cart', $products);
66 | return redirect()->route('cart.index');
67 | }
68 |
69 | public function cancel()
70 | {
71 | session()->forget('cart');
72 |
73 | flash('Desistência da compra realizada com sucesso!')->success();
74 | return redirect()->route('cart.index');
75 | }
76 |
77 | private function productIncrement($slug, $amount, $products)
78 | {
79 | $products = array_map(function($line) use($slug, $amount){
80 | if($slug == $line['slug']) {
81 | $line['amount'] += $amount;
82 | }
83 | return $line;
84 | }, $products);
85 |
86 | return $products;
87 | }
88 | }
89 |
--------------------------------------------------------------------------------
/app/Http/Controllers/CategoryController.php:
--------------------------------------------------------------------------------
1 | category = $category;
15 | }
16 |
17 | public function index($slug)
18 | {
19 | $category = $this->category->whereSlug($slug)->first();
20 |
21 | return view('category', compact('category'));
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/app/Http/Controllers/CheckoutController.php:
--------------------------------------------------------------------------------
1 | check()) {
18 | return redirect()->route('login');
19 | }
20 |
21 | if(!session()->has('cart')) return redirect()->route('home');
22 |
23 | $this->makePagSeguroSession();
24 |
25 | $cartItems = array_map(function($line){
26 | return $line['amount'] * $line['price'];
27 | }, session()->get('cart'));
28 |
29 | $cartItems = array_sum($cartItems);
30 |
31 | return view('checkout', compact('cartItems'));
32 |
33 | } catch (\Exception $e) {
34 | session()->forget('pagseguro_session_code');
35 | redirect()->route('checkout.index');
36 | }
37 | }
38 |
39 | public function proccess(Request $request)
40 | {
41 | try {
42 | $dataPost = $request->all();
43 | $user = auth()->user();
44 | $cartItems = session()->get('cart');
45 | $stores = array_unique(array_column($cartItems, 'store_id'));
46 | $reference = Uuid::uuid4();
47 |
48 | $creditCardPayment = new CreditCard($cartItems, $user, $dataPost, $reference);
49 | $result = $creditCardPayment->doPayment();
50 |
51 | $userOrder = [
52 | 'reference' => $reference,
53 | 'pagseguro_code' => $result->getCode(),
54 | 'pagseguro_status' => $result->getStatus(),
55 | 'items' => serialize($cartItems)
56 | ];
57 |
58 | $userOrder = $user->orders()->create($userOrder);
59 |
60 | $userOrder->stores()->sync($stores);
61 |
62 | //Notificar loja de novo pedido
63 | $store = (new Store())->notifyStoreOwners($stores);
64 |
65 | session()->forget('cart');
66 | session()->forget('pagseguro_session_code');
67 |
68 | return response()->json([
69 | 'data' => [
70 | 'status' => true,
71 | 'message' => 'Pedido criado com sucesso!',
72 | 'order' => $reference
73 | ]
74 | ]);
75 |
76 | } catch (\Exception $e) {
77 | $message = env('APP_DEBUG') ? simplexml_load_string($e->getMessage()) : 'Erro ao processar pedido!';
78 |
79 | return response()->json([
80 | 'data' => [
81 | 'status' => false,
82 | 'message' => $message
83 | ]
84 | ], 401);
85 | }
86 | }
87 |
88 | public function thanks()
89 | {
90 | return view('thanks');
91 | }
92 |
93 | public function notification()
94 | {
95 | try{
96 | $notification = new Notification();
97 | $notification = $notification->getTransaction();
98 |
99 | $reference = base64_decode($notification->getReference());
100 |
101 | $userOrder = UserOrder::whereReference($reference);
102 | $userOrder->update([
103 | 'pagseguro_status' => $notification->getStatus()
104 | ]);
105 |
106 | if($notification->getStatus() == 3) {
107 | // Liberar o pedido do usuário..., atualizar o status do pedido para em separação
108 | //Notificar o usuário que o pedido foi pago...
109 | //Notificar a loja da confirmação do pedido...
110 | }
111 |
112 | return response()->json([], 204);
113 |
114 | } catch (\Exception $e) {
115 | $message = env('APP_DEBUG') ? $e->getMessage() : '';
116 |
117 | return response()->json(['error' => $message], 500);
118 | }
119 | }
120 |
121 | private function makePagSeguroSession()
122 | {
123 | if(!session()->has('pagseguro_session_code')) {
124 |
125 | $sessionCode = \PagSeguro\Services\Session::create(
126 | \PagSeguro\Configuration\Configure::getAccountCredentials()
127 | );
128 |
129 | return session()->put('pagseguro_session_code', $sessionCode->getResult());
130 | }
131 | }
132 | }
133 |
--------------------------------------------------------------------------------
/app/Http/Controllers/Controller.php:
--------------------------------------------------------------------------------
1 | product = $product;
14 | }
15 |
16 | public function index()
17 | {
18 | $products = $this->product->limit(6)->orderBy('id', 'DESC')->get();
19 | $stores = \App\Store::limit(3)->orderBy('id', 'DESC')->get();
20 |
21 | return view('welcome', compact('products', 'stores'));
22 | }
23 |
24 | public function single($slug)
25 | {
26 | $product = $this->product->whereSlug($slug)->first();
27 |
28 | return view('single', compact('product'));
29 | }
30 | }
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/app/Http/Controllers/StoreController.php:
--------------------------------------------------------------------------------
1 | store = $store;
15 | }
16 |
17 | public function index($slug)
18 | {
19 | $store = $this->store->whereSlug($slug)->first();
20 | return view('store', compact('store'));
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/app/Http/Controllers/UserOrderController.php:
--------------------------------------------------------------------------------
1 | user()->orders()->paginate(15);
12 |
13 | return view('user-orders', compact('userOrders'));
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/app/Http/Kernel.php:
--------------------------------------------------------------------------------
1 | [
31 | \App\Http\Middleware\EncryptCookies::class,
32 | \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
33 | \Illuminate\Session\Middleware\StartSession::class,
34 | // \Illuminate\Session\Middleware\AuthenticateSession::class,
35 | \Illuminate\View\Middleware\ShareErrorsFromSession::class,
36 | \App\Http\Middleware\VerifyCsrfToken::class,
37 | \Illuminate\Routing\Middleware\SubstituteBindings::class,
38 | ],
39 |
40 | 'api' => [
41 | 'throttle:60,1',
42 | 'bindings',
43 | ],
44 | ];
45 |
46 | /**
47 | * The application's route middleware.
48 | *
49 | * These middleware may be assigned to groups or used individually.
50 | *
51 | * @var array
52 | */
53 | protected $routeMiddleware = [
54 | 'auth' => \App\Http\Middleware\Authenticate::class,
55 | 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
56 | 'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
57 | 'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
58 | 'can' => \Illuminate\Auth\Middleware\Authorize::class,
59 | 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
60 | 'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
61 | 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
62 | 'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
63 | 'user.has.store' => \App\Http\Middleware\UserHasStoreMiddleware::class,
64 | 'access.control.store.admin' => \App\Http\Middleware\AccessControlStoreAdmin::class
65 | ];
66 |
67 | /**
68 | * The priority-sorted list of middleware.
69 | *
70 | * This forces non-global middleware to always be in the given order.
71 | *
72 | * @var array
73 | */
74 | protected $middlewarePriority = [
75 | \Illuminate\Session\Middleware\StartSession::class,
76 | \Illuminate\View\Middleware\ShareErrorsFromSession::class,
77 | \App\Http\Middleware\Authenticate::class,
78 | \Illuminate\Routing\Middleware\ThrottleRequests::class,
79 | \Illuminate\Session\Middleware\AuthenticateSession::class,
80 | \Illuminate\Routing\Middleware\SubstituteBindings::class,
81 | \Illuminate\Auth\Middleware\Authorize::class,
82 | ];
83 | }
84 |
--------------------------------------------------------------------------------
/app/Http/Middleware/AccessControlStoreAdmin.php:
--------------------------------------------------------------------------------
1 | user()->role == 'ROLE_USER')
19 | return redirect()->route('user.orders');
20 |
21 | return $next($request);
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/app/Http/Middleware/Authenticate.php:
--------------------------------------------------------------------------------
1 | expectsJson()) {
18 | return route('login');
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/app/Http/Middleware/CheckForMaintenanceMode.php:
--------------------------------------------------------------------------------
1 | check()) {
21 | return redirect('/home');
22 | }
23 |
24 | return $next($request);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/Http/Middleware/TrimStrings.php:
--------------------------------------------------------------------------------
1 | user()->store()->count()) {
19 | flash('Você já possui uma loja!')->warning();
20 | return redirect()->route('admin.stores.index');
21 | }
22 |
23 | return $next($request);
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/app/Http/Middleware/VerifyCsrfToken.php:
--------------------------------------------------------------------------------
1 | 'required'
28 | ];
29 | }
30 |
31 | public function messages()
32 | {
33 | return [
34 | 'required' => 'Este campo é obrigatório!'
35 | ];
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/app/Http/Requests/ProductRequest.php:
--------------------------------------------------------------------------------
1 | 'required',
28 | 'description' => 'required|min:30',
29 | 'body' => 'required',
30 | 'price' => 'required',
31 | 'photos.*' => 'image'
32 | ];
33 | }
34 |
35 | public function messages()
36 | {
37 | return [
38 | 'required' => 'Este campo é obrigatório!',
39 | 'min' => 'Campo deve ter no mínimo :min caracteres',
40 | 'image' => 'Arquivo não é uma imagem válida!'
41 | ];
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/app/Http/Requests/StoreRequest.php:
--------------------------------------------------------------------------------
1 | 'required',
28 | 'description' => 'required|min:10',
29 | 'phone' => 'required',
30 | 'mobile_phone' => 'required',
31 | 'logo' => 'image'
32 | ];
33 | }
34 |
35 | public function messages()
36 | {
37 | return [
38 | 'required' => 'Este campo é obrigatório',
39 | 'min' => 'Campo deve ter no mínimo :min caracteres',
40 | 'image' => 'Arquivo não é uma imagem válida!'
41 | ];
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/app/Http/Views/CategoryViewComposer.php:
--------------------------------------------------------------------------------
1 | category = $category;
13 | }
14 |
15 | public function compose($view)
16 | {
17 | return $view->with('categories', $this->category->all(['name', 'slug']));
18 | }
19 | }
--------------------------------------------------------------------------------
/app/Mail/UserRegisteredEmail.php:
--------------------------------------------------------------------------------
1 | user = $user;
25 | }
26 |
27 | /**
28 | * Build the message.
29 | *
30 | * @return $this
31 | */
32 | public function build()
33 | {
34 | return $this
35 | ->subject('Conta Criada com Sucesso!')
36 | ->replyTo('contato@codeexperts.com.br')
37 | ->view('emails.user-registered');
38 | // ->with(['user' => $this->user]);
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/app/Notifications/StoreReceiveNewOrder.php:
--------------------------------------------------------------------------------
1 | subject('Você recebeu um novo pedido!')
46 | ->greeting('Olá vendedor, tudo bem?')
47 | ->line('Você recebeu um novo pedido na loja!')
48 | ->action('Ver pedido', route('admin.orders.my'));
49 | }
50 |
51 | /**
52 | * Get the array representation of the notification.
53 | *
54 | * @param mixed $notifiable
55 | * @return array
56 | */
57 | public function toArray($notifiable)
58 | {
59 | return [
60 | 'message' => 'Você têm um novo pedido solicitado'
61 | ];
62 | }
63 |
64 | public function toNexmo($notifiable)
65 | {
66 | return (new NexmoMessage)
67 | ->content('Você recebeu um novo pedido em nosso site!')
68 | ->from('5598984284714')
69 | ->unicode()
70 | ;
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/app/Payment/PagSeguro/CreditCard.php:
--------------------------------------------------------------------------------
1 | items = $items;
14 | $this->user = $user;
15 | $this->cardInfo = $cardInfo;
16 | $this->reference = $reference;
17 | }
18 |
19 | public function doPayment()
20 | {
21 | $creditCard = new \PagSeguro\Domains\Requests\DirectPayment\CreditCard();
22 |
23 | $creditCard->setReceiverEmail(env('PAGSEGURO_EMAIL'));
24 | $creditCard->setReference(base64_encode($this->reference));
25 | $creditCard->setCurrency("BRL");
26 |
27 | foreach($this->items as $item) {
28 | $creditCard->addItems()->withParameters(
29 | $item['id'],
30 | $item['name'],
31 | $item['amount'],
32 | $item['price']
33 | );
34 | }
35 |
36 | $user = $this->user;
37 | $email = env('PAGSEGURO_ENV') == 'sandbox' ? 'test@sandbox.pagseguro.com.br' : $user->email;
38 |
39 | $creditCard->setSender()->setName($user->name);
40 | $creditCard->setSender()->setEmail($email);
41 | $creditCard->setSender()->setPhone()->withParameters(
42 | 11,
43 | 56273440
44 | );
45 | $creditCard->setSender()->setDocument()->withParameters(
46 | 'CPF',
47 | '27121238918'
48 | );
49 | $creditCard->setSender()->setHash($this->cardInfo['hash']);
50 | $creditCard->setSender()->setIp('127.0.0.0');
51 |
52 | $creditCard->setShipping()->setAddress()->withParameters(
53 | 'Av. Brig. Faria Lima',
54 | '1384',
55 | 'Jardim Paulistano',
56 | '01452002',
57 | 'São Paulo',
58 | 'SP',
59 | 'BRA',
60 | 'apto. 114'
61 | );
62 |
63 | $creditCard->setBilling()->setAddress()->withParameters(
64 | 'Av. Brig. Faria Lima',
65 | '1384',
66 | 'Jardim Paulistano',
67 | '01452002',
68 | 'São Paulo',
69 | 'SP',
70 | 'BRA',
71 | 'apto. 114'
72 | );
73 |
74 | $creditCard->setToken($this->cardInfo['card_token']);
75 | list($quantity, $installmentAmount) = explode('|', $this->cardInfo['installment']);
76 |
77 | $installmentAmount = number_format($installmentAmount, 2, '.', '');
78 |
79 | $creditCard->setInstallment()->withParameters($quantity, $installmentAmount);
80 |
81 | $creditCard->setHolder()->setBirthdate('01/10/1979');
82 | $creditCard->setHolder()->setName($this->cardInfo['card_name']);
83 | $creditCard->setHolder()->setPhone()->withParameters(
84 | 11,
85 | 56273440
86 | );
87 | $creditCard->setHolder()->setDocument()->withParameters(
88 | 'CPF',
89 | '27121238918'
90 | );
91 |
92 | $creditCard->setMode('DEFAULT');
93 |
94 | $result = $creditCard->register(
95 | \PagSeguro\Configuration\Configure::getAccountCredentials()
96 | );
97 |
98 | return $result;
99 | }
100 | }
--------------------------------------------------------------------------------
/app/Payment/PagSeguro/Notification.php:
--------------------------------------------------------------------------------
1 | photos->first()->image;
17 | }
18 |
19 | public function store()
20 | {
21 | return $this->belongsTo(Store::class);
22 | }
23 |
24 | public function categories()
25 | {
26 | return $this->belongsToMany(Category::class);
27 | }
28 |
29 | public function photos()
30 | {
31 | return $this->hasMany(ProductPhoto::class);
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/app/ProductPhoto.php:
--------------------------------------------------------------------------------
1 | belongsTo(Product::class);
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/app/Providers/AppServiceProvider.php:
--------------------------------------------------------------------------------
1 | setName("Marketplace")->setRelease("1.0.0");
29 | \PagSeguro\Library::moduleVersion()->setName("Marketplace")->setRelease("1.0.0");
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/app/Providers/AuthServiceProvider.php:
--------------------------------------------------------------------------------
1 | 'App\Policies\ModelPolicy',
17 | ];
18 |
19 | /**
20 | * Register any authentication / authorization services.
21 | *
22 | * @return void
23 | */
24 | public function boot()
25 | {
26 | $this->registerPolicies();
27 |
28 | //
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/app/Providers/BroadcastServiceProvider.php:
--------------------------------------------------------------------------------
1 | share('categories', $categories);
29 | // view()->composer('*', function($view) use($categories){
30 | // $view->with('categories', $categories);
31 | // });
32 |
33 | view()->composer('layouts.front', 'App\Http\Views\CategoryViewComposer@compose');
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/app/Providers/EventServiceProvider.php:
--------------------------------------------------------------------------------
1 | [
19 | SendEmailVerificationNotification::class,
20 | ],
21 | ];
22 |
23 | /**
24 | * Register any events for your application.
25 | *
26 | * @return void
27 | */
28 | public function boot()
29 | {
30 | parent::boot();
31 |
32 | //
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/app/Providers/RouteServiceProvider.php:
--------------------------------------------------------------------------------
1 | mapApiRoutes();
39 |
40 | $this->mapWebRoutes();
41 |
42 | //
43 | }
44 |
45 | /**
46 | * Define the "web" routes for the application.
47 | *
48 | * These routes all receive session state, CSRF protection, etc.
49 | *
50 | * @return void
51 | */
52 | protected function mapWebRoutes()
53 | {
54 | Route::middleware('web')
55 | ->namespace($this->namespace)
56 | ->group(base_path('routes/web.php'));
57 | }
58 |
59 | /**
60 | * Define the "api" routes for the application.
61 | *
62 | * These routes are typically stateless.
63 | *
64 | * @return void
65 | */
66 | protected function mapApiRoutes()
67 | {
68 | Route::prefix('api')
69 | ->middleware('api')
70 | ->namespace($this->namespace)
71 | ->group(base_path('routes/api.php'));
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/app/Store.php:
--------------------------------------------------------------------------------
1 | belongsTo(User::class);
18 | }
19 |
20 | public function products()
21 | {
22 | return $this->hasMany(Product::class);
23 | }
24 |
25 | public function orders()
26 | {
27 | return $this->belongsToMany(UserOrder::class, 'order_store', null, 'order_id');
28 | }
29 |
30 | public function notifyStoreOwners(array $storesId = [])
31 | {
32 | $stores = $this->whereIn('id', $storesId)->get();
33 |
34 | $stores->map(function($store){
35 | return $store->user;
36 | })->each->notify(new StoreReceiveNewOrder());
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/app/Traits/Slug.php:
--------------------------------------------------------------------------------
1 | uniqueSlug($slug);
12 |
13 | $this->attributes['name'] = $value;
14 | $this->attributes['slug'] = $matchs ? $slug . '-' . $matchs : $slug;
15 | }
16 |
17 | public function uniqueSlug($slug)
18 | {
19 | $matchs = $this->whereRaw("slug REGEXP '^{$slug}(-[0-9]*)?$'")->count();
20 |
21 | return $matchs;
22 | }
23 | }
--------------------------------------------------------------------------------
/app/Traits/UploadTrait.php:
--------------------------------------------------------------------------------
1 | $image->store('products', 'public')];
15 | }
16 |
17 | } else {
18 | $uploadedImages = $images->store('logo', 'public');
19 | }
20 |
21 | return $uploadedImages;
22 | }
23 | }
--------------------------------------------------------------------------------
/app/User.php:
--------------------------------------------------------------------------------
1 | 'datetime'
38 | ];
39 |
40 | public function store()
41 | {
42 | return $this->hasOne(Store::class);
43 | }
44 |
45 | public function orders()
46 | {
47 | return $this->hasMany(UserOrder::class);
48 | }
49 |
50 | public function routeNotificationForNexmo($notification)
51 | {
52 | $storeMobilePhoneNumber = trim(str_replace(['(', ')', ' ', '-'], '', $this->store->mobile_phone));
53 | return '55' . $storeMobilePhoneNumber;
54 | }
55 | }
--------------------------------------------------------------------------------
/app/UserOrder.php:
--------------------------------------------------------------------------------
1 | belongsTo(User::class);
14 | }
15 |
16 | public function store()
17 | {
18 | return $this->belongsTo(Store::class);
19 | }
20 |
21 | public function stores()
22 | {
23 | return $this->belongsToMany(Store::class, 'order_store', 'order_id');
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/artisan:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env php
2 | make(Illuminate\Contracts\Console\Kernel::class);
34 |
35 | $status = $kernel->handle(
36 | $input = new Symfony\Component\Console\Input\ArgvInput,
37 | new Symfony\Component\Console\Output\ConsoleOutput
38 | );
39 |
40 | /*
41 | |--------------------------------------------------------------------------
42 | | Shutdown The Application
43 | |--------------------------------------------------------------------------
44 | |
45 | | Once Artisan has finished running, we will fire off the shutdown events
46 | | so that any final work may be done by the application before we shut
47 | | down the process. This is the last thing to happen to the request.
48 | |
49 | */
50 |
51 | $kernel->terminate($input, $status);
52 |
53 | exit($status);
54 |
--------------------------------------------------------------------------------
/bootstrap/app.php:
--------------------------------------------------------------------------------
1 | singleton(
30 | Illuminate\Contracts\Http\Kernel::class,
31 | App\Http\Kernel::class
32 | );
33 |
34 | $app->singleton(
35 | Illuminate\Contracts\Console\Kernel::class,
36 | App\Console\Kernel::class
37 | );
38 |
39 | $app->singleton(
40 | Illuminate\Contracts\Debug\ExceptionHandler::class,
41 | App\Exceptions\Handler::class
42 | );
43 |
44 | /*
45 | |--------------------------------------------------------------------------
46 | | Return The Application
47 | |--------------------------------------------------------------------------
48 | |
49 | | This script returns the application instance. The instance is given to
50 | | the calling script so we can separate the building of the instances
51 | | from the actual running of the application and sending responses.
52 | |
53 | */
54 |
55 | return $app;
56 |
--------------------------------------------------------------------------------
/bootstrap/cache/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 | !.gitignore
3 |
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "laravel/laravel",
3 | "type": "project",
4 | "description": "The Laravel Framework.",
5 | "keywords": [
6 | "framework",
7 | "laravel"
8 | ],
9 | "license": "MIT",
10 | "require": {
11 | "php": "^7.2",
12 | "fideloper/proxy": "^4.0",
13 | "laracasts/flash": "^3.0",
14 | "laravel/framework": "^6.0",
15 | "laravel/nexmo-notification-channel": "^2.3",
16 | "laravel/tinker": "^1.0",
17 | "laravel/ui": "^1.1",
18 | "pagseguro/pagseguro-php-sdk": "^6.0",
19 | "ramsey/uuid": "^3.9",
20 | "spatie/laravel-sluggable": "^2.2"
21 | },
22 | "require-dev": {
23 | "facade/ignition": "^1.4",
24 | "fzaninotto/faker": "^1.4",
25 | "mockery/mockery": "^1.0",
26 | "nunomaduro/collision": "^3.0",
27 | "phpunit/phpunit": "^8.0"
28 | },
29 | "config": {
30 | "optimize-autoloader": true,
31 | "preferred-install": "dist",
32 | "sort-packages": true
33 | },
34 | "extra": {
35 | "laravel": {
36 | "dont-discover": []
37 | }
38 | },
39 | "autoload": {
40 | "psr-4": {
41 | "App\\": "app/"
42 | },
43 | "classmap": [
44 | "database/seeds",
45 | "database/factories"
46 | ],
47 | "files": ["helpers/functions.php"]
48 | },
49 | "autoload-dev": {
50 | "psr-4": {
51 | "Tests\\": "tests/"
52 | }
53 | },
54 | "minimum-stability": "dev",
55 | "prefer-stable": true,
56 | "scripts": {
57 | "post-autoload-dump": [
58 | "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
59 | "@php artisan package:discover --ansi"
60 | ],
61 | "post-root-package-install": [
62 | "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
63 | ],
64 | "post-create-project-cmd": [
65 | "@php artisan key:generate --ansi"
66 | ]
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/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 | 'hash' => false,
48 | ],
49 | ],
50 |
51 | /*
52 | |--------------------------------------------------------------------------
53 | | User Providers
54 | |--------------------------------------------------------------------------
55 | |
56 | | All authentication drivers have a user provider. This defines how the
57 | | users are actually retrieved out of your database or other storage
58 | | mechanisms used by this application to persist your user's data.
59 | |
60 | | If you have multiple user tables or models you may configure multiple
61 | | sources which represent each model / table. These sources may then
62 | | be assigned to any extra authentication guards you have defined.
63 | |
64 | | Supported: "database", "eloquent"
65 | |
66 | */
67 |
68 | 'providers' => [
69 | 'users' => [
70 | 'driver' => 'eloquent',
71 | 'model' => App\User::class,
72 | ],
73 |
74 | // 'users' => [
75 | // 'driver' => 'database',
76 | // 'table' => 'users',
77 | // ],
78 | ],
79 |
80 | /*
81 | |--------------------------------------------------------------------------
82 | | Resetting Passwords
83 | |--------------------------------------------------------------------------
84 | |
85 | | You may specify multiple password reset configurations if you have more
86 | | than one user table or model in the application and you want to have
87 | | separate password reset settings based on the specific user types.
88 | |
89 | | The expire time is the number of minutes that the reset token should be
90 | | considered valid. This security feature keeps tokens short-lived so
91 | | they have less time to be guessed. You may change this as needed.
92 | |
93 | */
94 |
95 | 'passwords' => [
96 | 'users' => [
97 | 'provider' => 'users',
98 | 'table' => 'password_resets',
99 | 'expire' => 60,
100 | ],
101 | ],
102 |
103 | ];
104 |
--------------------------------------------------------------------------------
/config/broadcasting.php:
--------------------------------------------------------------------------------
1 | env('BROADCAST_DRIVER', 'null'),
19 |
20 | /*
21 | |--------------------------------------------------------------------------
22 | | Broadcast Connections
23 | |--------------------------------------------------------------------------
24 | |
25 | | Here you may define all of the broadcast connections that will be used
26 | | to broadcast events to other systems or over websockets. Samples of
27 | | each available type of connection are provided inside this array.
28 | |
29 | */
30 |
31 | 'connections' => [
32 |
33 | 'pusher' => [
34 | 'driver' => 'pusher',
35 | 'key' => env('PUSHER_APP_KEY'),
36 | 'secret' => env('PUSHER_APP_SECRET'),
37 | 'app_id' => env('PUSHER_APP_ID'),
38 | 'options' => [
39 | 'cluster' => env('PUSHER_APP_CLUSTER'),
40 | 'useTLS' => true,
41 | ],
42 | ],
43 |
44 | 'redis' => [
45 | 'driver' => 'redis',
46 | 'connection' => 'default',
47 | ],
48 |
49 | 'log' => [
50 | 'driver' => 'log',
51 | ],
52 |
53 | 'null' => [
54 | 'driver' => 'null',
55 | ],
56 |
57 | ],
58 |
59 | ];
60 |
--------------------------------------------------------------------------------
/config/cache.php:
--------------------------------------------------------------------------------
1 | env('CACHE_DRIVER', 'file'),
22 |
23 | /*
24 | |--------------------------------------------------------------------------
25 | | Cache Stores
26 | |--------------------------------------------------------------------------
27 | |
28 | | Here you may define all of the cache "stores" for your application as
29 | | well as their drivers. You may even define multiple stores for the
30 | | same cache driver to group types of items stored in your caches.
31 | |
32 | */
33 |
34 | 'stores' => [
35 |
36 | 'apc' => [
37 | 'driver' => 'apc',
38 | ],
39 |
40 | 'array' => [
41 | 'driver' => 'array',
42 | ],
43 |
44 | 'database' => [
45 | 'driver' => 'database',
46 | 'table' => 'cache',
47 | 'connection' => null,
48 | ],
49 |
50 | 'file' => [
51 | 'driver' => 'file',
52 | 'path' => storage_path('framework/cache/data'),
53 | ],
54 |
55 | 'memcached' => [
56 | 'driver' => 'memcached',
57 | 'persistent_id' => env('MEMCACHED_PERSISTENT_ID'),
58 | 'sasl' => [
59 | env('MEMCACHED_USERNAME'),
60 | env('MEMCACHED_PASSWORD'),
61 | ],
62 | 'options' => [
63 | // Memcached::OPT_CONNECT_TIMEOUT => 2000,
64 | ],
65 | 'servers' => [
66 | [
67 | 'host' => env('MEMCACHED_HOST', '127.0.0.1'),
68 | 'port' => env('MEMCACHED_PORT', 11211),
69 | 'weight' => 100,
70 | ],
71 | ],
72 | ],
73 |
74 | 'redis' => [
75 | 'driver' => 'redis',
76 | 'connection' => 'cache',
77 | ],
78 |
79 | 'dynamodb' => [
80 | 'driver' => 'dynamodb',
81 | 'key' => env('AWS_ACCESS_KEY_ID'),
82 | 'secret' => env('AWS_SECRET_ACCESS_KEY'),
83 | 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
84 | 'table' => env('DYNAMODB_CACHE_TABLE', 'cache'),
85 | 'endpoint' => env('DYNAMODB_ENDPOINT'),
86 | ],
87 |
88 | ],
89 |
90 | /*
91 | |--------------------------------------------------------------------------
92 | | Cache Key Prefix
93 | |--------------------------------------------------------------------------
94 | |
95 | | When utilizing a RAM based store such as APC or Memcached, there might
96 | | be other applications utilizing the same cache. So, we'll specify a
97 | | value to get prefixed to all our keys so we can avoid collisions.
98 | |
99 | */
100 |
101 | 'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_cache'),
102 |
103 | ];
104 |
--------------------------------------------------------------------------------
/config/database.php:
--------------------------------------------------------------------------------
1 | env('DB_CONNECTION', 'mysql'),
19 |
20 | /*
21 | |--------------------------------------------------------------------------
22 | | Database Connections
23 | |--------------------------------------------------------------------------
24 | |
25 | | Here are each of the database connections setup for your application.
26 | | Of course, examples of configuring each database platform that is
27 | | supported by Laravel is shown below to make development simple.
28 | |
29 | |
30 | | All database work in Laravel is done through the PHP PDO facilities
31 | | so make sure you have the driver for your particular database of
32 | | choice installed on your machine before you begin development.
33 | |
34 | */
35 |
36 | 'connections' => [
37 |
38 | 'sqlite' => [
39 | 'driver' => 'sqlite',
40 | 'url' => env('DATABASE_URL'),
41 | 'database' => env('DB_DATABASE', database_path('database.sqlite')),
42 | 'prefix' => '',
43 | 'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),
44 | ],
45 |
46 | 'mysql' => [
47 | 'driver' => 'mysql',
48 | 'url' => env('DATABASE_URL'),
49 | 'host' => env('DB_HOST', '127.0.0.1'),
50 | 'port' => env('DB_PORT', '3306'),
51 | 'database' => env('DB_DATABASE', 'forge'),
52 | 'username' => env('DB_USERNAME', 'forge'),
53 | 'password' => env('DB_PASSWORD', ''),
54 | 'unix_socket' => env('DB_SOCKET', ''),
55 | 'charset' => 'utf8mb4',
56 | 'collation' => 'utf8mb4_unicode_ci',
57 | 'prefix' => '',
58 | 'prefix_indexes' => true,
59 | 'strict' => true,
60 | 'engine' => null,
61 | 'options' => extension_loaded('pdo_mysql') ? array_filter([
62 | PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
63 | ]) : [],
64 | ],
65 |
66 | 'pgsql' => [
67 | 'driver' => 'pgsql',
68 | 'url' => env('DATABASE_URL'),
69 | 'host' => env('DB_HOST', '127.0.0.1'),
70 | 'port' => env('DB_PORT', '5432'),
71 | 'database' => env('DB_DATABASE', 'forge'),
72 | 'username' => env('DB_USERNAME', 'forge'),
73 | 'password' => env('DB_PASSWORD', ''),
74 | 'charset' => 'utf8',
75 | 'prefix' => '',
76 | 'prefix_indexes' => true,
77 | 'schema' => 'public',
78 | 'sslmode' => 'prefer',
79 | ],
80 |
81 | 'sqlsrv' => [
82 | 'driver' => 'sqlsrv',
83 | 'url' => env('DATABASE_URL'),
84 | 'host' => env('DB_HOST', 'localhost'),
85 | 'port' => env('DB_PORT', '1433'),
86 | 'database' => env('DB_DATABASE', 'forge'),
87 | 'username' => env('DB_USERNAME', 'forge'),
88 | 'password' => env('DB_PASSWORD', ''),
89 | 'charset' => 'utf8',
90 | 'prefix' => '',
91 | 'prefix_indexes' => true,
92 | ],
93 |
94 | ],
95 |
96 | /*
97 | |--------------------------------------------------------------------------
98 | | Migration Repository Table
99 | |--------------------------------------------------------------------------
100 | |
101 | | This table keeps track of all the migrations that have already run for
102 | | your application. Using this information, we can determine which of
103 | | the migrations on disk haven't actually been run in the database.
104 | |
105 | */
106 |
107 | 'migrations' => 'migrations',
108 |
109 | /*
110 | |--------------------------------------------------------------------------
111 | | Redis Databases
112 | |--------------------------------------------------------------------------
113 | |
114 | | Redis is an open source, fast, and advanced key-value store that also
115 | | provides a richer body of commands than a typical key-value system
116 | | such as APC or Memcached. Laravel makes it easy to dig right in.
117 | |
118 | */
119 |
120 | 'redis' => [
121 |
122 | 'client' => env('REDIS_CLIENT', 'phpredis'),
123 |
124 | 'options' => [
125 | 'cluster' => env('REDIS_CLUSTER', 'redis'),
126 | 'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'),
127 | ],
128 |
129 | 'default' => [
130 | 'url' => env('REDIS_URL'),
131 | 'host' => env('REDIS_HOST', '127.0.0.1'),
132 | 'password' => env('REDIS_PASSWORD', null),
133 | 'port' => env('REDIS_PORT', 6379),
134 | 'database' => env('REDIS_DB', 0),
135 | ],
136 |
137 | 'cache' => [
138 | 'url' => env('REDIS_URL'),
139 | 'host' => env('REDIS_HOST', '127.0.0.1'),
140 | 'password' => env('REDIS_PASSWORD', null),
141 | 'port' => env('REDIS_PORT', 6379),
142 | 'database' => env('REDIS_CACHE_DB', 1),
143 | ],
144 |
145 | ],
146 |
147 | ];
148 |
--------------------------------------------------------------------------------
/config/filesystems.php:
--------------------------------------------------------------------------------
1 | env('FILESYSTEM_DRIVER', 'local'),
17 |
18 | /*
19 | |--------------------------------------------------------------------------
20 | | Default Cloud Filesystem Disk
21 | |--------------------------------------------------------------------------
22 | |
23 | | Many applications store files both locally and in the cloud. For this
24 | | reason, you may specify a default "cloud" driver here. This driver
25 | | will be bound as the Cloud disk implementation in the container.
26 | |
27 | */
28 |
29 | 'cloud' => env('FILESYSTEM_CLOUD', 's3'),
30 |
31 | /*
32 | |--------------------------------------------------------------------------
33 | | Filesystem Disks
34 | |--------------------------------------------------------------------------
35 | |
36 | | Here you may configure as many filesystem "disks" as you wish, and you
37 | | may even configure multiple disks of the same driver. Defaults have
38 | | been setup for each driver as an example of the required options.
39 | |
40 | | Supported Drivers: "local", "ftp", "sftp", "s3"
41 | |
42 | */
43 |
44 | 'disks' => [
45 |
46 | 'local' => [
47 | 'driver' => 'local',
48 | 'root' => storage_path('app'),
49 | ],
50 |
51 | 'public' => [
52 | 'driver' => 'local',
53 | 'root' => storage_path('app/public'),
54 | 'url' => env('APP_URL').'/storage',
55 | 'visibility' => 'public',
56 | ],
57 |
58 | 's3' => [
59 | 'driver' => 's3',
60 | 'key' => env('AWS_ACCESS_KEY_ID'),
61 | 'secret' => env('AWS_SECRET_ACCESS_KEY'),
62 | 'region' => env('AWS_DEFAULT_REGION'),
63 | 'bucket' => env('AWS_BUCKET'),
64 | 'url' => env('AWS_URL'),
65 | ],
66 |
67 | ],
68 |
69 | ];
70 |
--------------------------------------------------------------------------------
/config/hashing.php:
--------------------------------------------------------------------------------
1 | 'bcrypt',
19 |
20 | /*
21 | |--------------------------------------------------------------------------
22 | | Bcrypt Options
23 | |--------------------------------------------------------------------------
24 | |
25 | | Here you may specify the configuration options that should be used when
26 | | passwords are hashed using the Bcrypt algorithm. This will allow you
27 | | to control the amount of time it takes to hash the given password.
28 | |
29 | */
30 |
31 | 'bcrypt' => [
32 | 'rounds' => env('BCRYPT_ROUNDS', 10),
33 | ],
34 |
35 | /*
36 | |--------------------------------------------------------------------------
37 | | Argon Options
38 | |--------------------------------------------------------------------------
39 | |
40 | | Here you may specify the configuration options that should be used when
41 | | passwords are hashed using the Argon algorithm. These will allow you
42 | | to control the amount of time it takes to hash the given password.
43 | |
44 | */
45 |
46 | 'argon' => [
47 | 'memory' => 1024,
48 | 'threads' => 2,
49 | 'time' => 2,
50 | ],
51 |
52 | ];
53 |
--------------------------------------------------------------------------------
/config/logging.php:
--------------------------------------------------------------------------------
1 | env('LOG_CHANNEL', 'stack'),
21 |
22 | /*
23 | |--------------------------------------------------------------------------
24 | | Log Channels
25 | |--------------------------------------------------------------------------
26 | |
27 | | Here you may configure the log channels for your application. Out of
28 | | the box, Laravel uses the Monolog PHP logging library. This gives
29 | | you a variety of powerful log handlers / formatters to utilize.
30 | |
31 | | Available Drivers: "single", "daily", "slack", "syslog",
32 | | "errorlog", "monolog",
33 | | "custom", "stack"
34 | |
35 | */
36 |
37 | 'channels' => [
38 | 'stack' => [
39 | 'driver' => 'stack',
40 | 'channels' => ['daily'],
41 | 'ignore_exceptions' => false,
42 | ],
43 |
44 | 'single' => [
45 | 'driver' => 'single',
46 | 'path' => storage_path('logs/laravel.log'),
47 | 'level' => 'debug',
48 | ],
49 |
50 | 'daily' => [
51 | 'driver' => 'daily',
52 | 'path' => storage_path('logs/laravel.log'),
53 | 'level' => 'debug',
54 | 'days' => 14,
55 | ],
56 |
57 | 'slack' => [
58 | 'driver' => 'slack',
59 | 'url' => env('LOG_SLACK_WEBHOOK_URL'),
60 | 'username' => 'Laravel Log',
61 | 'emoji' => ':boom:',
62 | 'level' => 'critical',
63 | ],
64 |
65 | 'papertrail' => [
66 | 'driver' => 'monolog',
67 | 'level' => 'debug',
68 | 'handler' => SyslogUdpHandler::class,
69 | 'handler_with' => [
70 | 'host' => env('PAPERTRAIL_URL'),
71 | 'port' => env('PAPERTRAIL_PORT'),
72 | ],
73 | ],
74 |
75 | 'stderr' => [
76 | 'driver' => 'monolog',
77 | 'handler' => StreamHandler::class,
78 | 'formatter' => env('LOG_STDERR_FORMATTER'),
79 | 'with' => [
80 | 'stream' => 'php://stderr',
81 | ],
82 | ],
83 |
84 | 'syslog' => [
85 | 'driver' => 'syslog',
86 | 'level' => 'debug',
87 | ],
88 |
89 | 'errorlog' => [
90 | 'driver' => 'errorlog',
91 | 'level' => 'debug',
92 | ],
93 |
94 | 'null' => [
95 | 'driver' => 'monolog',
96 | 'handler' => NullHandler::class,
97 | ],
98 | ],
99 |
100 | ];
101 |
--------------------------------------------------------------------------------
/config/mail.php:
--------------------------------------------------------------------------------
1 | env('MAIL_DRIVER', 'smtp'),
20 |
21 | /*
22 | |--------------------------------------------------------------------------
23 | | SMTP Host Address
24 | |--------------------------------------------------------------------------
25 | |
26 | | Here you may provide the host address of the SMTP server used by your
27 | | applications. A default option is provided that is compatible with
28 | | the Mailgun mail service which will provide reliable deliveries.
29 | |
30 | */
31 |
32 | 'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
33 |
34 | /*
35 | |--------------------------------------------------------------------------
36 | | SMTP Host Port
37 | |--------------------------------------------------------------------------
38 | |
39 | | This is the SMTP port used by your application to deliver e-mails to
40 | | users of the application. Like the host we have set this value to
41 | | stay compatible with the Mailgun e-mail application by default.
42 | |
43 | */
44 |
45 | 'port' => env('MAIL_PORT', 587),
46 |
47 | /*
48 | |--------------------------------------------------------------------------
49 | | Global "From" Address
50 | |--------------------------------------------------------------------------
51 | |
52 | | You may wish for all e-mails sent by your application to be sent from
53 | | the same address. Here, you may specify a name and address that is
54 | | used globally for all e-mails that are sent by your application.
55 | |
56 | */
57 |
58 | 'from' => [
59 | 'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'),
60 | 'name' => env('MAIL_FROM_NAME', 'Example'),
61 | ],
62 |
63 | /*
64 | |--------------------------------------------------------------------------
65 | | E-Mail Encryption Protocol
66 | |--------------------------------------------------------------------------
67 | |
68 | | Here you may specify the encryption protocol that should be used when
69 | | the application send e-mail messages. A sensible default using the
70 | | transport layer security protocol should provide great security.
71 | |
72 | */
73 |
74 | 'encryption' => env('MAIL_ENCRYPTION', 'tls'),
75 |
76 | /*
77 | |--------------------------------------------------------------------------
78 | | SMTP Server Username
79 | |--------------------------------------------------------------------------
80 | |
81 | | If your SMTP server requires a username for authentication, you should
82 | | set it here. This will get used to authenticate with your server on
83 | | connection. You may also set the "password" value below this one.
84 | |
85 | */
86 |
87 | 'username' => env('MAIL_USERNAME'),
88 |
89 | 'password' => env('MAIL_PASSWORD'),
90 |
91 | /*
92 | |--------------------------------------------------------------------------
93 | | Sendmail System Path
94 | |--------------------------------------------------------------------------
95 | |
96 | | When using the "sendmail" driver to send e-mails, we will need to know
97 | | the path to where Sendmail lives on this server. A default path has
98 | | been provided here, which will work well on most of your systems.
99 | |
100 | */
101 |
102 | 'sendmail' => '/usr/sbin/sendmail -bs',
103 |
104 | /*
105 | |--------------------------------------------------------------------------
106 | | Markdown Mail Settings
107 | |--------------------------------------------------------------------------
108 | |
109 | | If you are using Markdown based email rendering, you may configure your
110 | | theme and component paths here, allowing you to customize the design
111 | | of the emails. Or, you may simply stick with the Laravel defaults!
112 | |
113 | */
114 |
115 | 'markdown' => [
116 | 'theme' => 'default',
117 |
118 | 'paths' => [
119 | resource_path('views/vendor/mail'),
120 | ],
121 | ],
122 |
123 | /*
124 | |--------------------------------------------------------------------------
125 | | Log Channel
126 | |--------------------------------------------------------------------------
127 | |
128 | | If you are using the "log" driver, you may specify the logging channel
129 | | if you prefer to keep mail messages separate from other log entries
130 | | for simpler reading. Otherwise, the default channel will be used.
131 | |
132 | */
133 |
134 | 'log_channel' => env('MAIL_LOG_CHANNEL'),
135 |
136 | ];
137 |
--------------------------------------------------------------------------------
/config/queue.php:
--------------------------------------------------------------------------------
1 | env('QUEUE_CONNECTION', 'sync'),
17 |
18 | /*
19 | |--------------------------------------------------------------------------
20 | | Queue Connections
21 | |--------------------------------------------------------------------------
22 | |
23 | | Here you may configure the connection information for each server that
24 | | is used by your application. A default configuration has been added
25 | | for each back-end shipped with Laravel. You are free to add more.
26 | |
27 | | Drivers: "sync", "database", "beanstalkd", "sqs", "redis", "null"
28 | |
29 | */
30 |
31 | 'connections' => [
32 |
33 | 'sync' => [
34 | 'driver' => 'sync',
35 | ],
36 |
37 | 'database' => [
38 | 'driver' => 'database',
39 | 'table' => 'jobs',
40 | 'queue' => 'default',
41 | 'retry_after' => 90,
42 | ],
43 |
44 | 'beanstalkd' => [
45 | 'driver' => 'beanstalkd',
46 | 'host' => 'localhost',
47 | 'queue' => 'default',
48 | 'retry_after' => 90,
49 | 'block_for' => 0,
50 | ],
51 |
52 | 'sqs' => [
53 | 'driver' => 'sqs',
54 | 'key' => env('AWS_ACCESS_KEY_ID'),
55 | 'secret' => env('AWS_SECRET_ACCESS_KEY'),
56 | 'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'),
57 | 'queue' => env('SQS_QUEUE', 'your-queue-name'),
58 | 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
59 | ],
60 |
61 | 'redis' => [
62 | 'driver' => 'redis',
63 | 'connection' => 'default',
64 | 'queue' => env('REDIS_QUEUE', 'default'),
65 | 'retry_after' => 90,
66 | 'block_for' => null,
67 | ],
68 |
69 | ],
70 |
71 | /*
72 | |--------------------------------------------------------------------------
73 | | Failed Queue Jobs
74 | |--------------------------------------------------------------------------
75 | |
76 | | These options configure the behavior of failed queue job logging so you
77 | | can control which database and table are used to store the jobs that
78 | | have failed. You may change them to any database / table you wish.
79 | |
80 | */
81 |
82 | 'failed' => [
83 | 'driver' => env('QUEUE_FAILED_DRIVER', 'database'),
84 | 'database' => env('DB_CONNECTION', 'mysql'),
85 | 'table' => 'failed_jobs',
86 | ],
87 |
88 | ];
89 |
--------------------------------------------------------------------------------
/config/services.php:
--------------------------------------------------------------------------------
1 | [
18 | 'domain' => env('MAILGUN_DOMAIN'),
19 | 'secret' => env('MAILGUN_SECRET'),
20 | 'endpoint' => env('MAILGUN_ENDPOINT', 'api.mailgun.net'),
21 | ],
22 |
23 | 'postmark' => [
24 | 'token' => env('POSTMARK_TOKEN'),
25 | ],
26 |
27 | 'ses' => [
28 | 'key' => env('AWS_ACCESS_KEY_ID'),
29 | 'secret' => env('AWS_SECRET_ACCESS_KEY'),
30 | 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
31 | ],
32 |
33 | ];
34 |
--------------------------------------------------------------------------------
/config/view.php:
--------------------------------------------------------------------------------
1 | [
17 | resource_path('views'),
18 | ],
19 |
20 | /*
21 | |--------------------------------------------------------------------------
22 | | Compiled View Path
23 | |--------------------------------------------------------------------------
24 | |
25 | | This option determines where all the compiled Blade templates will be
26 | | stored for your application. Typically, this is within the storage
27 | | directory. However, as usual, you are free to change this value.
28 | |
29 | */
30 |
31 | 'compiled' => env(
32 | 'VIEW_COMPILED_PATH',
33 | realpath(storage_path('framework/views'))
34 | ),
35 |
36 | ];
37 |
--------------------------------------------------------------------------------
/database/.gitignore:
--------------------------------------------------------------------------------
1 | *.sqlite
2 | *.sqlite-journal
3 |
--------------------------------------------------------------------------------
/database/factories/CategoryFactory.php:
--------------------------------------------------------------------------------
1 | define(\App\Category::class, function (Faker $faker) {
9 | return [
10 | 'name' => $faker->name,
11 | 'description' => $faker->sentence,
12 | 'slug' => $faker->slug
13 | ];
14 | });
15 |
--------------------------------------------------------------------------------
/database/factories/ProductFactory.php:
--------------------------------------------------------------------------------
1 | define(\App\Product::class, function (Faker $faker) {
9 | return [
10 | 'name' => $faker->name,
11 | 'description' => $faker->sentence,
12 | 'body' => $faker->paragraph(5, true),
13 | 'price' => $faker->randomFloat(2, 1, 10),
14 | 'slug' => $faker->slug,
15 | ];
16 | });
17 |
--------------------------------------------------------------------------------
/database/factories/StoreFactory.php:
--------------------------------------------------------------------------------
1 | define(\App\Store::class, function (Faker $faker) {
9 | return [
10 | 'name' => $faker->name,
11 | 'description' => $faker->sentence,
12 | 'phone' => $faker->phoneNumber,
13 | 'mobile_phone' => $faker->phoneNumber,
14 | 'slug' => $faker->slug,
15 | ];
16 | });
17 |
--------------------------------------------------------------------------------
/database/factories/UserFactory.php:
--------------------------------------------------------------------------------
1 | define(User::class, function (Faker $faker) {
20 | return [
21 | 'name' => $faker->name,
22 | 'email' => $faker->unique()->safeEmail,
23 | 'email_verified_at' => now(),
24 | 'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password
25 | 'remember_token' => Str::random(10),
26 | ];
27 | });
28 |
--------------------------------------------------------------------------------
/database/migrations/2014_10_12_000000_create_users_table.php:
--------------------------------------------------------------------------------
1 | bigIncrements('id');
18 | $table->string('name');
19 | $table->string('email')->unique();
20 | $table->timestamp('email_verified_at')->nullable();
21 | $table->string('password');
22 | $table->rememberToken();
23 | $table->timestamps();
24 | });
25 | }
26 |
27 | /**
28 | * Reverse the migrations.
29 | *
30 | * @return void
31 | */
32 | public function down()
33 | {
34 | Schema::dropIfExists('users');
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/database/migrations/2014_10_12_100000_create_password_resets_table.php:
--------------------------------------------------------------------------------
1 | string('email')->index();
18 | $table->string('token');
19 | $table->timestamp('created_at')->nullable();
20 | });
21 | }
22 |
23 | /**
24 | * Reverse the migrations.
25 | *
26 | * @return void
27 | */
28 | public function down()
29 | {
30 | Schema::dropIfExists('password_resets');
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/database/migrations/2019_08_19_000000_create_failed_jobs_table.php:
--------------------------------------------------------------------------------
1 | bigIncrements('id');
18 | $table->text('connection');
19 | $table->text('queue');
20 | $table->longText('payload');
21 | $table->longText('exception');
22 | $table->timestamp('failed_at')->useCurrent();
23 | });
24 | }
25 |
26 | /**
27 | * Reverse the migrations.
28 | *
29 | * @return void
30 | */
31 | public function down()
32 | {
33 | Schema::dropIfExists('failed_jobs');
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/database/migrations/2019_10_18_212717_create_table_store.php:
--------------------------------------------------------------------------------
1 | bigIncrements('id');
18 | $table->unsignedBigInteger('user_id');
19 |
20 | $table->string('name');
21 | $table->string('description');
22 | $table->string('phone');
23 | $table->string('mobile_phone');
24 | $table->string('slug');
25 |
26 | $table->timestamps();
27 |
28 | $table->foreign('user_id')->references('id')->on('users'); //Nome da chave stran: stores_user_id_foreign
29 | });
30 | }
31 |
32 | /**
33 | * Reverse the migrations.
34 | *
35 | * @return void
36 | */
37 | public function down()
38 | {
39 | Schema::dropIfExists('stores');
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/database/migrations/2019_10_18_214944_create_products_table.php:
--------------------------------------------------------------------------------
1 | bigIncrements('id');
18 | $table->unsignedBigInteger('store_id');
19 |
20 | $table->string('name');
21 | $table->string('description');
22 | $table->text('body');
23 | $table->decimal('price', 10, 2);
24 | $table->string('slug');
25 |
26 | $table->timestamps();
27 |
28 | $table->foreign('store_id')->references('id')->on('stores')->onDelete('cascade');
29 | });
30 | }
31 |
32 | /**
33 | * Reverse the migrations.
34 | *
35 | * @return void
36 | */
37 | public function down()
38 | {
39 | Schema::dropIfExists('products');
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/database/migrations/2019_10_27_173536_create_categories_table.php:
--------------------------------------------------------------------------------
1 | bigIncrements('id');
18 |
19 | $table->string('name');
20 | $table->string('description')->nullable();
21 | $table->string('slug');
22 |
23 | $table->timestamps();
24 | });
25 | }
26 |
27 | /**
28 | * Reverse the migrations.
29 | *
30 | * @return void
31 | */
32 | public function down()
33 | {
34 | Schema::dropIfExists('categories');
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/database/migrations/2019_10_27_173744_create_category_product_table.php:
--------------------------------------------------------------------------------
1 | unsignedBigInteger('product_id');
18 | $table->unsignedBigInteger('category_id');
19 |
20 | $table->foreign('product_id')->references('id')->on('products');
21 | $table->foreign('category_id')->references('id')->on('categories');
22 | });
23 | }
24 |
25 | /**w
26 | * Reverse the migrations.
27 | *
28 | * @return void
29 | */
30 | public function down()
31 | {
32 | Schema::dropIfExists('category_product');
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/database/migrations/2019_12_04_201729_create_product_photos_table.php:
--------------------------------------------------------------------------------
1 | bigIncrements('id');
18 |
19 | $table->unsignedBigInteger('product_id');
20 |
21 | $table->string('image');
22 |
23 | $table->timestamps();
24 |
25 | $table->foreign('product_id')->references('id')->on('products');
26 | });
27 | }
28 |
29 | /**
30 | * Reverse the migrations.
31 | *
32 | * @return void
33 | */
34 | public function down()
35 | {
36 | Schema::dropIfExists('product_photos');
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/database/migrations/2019_12_04_202057_alter_table_stores_add_column_logo.php:
--------------------------------------------------------------------------------
1 | string('logo')->nullable();
18 | });
19 | }
20 |
21 | /**
22 | * Reverse the migrations.
23 | *
24 | * @return void
25 | */
26 | public function down()
27 | {
28 | Schema::table('stores', function (Blueprint $table) {
29 | $table->dropColumn('logo');
30 | });
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/database/migrations/2019_12_28_140645_create_user_order_table.php:
--------------------------------------------------------------------------------
1 | bigIncrements('id');
18 | $table->unsignedBigInteger('user_id');
19 |
20 | $table->string('reference');
21 | $table->string('pagseguro_code');
22 | $table->integer('pagseguro_status');
23 |
24 | $table->text('items');
25 |
26 | $table->timestamps();
27 |
28 | $table->foreign('user_id')->references('id')->on('users');
29 | });
30 | }
31 |
32 | /**
33 | * Reverse the migrations.
34 | *
35 | * @return void
36 | */
37 | public function down()
38 | {
39 | Schema::dropIfExists('user_orders');
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/database/migrations/2020_02_07_183221_create_order_store_table.php:
--------------------------------------------------------------------------------
1 | unsignedBigInteger('store_id');
18 | $table->unsignedBigInteger('order_id');
19 |
20 | $table->foreign('store_id')->references('id')->on('stores');
21 | $table->foreign('order_id')->references('id')->on('user_orders');
22 | });
23 | }
24 |
25 | /**
26 | * Reverse the migrations.
27 | *
28 | * @return void
29 | */
30 | public function down()
31 | {
32 | Schema::dropIfExists('order_store');
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/database/migrations/2020_02_09_153417_create_notifications_table.php:
--------------------------------------------------------------------------------
1 | uuid('id')->primary();
18 | $table->string('type');
19 | $table->morphs('notifiable');
20 | $table->text('data');
21 | $table->timestamp('read_at')->nullable();
22 | $table->timestamps();
23 | });
24 | }
25 |
26 | /**
27 | * Reverse the migrations.
28 | *
29 | * @return void
30 | */
31 | public function down()
32 | {
33 | Schema::dropIfExists('notifications');
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/database/migrations/2020_02_22_165158_alter_users_table.php:
--------------------------------------------------------------------------------
1 | string('role')->default('ROLE_USER');
18 | });
19 | }
20 |
21 | /**
22 | * Reverse the migrations.
23 | *
24 | * @return void
25 | */
26 | public function down()
27 | {
28 | Schema::table('users', function (Blueprint $table) {
29 | $table->dropColumn('role');
30 | });
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/database/seeds/DatabaseSeeder.php:
--------------------------------------------------------------------------------
1 | call(UsersTableSeeder::class);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/database/seeds/StoreTableSeeder.php:
--------------------------------------------------------------------------------
1 | products()->save(factory(\App\Product::class)->make());
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/database/seeds/UsersTableSeeder.php:
--------------------------------------------------------------------------------
1 | insert(
15 | // [
16 | // 'name' => 'Administrator',
17 | // 'email' => 'admin@admin.com',
18 | // 'email_verified_at' => now(),
19 | // 'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password
20 | // 'remember_token' => 'okokdsdsdsdsdsd',
21 | // ]
22 | // );
23 |
24 | factory(\App\User::class, 40)->create()->each(function($user){
25 | $user->store()->save(factory(\App\Store::class)->make());
26 | });
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/helpers/functions.php:
--------------------------------------------------------------------------------
1 |
2 | `;
10 | spanBrand.innerHTML = imgFlag;
11 | document.querySelector('input[name=card_brand]').value = res.brand.name;
12 |
13 | getInstallments(amoutTransaction, res.brand.name);
14 | },
15 | error: function(err) {
16 | console.log(err);
17 | },
18 | complete: function(res) {
19 | //console.log('Complete', res);
20 | }
21 | });
22 | }
23 | });
24 |
25 | let submitButton = document.querySelector('button.processCheckout');
26 |
27 | submitButton.addEventListener('click', function(event){
28 | event.preventDefault();
29 | document.querySelector('div.msg').innerHTML = '';
30 |
31 | let buttonTarget = event.target;
32 |
33 | buttonTarget.disabled = true;
34 | buttonTarget.innerHTML = 'Carregando...';
35 |
36 | PagSeguroDirectPayment.createCardToken({
37 | cardNumber: document.querySelector('input[name=card_number]').value,
38 | brand: document.querySelector('input[name=card_brand]').value,
39 | cvv: document.querySelector('input[name=card_cvv]').value,
40 | expirationMonth: document.querySelector('input[name=card_month]').value,
41 | expirationYear: document.querySelector('input[name=card_year]').value,
42 | success: function(res) {
43 | proccessPayment(res.card.token, buttonTarget);
44 | },
45 | error: function(err) {
46 | buttonTarget.disabled = false;
47 | buttonTarget.innerHTML = 'Efetuar Pagamento';
48 |
49 | for(let i in err.errors) {
50 | document.querySelector('div.msg').innerHTML = showErrorMessages(errorsMapPagseguroJS(i));
51 | }
52 | }
53 | });
54 | });
--------------------------------------------------------------------------------
/public/js/pagseguro_functions.js:
--------------------------------------------------------------------------------
1 | function proccessPayment(token, buttonTarget)
2 | {
3 | let data = {
4 | card_token: token,
5 | hash: PagSeguroDirectPayment.getSenderHash(),
6 | installment: document.querySelector('select.select_installments').value,
7 | card_name: document.querySelector('input[name=card_name]').value,
8 | _token: csrf
9 | };
10 |
11 | $.ajax({
12 | type: 'POST',
13 | url: urlProccess,
14 | data: data,
15 | dataType: 'json',
16 | success: function(res) {
17 |
18 | toastr.success(res.data.message, 'Sucesso');
19 | window.location.href = `${urlThanks}?order=${res.data.order}`;
20 | },
21 | error: function(err) {
22 | buttonTarget.disabled = false;
23 | buttonTarget.innerHTML = 'Efetuar Pagamento';
24 |
25 | let message = JSON.parse(err.responseText);
26 | document.querySelector('div.msg').innerHTML = showErrorMessages(message.data.message.error.message);
27 | }
28 | });
29 | }
30 |
31 |
32 | function getInstallments(amount, brand) {
33 | PagSeguroDirectPayment.getInstallments({
34 | amount: amount,
35 | brand: brand,
36 | maxInstallmentNoInterest: 0,
37 | success: function(res) {
38 | let selectInstallments = drawSelectInstallments(res.installments[brand]);
39 | document.querySelector('div.installments').innerHTML = selectInstallments;
40 | },
41 | error: function(err) {
42 | console.log(err);
43 | },
44 | complete: function(res) {
45 |
46 | },
47 | })
48 | }
49 |
50 | function drawSelectInstallments(installments) {
51 | let select = '';
52 |
53 | select += '';
61 |
62 | return select;
63 | }
64 |
65 | function showErrorMessages(message)
66 | {
67 | return `
68 |
# | 12 |Nome | 13 |Ações | 14 |
---|---|---|
{{$category->id}} | 20 |{{$category->name}} | 21 |
22 |
23 | EDITAR
24 |
29 |
30 | |
31 |
Notificação | 15 |Criado em | 16 |Ações | 17 |
---|---|---|
{{$n->data['message']}} | 23 |{{$n->created_at->locale('pt')->diffForHumans()}} | 24 |
25 |
26 | Marcar como lida
27 |
28 | |
29 |
33 | Nenhuma notificação encontrada!
34 | |
35 |
# | 11 |Nome | 12 |Preço | 13 |Loja | 14 |Ações | 15 |
---|---|---|---|---|
{{$p->id}} | 21 |{{$p->name}} | 22 |R$ {{number_format($p->price, 2, ',', '.')}} | 23 |{{$p->store->name}} | 24 |
25 |
26 | EDITAR
27 |
32 |
33 | |
34 |
# | 12 |Loja | 13 |Total de Produtos | 14 |Ações | 15 |
---|---|---|---|
{{$store->id}} | 20 |{{$store->name}} | 21 |{{$store->products->count()}} | 22 |
23 |
24 | EDITAR
25 |
30 |
31 | |
32 |
Produto | 16 |Preço | 17 |Quantidade | 18 |Subtotal | 19 |Ação | 20 |
---|---|---|---|---|
{{$c['name']}} | 29 |R$ {{number_format($c['price'], 2, ',', '.')}} | 30 |{{$c['amount']}} | 31 | 32 | @php 33 | $subtotal = $c['price'] * $c['amount']; 34 | $total += $subtotal; 35 | @endphp 36 | 37 |R$ {{number_format($subtotal, 2, ',', '.')}} | 38 |39 | REMOVER 40 | | 41 |
Total: | 47 |R$ {{number_format($total, 2, ',', '.')}} | 48 |
22 | {{$product->description}} 23 |
24 |
6 | Faça bom proveito e excelentes compras em nosso marketplace!
7 | Seu email de cadastro é: {{$user->email}}
8 | Sua senha: Por questões de segurança não enviamos sua senha mas você deve se lembrar!
9 |
25 | {{$product->description}} 26 |
27 | 28 |{{$store->description}}
17 |18 | Contatos: 19 | {{$store->phone}} | {{$store->mobile_phone}} 20 |
21 |39 | {{$product->description}} 40 |
41 |18 | {{$product->description}} 19 |
20 |48 | {{$store->description}} 49 |
50 | Ver Loja 51 |