JorgeAlberto

JorgeAlberto

Member Since 8 Months Ago

Experience Points 900
Experience Level 1

4,100 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.

12 Sep
3 days ago

JorgeAlberto started a new conversation WebPush Notifications In Background?

Hello

attempt to make a system that sends notifications in the background. That is, it does not matter if the browser window is closed, notifications have to continue to be delivered.

I made a websoket with which I can send the notification messages in real time, however I cannot use the websoxket in the service worker

If you know any tutorial where this can be done, I will thank you

this is my code.


// register service worker
const registerServiceWorker = async () => {
  const swRegistration = await navigator.serviceWorker.register("service.js").then(registration => {
    registration.pushManager.subscribe({
      userVisibleOnly: true
    }).then(subscription => {
      registration.showNotification('Hola Mundo');
      console.log(subscription);
    })
  })
  return swRegistration;
};

// service worker
importScripts('https://cdnjs.cloudflare.com/ajax/libs/axios/0.19.0/axios.js');
importScripts('Pusher.js');

load();
async function load() {
  await axios.get("google.com").then(res => {
      console.log(res);
    },
    err => {
      console.log(err);
    });
}



self.addEventListener('push', event => {
  event.waitUntil(
    self.registration.showNotification('Hola Mundo Push')
  );
});
11 Sep
4 days ago

JorgeAlberto started a new conversation Laravel Web Sockets.

Hello, I am doing a local project with which I send push notifications but I do not have an ssl certificate, however I can access the page but I cannot connect to the socket

window.Echo = new Echo({
    broadcaster: 'pusher',
    key: 'ESDASD2222',
    wsHost: 'task.rxmxit.com',
    wsPort: 6001,

    cluster: 'mt1',
    disableStats: false,
    scheme: 'http',
    // encrypted: true,
    transports: ['websocket', 'polling', 'flashsocket'],
    enabledTransports: ['ws', 'wss'],
    disabledTransports: ['sockjs', 'xhr_polling', 'xhr_streaming']
});

this is intended to connect securely to the sokect but I don't have a certificate to put it to socket.

pusher.js?782e:425 WebSocket connection to 'wss://task.rxmxit.com/app/ESDASD2222?protocol=7&client=js&version=5.0.1&flash=false' failed: Error during WebSocket handshake: Unexpected response code: 404

however I can connect if the protocol is just ws.

can you help me configure the echo instance to connect without the wss protocol

Thanks in advance

09 Sep
6 days ago

JorgeAlberto left a reply on I Can't Run Background Tasks

thanks for your help.

05 Sep
1 week ago

JorgeAlberto left a reply on I Have A Problem With For Models Laravel 6

excuseme but my inglish not is good. In Laravel 5.8 this was not happening to me. I solved it using carbon.

$model->created_at =  Carbon::parse("2019-09-05 10:11:45")->format('Y-m-d H:i:s.u');

But I wanted to see if there is a way to fix it globally in the system

JorgeAlberto started a new conversation I Can't Run Background Tasks

I saw that more people have this problem.

I already have my cron scheduled but it never calls the tasks that have the function runInbackgroud ()

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe php C:\inetpub\task\public\artisan schedule:run 1>> $NULL 2>&1
    protected function schedule(Schedule $schedule)
    {
     $schedule->command('enf2019:local')
                        ->everyMinute()
                        ->appendOutputTo(storage_path() . '\logs\enf-local.log');

     $schedule->command('registros:enf2019')
                        ->everyMinute()
                        ->appendOutputTo(storage_path() . '\logs\enf-registro-json.log')
                        ->runInBackground();
        
    }

This only runs the first command but if I take the second function runInBackground () also runs it

He has the same problem, we both use windows https://laracasts.com/discuss/channels/laravel/run-in-background-artisan-schedule-on-windows

in my case windows server 2012

JorgeAlberto left a reply on I Have A Problem With For Models Laravel 6

because I already have the dates of another record

JorgeAlberto started a new conversation I Have A Problem With For Models Laravel 6

I try to insert a record in my database table, but the created_at and updated_at fields take them as invalid fields

this is my query

$model = new Model;
$model->created_at = "2019-09-05 10:11:45";
$model->updated_at = "2019-09-05 10:11:45";
$model->save();

this is error

   InvalidArgumentException  : Data missing

  at C:\inetpub\task\public\vendor\nesbot\carbon\src\Carbon\Carbon.php:917
    913|
    914|             return $instance;
    915|         }
    916|
  > 917|         throw new InvalidArgumentException(implode(PHP_EOL, $lastErrors['errors']));
    918|     }
    919|
    920|     /**
    921|      * Set last errors.

  Exception trace:

  1   Carbon\Carbon::createFromFormat("Y-m-d H:i:s.u", "2019-09-04 19:20:34")
      C:\inetpub\task\public\vendor\laravel\framework\src\Illuminate\Support\DateFactory.php:216

  2   Illuminate\Support\DateFactory::__call("createFromFormat")
      C:\inetpub\task\public\vendor\laravel\framework\src\Illuminate\Support\Facades\Facade.php:239

  Please use the argument -v to see more details.

09 Jul
2 months 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

the goal is to do the following

with first example:

$user = User::('email', $email)->first();
$user->data;


/* response
{
    "Status": 3,
    "email": "[email protected]",
    "changes": [
        {
            "name": "jORGE",
            "lastname": "aLBERTO"
        }
    ]
}
*/

with first example:

$user = User::('email', $email)->first();
$user->data;


/* response
{
    "Status": 3,
    "email": "[email protected]",
    "changes": [
        {
            "name": "jORGE",
            "lastname": "aLBERTO"
        }
    ]
}
*/

second example:

$user = User::('email', $email)->first();
$user->data;

/* response
{
    "Status": 3,
    "email": "[email protected]",
    "changes": [
        {
            "ResID": 6731,
            "Res": 1,
            "UserID": 22,
            "Text": "jORGE",
            "created_at": "2019-06-05 22:32:23",
            "updated_at": "2019-06-05 22:32:23"
        },
        {
            "ResID": 6732,
            "Res": 2,
            "UserID": 22,
            "Text": "aLBERTO",
            "created_at": "2019-06-05 22:32:26",
            "updated_at": "2019-06-05 22:32:26"
        }
    ]
}
08 Jul
2 months 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',
    ],
],




now the passport models do not point to the correct database. and I do not know how to specify the correct connection to the models

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
4 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 > client

20 Mar
5 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
6 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.


<tr> 
         <td bgcolor="#f2f2f2">
             <table width="550" align="center" cellpadding="0" cellspacing="0" border="0">
                 <tr>
                    <td align="center" width="650px" bgcolor="#f2f2f2" style="font-size: 11px; padding-bottom: 10px">
                      <span rel="nofollow" style="widh: 500px; word-break: break-all; ">
                       https://{{$_SERVER['HTTP_HOST']}}/confirm&#8209;email/{{$data->token}}
                      </span>
                    </td>
                </tr>
             </table>
            </td>
         </tr>
<tr>    

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
6 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
7 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
8 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
8 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. 
        */
    }

}

Sorry, the syntax is not right to format the questions

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
8 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?