GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — working on refactoring · rubythonode/App-2@4b8d1e5

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • app
    • 1_Address.php
    • Http
      • Controllers
        • 1_AddressesController.php
        • HomeController.php
      • Middleware
        • CheckRole.php
  • database/seeds
    • AddressesTableSeeder.php
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎app/1_Address.php‎

Copy file name to clipboardExpand all lines: app/1_Address.php
-42Lines changed: 0 additions & 42 deletions
This file was deleted.
Collapse file

‎app/Http/Controllers/1_AddressesController.php‎

Copy file name to clipboardExpand all lines: app/Http/Controllers/1_AddressesController.php
-202Lines changed: 0 additions & 202 deletions
This file was deleted.
Collapse file

‎app/Http/Controllers/HomeController.php‎

Copy file name to clipboardExpand all lines: app/Http/Controllers/HomeController.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
* @author Gustavo Ocanto <[email protected]>
99
*/
1010

11+
use App\Order;
12+
use App\Product;
1113
use App\FreeProduct;
1214
use App\Helpers\productsHelper;
1315
use App\Http\Controllers\Controller;
14-
use App\Order;
15-
use App\Product;
1616

1717
class HomeController extends Controller
1818
{
Collapse file

‎app/Http/Middleware/CheckRole.php‎

Copy file name to clipboardExpand all lines: app/Http/Middleware/CheckRole.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public function handle($request, Closure $next)
1818
{
1919
$roles = $this->getRequiredRoleForRoute($request->route());
2020

21-
if ($request->user()->hasRole($roles) || !$roles) {
21+
if (auth()->check() && $request->user()->hasRole($roles) || !$roles) {
2222
return $next($request);
2323
}
2424
// return response([
Collapse file

‎database/seeds/AddressesTableSeeder.php‎

Copy file name to clipboard
+47-22Lines changed: 47 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
<?php
22

3-
/**
4-
* Antvel - Seeder
5-
* Addresses Table.
3+
/*
4+
* This file is part of the Antvel Shop package.
65
*
7-
* @author Gustavo Ocanto <[email protected]>
6+
* (c) Gustavo Ocanto <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
810
*/
911

1012
use App\User as User;
@@ -14,28 +16,51 @@
1416

1517
class AddressesTableSeeder extends Seeder
1618
{
19+
/**
20+
* Handles the seeder.
21+
*
22+
* @return void
23+
*/
1724
public function run()
1825
{
19-
$faker = Faker::create();
20-
2126
for ($i = 0; $i < 10; $i++) {
27+
Address::create(
28+
$this->faker($i)
29+
);
30+
}
31+
}
2232

23-
$user = User::select('id')
24-
->inRandomOrder()
25-
->first();
33+
/**
34+
* Return a fake address.
35+
* @param int $pos
36+
* @return array
37+
*/
38+
protected function faker(int $pos) : array
39+
{
40+
$faker = Faker::create();
41+
$user_id = $pos <= 2 ? 4 : $this->user()->id;
2642

27-
$address = Address::create([
28-
'user_id' => ($i <= 2) ? 4 : $user->id,
29-
'default' => 0,
30-
'line1' => $faker->streetAddress,
31-
'line2' => $faker->streetAddress,
32-
'phone' => $faker->e164PhoneNumber,
33-
'name_contact' => $faker->streetName,
34-
'zipcode' => $faker->postcode,
35-
'city' => $faker->city,
36-
'country' => $faker->country,
37-
'state' => $faker->state,
38-
]);
39-
}
43+
return [
44+
'default' => 0,
45+
'user_id' => $user_id,
46+
'city' => $faker->city,
47+
'state' => $faker->state,
48+
'country' => $faker->country,
49+
'zipcode' => $faker->postcode,
50+
'line1' => $faker->streetAddress,
51+
'line2' => $faker->streetAddress,
52+
'phone' => $faker->e164PhoneNumber,
53+
'name_contact' => $faker->streetName,
54+
];
55+
}
56+
57+
/**
58+
* Return a random user.
59+
*
60+
* @return User
61+
*/
62+
protected function user() : User
63+
{
64+
return User::select('id')->inRandomOrder()->first();
4065
}
4166
}

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.