scottsuhy

Member Since 1 Year Ago

Experience Points
1,800
Total
Experience

3,200 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
3
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start your 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-in-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 Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist 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.

  • Community Pillar

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

Level 1
1,800 XP
Mar
04
1 month ago
Activity icon

Replied to Period In A URL Gives 403

it's safer to rewrite the code and take the variables out of the URL than to update the database. When I was first learning laravel I was passing everything in the URLs but now I realize that this isn't a very good approach and should rewrite a lot of the older code.

i thought i might have been missing something simple and misinterpreting the RFC https://pretty-rfc.herokuapp.com/RFC3986#unreserved

thanks for your help.

Activity icon

Replied to Period In A URL Gives 403

This looks like a nginx issue on AWS not a laravel or forge issue. thanks. I'll just rewrite the calls that deal with that data to AJAX.

Activity icon

Replied to Period In A URL Gives 403

sorry for the confusion. No, the variable is ".5 Kopek"

see https://imgur.com/PVXznz6 for postgres view

Mar
03
1 month ago
Activity icon

Replied to Period In A URL Gives 403

no, it's just a variable stored in postgres. it's the name of a type of coin (like "Morgan Dollar" but this is a Russian "1/2 Kopek")

Activity icon

Replied to Period In A URL Gives 403

encoding with %2e gets same result.

AWS is nginx/1.17.3 Local is Apache (on Windows) 2.4.41.0

Activity icon

Started a new Conversation Period In A URL Gives 403

OK, can someone school me on periods in URLs. I'm using Forge/AWS.

on the dev system the URL resolves fine with the period (.5) as follows:

http://127.0.0.1:8082/eBayX/.5%20Kopek/ANY/Russia/1734

however, in production, I get a 403

https://icollect.money/eBayX/.5%20Kopek/ANY/Russia/1734

