Skip to content

Commit

Permalink
refactor: change project for used taiwind css in admin painel with te…
Browse files Browse the repository at this point in the history
…mplate. é web used materialcss
  • Loading branch information
lcs13761 committed May 18, 2023
1 parent 37febb4 commit e30c573
Show file tree
Hide file tree
Showing 87 changed files with 17,862 additions and 1,248 deletions.
17 changes: 14 additions & 3 deletions app/Helpers/Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ function config($value)
{
if (str_contains($value, ".")) {
$array = explode(".", $value);

$configResult = include base_app("config/$array[0].php");

$values = $configResult;
unset($array[0]);

Expand All @@ -117,7 +119,16 @@ function config($value)
if (!function_exists('base_app')) {
function base_app(string $path): string
{
return realpath('../' . $path);
$currentPath = getcwd();

while (!file_exists($currentPath . '/' . $path)) {
$currentPath = dirname($currentPath);
if ($currentPath === '/') {
break;
}
}

return $currentPath . '/' . $path;
}
}

Expand Down Expand Up @@ -163,7 +174,7 @@ function __(string $string, array $options = [])
if (!function_exists('assets')) {
function assets($path)
{
return env('APP_URL') . "/" . ($path[0] == "/" ? mb_substr($path, 1) : $path);
return env('APP_URL') . "/" . ($path[0] == "/" ? mb_substr($path, 1) : $path);
}
}

Expand All @@ -181,4 +192,4 @@ function value($value, ...$args)
{
return $value instanceof Closure ? $value(...$args) : $value;
}
}
}
14 changes: 13 additions & 1 deletion app/Helpers/MenuLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,18 @@ public function menu(): array
'icon' => 'pie-chart',
'authorized' => ['default']
],
[
'navheader' => __('locale.admin'),
'slug' => '',
'authorized' => ['default']
],
[
'name' => __('locale.users'),
'url' => url('admin.users.index'),
'slug' => 'admin.users',
'icon' => 'pie-chart',
'authorized' => ['default']
],
];
}
}
}
64 changes: 56 additions & 8 deletions app/Http/Controllers/Admin/User/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,69 @@
namespace App\Http\Controllers\Admin\User;

use App\Http\Controllers\Controller;
use App\Http\Resource\User\UserCollection;
use App\Http\Resource\User\UserResource;
use App\Models\User;
use App\Services\Admin\User\UserService;
use Pecee\Controllers\IResourceController;

class UserController extends Controller
class UserController extends Controller implements IResourceController
{
public function index(){}
private UserService $userService;

public function create(){}
public function __construct()
{
$this->userService = new UserService(new User());
}

public function store(){}
public function index()
{
return view('admin.user.index', [
'users' => (new UserCollection($this->userService->all()))->toArray()
]);
}

public function show($request,$id){}
public function create()
{
return view('admin.user.create', [
'user' => new User
]);
}

public function edit($request,$id){}
public function store()
{
$this->userService->create(input()->all());

public function update($id){}
return redirect('/admin/users');
}

public function destroy($id){}
public function show($id)
{
}

public function edit($id)
{
return view('admin.user.edit', [
'user' => new UserResource($this->userService->find($id)),
]);
}

public function update($id)
{
$user = $this->userService->find($id);

$this->userService->update($user, input()->all());

return redirect('/admin/users');
}

public function destroy($id)
{
$user = $this->userService->find($id);

$this->userService->delete($user);

return redirect('/admin/users');
}

}
30 changes: 15 additions & 15 deletions app/Http/Controllers/Auth/AuthenticatedSessionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class AuthenticatedSessionController extends Controller
*/
public function create()
{
return view('auth.login');
return view('auth.login.login');
}

// /**
Expand All @@ -31,20 +31,20 @@ public function store()
// return redirect()->intended(RouteServiceProvider::HOME);
}

// /**
// * Destroy an authenticated session.
// *
// * @param \Illuminate\Http\Request $request
// * @return \Illuminate\Http\RedirectResponse
// */
// public function destroy(Request $request)
// {
// Auth::guard('web')->logout();
// /**
// * Destroy an authenticated session.
// *
// * @param \Illuminate\Http\Request $request
// * @return \Illuminate\Http\RedirectResponse
// */
// public function destroy(Request $request)
// {
// Auth::guard('web')->logout();

// $request->session()->invalidate();
// $request->session()->invalidate();

// $request->session()->regenerateToken();
// $request->session()->regenerateToken();

// return redirect('/login');
// }
}
// return redirect('/login');
// }
}
4 changes: 2 additions & 2 deletions app/Http/Controllers/Web/HomeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ class HomeController extends Controller
*/
public function index()
{
return view('web.home');
return view('web.home.home');
}
}
}
16 changes: 16 additions & 0 deletions app/Http/Resource/User/UserCollection.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace App\Http\Resource\User;

use App\Http\Resource\User\UserResource;
use App\Supports\Resources\ResourceCollection;

class UserCollection extends ResourceCollection
{
public function toArray()
{
return [
'data' => UserResource::collection($this->collection),
];
}
}
21 changes: 21 additions & 0 deletions app/Http/Resource/User/UserResource.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace App\Http\Resource\User;

use App\Supports\Resources\JsonResource;

class UserResource extends JsonResource
{
public function toArray()
{
return [
'id' => $this->id,
'full_name' => "{$this->first_name} {$this->last_name}",
'first_name' => $this->first_name,
'last_name' => $this->last_name,
'email' => $this->email,
'created_at' => $this->created_at,
'updated_at' => $this->updated_at
];
}
}
77 changes: 77 additions & 0 deletions app/Models/User.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?php

namespace App\Models;

use App\Supports\Model\Model as Model;

class User extends Model
{
protected string $table = 'users';

/**
* @return string
*/
public function fullName(): string
{
return "{$this->first_name} {$this->last_name}";
}


// /**
// * @return bool
// */
// public function save(): bool
// {
// if (!$this->required()) {
// $this->message->warning("Nome, sobrenome, email e senha são obrigatórios");
// return false;
// }

// if (!is_email($this->email)) {
// $this->message->warning("O e-mail informado não tem um formato válido");
// return false;
// }

// if (!is_passwd($this->password)) {
// $min = CONF_PASSWD_MIN_LEN;
// $max = CONF_PASSWD_MAX_LEN;
// $this->message->warning("A senha deve ter entre {$min} e {$max} caracteres");
// return false;
// } else {
// $this->password = passwd($this->password);
// }

// /** User Update */
// if (!empty($this->id)) {
// $userId = $this->id;

// if ($this->find("email = :e AND id != :i", "e={$this->email}&i={$userId}", "id")->fetch()) {
// $this->message->warning("O e-mail informado já está cadastrado");
// return false;
// }

// $this->update($this->safe(), "id = :id", "id={$userId}");
// if ($this->fail()) {
// $this->message->error("Erro ao atualizar, verifique os dados");
// return false;
// }
// }

// /** User Create */
// if (empty($this->id)) {
// if ($this->findByEmail($this->email, "id")) {
// $this->message->warning("O e-mail informado já está cadastrado");
// return false;
// }

// $userId = $this->create($this->safe());
// if ($this->fail()) {
// $this->message->error("Erro ao cadastrar, verifique os dados");
// return false;
// }
// }

// $this->data = ($this->findById($userId))->data();
// return true;
// }
}
Empty file.
Loading

0 comments on commit e30c573

Please sign in to comment.