joshsalway

joshsalway

Member Since 10 Months Ago

Experience Points
46,330
Total
Experience

3,670 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
440
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.

Level 10
46,330 XP
Apr
14
1 month ago
Activity icon

Replied to How To Overwrite Optimistdigital/nova-multiselect-field Package?

I've done exactly like the documentation and tried editing the data and nothing changes for the Vue multi-select field.

Activity icon

Started a new Conversation How To Overwrite Optimistdigital/nova-multiselect-field Package?

https://github.com/optimistdigital/nova-multiselect-field

This package allows you to add multi-select fields to Nova.

Within the readme, it says that you can overwrite the vue file.

What am I missing? Does this still work?

Apr
09
1 month ago
Activity icon

Replied to Adding Brands A User Can See? Eg. Tags From Database Saved As Pivot Table

With this package. It saves it as a JSON data into a Text, String or VarChar.

In order to keep the database the same.

This package saves the data like this:

| ID | user_id | brand_id | |----|:-------:|---------:| | 1 | 1 | [1,2] |

However, I need to save the data like so:

| ID | user_id | brand_id | |----|:-------:|---------:| | 1 | 1 | 1 | | 2 | 1 | 2 |

Any suggestions on how to do so?

Apr
07
1 month ago
Activity icon

Started a new Conversation UserToProductDiscount Relationship NOT Working?

User Categories works:

app/user.php

    public function category()
    {
        return $this->belongsToMany(Category::class, 'users_to_categories', 'user_id', 'category_id');
    }
app/category.php

    public function user()
    {
        return $this->belongsToMany(User::class, 'users_to_categories', 'category_id', 'user_id');
    }

Nova\User.php

                'User Categories' => [
                    HasMany::make('Category', 'Category')
                ],

User Product Discounts does NOT work:

App\User.php

    public function productDiscount()
    {
        return $this->belongsToMany(ProductDiscount::class, 'users_to_products_discount', 'user_id', 'product_id');
    }

App\ProductDiscount.php

    public function user()
    {
        return $this->belongsToMany(User::class, 'users_to_products_discount', 'product_id', 'user_id');
    }
user_to_produt_discount migration...

        Schema::create('users_to_products_discount', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->bigInteger('user_id')->unsigned()->index();
            $table->foreign('user_id')->references('id')->on('users');
            $table->bigInteger('product_id')->unsigned()->index();
            $table->foreign('product_id')->references('id')->on('products');
            $table->boolean('status');
            $table->decimal('discount_percentage',8,2);
            $table->timestamps();
        });

Am I using the wrong relationship in Laravel Nova?

Activity icon

Started a new Conversation Composer Installation Failed?

Package jakub-onderka/php-console-color is abandoned, you should avoid using it. Use php-parallel-lint/php-console-color instead.
Package jakub-onderka/php-console-highlighter is abandoned, you should avoid using it. Use php-parallel-lint/php-console-highlighter instead.
Package moontoast/math is abandoned, you should avoid using it. Use brick/math instead.

Installation failed, reverting ./composer.json to its original content.


  [Composer\Repository\InvalidRepositoryException]
  Invalid repository data in /home/vagrant/code/project-name/vendor/composer/installed.json, packages could not be loaded: [Seld\JsonLint\ParsingException] "/home/vagrant/co
  de/pharmazo-laravel/vendor/composer/installed.json" does not contain valid JSON
  Parse error on line 1:

  ^
  Expected one of: 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '['


