Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,16 @@ public function index()
//
}

public function swiperDisplays(){
public function swiperDisplays()
{
// $guzzleSwippers = guzzleSwipper::all();
// return view('guzzleSwiper.index', compact('guzzleSwippers'));
return Inertia::render("Newproducts" , [
return Inertia::render("Newproducts", [
'canLogin' => Route::has('login'),
'canRegister' => Route::has('register'),
'home' => Route::has('/'),
'laravelVersion' => Application::VERSION,
'phpVersion' => PHP_VERSION,
'canRegister' => Route::has('register'),
'home' => Route::has('/'),
'laravelVersion' => Application::VERSION,
'phpVersion' => PHP_VERSION,
]);
}

Expand Down
1 change: 1 addition & 0 deletions laravelReactApp/app/Http/Controllers/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public function editUser(Request $request){

public function loadUsers(){

// Arriba tienes importado en model User, entonces no es necesario usar todo el namespace aqui
$users = \App\Models\User::all();
$user = Auth::user();

Expand Down
1 change: 1 addition & 0 deletions laravelReactApp/app/Http/Requests/ProfileUpdateRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class ProfileUpdateRequest extends FormRequest
*/
public function rules(): array
{
// Buen uso de validaciones
return [
'name' => ['required', 'string', 'max:255'],
'email' => [
Expand Down
3 changes: 2 additions & 1 deletion laravelReactApp/app/Models/CryptofetchModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

class CryptofetchModel extends Model
{
//
// Aqui la logica de conectarse a la api podrias delegarse a un servicio app/services/CoinGeckoService
// Y aqui podrias llamar a ese servicio con CoinGeckoService::getAll() o algo parecido

public function CoinGeckofetchCrypto(){
$client = new \GuzzleHttp\Client();
Expand Down
1 change: 1 addition & 0 deletions laravelReactApp/app/Models/collectionPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class collectionPage extends Model
{
//https://laravel.com/docs/11.x/collections
public function productsCollections() {
// Esto no se usa en ningun lado
$myArray = ['php' , 'javascript' , 'react' , 'angular' , 'typescript' , 'sqlite' , 'html' , 'css' ] ;
$collection = collect([1, 2, 3, 4, 5]);
return $collection->all();
Expand Down
3 changes: 3 additions & 0 deletions laravelReactApp/app/Models/guzzlepage1.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ class guzzlepage1 extends Model
//
protected $fillable = ['url', 'content'];

// Igual aqui se podria delegar el consumir la api a un servicio, para mantener la logica separada
// Se recomienda usar algun formateador de codigo tal como https://laravel.com/docs/11.x/pint

public function getData(){
$client = new \GuzzleHttp\Client();
$response = $client->request('GET', 'https://api.github.com/users');
Expand Down
4 changes: 4 additions & 0 deletions laravelReactApp/routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
})->middleware(['auth', 'verified'])->name('dashboard');


// En este caso podrias mejor usar resource
// Y esto va a genera todas las rutas, asi te evitas de hacerlo de forma manual
Route::resource('users', UserController::class);

//router routes
Route::get("/users", [UserController::class,'loadUsers'])->name("users.index");
Route::post("/edit/user", [UserController::class,'editUser'])->name("users.update");
Expand Down
10 changes: 7 additions & 3 deletions laravelReactApp/tests/Feature/ProfileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@

use App\Models\User;

test('profile page is displayed', function () {
$user = User::factory()->create();
// Se podria hacer un beforeEach

beforeEach(function() {
$this->user = User::factory()->create();
});

test('profile page is displayed', function () {
$response = $this
->actingAs($user)
->actingAs($this->user) // Y a qui usar $this->user
->get('/profile');

$response->assertOk();
Expand Down