manojow

manojow

Web Developer at PJ CorporaciĆ³n

Member Since 2 Years Ago

Lima

Experience Points
31,630
Total
Experience

3,370 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
296
Lessons
Completed
Best Reply Awards
1
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.

Level 7
31,630 XP
Oct
06
2 weeks ago
Activity icon

Commented on Livewire Polling

Thats what I thought. If you manually set the revenue to 40 you be only testing that the public $revenue show on view instead of changing the value with the orders.

Sep
27
3 weeks ago
Activity icon

Replied to Get All Possible Elements From BelongsToMany Relationship

@marianomoreyra Thanks for the reply:

In your case you are considering the product collection separately in each category. I need all products from category 1 and 2 together in the same collection

I dropped my loop and now I am using this logic

Product::whereIn(
   'id',
   CategoryProduct::whereIn('category_id', [1, 2])->pluck('product_id')
)->get(); 

Where CategoryProduct is a pivot model class that I just created. I think thats it.

Activity icon

Started a new Conversation Get All Possible Elements From BelongsToMany Relationship

Hello community,

I have 3 tables

products categories category_product

Given I have a collection with categories

$category = Category::findMany([1, 2]);

I want to get all possible products from both categories in a collection

So far i am creating a foreach loop and combining arrays but want a cleaner way if possible

Thanks in advance.

Sep
18
1 month ago
Activity icon

Replied to Cannot Declare Class. Conflicts Between Legacy And Eloquent Factories

Yes. I know how to use. The problem is when I try to make it work together with legacy factories. The new ones throw errors because reasignations

Activity icon

Started a new Conversation Cannot Declare Class. Conflicts Between Legacy And Eloquent Factories

I created new eloquent factories to my new project that I recently updated to laravel 8. Now when I want to test with phpunit I get this message

Cannot declare class Database\Factories\FooFactory, because the name is already in use in /var/www/atsnacks/database/factories/FooFactory.php on line 9

Is anyone facing the same problem? It is impossible now to mix between legacy and eloquent factories?

Sep
17
1 month ago
Activity icon

Commented on How It Works

That's something I will dive into it. Do you think livewire can fully replace a javascript framework in a real project? Now I just want to refactor all my codes from the past with this new concept haha thanks for the class

Sep
14
1 month ago
Activity icon

Commented on Upgrade The Laracasts Codebase To Laravel 8

What phpunit test are you using? Why your tests are all beautifully printed? I got the dots when I test

Activity icon

Commented on Upgrade The Laracasts Codebase To Laravel 8

Hey Jeffrey, can you please show off your laravel nova panel? i' ve been working on nova for almost a year and I will be very thankful to see how someone else is doing in a real proyect like laracasts.

Sep
04
1 month ago
Activity icon

Replied to Sum Field Of Relation In A Eloquent Collection

I see you edited the message. Thats It! WhereIn with Pluck OrderIds you are a mvp sir thanks!

Activity icon

Replied to Sum Field Of Relation In A Eloquent Collection

This does not help. I need all sales from my collection of orders

Activity icon

Started a new Conversation Sum Field Of Relation In A Eloquent Collection

Hello,

I have this relation in my DB

Order has Many Sale

I want to sum all field from sales from a collection of orders. Something like this

$orders = Orders::all()->get();
$sum_sales_price = $orders->sales->sum('field');

There is a pretty way to solve this?

Sep
02
1 month ago
Activity icon

Awarded Best Reply on Problem With PHPUnit + SQLite DropColumn()

After 14 Hours I managed to fix the problem by downgrading dbal/doctine version from 2.10.13 to 2.10.12 in composer.json

"doctrine/dbal": "2.10.2"

The doctrine 2.10.3 for some reason cant find well the foreign key name at line 2586 in file /vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php returning 1 or 0 on getQuotedName method

if (strlen($foreignKey->getName())) {
    $sql .= 'CONSTRAINT ' . $foreignKey->getQuotedName($this) . ' ';
}
Activity icon

Replied to Problem With PHPUnit + SQLite DropColumn()

After 14 Hours I managed to fix the problem by downgrading dbal/doctine version from 2.10.13 to 2.10.12 in composer.json

"doctrine/dbal": "2.10.2"

The doctrine 2.10.3 for some reason cant find well the foreign key name at line 2586 in file /vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php returning 1 or 0 on getQuotedName method

if (strlen($foreignKey->getName())) {
    $sql .= 'CONSTRAINT ' . $foreignKey->getQuotedName($this) . ' ';
}
Activity icon

Replied to Problem With PHPUnit + SQLite DropColumn()