require [--dev] [--prefer-source] [--prefer-dist] [--fixed] [--no-progress] [--no-suggest] [--no-update] [--no-scripts] [--update-no-dev] [--update-with-dependencies] [--update-wih-all-dependencies] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [--sort-packages] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [-- [<packages>]...
{
    "name": "laravel/laravel",
    "type": "project",
    "description": "The Laravel Framework.",
    "keywords": [
        "framework",
        "laravel"
    ],
    "license": "MIT",
    "require": {
        "php": "^7.2",
        "ext-intl": "*",
        "ext-json": "*",
        "barryvdh/laravel-dompdf": "^0.8.5",
        "braintree/braintree_php": "^4.6",
        "darryldecode/cart": "~4.0",
        "digital-creative/clickable-table-row": "^0.1.4",
        "doctrine/dbal": "^2.10",
        "eminiarts/nova-tabs": "^1.2",
        "fideloper/proxy": "^4.0",
        "guzzlehttp/guzzle": "^6.5",
        "kitetail/zttp": "^0.6.0",
        "laravel/framework": "^6.2",
        "laravel/helpers": "^1.1",
        "laravel/nova": "~2.0",
        "laravel/passport": "^8.4",
        "laravel/tinker": "^2.0",
        "spatie/laravel-permission": "^3.11",
        "typicms/nestablecollection": "^1.1"
    },
    "require-dev": {
        "barryvdh/laravel-debugbar": "^3.2",
        "facade/ignition": "^1.4",
        "fzaninotto/faker": "^1.4",
        "laravel/ui": "^1.1",
        "mockery/mockery": "^1.0",
        "nunomaduro/collision": "^3.0",
        "phpunit/phpunit": "^8.0"
    },
    "repositories": [
        {
            "type": "composer",
            "url": "https://nova.laravel.com"
        }
    ],
    "config": {
        "optimize-autoloader": true,
        "preferred-install": "dist",
        "sort-packages": true
    },
    "extra": {
        "laravel": {
            "dont-discover": []
        }
    },
    "autoload": {
        "files": [
            "app/Helpers/helper.php"
        ],
        "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"
        ]
    }
}

Any ideas on how to resolve these issues, I keep doing this and the error keeps coming back.

 rm -rf vendor/
composer install

I'm running on Windows 10, Homestead...

Apr
06
1 month ago
Activity icon

Started a new Conversation Adding Brands A User Can See? Eg. Tags From Database Saved As Pivot Table

The feature is: A User can see only certain Brands and this is specified by Laravel Nova.

User UserBrand (pivot table) Brand

How would you use Laravel Nova to multi-select and edit a Users relationship to Brands?

Anyone have any suitable suggestions?

This package allows you to add multi-select fields to Laravel Nova: https://github.com/optimistdigital/nova-multiselect-field

However, it saves the data as JSON data. Is there any way to use the database to utilize the Pivot table and save the data accordingly or is that unreasonable?

Mar
11
2 months ago
Activity icon

Replied to How Do I Remove A Laravel Nova Theme?

Ok, Wish I did that earlier... So many issues on the server now.

Activity icon

Started a new Conversation How Do I Remove A Laravel Nova Theme?

Laravel Nova v2

How do I remove a laravel nova theme?

I have CSS that I can't work out how to remove

Mar
04
2 months ago
Activity icon

Replied to Validation Rule For Unique On 2 Fields?

@sinnbeck

2nd example works...

        // Validate against duplicate fulfillment_tracking_number + FulfillmentCompany
        // fulfillment_freight_company is a string so it has to be exactly the same to throw a validation error
        $rules = [
            'fulfillment_tracking_number' => [Rule::unique('order_fulfillments')->where(function ($query) use ($request) {
                return $query->where('fulfillment_tracking_number', $request->input('fulfillment_tracking_number'))->where('fulfillment_freight_company', $request->input('fulfillment_freight_company'));
            }),]
        ];
Activity icon

Replied to Validation Rule For Unique On 2 Fields?

I'm using Laravel 6. I get this error message...

