JorgeAlberto

JorgeAlberto

Member Since 6 Months Ago

Experience Points 670
Experience Level 1

4,330 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed 0
Lessons
Completed
Best Reply Awards 0
Best Reply
Awards
  • start-engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist Created with Sketch.

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

09 Jul
1 week ago

JorgeAlberto started a new conversation Relations Ships In Models

hello I want to make a query with the query builder but I want this query to be accessible from a model.

example:


<?php
namespace App\Models;
use Illuminate\Notifications\Notifiable;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable
{
    use Notifiable;

    protected $table = 'users';

    protected $fillable = [
        'id', 'email',  'OrigenID', 'BlacklistID', 'StatusID',  
    ];

    protected $hidden = [
        'password', 
    ];

    public function data($query)
    {
        return $query->select('

    select 
            max(case when Res = 1 then text end)  as name,
        max(case when Res = 2 then text end)  as lastname 
    from
        datausers
    where
        UserID = $var_1 and Res in (1,2)  

    ');
    }
}


i don´t know how set the $var_1

This relation ship I already have but in this way.

 public function data($query)
    {
        return $this->hasMany('App\Modesl\Res','UserID', 'id');
    }

however, it does not work for me,

I just want you to return my name and surname

08 Jul
2 weeks ago

JorgeAlberto left a reply on Login With Passport

Yes, excuse me, i make the new guard. But it does not works

'guards' => [
    'web' => [
        'driver' => 'session',
        'provider' => 'users',
    ],
 
    'api' => [
        'driver' => 'passport',
        'provider' => 'users_api',
    ],
     
    'guard' => [
      'driver' => 'session',
      'provider' => 'users_api',
    ],
],

JorgeAlberto left a reply on Login With Passport

already try to follow the documentation step by step. because I already have a system that works and did not have this part. Now that I try to implement it, I have problems. Especially because the databases are in different bases I have a database for the common users and one for the subscribers who will use the api

JorgeAlberto left a reply on Login With Passport

already try to follow the documentation step by step. because I already have a system that works and did not have this part. Now that I try to implement it, I have problems. Especially because the databases are in different bases I have a database for the common users and one for the subscribers who will use the api

JorgeAlberto started a new conversation Login With Passport

Hello, I am trying to implement passport for the login of an api.

I have the following problem.

config:

config/auth.php


    'guards' => [
        'web' => [
            'driver' => 'session',
            'provider' => 'users',
        ],

        'api' => [
            'driver' => 'passport',
            'provider' => 'users_api',
            'hash' => false,
        ],
    ],

    'providers' => [
        'users' => [
            'driver' => 'eloquent',
            'model' => App\User::class,
        ],
        'users_api' => [
            'driver' => 'eloquent',
            'model' => App\Models\Api\User::class,
        ]
    ],


Model:

App\Models\Api\User.php

<?php

namespace App\Models\Api;

use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Laravel\Passport\HasApiTokens;

class User extends Authenticatable
{
    use HasApiTokens, Notifiable;

    protected $connection = 'api';
    protected $table = 'users';
    protected $primaryKey = 'id';

    protected $fillable = [
        'name', 'email', 'password',
    ];

    protected $hidden = [
        'password', 'remember_token',
    ];
}


controller:

<?php

namespace App\Http\Controllers;

use App\User;
use Carbon\Carbon;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;

class AuthController extends Controller
{
    
    public function login(Request $request)
    {
        $request->validate([
            'email'       => 'required|string|email',
            'password'    => 'required|string',
            'remember_me' => 'boolean',
        ]);

        $credentials = request(['email', 'password']);


        if (!Auth::guard('api')->attempt($credentials)) {
            return response()->json([
                'message' => 'Unauthorized'
            ], 401);
        }
       
    }

    public function logout(Request $request)
    {
        $request->user()->token()->revoke();
        return response()->json(['message' =>
        'Successfully logged out']);
    }
   
}

My problem is this.

"message": "Method Illuminate\Auth\RequestGuard::attempt does not exist."

23 Apr
2 months ago

JorgeAlberto started a new conversation Send A Csrf_token From A Route

Hi.

I try send a csrf_token from a route but i don´t know how do it.

i need this because i make an authentication for an API

according to me. My authentication must of set:

step 1: greeting

makes a request > client send a csrf_token < server

step 2: send credentials > client send token (jwt) < server

step 3: consume API >

20 Mar
4 months ago

JorgeAlberto started a new conversation Try Links With Guzzle So They Do Not Have 404 Or 500 Error

i have the problem next:

I try to test the addresses that my users give me to know if they have any state other than 200.

$client = new GuzzleHttp\Client();
echo $client->request('GET', 'alberto.dhasg')->getStatusCode();

the problem is that when you can not resolve the host, the error that gives guzzle is an internal error and I do not know how to handle it to send the error, in a friendly way to my user.

I know another way is to ping the console but I do not know how to handle the outputs of artisan in a controller.

12 Mar
4 months ago

JorgeAlberto left a reply on Shortest Url

@CRONIX - in fact I use an encrypted guid and remove this so that it only has 31 characters

JorgeAlberto left a reply on Shortest Url

@WILK_RANDALL - I already gave them but outlook version for desktop does not take them and converts my url into a link. even though this is not a link.

`` `

https://{{$_SERVER['HTTP_HOST']}}/confirm‑email/{{$data->token}} `` `

JorgeAlberto left a reply on Shortest Url

@WILK_RANDALL - because I send it in an email. And in outlook the link leaves the table

JorgeAlberto started a new conversation Shortest Url

Hi.

Does anyone know a shortener of urls for laravel?

I have too long urls that I would like to shorten

for example

´´´ // url long

// https://my-page.com/validate_mail/kjakjsdakljfklasjdfklasdjfklñjasdfkljasdklfjasklñdfjaefhjergteghrtuihigbkjbjkhajñdjhañoejrioeuieryt75468u456iojtiokjdgklñn fguhsbui3y4589234589hgihr9tyu589hdfghdjkghuiowergy895y683496yhrguwehuioyv78dsyduifghsduifgh8954y6456==

´´´

´´´ // url short

// https://my-page.com/validate_mail/aasdfsdfhertertikjhaskdf23498789sdfsdf

´´´

07 Mar
4 months ago

JorgeAlberto started a new conversation How To Encrypt A Guid In 80 Characters

Hello, Good morning.

I want to encrypt guid to build the url, I can not use the guid directly because it is a password of my system.

I currently encrypt it in this way:


use Illuminate\Support\Facades\Crypt;

class EncryptGuids{

    public guid_encrypt($guid){
        return Crypt::encryptString($guid);
    }

}

This causes me a text string too long, so it is impractical for a URL

I need to encrypt this guid in only 60 characters

// this url is with my code

$url = "https://my_domin.com/token/eyJpdiI6Ik92dDVFdFdROVwvK0MwOWIrRUllcDRRPT0iLCJ2YWx1ZSI6IlNTdU1BNUljSEtxcjYyUTY4N1I5bmo3UzRzeHl4WHEwTGZaaHVJS1hzUjd4UnFmRFNCaVJTalNvd2wxc3FiSTAiLCJtYWMiOiJmMjMzZjJjZjJmNTlmYTdiODdjNTZjNjZhYTgwZjExYmQ0NDFlYzU2Yzk5NDQwY2Y1NDY1M2E5NzE1MThkMzQ5In0=";
$url = "https://my_domin.com/token/a24saasdasd56548789asd132a1asd54897asd213fgdfgghj54bnmh54kui"
// this is the url I need


I need to encrypt this and at the same time decrypt

thanks for your help

09 Feb
5 months ago

JorgeAlberto started a new conversation Mail Delivery Configuration.

hi. good night.

I have a problem with the configuration of mailings.

I have a shared hosting

`` ` Host SMTP smtp.hostinger.mx Puertos SMTP (seguro) 587 Registro MX mx1.hostinger.mx

`` `

this is my config in the .env

`` ` MAIL_DRIVER=smtp MAIL_HOST=smtp.hostinger.com MAIL_PORT=587 [email protected] MAIL_PASSWORD=******** MAIL_ENCRYPTION=tls [email protected] MAIL_FROM_NAME="message"

`` `

this gives me an error

` Expected response code 354 but got code "554", with message "554 5.5.1 Error: no valid recipients " `

15 Jan
6 months ago

JorgeAlberto left a reply on Problem When Executing A Function

the function _.debounce is not executed directly.

The solution that is working for me is this:

    save: _.debounce(
                ()=>{
            alert();
        }
    ,800);

JorgeAlberto left a reply on Problem When Executing A Function

@SYLAR - I just need the save function. I do not want to load with watchers, I have 15 inputs text.

JorgeAlberto started a new conversation Problem When Executing A Function

hi.

i have problem this with:

I want to execute a function. when the user stops typing

I use vue, vutify and lodash.

<template>
    <v-app>
        <v-text-field v-model="a" @keyup="save()">

        </ v-text-field>
    </v-app>
</template>

<script>
        export default {
        data() {
                    return {
                a: '',
            }
        },
        
        methods: {
            save(){
                _.debounce(function(){
                    alert('this execute from  save function');
                },800);
            }
        },
        watch: {
            a: _.debounce(function(){
                alert('this execute from  watcher');
            },800),
        }
    }
</script>

My problem is that it does not run in the function, it only runs in the watcher

14 Jan
6 months ago

JorgeAlberto left a reply on Relationships Based On A Pivot Table From The Models

@VILFAGO - but this would not go on the model, right?

JorgeAlberto left a reply on Relationships Based On A Pivot Table From The Models

@VILFAGO - Your use case is when you want to know the suggestions I made to the logged-in user

JorgeAlberto left a reply on Relationships Based On A Pivot Table From The Models

     Table Users

user_id(primary key) name email password

  Table Suggestions

suggestion_id (primary key) suggestion

pivot Table UsersSuggestions

usersuggestion_id(primary key) user_id (foreign key) suggestion_id (foreign key)

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Suggestion extends Model
{
    protected $table = 'Suggestions';
    protected $primarykey = 'suggestion_id';

    public function UserSuggestion_r(){
        
        /*
            if I do the query on the UsersSuggestions table directly
                        
                       return UserSuggestion::where('suggestion_id ', $data)->where('user_id', \Auth::id())->get();

                       if the other methods are implemented: hasOne, hasMany, belogsTo, etc. 
        */
    }

}

JorgeAlberto started a new conversation Relationships Based On A Pivot Table From The Models

Hi. I seek to make relationships in the models towards a pivot table.

the tables are these:

table A: a_id

table B: b_id

table C

c_id, a_id, b_id,

What I'm looking for in the models is for example.

in the model of table C

public function A_r(){

make a query that returns only the data that comply with the relationship from a to b from the C table to

example

}

for do

$c = C::where('a_id', 1)->get(); $data = $c->A_r

which should bring me the data from table A. Even if you request them from table C

09 Jan
6 months ago

JorgeAlberto left a reply on Because It Redirects Me??

Thanks, comment again on the AuthenticateSession middleware and it does not redirect me

JorgeAlberto left a reply on Because It Redirects Me??

@AURAWINDSURFING - yes, I decompose the AuthenticateSession middleware because I need only one session per user

JorgeAlberto started a new conversation Because It Redirects Me??

Hi. because when I use the Auth facade on a route that does not contain a middleware, it redirects me to the login path?