Okay I have a pre production server that I didnt update composer and I was able to make the final proof that there is a broken package in laravel with phpunit

where is my terminal commands and outputs

[email protected]:/var/www/atsnacks$ php vendor/bin/phpunit
PHPUnit 8.5.8 by Sebastian Bergmann and contributors.

...............................................................  63 / 167 ( 37%)
............................................................... 126 / 167 ( 75%)
.........................................                       167 / 167 (100%)

Time: 21.1 seconds, Memory: 70.50 MB

OK (167 tests, 288 assertions)
[email protected]:/var/www/atsnacks$ composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 1 install, 30 updates, 0 removals
  - Updating doctrine/dbal (2.10.2 => 2.10.3): Downloading (100%)         
  - Updating symfony/css-selector (v5.1.3 => v5.1.5): Downloading (100%)         
  - Updating symfony/var-dumper (v5.1.3 => v5.1.5): Downloading (100%)         
  - Updating symfony/routing (v5.1.3 => v5.1.5): Downloading (100%)         
  - Updating symfony/process (v5.1.3 => v5.1.5): Downloading (100%)         
  - Updating symfony/mime (v5.1.3 => v5.1.5): Downloading (100%)         
  - Updating symfony/string (v5.1.3 => v5.1.5): Downloading (100%)         
  - Updating symfony/http-foundation (v5.1.3 => v5.1.5): Downloading (100%)         
  - Updating symfony/event-dispatcher (v5.1.3 => v5.1.5): Downloading (100%)         
  - Updating symfony/error-handler (v5.1.3 => v5.1.5): Downloading (100%)         
  - Updating symfony/http-kernel (v5.1.3 => v5.1.5): Downloading (100%)         
  - Updating symfony/finder (v5.1.3 => v5.1.5): Downloading (100%)         
  - Updating symfony/console (v5.1.3 => v5.1.5): Downloading (100%)         
  - Updating brick/math (0.8.15 => 0.8.17): Downloading (100%)         
  - Updating ramsey/uuid (4.1.0 => 4.1.1): Downloading (100%)         
  - Updating symfony/translation (v5.1.3 => v5.1.5): Downloading (100%)         
  - Updating nesbot/carbon (2.38.0 => 2.39.0): Downloading (100%)         
  - Updating league/flysystem (1.1.1 => 1.1.3): Downloading (100%)         
  - Updating league/commonmark (1.5.3 => 1.5.4): Downloading (100%)         
  - Updating laravel/framework (v7.25.0 => v7.27.0): Downloading (100%)         
  - Updating laravel/ui (v2.1.0 => v2.2.0): Downloading (100%)         
  - Updating manojo123/nova-attach-pivot (1.0.14 => 1.0.16): Downloading (100%)         
  - Updating spatie/laravel-permission (3.15.0 => 3.16.0): Downloading (100%)         
  - Updating cakephp/chronos (2.0.5 => 2.0.6): Downloading (100%)         
  - Updating symfony/intl (v5.1.3 => v5.1.5): Downloading (100%)         
  - Updating nikic/php-parser (v4.8.0 => v4.9.1): Downloading (100%)         
  - Updating spatie/laravel-medialibrary (8.5.0 => 8.6.0): Downloading (100%)         
  - Updating lcobucci/jwt (3.3.2 => 3.3.3): Downloading (100%)         
  - Updating markbaker/complex (1.4.8 => 1.5.0): Downloading (100%)         
  - Updating markbaker/matrix (1.2.0 => 1.2.1): Downloading (100%)         
  - Installing inspheric/nova-indicator-field (v1.43): Downloading (100%)         
