JorgeAlberto

JorgeAlberto

Member Since 10 Months Ago

Experience Points
900
Total
Experience

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.

Level 1
900 XP
Sep
12
2 months ago
Activity icon

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')
  );
});
Sep
11
2 months ago
Activity icon

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

Sep
09
2 months ago
Activity icon

Replied to I Can't Run Background Tasks

thanks for your help.

Sep
05
2 months ago
Activity icon

Replied to 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

Activity icon

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

Activity icon

Replied to I Have A Problem With For Models Laravel 6

because I already have the dates of another record

Activity icon

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.

Jul
09
4 months ago
Activity icon

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"
        }
    ]
}
Jul
08
4 months ago
Activity icon

Replied to 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
Activity icon

Replied to 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

Activity icon

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."