{
    "message": "Call to undefined method Illuminate\Contracts\Validation\Rule::unique()",
    "exception": "Symfony\Component\Debug\Exception\FatalThrowableError",
Activity icon

Replied to Validation Rule For Unique On 2 Fields?

@sinnbeck not quite..

That would mean its checking for fulfillment_freight_company has to be unique.

For an online eCommerce store...

An order can be sent by multiple fulfillment_freight_company (s)...

However, for example: fulfillment_freight_company (1) tracking_number: 123456

fulfillment_freight_company (2) tracking_number: 123456

that is fine...

However,

fulfillment_freight_company (1) tracking_number: 123456

fulfillment_freight_company (1) tracking_number: 123456

That is not fine.

Mar
03
3 months ago
Activity icon

Started a new Conversation Validation Rule For Unique On 2 Fields?

See this code example which checks to see if fulfillment_tracking_number on the order_fulfillments table is unique.

        // Validate against duplicate fulfillment_tracking_number
        $rules = [
            'fulfillment_tracking_number' => 'required|unique:order_fulfillments,fulfillment_tracking_number',
        ];

        $validator = Validator::make($request->all(), $rules);

        if($validator->fails()) {
            return response()->json($validator->errors(), 403);
        }

I want to also check if the fulfillment_freight_company is the same in the same validation rule, how do I do that with Laravel Validation rules?

Feb
26
3 months ago
Activity icon

Commented on Guzzle API Requests With Tests

perhaps you should do one on ZTTP :)

Activity icon

Commented on Guzzle API Requests With Tests

@bobbybouwmann Can we have a github repo, I'd like to re-use this code for my guzzle requests :)

Feb
25
3 months ago
Activity icon

Replied to How To Get Billing Address From Eloquent Model With Where Clause?

Thank you, this works...

OrderController (index)

    public function index()
    {
//        $orders = Order::all();
//        return new OrderResource($orders);

        $orders = Order::with('order_fulfillment', 'cart.product', 'user.billingAddress', 'user.shippingAddress', 'payment')->get();
        return new OrderResource($orders);
    }

User Model:

    public function address()
    {
        return $this->hasMany(Address::class, 'refer_id', 'id');
    }

    public function billingAddress()
    {
        return $this->hasOne(Address::class, 'refer_id', 'id')
            ->where('type', '=', 1);
    }

    public function shippingAddress()
    {
        return $this->hasOne(Address::class, 'refer_id', 'id')
            ->where('type', '=', 2);
    }
Activity icon

Replied to How To Get Billing Address From Eloquent Model With Where Clause?

I'll have to give those suggestions a go.

Activity icon

Replied to How To Get Billing Address From Eloquent Model With Where Clause?

@sinnbeck Yes... But I need a way to differentiate between the 2 types of addresses.

Alternatively, Maybe I need a global scope on Address (model) to get BillingAddress and ShippingAddress

Feb
24
3 months ago
Activity icon

Started a new Conversation How To Get Billing Address From Eloquent Model With Where Clause?

For example I can use:

$address = $user->address

which will return the addresses for the user.

// User.php (model)

public function address()
{
    return $this->hasMany(Address::class, 'refer_id', 'id');
}
public function billingAddress()
{
    return $this->address()
        ->where('type', '=', 1)
        ->where('refer_id', '=', $this->id)
        ->first();
}

However, I would like to return the BillingAddress for the user depending on this where clause. How do I do it?

EDIT: If I use this inside... [email protected] it returns correctly

        $orders = Order::with('order_fulfillment', 'cart.product', 'user.address', 'payment')->get();
        return new OrderResource($orders);

However, If I change it to:

        $orders = Order::with('order_fulfillment', 'cart.product', 'user.billingAddress', 'payment')->get();
        return new OrderResource($orders);

I get this error: Symfony\Component\Debug\Exception\FatalThrowableError Call to a member function addEagerConstraints() on null

ps. if type = 1.. BillingAddress. If type = 2 shipping address.

Feb
22
3 months ago
Activity icon

Started a new Conversation Can You Use Laravel Cashier For One-off Payments, For Example, Extend It To Use For A Shopping Cart?

Can you use Laravel Cashier for one-off payments, for example, extend it to use for a Shopping Cart? Or is Cashier already capable of doing this without subscriptions?

Feb
14
3 months ago
Activity icon

Replied to Laracasts Quizzes

@jeffreyway Can you show us how you created that quiz?

Activity icon

Replied to Laracasts GraphQL Series

I'm keen for this too!

Feb
13
3 months ago
Activity icon

Commented on Guzzle API Requests With Tests

Can't you just use ISO8601?

