Skip to content

Commit

Permalink
feat:the views were created to create and edit the products using the…
Browse files Browse the repository at this point in the history
… rest API.
  • Loading branch information
Josemprog committed Dec 7, 2020
1 parent 247cb7b commit f5f7ad8
Show file tree
Hide file tree
Showing 25 changed files with 196 additions and 440 deletions.
2 changes: 1 addition & 1 deletion app/Exports/ProductsExport.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
class ProductsExport implements FromQuery, ShouldQueue, WithHeadings
{
use Exportable;

public function query()
{
return Product::query();
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Admin/PanelController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function __construct()
/**
* Show the application dashboard.
*
* @return \Illuminate\Contracts\Support\Renderable
* @return \Illuminate\View\View
*/
public function index(): \Illuminate\View\View
{
Expand Down
6 changes: 3 additions & 3 deletions app/Http/Controllers/Admin/ProductController.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function index(Request $request): \Illuminate\View\View
->brand($products->brand)
->name($products->name)
->price($products->price)
->paginate(25);
->paginate(10);

return view('admin.products.index')->with('products', $products);
}
Expand All @@ -49,7 +49,7 @@ public function create(): \Illuminate\View\View
* @param ProductsRequest $request
* @return \Illuminate\Http\RedirectResponse
*/
public function store(ProductsRequest $request)
public function store(ProductsRequest $request): \Illuminate\Http\RedirectResponse
{
$product = new Product($request->validated());
$product->image = $request->file('image')->store('images', 'public');
Expand Down Expand Up @@ -77,7 +77,7 @@ public function show(Product $product): \Illuminate\View\View
* @param Product $product
* @return \Illuminate\View\View
*/
public function edit(Product $product)
public function edit(Product $product): \Illuminate\View\View
{
return view('admin.products.edit')->with('product', $product);
}
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Admin/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function index(Request $request): \Illuminate\View\View
->name($users->name)
->email($users->email)
->enabled($users->enabled)
->paginate(6);
->paginate(10);

return view('admin.users.index')->with('users', $users);
}
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Auth/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ protected function credentials(Request $request)
* @param mixed $user
* @return mixed
*/
protected function authenticated(Request $request, $user)
protected function authenticated($user)
{
if ($user->hasRole('admin')) {
$user->api_token = Str::random(60);
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/HomeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function index(Request $request): \Illuminate\View\View
->brand($products->brand)
->name($products->name)
->price($products->price)
->paginate(20);
->paginate(28);

return view('home')->with('products', $products);
}
Expand Down
26 changes: 0 additions & 26 deletions app/Http/Controllers/VueController.php

This file was deleted.

2 changes: 1 addition & 1 deletion app/Http/Resources/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Product extends JsonResource
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
public function toArray($request): array
{
return [
'id' => $this->id,
Expand Down
2 changes: 1 addition & 1 deletion app/Imports/ProductsImport.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function createProduct($row)
'enabled' => $row['enabled'],
]);
}

public function updateProduct(Product $product, $row)
{
$product->update($row);
Expand Down
2 changes: 1 addition & 1 deletion database/seeds/ProductSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ class ProductSeeder extends Seeder
*/
public function run()
{
factory(App\Product::class, 5)->create();
factory(App\Product::class, 100)->create();
}
}
20 changes: 15 additions & 5 deletions database/seeds/UserSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,15 @@ public function run()
{
Role::truncate();

// Roles
$adminRole = Role::create(['name' => 'admin']);

// Permisos
$permisoShowArticles = Permission::create(['name' => 'show articles']);
$permisoStoreArticles = Permission::create(['name' => 'store articles']);
$permisoEditArticles = Permission::create(['name' => 'edit articles']);
$permisoDestroyArticles = Permission::create(['name' => 'destroy articles']);

$admin = new User();
$admin->name = 'JoseM';
$admin->email = '[email protected]';
Expand All @@ -31,12 +38,15 @@ public function run()
$admin->remember_token = Str::random(10);
$admin->save();

// Asignando roles
$admin->assignRole($adminRole);

// Asignando Permisos
$adminRole->givePermissionTo($permisoShowArticles);
$adminRole->givePermissionTo($permisoStoreArticles);
$adminRole->givePermissionTo($permisoEditArticles);
$adminRole->givePermissionTo($permisoDestroyArticles);

$permiso = Permission::create(['name' => 'edit articles']);

$adminRole->givePermissionTo($permiso);

factory(App\User::class, 5)->create();
factory(App\User::class, 100)->create();
}
}
Loading

0 comments on commit f5f7ad8

Please sign in to comment.