Package alexbowers/nova-prepopulate-searchable is abandoned, you should avoid using it. Use genealabs/nova-prepopulate-searchable instead.
Package moontoast/math is abandoned, you should avoid using it. Use brick/math instead.
Package phpunit/php-token-stream is abandoned, you should avoid using it. No replacement was suggested.
Package zendframework/zend-diactoros is abandoned, you should avoid using it. Use laminas/laminas-diactoros instead.
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
Discovered Package: alexbowers/nova-prepopulate-searchable
Discovered Package: arcanedev/log-viewer
Discovered Package: barryvdh/laravel-dompdf
Discovered Package: beyondcode/laravel-dump-server
Discovered Package: coderello/laravel-nova-lang
Discovered Package: david-griffiths/nova-dark-theme
Discovered Package: ebess/advanced-nova-media-library
Discovered Package: fideloper/proxy
Discovered Package: gregoriohc/laravel-nova-theme-responsive
Discovered Package: inspheric/nova-indicator-field
Discovered Package: intervention/image
Discovered Package: kabbouchi/nova-impersonate
Discovered Package: lab404/laravel-impersonate
Discovered Package: laravel/nova
Discovered Package: laravel/passport
Discovered Package: laravel/tinker
Discovered Package: laravel/ui
Discovered Package: maatwebsite/excel
Discovered Package: maatwebsite/laravel-nova-excel
Discovered Package: manojo123/laravel-nova-permission
Discovered Package: manojo123/nova-attach-pivot
Discovered Package: manojo123/novapassport
Discovered Package: manojo123/shoppingcart
Discovered Package: nesbot/carbon
Discovered Package: nunomaduro/collision
Discovered Package: php-junior/nova-logs
Discovered Package: simplesoftwareio/simple-qrcode
Discovered Package: spatie/laravel-medialibrary
Discovered Package: spatie/laravel-permission
Discovered Package: tanmuhittin/nova-collapsible-groups
Package manifest generated successfully.
[email protected]:/var/www/atsnacks$ php vendor/bin/phpunit
PHPUnit 8.5.8 by Sebastian Bergmann and contributors.

EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE  63 / 167 ( 37%)
EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE 126 / 167 ( 75%)
EEEEEEEEEEEEEEEEEEEEEEE^[email protected]:/var/www/atsnacks$ 

Now I will try to identify with package is broken. I will be glad if someone could help me with that.

Activity icon

Replied to Problem With PHPUnit + SQLite DropColumn()

I pushed all my changes to production and executed composer update. Then all my tests broke. Looks like a very new bug from vendor. I will investigate and post here if I find something.

Activity icon

Replied to Problem With PHPUnit + SQLite DropColumn()

I do not have a .env.testing

Everything is inside .env

APP_NAME=Laravel
APP_ENV=local
APP_KEY=MY_KEY
APP_DEBUG=true
APP_URL=http://localhost

EDITOR=vim
LOG_CHANNEL=stack

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=atsnacks
DB_USERNAME=root
DB_PASSWORD=

BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
SESSION_DRIVER=database
SESSION_LIFETIME=120

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=

PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

DEFAULT_COMPANY=2
DEFAULT_ADDRESS=1
DEFAULT_DOCUMENT=1
DEFAULT_PROVIDER_COMPANY=4
TEST_SHOP=0666
TEST_SERIE=900
TEST_SERIE_NC=901

phpunit:

<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
         backupStaticAttributes="false"
         bootstrap="vendor/autoload.php"
         colors="true"
         convertErrorsToExceptions="true"
         convertNoticesToExceptions="true"
         convertWarningsToExceptions="true"
         processIsolation="false"
         stopOnFailure="false">
    <testsuites>
        <testsuite name="Unit">
            <directory suffix="Test.php">./tests/Unit</directory>
        </testsuite>

        <testsuite name="Feature">
            <directory suffix="Test.php">./tests/Feature</directory>
        </testsuite>
    </testsuites>
    <filter>
        <whitelist processUncoveredFilesFromWhitelist="true">
            <directory suffix=".php">./app</directory>
        </whitelist>
    </filter>
    <php>
        <server name="APP_ENV" value="testing"/>
        <server name="BCRYPT_ROUNDS" value="4"/>
        <server name="CACHE_DRIVER" value="array"/>
        <server name="MAIL_DRIVER" value="array"/>
        <server name="QUEUE_CONNECTION" value="sync"/>
        <server name="SESSION_DRIVER" value="array"/>
        <server name="DB_CONNECTION" value="sqlite"/>
        <server name="DB_DATABASE" value=":memory:"/>
    </php>
</phpunit>

Activity icon

Started a new Conversation Problem With PHPUnit + SQLite DropColumn()

Hello Everyone,

Suddenly all my tests started to fail with the same error.

  • Im using Laravel Framework 7.27.0

  • Ubuntu 20.04

  • PHPUnit in :memory: database and sqlite

  • I did not change any migration and always worked before without problems.

  • If run phpunit on my production server, works, looks like some bad configuration issue

  • If I create blank project and add a dropCOlumn migration works without a problem.

  • If I git reset --hard a week ago (yesterday was working without any problems) I still get errors