I can fix by making all the calls that could be impacted AJAX but I'm now curious why "." doesn't work in URL syntax. I thought that a period was 'unreserved' and allowed in URLs (see https://perishablepress.com/stop-using-unsafe-characters-in-urls/)

here is route:

Route::get('/eBayX/{series}/{rating}/{mint}/{year}', '[email protected]')->middleware('auth');

thanks

Feb
17
1 month ago
Activity icon

Replied to Friendly Plan (pricing) Names Used In Cashier

@jlrdw That's what I originally thought too but the nickname doesn't work in the api, however it does show up in the plan json so i can create something that works better. i just thought i was missing something because of how the laravel docs were written.

Feb
16
1 month ago
Activity icon

Started a new Conversation Friendly Plan (pricing) Names Used In Cashier

I'm sure that this is a very simple question (so apologies upfront) but I can't seem to find an answer to it via Google.

in Cashier/Subscriptions Laravel docs I see references to plan/pricing names like 'monthly' and 'yearly'.

if ($user->subscribedToPlan(['monthly', 'yearly'], 'default')) {
    //
}

up to now, i've been putting the actual price ID in these fields and it works fine. Example: ' price_1IJo9hCDdBCrDroVD3kKZFO3' but it would be a lot better if I could use friendly names.

The Question: How do you actually configure Stripe with a friendly name like 'monthly' or 'yearly'?

I tried to use additional options/price description and that shows up in 'nickname' but doesn't work in the subscribedToPlan API.

Stripe\Plan JSON: { 
"id": "price_1IJo9hCDdBCrDroVD3kKZFO3", 
"object": "plan", 
"active": true, 
"aggregate_usage": null, 
"amount": 2500, 
"amount_decimal": "2500", 
"billing_scheme": "per_unit", 
"created": 1613059295, 
"currency": "usd", 
"interval": "month", 
"interval_count": 1, 
"livemode": false, 
"metadata": [], 
"nickname": null, 
Dec
01
4 months ago
Activity icon

Awarded Best Reply on Getting "Class 'Doctrine\DBAL\Driver\PDOPgSql\Driver' Not Found" Error

I had to manually delete the dbal directory then

composer remove doctrine/dbal
composer require doctrine/dbal
php artisan migrate

and it worked.

no idea why i had to manually delete it

Nov
30
4 months ago
Activity icon

Replied to Getting "Class 'Doctrine\DBAL\Driver\PDOPgSql\Driver' Not Found" Error

I had to manually delete the dbal directory then

composer remove doctrine/dbal
composer require doctrine/dbal
php artisan migrate

and it worked.

no idea why i had to manually delete it

Activity icon

Replied to Getting "Class 'Doctrine\DBAL\Driver\PDOPgSql\Driver' Not Found" Error

here is composer.json

{
    "name": "laravel/laravel",
    "type": "project",
    "description": "The Laravel Framework.",
    "keywords": [
        "framework",
        "laravel"
    ],
    "license": "MIT",
    "require": {
        "php": "^7.3",
        "ext-json": "*",
        "doctrine/dbal": "^3.0",
        "fideloper/proxy": "^4.0",
        "intervention/image": "^2.5",
        "laravel/cashier": "^12.0",
        "laravel/framework": "^8.0",
        "laravel/sanctum": "^2.8",
        "laravel/telescope": "^4.0",
        "laravel/tinker": "^2.0",
        "league/csv": "^9.6",
        "league/flysystem-aws-s3-v3": "~1.0",
        "league/flysystem-cached-adapter": "~1.0",
        "nesbot/carbon": "^2.32",
        "pusher/pusher-php-server": "^4.1",
        "spatie/laravel-cookie-consent": "^2.12",
        "stripe/stripe-php": "^7.52",
        "yajra/laravel-datatables": "^1.5",
        "yajra/laravel-datatables-editor": "^1.21",
        "yajra/laravel-datatables-oracle": "^9.8"
    },
    "require-dev": {
        "facade/ignition": "^2.3.6",
        "fzaninotto/faker": "^1.9.1",
        "laravel/ui": "^3.0",
        "mockery/mockery": "^1.0",
        "nunomaduro/collision": "^5.0",
        "phpunit/phpunit": "^9.0"
    },
    "config": {
        "optimize-autoloader": true,
        "preferred-install": "dist",
        "sort-packages": true
    },
    "extra": {
        "laravel": {
            "dont-discover": []
        }
    },
    "autoload": {
        "psr-4": {
            "App\": "app/"
        },
        "classmap": [
            "database/seeds",
            "database/factories"
        ]
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\": "tests/"
        }
    },
    "minimum-stability": "dev",
    "prefer-stable": true,
    "scripts": {
        "post-autoload-dump": [
            "Illuminate\Foundation\ComposerScripts::postAutoloadDump",
            "@php artisan package:discover --ansi"
        ],
        "post-root-package-install": [
            "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "@php artisan key:generate --ansi"
        ]
    }
}
Activity icon

Replied to Getting "Class 'Doctrine\DBAL\Driver\PDOPgSql\Driver' Not Found" Error

Here is error: Class 'Doctrine\DBAL\Driver\PDOPgSql\Driver' not found

but if you look in that directory it's empty

C:\Apache24\htdocs\myproject\vendor\doctrine\dbal>dir
 Volume in drive C is OS
 Volume Serial Number is 7CFF-A94F

 Directory of C:\Apache24\htdocs\myproject\vendor\doctrine\dbal

11/30/2020  02:38 PM    <DIR>          .
11/30/2020  02:38 PM    <DIR>          ..
11/30/2020  02:38 PM    <DIR>          bin
11/30/2020  02:38 PM             2,029 composer.json
11/30/2020  02:38 PM               177 CONTRIBUTING.md
11/30/2020  02:38 PM             1,065 LICENSE
11/30/2020  02:38 PM             6,828 psalm.xml
11/30/2020  02:38 PM             2,272 README.md
11/30/2020  02:38 PM    <DIR>          src
               5 File(s)         12,371 bytes

However it does appear the driver exists in the src directory but I'm not sure if this is relevant or not.

C:\Apache24\htdocs\myproject\vendor\doctrine\dbal\src\Driver\PDO\PgSQL>dir
 Volume in drive C is OS
 Volume Serial Number is 7CFF-A94F

 Directory of C:\Apache24\htdocs\myproject\vendor\doctrine\dbal\src\Driver\PDO\PgSQL

11/30/2020  02:38 PM    <DIR>          .
11/30/2020  02:38 PM    <DIR>          ..
11/30/2020  02:38 PM             3,277 Driver.php
               1 File(s)          3,277 bytes

there doesn't appear to be an issue related to this on https://github.com/doctrine/dbal/issues

Activity icon

Replied to Getting "Class 'Doctrine\DBAL\Driver\PDOPgSql\Driver' Not Found" Error

upgraded to composer 2 removed vendor... and and ran composer install

same issue...

Activity icon

Started a new Conversation Getting "Class 'Doctrine\DBAL\Driver\PDOPgSql\Driver' Not Found" Error

Getting this error when trying to update a table "Class 'Doctrine\DBAL\Driver\PDOPgSql\Driver' not found"

Per doc, i've required doctrine/dbal https://laravel.com/docs/8.x/migrations#modifying-columns

here is migration:

<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class Updatecoinstabletoaddforsaledefault extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('coins', function (Blueprint $table) {
            $table->integer('for_sale')->nullable()->default(0)->change();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        //
    }
}

Here is installation, migration and error:

C:\Apache24\htdocs\myproject>composer require doctrine/dbal
Warning from https://repo.packagist.org: You are using an outdated version of Composer. Composer 2.0 is now available and you should upgrade. See https://getcomposer.org/2
Using version ^3.0 for doctrine/dbal
./composer.json has been updated
Loading composer repositories with package information
Warning from https://repo.packagist.org: You are using an outdated version of Composer. Composer 2.0 is now available and you should upgrade. See https://getcomposer.org/2
Updating dependencies (including require-dev)
Package operations: 1 install, 1 update, 0 removals
  - Installing composer/package-versions-deprecated (1.11.99.1): Downloading (100%)
  - Updating doctrine/dbal (2.11.2 => 3.0.0): Downloading (100%)
Package fzaninotto/faker is abandoned, you should avoid using it. No replacement was suggested.
Writing lock file
Generating optimized autoload files
Deprecation Notice: Class App\collection located in C:/Apache24/htdocs/myproject/app\collection_bak.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v2.0. in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:201
composer/package-versions-deprecated: Generating version class...
composer/package-versions-deprecated: ...done generating version class
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
Discovered Package: facade/ignition
Discovered Package: fideloper/proxy
Discovered Package: intervention/image
Discovered Package: laravel/cashier
Discovered Package: laravel/sanctum
Discovered Package: laravel/telescope
Discovered Package: laravel/tinker
Discovered Package: laravel/ui
Discovered Package: laravelcollective/html
Discovered Package: maatwebsite/excel
Discovered Package: nesbot/carbon
Discovered Package: nunomaduro/collision
Discovered Package: spatie/laravel-cookie-consent
Discovered Package: yajra/laravel-datatables-buttons
Discovered Package: yajra/laravel-datatables-editor
Discovered Package: yajra/laravel-datatables-fractal
Discovered Package: yajra/laravel-datatables-html
Discovered Package: yajra/laravel-datatables-oracle
Package manifest generated successfully.
86 packages you are using are looking for funding.
Use the `composer fund` command to find out more!

C:\Apache24\htdocs\myproject>php artisan make:migration updatecoinstabletoaddforsaledefault
Created Migration: 2020_11_30_150943_updatecoinstabletoaddforsaledefault

C:\Apache24\htdocs\myproject>php artisan migrate
Migrating: 2020_11_30_150943_updatecoinstabletoaddforsaledefault

   Error

  Class 'Doctrine\DBAL\Driver\PDOPgSql\Driver' not found

  at C:\Apache24\htdocs\myproject\vendor\laravel\framework\src\Illuminate\Database\PostgresConnection.php:104
    100▕      * @return \Doctrine\DBAL\Driver\PDOPgSql\Driver
    101▕      */
    102▕     protected function getDoctrineDriver()
    103▕     {
  ➜ 104▕         return new DoctrineDriver;
    105▕     }
    106▕ }
    107▕

  1   C:\Apache24\htdocs\myproject\vendor\laravel\framework\src\Illuminate\Database\Connection.php:894
      Illuminate\Database\PostgresConnection::getDoctrineDriver()

  2   C:\Apache24\htdocs\myproject\vendor\laravel\framework\src\Illuminate\Database\Schema\Grammars\ChangeColumn.php:36
      Illuminate\Database\Connection::getDoctrineSchemaManager()