// create ISO8601 dateTime 
createFromFormat(DateTime::ISO8601, '2016-07-27T19:30:00Z');
Feb
08
3 months ago
Jan
23
4 months ago
Activity icon

Commented on API Resources

It would be great if there was a course surrounding this topic in a real world scenario..

Jan
21
4 months ago
Activity icon

Commented on Server-Fetched Partials

Very useful stuff thank you

Jan
05
4 months ago
Activity icon

Commented on How Do I Sort Tags By Letter

13:05 I hear "fuck" lol :)

But I think it's meant to be "Pluck"

Dec
23
5 months ago
Activity icon

Started a new Conversation Laracasts: Stay Full-screen Video So You Continue To Binge Like The Slogan?

Laracasts: Stay full-screen video so you continue to binge like the slogan?

Dec
17
5 months ago
Activity icon

Started a new Conversation How Do I Drop Foreign Key Constraints With Migrations?

How do I drop Foreign Key constraints with Migrations?

Laravel Docs says (https://laravel.com/docs/6.x/migrations#foreign-key-constraints): To drop a foreign key, you may use the dropForeign method. Foreign key constraints use the same naming convention as indexes. So, we will concatenate the table name and the columns in the constraint then suffix the name with "_foreign":

$table->dropForeign('posts_user_id_foreign');

Or, you may pass an array value which will automatically use the conventional constraint name when dropping:

$table->dropForeign(['user_id']);

However, It doesn't drop the foreign key constraint. I need to do it in combination to remove the FK constraint and then the column, like so:

Schema::table('posts', function (Blueprint $table) {
      $table->dropForeign('posts_user_id_foreign');
      $table->dropColumn('user_id');
});

Once I removed the foreign key and column, I was able to re-add the same column without the Foreign Key constraint and in the same correct order using the ->after('column') modifier, like so:

Edit:

    public function up()
    {
        Schema::table('posts', function (Blueprint $table) {
            $table->bigInteger('user_id')->after('id')->nullable();
        });
    }
Dec
16
5 months ago
Activity icon

Started a new Conversation How To Update Multiple Rows In Laravel Nova?

Considering this code below which is an action applied to a Resource in Laravel Nova:

I can only update 1 row, however not multiple rows?

How do I fix the code to allow the ability to update multiple rows?

public function handle(ActionFields $fields, Collection $models)
    {
        foreach ($models as $model) {
            try {
                $inventory = $model->inventory_item_id;
                $quantity = $fields->quantity;

                // Logging used for debugging
                Log::info('UpdateAvailablity action called: $inventory: ' . $inventory . ', $quantity: ' . $quantity);

                $inventoryLevelAvailabilityController = new InventoryLevelAvailabilityController();
                $inventoryLevelAvailabilityController
->updateProductInventoryStockAvailable($inventory, $quantity);
            } catch (\Exception $e) {
                $this->markAsFailed($model, $e);
            }
        }
    }
Dec
11
5 months ago
Activity icon

Replied to Multi-tenant Login, 2 Logins, With Multiple Guards?

Thanks Bobby, I guess I gotta learn about that.

Any good tutorials you'd recommend?

Activity icon

Started a new Conversation Multi-tenant Login, 2 Logins, With Multiple Guards?

I need to build a website that has multi-tenants and 2 logins in Laravel.

First I'd login to the school website for the grade and that will redirect to:

grade1.example.com

Once, we are logged-in to the grade level there is another login to login as a parent, I can then view the student profile linked to my account.

grade1.example.com/student/1

Does anyone have any suggestions on how to do this?

Dec
10
5 months ago
Activity icon

Started a new Conversation Multitenancy With Laravel

Multitenancy with Laravel would be a useful series? :)

Dec
04
5 months ago
Activity icon

Commented on Inheritance

This video is fresh just come out today yewww! Loving the update on this series.

Dec
03
6 months ago
Activity icon

Commented on Intro To Application Testing

Which TDD video?

Dec
02
6 months ago
Activity icon

Commented on Manage Your Local Dev Environment With Docker

Love these guest spotlight videos. It would be cool if people could apply to do series on here too.