Tests\Unit\UserTest::it_has_many_categories
Illuminate\Database\QueryException: SQLSTATE[HY000]: General error: 1 near "1": syntax error (SQL: CREATE TABLE products (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, user_id INTEGER NOT NULL, code VARCHAR(255) NOT NULL COLLATE BINARY, name VARCHAR(255) NOT NULL COLLATE BINARY, slug VARCHAR(255) NOT NULL COLLATE BINARY, description VARCHAR(255) DEFAULT NULL COLLATE BINARY, price NUMERIC(10, 0) NOT NULL, image VARCHAR(255) DEFAULT NULL COLLATE BINARY, active BOOLEAN DEFAULT '1' NOT NULL, created_at DATETIME DEFAULT NULL, updated_at DATETIME DEFAULT NULL, stock INTEGER DEFAULT 0 NOT NULL, title CLOB DEFAULT NULL COLLATE BINARY, CONSTRAINT 1 FOREIGN KEY (user_id) REFERENCES users (id) ON UPDATE NO ACTION ON DELETE NO ACTION NOT DEFERRABLE INITIALLY IMMEDIATE))

/var/www/atsnacks/vendor/laravel/framework/src/Illuminate/Database/Connection.php:671
/var/www/atsnacks/vendor/laravel/framework/src/Illuminate/Database/Connection.php:631
/var/www/atsnacks/vendor/laravel/framework/src/Illuminate/Database/Connection.php:465
/var/www/atsnacks/vendor/laravel/framework/src/Illuminate/Database/Schema/Blueprint.php:102
/var/www/atsnacks/vendor/laravel/framework/src/Illuminate/Database/Schema/Builder.php:290
/var/www/atsnacks/vendor/laravel/framework/src/Illuminate/Database/Schema/Builder.php:151
/var/www/atsnacks/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:261
/var/www/atsnacks/database/migrations/2019_10_17_095205_drop_category_id_in_products_table.php:21
/var/www/atsnacks/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:392
/var/www/atsnacks/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:401
/var/www/atsnacks/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:200
/var/www/atsnacks/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:165
/var/www/atsnacks/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:110
/var/www/atsnacks/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/MigrateCommand.php:72
/var/www/atsnacks/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:541
/var/www/atsnacks/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/MigrateCommand.php:81
/var/www/atsnacks/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:37
/var/www/atsnacks/vendor/laravel/framework/src/Illuminate/Container/Util.php:37
/var/www/atsnacks/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:95
/var/www/atsnacks/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:39
/var/www/atsnacks/vendor/laravel/framework/src/Illuminate/Container/Container.php:596
/var/www/atsnacks/vendor/laravel/framework/src/Illuminate/Console/Command.php:134
/var/www/atsnacks/vendor/symfony/console/Command/Command.php:258
/var/www/atsnacks/vendor/laravel/framework/src/Illuminate/Console/Command.php:121
/var/www/atsnacks/vendor/symfony/console/Application.php:916
/var/www/atsnacks/vendor/symfony/console/Application.php:264
/var/www/atsnacks/vendor/symfony/console/Application.php:140
/var/www/atsnacks/vendor/laravel/framework/src/Illuminate/Console/Application.php:93
/var/www/atsnacks/vendor/laravel/framework/src/Illuminate/Console/Application.php:185
/var/www/atsnacks/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:263
/var/www/atsnacks/vendor/laravel/framework/src/Illuminate/Testing/PendingCommand.php:171
/var/www/atsnacks/vendor/laravel/framework/src/Illuminate/Testing/PendingCommand.php:291
/var/www/atsnacks/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithConsole.php:52
/var/www/atsnacks/vendor/laravel/framework/src/Illuminate/Foundation/Testing/RefreshDatabase.php:40
/var/www/atsnacks/vendor/laravel/framework/src/Illuminate/Foundation/Testing/RefreshDatabase.php:17
/var/www/atsnacks/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestCase.php:115
/var/www/atsnacks/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestCase.php:84

Here is my migration file from the error. If I full comment this migration the error goes to the next dropColumn migration. As I could see. The column got dropped but then fails for some reason.

class DropCategoryIdInProductsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('products', function (Blueprint $table) {
            if(DB::connection()->getDatabaseName() != ':memory:'){
                $table->dropForeign('products_category_id_foreign');
            }
            $table->dropColumn('category_id');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('products', function (Blueprint $table) {
            $table->unsignedBigInteger('category_id')->index();
            $table->foreign('category_id')->references('id')->on('categories')->onDelete('cascade');
        });
    }

Anyone has an Idea what can be? Thanks in advance.

Jul
01
3 months ago
Activity icon

Commented on Automatic PSR-2 Formatting

Thats the same package. We are just installing the plugin

Jun
25
3 months ago
Activity icon

Commented on Faster Browsing With CtrlP

I know it was posted long time ago. In order to make it work on ubuntu now, you need to execute this command

sudo apt-get install exuberant-ctags