Nov
10
5 months ago
Activity icon

Replied to Is It Possible To Use The Laravel Task Scheduler To Execute A Python Script?

Thank you for the dialog. it's been helpful for me to think a bit differently (i've not used queue:worker tasks and need to dig into this)

You are correct about auctions being event driven but they are also time driven--Time is important for when they start (example: this auction is at 6pm Friday). So at a specific time, some process has to read and get a database of items, let users know what item is up for bid and who is the winner. Time is also important on the last bid (who has highest bid before the time that the hammer is dropped on the item.

I'll dig into what you suggested. thanks again.

Activity icon

Replied to Is It Possible To Use The Laravel Task Scheduler To Execute A Python Script?

sorry, 'ring' is an auction thing not a python thing. it's the current item being bid on.

given your comment about "'cronjobs' only have resolution of 1 minute" -- that may be a problem because auctions can take hours (hundreds of items being bid on and each item can take 1-5 min depending on popularity).

let me explain a bit more detail to see if you still think this is a bad approach.

This is essentially what the current python script does:

connect to auction_items DB to get all items users will bid on in the auction for $auction_number passed as argument
for loop for each item
	call controller "/beginBiddingOnItem" to begin bidding on current item (this basically updates all the users screens via pusher)
	sleep for some time to let bids pile up on the new item
	While(true)
		call controller "/auctionClosingProcessForItem" to start the countdown on the item. It reads the last/highest bid and goes through a lot of logic that goes from 'fair warning...' to 'going going...' to 'we have a winner...'
		break when we have a winner
		sleep(1 second)

While this is happening users are interacting with the auction via Pusher message (send bid in.., you winning.., you've been outbid.., you won...)

since several auctions will be run at the same time and scheduled by a user that created the auction (listing agent) I was looking for 1. a way to schedule and execute this python script auctioneer logic at a specific date/time determined by the listing agent user 2. allow for scalability (more auctions just need more cpu/memory)--the script only runs if there is a live auction scheduled

I've read your response a few times and I think what you are saying is don't use cron and create my own scheduling logic--that is doable. Am I understanding you correctly?

Activity icon

Replied to Is It Possible To Use The Laravel Task Scheduler To Execute A Python Script?

  1. The listing agent (the user that created "auction #x" and scheduled it) wants it to happen (run) at a specific time on a specific day.

  2. RunAuction.py starts auction x for the users that are registered for auction=x, the script puts an item in the ring and then users bid on it. the RunAuction process then counts down, chooses a winner, closes the item and moves another item into the ring. The interaction between the users of the auction and the controller is done with Pusher. Note: I originally built it all in a controller but it was giving me a lot of blocking issues so I redesigned to use Pusher.

  3. many auctions will be scheduled/running at the same time and it needs to scale with success. this is why i pulled the logic out into a separate process per auction and why I first went to Lamda/EventBridge (but there are numerous issues there that would require a rewrite of the python script--so before I do that I wanted to look at all other potential solutions).

Activity icon

Started a new Conversation Is It Possible To Use The Laravel Task Scheduler To Execute A Python Script?

I'm using Laravel 8 w/Forge-AWS. I am looking for some architecture guidance for scheduling processes. Currently my online auctions are manual (run by human auctioneer). I have built a python process that now can act as the auctioneer. I am researching the best architecture to schedule/running this process. I was considering AWS Lambda/Eventbridge but there are many gotchas. In reading more about the Laravel Task scheduler on Forge I was wondering if I could use it + Symfony as a potential solution. There will be many online auctions running at the same time and the UI has to be able to schedule those auction processes programmatically as cron jobs to run on a certain date/time.

I was wondering if something like this would work but I am not understanding a few things outline below (and I'm not sure if its feasible or even a good approach).

From reading the docs I think I'd have to :

A. Create a command

php artisan make:command RunAuction

B. In app/Console/Commands/RunAuction.php do something like this:

use Symfony\Component\Process\Process;
use Symfony\Component\Process\Exception\ProcessFailedException;

public function handle()
{

	$auction_number = 123; //auction # - 
	$process = new Process("python3 /Path/To/run_auction.py {$auction_number}");
	$process->run();

	if (!$process->isSuccessful()) {
	    throw new ProcessFailedException($process);
	}

	echo $process->getOutput();
}

C. Make the command available in app/Console/Kernel.php

    protected $commands = [
        Commands\Inspire::class,
        Commands\RunAuction::class
    ];

but then I'm unsure of what to do next. I see how to use the "protected function schedule(Schedule $schedule)" in Kernel.php but how can I do this programmatically based on the users choice to run the auction versus hardcoding a cron schedule here? I'd want to do something like:

$schedule->command('RunAuction')->cron($cron_string); 

where $cron_string is created by the user/UI - example: "0 30 4,12 4 NOV ? 2020"

Is this feasible? If so, how best to do it? Do you see a better architecture for this use case?

Nov
06
5 months ago
Activity icon

Replied to Sanctum Question

That was it. Very strange behavior without it. Thank you--I was pulling my hair out. You rock!

Nov
05
5 months ago
Activity icon

Started a new Conversation Sanctum Question

updated question below

I have a current application using Laravel's built-in authentication services on Laravel 8 hosted on AWS/Forge.

I need to create a REST API for a current authenticated route for third party apps (from different domains) to use to add items to a table.

I followed https://laravel.com/docs/8.x/sanctum

and in the api.php file if the route is in the authe:sanctum middleware the call fails but if it's outside of it the call succeeds.

what am I doing wrong?

Route::post('/apilogin', '[email protected]');

//Route::get('/getallusers', '[email protected]');  //this succeeds

Route::middleware(['auth:sanctum'])->group(function () {
    Route::get('/getallusers', '[email protected]');  //this fails 
});

I'm calling it from python:

import psycopg2
import requests
import re
import json

url = 'http://127.0.0.1:8092/api/apilogin' 

############## LOGIN ####################
data = {
    'email': '[email protected]',
    'password': 'mypassword'}
    
r = requests.post(url, data=data) 
user = json.loads(r.text)

############## MAKE REST API CALL using login token from prior call ####################

url = 'http://127.0.0.1:8092/api/getallusers'
headers = {	'Bearer': user["token"]}    
r = requests.get(url, headers=headers)
users = json.loads(r.text)
print (r, users["users"])