scottsuhy

scottsuhy

Member Since 5 Months Ago

Experience Points
1,240
Total
Experience

3,760 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.

Level 1
1,240 XP
Sep
17
6 days ago
Activity icon

Replied to How To Do A Query Prior To User Logging Out (but Triggered By Logout)

worked great. a couple of changes because it's Laravel 6.18

  1. destroy() to logout()
  2. $this->guard to $this->guard()
  3. return to return redirect(URL)

you guys rock!

public function logout(Request $request)
    {
	$store_owner = auth()->user();

        $this->guard()->logout();

        $request->session()->invalidate();

        $request->session()->regenerateToken();


        if(is_null($store_owner->referrer)){
            return RouteServiceProvider::HOME;
        }
        else {
            return redirect( 'https://icollect.money/stores_user/'.$store_owner->referrer);
        }
    }
Activity icon

Replied to How To Do A Query Prior To User Logging Out (but Triggered By Logout)

Thank you very much. and great advice on the URL. I'll fix that now as well.

Activity icon

Replied to How To Do A Query Prior To User Logging Out (but Triggered By Logout)

Laravel Framework 6.18.0

I need to upgrade but it's still on the backlog

Activity icon

Started a new Conversation How To Do A Query Prior To User Logging Out (but Triggered By Logout)

I need to do a DB query prior to the user logging out in order to determine what page to send them to upon logout.

I thought putting the following in the LoginController would work but by the time this function overrides [email protected]() the user session is already terminated so auth()->user() is not available.

Is there a risk in putting code in the [email protected]() function? Is it possible to override logout()--if so how?

Is there a better way to do this?

protected function loggedOut (Request $request) {

        $store_owner = DB::table('users')->select('referrer')
            ->where('email', auth()->user()->email)
            ->first();

        if(is_null($store_owner->referrer)){
            return RouteServiceProvider::HOME;
        }
        else{
            return 'https://icollect.money/stores_user/'.$store_owner->referrer;
        }
}
Sep
10
1 week ago
Activity icon

Replied to Laravel And Latest Version Of Stripe Checkout

jlrdw -- I wrote it by using the GitHub code provided by Stripe... was fun anyway. a good dev could probably have done this in a couple hours where it took me a couple days :-) and it's probably not very high quality... but it works.

I documented it so other new devs won't have to go thru the painful learning :-)

https://scottsuhy.com/2020/09/10/set-up-future-payments-on-stripe-using-laravel/

Sep
08
2 weeks ago
Activity icon

Replied to Laravel And Latest Version Of Stripe Checkout

that example is using legacy stripe from what I see. In legacy your app collects card information from the customer and sends the token to the server to charge it. in the new version of Checkout you create a Checkout Session on your server then pass the session ID to the client and redirect the customer to Checkout to complete the payment (the page is hosted by Stripe). Opens up a lot of new features for them and is more secure.

since so many people use Stripe with Laravel, and the new Stripe design has been out for a while it doesn't make sense that more people haven't discussed how to integrate so I must be missing something here.

Sep
07
2 weeks ago
Activity icon

Replied to Laravel And Latest Version Of Stripe Checkout

I'm not using Cashier right now. Should I be?

i was under the impression that Cashier was only for the "subscription" usecase -- from Doc: 'Laravel Cashier provides an expressive, fluent interface to Stripe's subscription billing services. It handles almost all of the boilerplate subscription billing code you are dreading writing. '

I'm building an auction app functionality that has to charge all the customers after the auction is complete. some will be return customers. I'm not building a saas subscription app.

I was worried about this reference in the doc: 'Of course, when making a single charge against a customer's payment method we'll only need to use a payment method identifier a single time. Due to Stripe limitations, you may not use the stored default payment method of a customer for single charges. You must allow the customer to enter their payment method details using the Stripe.js library.'

are you saying that I can use Cashier for a use-case that stores cards and charges them once service is complete (but not ongoing)? If so, great.

Activity icon

Started a new Conversation Laravel And Latest Version Of Stripe Checkout

I see numerous examples/blogs that show how to use Laravel with the legacy version of Stripe Checkout but I can't find one that uses the new version. https://stripe.com/docs/payments/checkout/migration

I currently use Stripe to take one time payments but want to now save the users card for future payments but it looks like things have changed a bit on the Stripe side. Example here: https://github.com/stripe-samples/saving-card-without-payment/blob/master/server/php/index.php

Can anyone point me to an example with Laravel? or is the Github example the best out there?

Aug
06
1 month ago
Activity icon

Replied to Eloquent Relationships That Deal With 3 Tables

actually, i guess its this because I have the ID of the user.

 $myauctionregistrationscount = Auctionregistration::select('id')
            ->leftJoin('auctionschedule', function($join){
                $join->on('auctionschedule.id', '=', 'auctionregistrations.auction_id');
            })
            ->where('auctionschedule.scheduled_for', '>=', Now())
            ->where('auctionregistrations.auction_user_id', '=', auth()->user()->id)
            ->count();
Activity icon

Replied to Eloquent Relationships That Deal With 3 Tables

Got it. So essentially this:

SELECT auctionschedule.scheduled_for, auctionschedule.auctionname, auctionregistrations.auction_id, auctionregistrations.auction_user_id
            FROM auctionregistrations
            left JOIN auctionschedule ON auctionschedule.id = auctionregistrations.auction_id
            left JOIN users ON users.id = auctionregistrations.auction_user_id
            where auctionschedule.scheduled_for > now()
            order by auctionschedule.scheduled_for
        $myauctionregistrationscount = Auctionregistration::select('id')
            ->leftJoin('auctionschedule', function($join){
                $join->on('auctionschedule.id', '=', 'auctionregistrations.auction_id');
            })
            ->leftJoin('users', function($join){
                $join->on('users.id', '=', 'auctionregistrations.auction_user_id');
            })
            ->where('auctionschedule.scheduled_for', '>=', Now())
            ->where('auctionregistrations.auction_user_id', '=', auth()->user()->id)
            ->count();
Activity icon

Started a new Conversation Eloquent Relationships That Deal With 3 Tables

I have made all the one to many relationships in 3 models ‘user’, ‘auctionschedule’ and ‘auctionregistrations’ for “hasMany” and “belongsTo”. Here is what they look like https://imgur.com/u7aexVt

This allows for some very powerful (easy to create) queries. For example, this query is great:

It gives me a count of all the auctions the user has scheduled that are after Now()

$count = auth()->user()->auctionschedule()->where('date', '>=', Now())->count();

But how do I get a count of all the auctions the user is registered for that are scheduled for after Now(). Note that the auction date is in the auctionschedule table. So with this query, all 3 tables are involved. I’ve tried everything I can think of such as this but nothing seems to work-example:

$count = auth()->user()->auctionregistrations()->where('auctionschedule.date', '>', Now())->count();
Aug
03
1 month ago
Activity icon

Replied to Need Recommendation On Best Approach To Implement A Daemon Process In Laravel

There is https://github.com/billythekid/auctioneer that uses sockets. very good example and i used it as guidance but its not realtime. more like ebay. i'm going to dig into ReactPHP and see how far I get. Thanks for the ideas.

Activity icon

Replied to Need Recommendation On Best Approach To Implement A Daemon Process In Laravel

but i'm reading about ReactPHP from that site. This sounds like it has potential.

Activity icon

Replied to Need Recommendation On Best Approach To Implement A Daemon Process In Laravel

yep. use forge to manage my aws. love it.

I stumbled upon this site yesterday in some google searching but it's implementation guidance is non existent from what i can tell.

have you ever used it? Pusher--at least gave some great examples :-)

Activity icon

Started a new Conversation Need Recommendation On Best Approach To Implement A Daemon Process In Laravel

I've built an auction site that works like eBay on Laravel. It was a straight forward exercise.

However, now I want to try to make it real time for customers to hold real time auctions (like liveauctioneer or proxibid).

I realize that Php is stateless so this might be a challenge.

The Question: Does anyone have a recommendations on how best to accomplish this task within a Laravel framework given I'll be using all the assets (DB/logic etc) from the current system?

I will need a semi-real time daemon process that acts like an auctioneer.

Here are some examples of what the daemon process would do (one for each auction running):

If the starting price for an item doesn’t get interest after x seconds the auctioneer daemon process would lower the starting price. If the Time between bids) >= Max Time between bids the daemon would lower the bid increment and send event to all bidders "Fair Warning" If this happens a second time the daemon would send an event to all bidders “Going Once, Going Twice…” If this happens a third time the daemon would send an event to all bidders that a certain bid has won the auction The the daemon would then send an event to announce the next item up in the auction etc...

So the daemon process needs to track the time of bids and be able to deal with logic to update tables in the DB and send events

I've read about Queuing and task scheduling but I don't think this would work for this use case. Maybe an event listener?

any ideas appreciated.

Aug
02
1 month ago
Activity icon

Replied to Not Able To Receive Pusher Event.

yes, been thru them. i found the issue, just not sure yet how to solve it. on one of those tutorials it shows that private channels need to have "private-" in front of them. I did that and now i'm getting auth errors.

Pusher : : ["Error: Unable to retrieve auth string from auth endpoint - received status: 404 from /pusher_auth.php. Clients must be authenticated to join private or presence channels. See: https://pusher.com/docs/authenticating_users"]

working on a few tests now on how to do this correctly in javascript.

Activity icon

Started a new Conversation Not Able To Receive Pusher Event.

using: php artisan --version Laravel Framework 6.18.0

I'm trying to get Pusher setup. Just testing it now and I'm not able to receive the event for some reason. I think Its something simple but nothing I've tried gets me the event. I've also tried Echo with similar result.

Any pointers would be very helpful. Thank you.

This is the JS that never gets triggered:

   channel.bind('App\Events\BidSent', function(data) { ///<--this never triggers!
       console.log("Data:".data);
   });

Here is the console log note the 1 violation...

Pusher :  : ["State changed","initialized -> connecting"]
pusher.min.js:8 Pusher :  : ["Connecting",{"transport":"ws","url":"wss://ws-us2.pusher.com:443/app/64936XXXXXXXXXX?protocol=7&client=js&version=7.0.0&flash=false"}]
pusher.min.js:8 Pusher :  : ["State changed","connecting -> connected with new socket ID 7769.6572718"]
pusher.min.js:8 Pusher :  : ["Event sent",{"event":"pusher:subscribe","data":{"auth":"","channel":"bid"}}]
pusher.min.js:8 Pusher :  : ["Event recd",{"event":"pusher_internal:subscription_succeeded","channel":"bid","data":{}}]
pusher.min.js:8 [Violation] 'message' handler took 1921ms
laravel.app.js:64177 XHR finished loading: POST "http://localhost:8082/broadcasting/auth".
laravel.app.js:39404 XHR finished loading: GET "http://localhost:8082/notify".
laravel.app.js:39404 XHR finished loading: POST "http://localhost:8082/bids".

bid.blade.php

 <script src="https://js.pusher.com/7.0/pusher.min.js"></script>

    <script type="text/javascript">

        // Enable pusher logging - don't include this in production
        Pusher.logToConsole = true;

        var pusher = new Pusher('64936XXXXXXXXXXXXX', {
               cluster: 'us2',
               encrypted: true
        });

        var channel = pusher.subscribe('bid');

        channel.bind('pusher:subscription_succeeded', function(members) {
            alert('successfully subscribed!');
        });

        channel.bind('pusher:subscription_error', function(data) {
            console.log(data);
        });

       channel.bind('App\Events\BidSent', function(data) { ///<--this never triggers!
           console.log("Data:".data);
       });

        $.ajaxSetup({
            headers: {
                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
            }
        });

        $(document).on('click', '.bidbutton', function(event){
            event.preventDefault();

            var auction_id = $("#auction_id").val();
            var auction_bidder_id = $("#auction_bidder_id").val();
            var auction_item_id = $("#auction_item_id").val();
            var bid = $("#bid").val();

            $.ajax({
                url:"/bids",
                type: "POST",
                data:{auction_id:auction_id, auction_bidder_id:auction_bidder_id, auction_item_id:auction_item_id, bid:bid},
            });
        });

    </script>

Creating the event

namespace App\Events;
use App\User;
use App\Auctionbid;

use Illuminate\Broadcasting\Channel;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Broadcasting\PresenceChannel;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;

class BidSent implements ShouldBroadcast
{
    use Dispatchable, InteractsWithSockets, SerializesModels;
    public $user;
    public $bid;

    /**
     * Create a new event instance.
     *
     * @return void
     */
    public function __construct(User $user, Auctionbid $bid)
    {
        $this->user = $user;
        $this->bid = $bid;
    }

    /**
     * Get the channels the event should broadcast on.
     *
     * @return \Illuminate\Broadcasting\Channel|array
     */
    public function broadcastOn()
    {
        return new PrivateChannel('bid');
    }
}

Controller:

namespace App\Http\Controllers;

use App\Events\BidSent;
use App\Auctionbid;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;

class AuctionBidsController extends Controller
{

    public function __construct()
    {
        $this->middleware('auth');
     }

    public function index()
    {
        return view('auction.bid');
    }

    public function getBid()
    {
        return Auctionbid::with('user')->get();
    }

    public function sendBid(Request $request)
    {

          $user = Auth::user();

          $bid = Auctionbid::create([
            'auction_id' => $request->auction_id,
            'auction_bidder_id' => $request->auction_bidder_id,
            'auction_item_id' => $request->auction_item_id,
            'bid' => $request->bid,
            'bid_timestamp' => Now()
           ]);

          broadcast(new BidSent($user, $bid))->toOthers();

          return ['status' => 'Bid Sent!'];

    }

}

channels.php

Broadcast::channel('bid', function ($user) {
    return Auth::check();
});

broadcasting.php

        'pusher' => [
            'driver' => 'pusher',
            'key' => env('PUSHER_APP_KEY'),
            'secret' => env('PUSHER_APP_SECRET'),
            'app_id' => env('PUSHER_APP_ID'),
            'options' => [
                'cluster' => env('PUSHER_APP_CLUSTER'),
                'useTLS' => true,
            ],
        ],

web.php

    Route::get('bids', '[email protected]')->middleware('auth');
    Route::post('bids', '[email protected]')->middleware('auth');

Pusher debug console shows event sent:

https://imgur.com/WBSBcTd

Jul
30
1 month ago
Activity icon

Replied to How To Keep User On Same Paginated Page After Deleting An Item?

You rock. (again :-) )

    $(document).on('click','.removeFromAuction', function(event) {
        var itemid = $(this).attr('itemid');
        var show = $("#show option:selected").val();
        var page = $(this).attr('currentpage');  //<<<<<<<-added this, also updated the HTML and controller to return current page.

        $.ajax({
            url:"/removeitemfromauction?page="+page,  //<<<<<<<-changed this
            data:{show:show, itemid:itemid},
            success:function(data_return)
            {
                $('#auction_items_pagination').html(data_return);
            }
        });
    });
Activity icon

Started a new Conversation How To Keep User On Same Paginated Page After Deleting An Item?

Using pagination. When a user deletes an item on page >=2 they are taken back to page 1 versus left on the page they were on.

I need to keep the user on the page that they were on.

How do I do this?

Here is the code for the JS and controller function:

Javascript

    $(document).on('click','.removeFromAuction', function(event) {
        var itemid = $(this).attr('itemid');
        var show = $("#show option:selected").val();
        $.ajax({
            url:"/removeitemfromauction",
            data:{show:show, itemid:itemid},
            success:function(data_return)
            {
                $('#auction_items_pagination').html(data_return);
            }
        });
    });

Controller function

    function removeitemfromauction(Request $request)
    {
        $result = DB::table('auctionitems')
            ->where('coin_id', '=', $request->itemid)
            ->delete();

        if($result){
            $errormsg = 0;
        }
        else{
            $errormsg = 1;
        }

        $items = DB::table('coins')
            ->select(DB::raw('coins.id, auctionitems.auction_id, auctionitems.item_reserve, coins.series, coins.year, coins.mint, coins.rating, coins.rating_group, coins.notable_value_description, coins.purchase_price_total, coins.retail_value'))
            ->leftJoin('auctionitems', function($join){
                $join->on('auctionitems.coin_id', '=', 'coins.id');
            })
            ->where('user_email', '=', auth()->user()->email)
            ->orderBy('coins.id', 'asc')
            ->paginate($request->show);

        return view('auction.auction_items_pagination_data', compact('errormsg','items'))->render();
    }
Jul
23
2 months ago
Activity icon

Replied to How To Use (COUNT) In A Database Query

you rock.

        $number_of_auctions_of_each_category = Auctionschedule::select('category')
            ->selectRaw('count(category)')
            ->where('scheduled_for', '>=', $date)
            ->groupBy('category')
            ->get();

i didn't want to do it like this but i guess it would work too:

$number_of_auctions_of_each_category = DB::table('auctionschedule')->select(DB::raw('category, COUNT(category)'))
            ->where('scheduled_for', '>=', $date)
            ->groupBy('category')
            ->get();
Activity icon

Started a new Conversation How To Use (COUNT) In A Database Query

I am trying to replicate this postgres query:

select category, COUNT(category) from auctionschedule  where scheduled_for >= now() group by (category);

I was attempting this, but I get an error "Call to a member function groupBy() on int"

        $date = new \DateTime();
        $date->getTimestamp();

        $number_of_auctions_of_each_category = Auctionschedule::select('category')
            ->where('scheduled_for', '>=', $date)
            ->count('category')
            ->groupBy('category')
            ->get();

If I comment out "->count('category')" then the query completes but there is no summary of the category.

What am I missing?

May
27
3 months ago
Activity icon

Replied to How To Copy File From URL To S3 Bucket Using Storage::get() And StoreAs()

I found a way around the issues but it does not seem like its the most efficient / effective solution. Please let me know if you know a better way to approach this:

use Image;
use Storage;

$file = Image::make(URL);
$file->encode('jpg');
$s3 = Storage::disk('s3');
$s3->put($destinationPath.$fileName, $file);
Activity icon

Started a new Conversation How To Copy File From URL To S3 Bucket Using Storage::get() And StoreAs()

2 related questions. I simplified the code to focus the question on the issue.

question 1: I am attempting to copy an images from a URL to S3. When I call the following function on this URL:

$file = Storage::get("https://thumbs1.ebaystatic.com/m/meDwXina-edrySG-30Phiyw/140.jpg");

I get the following error: Illuminate\Contracts\Filesystem\FileNotFoundException but the file exists.

question 2: I then want to store the image in an existing S3 bucket that i am already using:

$file->storeAs($destinationPath, $fileName, 's3');

Is this the correct syntax? I believe this is what it shows in https://laravel.com/docs/7.x/filesystem

Activity icon

Replied to I Am Having Issues With Eloquent Naming Convention

Well, that did it. I change over to this and it worked:

                            $status = Watchesmldata::create(array(
                                    'watchesmlid' => $id,
                                    'series' => $series,
                                    'rating' => $rating,

thank you both.

Activity icon

Replied to I Am Having Issues With Eloquent Naming Convention

Sorry, I should have mentioned that I have the DB working fine and used the migration:

class CreateWatchesmldataTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('watchesmldata', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->bigInteger('watchesmlid')->nullable();
            $table->text('series')->nullable();

I think i'm getting twisted up by the singular / plural thing that Laravel does...

Activity icon

Started a new Conversation I Am Having Issues With Eloquent Naming Convention

I think i screwed up the naming convention for the Eloquent model

here is how I created the table:

php artisan make:migration create_watchesmldata_table --create=watchesmldata
php artisan migrate

I then created a file in the Http directory and put a file in it called Watchesmldata.php with the following in it:

namespace App;
use Illuminate\Database\Eloquent\Model;
class Watchesmldata extends Model
{
    protected $fillable = [
                    'watchesmlid',
                    'series',
                    'rating'
    ];
}

but when I write to the file

                            DB::table('watchesmldata')
                                ->update(['watchesmlid' => $id,
                                    'series' => $series,
                                    'rating' => $rating,
                                    'updated_at' => NOW()]);

The data is in the debugger so I know it's trying to write it. However, nothing is getting written. It's like the Watchesmldata.php isn't recognized.

Where did I go wrong?

Apr
29
4 months ago
Activity icon

Replied to Moving \public From EC2 (EBS) To S3

Thanks. After spending the day looking at it and a few test i started to realize this was a bad idea (hard learning...). I did end up moving the significant picture files that take up the most storage to S3 by:

Installing: Amazon S3: league/flysystem-aws-s3-v3 ~1.0 CachedAdapter: league/flysystem-cached-adapter ~1.0

and updating a few calls (request('image')->store('profile', 's3');) with s3.

that worked out so i think i'm set.

thanks for confirming.

Activity icon

Replied to I Want To Upload Multiple Images With Yajra Data Tables

this is not an answer but there is a bit on it here https://github.com/yajra/laravel-datatables-editor/issues/17

I found that dropzone was a better alternative for my use case.

Here is the call:

File::make('property_documents[]')->multiple()->label('Property Documents'),

Apr
28
4 months ago
Activity icon

Started a new Conversation Moving \public From EC2 (EBS) To S3

I launched my site on EC2 via Forge and my \public folder is on the EC2 instance (EBS). I want to change \public to my S3. Is there a recommended procedure for this transition (i.e. best approach to copy files, etc..) so there is little user disruption?

Apr
25
4 months ago
Activity icon

Replied to DNS Forwarding/Masking Not Working

Found the issue. It was the nginx config at Forge. Found it in this article https://voutzinos.com/blog/cross-origin-iframe-laravel/

Activity icon

Started a new Conversation DNS Forwarding/Masking Not Working

i've hosted on AWS and using Forge. Laravel 6.18

I'm using a domain at godaddy to forward w/masking to a small portion of the project.

I'm getting a "refused to display" (URL) "in a frame because it set 'X-Frame-Options' to 'sameorigin'."

The only reference i see in the code to SAMEORIGIN is in

vendor\laravel\framework\src\Illuminate\Http\Middleware\FrameGuard.php: $response->headers->set('X-Frame-Options', 'SAMEORIGIN', false);

but i see a reference here that its been removed https://stackoverflow.com/questions/24082504/laravel-4-refuses-to-load-iframe-due-to-x-frame-options-to-sameorigin/24089364#24089364

any thoughts on how to get around this?

Apr
23
5 months ago
Activity icon

Replied to Migration Files Not Moving To GitHub, Forge Deployment Then Fails.

I think i get it now. its because you can change the migration 10 times before you want it to go into production. check...

Apr
22
5 months ago
Activity icon

Replied to Migration Files Not Moving To GitHub, Forge Deployment Then Fails.

I forced the commit of the 1 file and it pushed to GitHub. still not sure why it didn't go by default with the rest of the project.

Activity icon

Started a new Conversation Migration Files Not Moving To GitHub, Forge Deployment Then Fails.

another noob question...

I'm using Laravel Framework 6.18.0 on Windows 10, PhpStorm, GitHub, Forge and AWS

I needed to change my model and add a column to a table. Worked find on my local machine.

When I did the commit/Push (in PhpStorm) to Github the php/html code moved but the migration file didn't and then I had a an issue with the hosted site (test for now so not a big issue as I'm learning the nuances of the platform). the upside is that its made me put in a lot more error checking :-)

What is the secret to getting the migration files to move to GitHub and why didn't they move with the commit/Push? is this a feature? or did I misconfigure something?

Apr
20
5 months ago
Activity icon

Replied to ->storedAs Migration Question

I'm already down a path of doing it the way you suggest. However, I was reading a bit more about migration modifiers here https://laravel.com/docs/7.x/migrations and i see an example of how some of them are being used. the ->storedAs is confusing if it can't be used in the context of a migration. When would you use it? sorry for newbe question.

Activity icon

Started a new Conversation ->storedAs Migration Question

sorry, beginner here and still learning the platform... Just need a bit of a general push in the right direction on 2 questions related to ->storedAs

2 weeks ago I created a table called 'coins': php artisan make:migration coins and in up() I have: $table->float('purchase_price_total', 10,2)->nullable();

1 week ago I added two other fields 'tax' and 'purchase_price': php artisan make:migration add_tax_and_purchase_price_to_coins_table

now I want to make 'purchase_price_total' = 'purchase_price' + 'tax'

Do I create another migration or edit the original 'coins' migration? (php artisan make:migration ????)

What do I put in it? ($table->float('purchase_price_total', 10,2)->storedAs('purchase_price' + 'tax');)

Mar
29
5 months ago
Activity icon

Replied to Beginner: Having Trouble Understanding How To Extract The Data Out Of A Result From A Query.

You guys are great!

I changed the controller query to use "->first()" and change the variable

        $purchase_price_total_LY = DB::table('coins')
			->select(DB::raw('SUM (purchase_price) as purchase_price_total_LY'))
			->where('user_email', '=', auth()->user()->email)
			->whereBetween(DB::raw('DATE(purchase_date)'), [$range_lastyr_start, $range_lastyr_end])
			->first();
	```

then changed the return to this:
```		
return view ('pages.financials', compact('user', 'purchase_price_total_LY')

Then in the view I changed to this:

<tr><td>Purchase Price:</td><td><a>{{$purchase_price_total_LY->purchase_price_total_ly }}</a></td>

and now i have an answer of 37.

thank you. after 2 hours of trying several attempts (and learning a lot) you provided great advice.

Activity icon

Started a new Conversation Beginner: Having Trouble Understanding How To Extract The Data Out Of A Result From A Query.

I am new to Laravel/Eloquent and I'm having trouble understanding how to extract the data out of a result from a query.

I'm calling the following query in the controller

$purchase['purchase_price_total_LY'] = DB::table('coins')
		->select(DB::raw('SUM (purchase_price) as purchase_price_total_LY'))
		->where('user_email', '=', auth()->user()->email)
		->whereBetween(DB::raw('DATE(purchase_date)'), [$range_lastyr_start, $range_lastyr_end])
		->get();

and passing the result back to the view in the return as follows:

		return view ('pages.financials', compact('user', 'purchase'));

In the view:

<td>Purchase Price:</td><td><a> {{$purchase['purchase_price_total_LY']}}</a></td>

The result in the view is this:

[{"purchase_price_total_ly":"37"}]		

When I do a dd($purchase, $purchase['purchase_price_total_LY']); I see the following:

array:1 [▼
  "purchase_price_total_LY" => Illuminate\Support\Collection {#548 ▼
    #items: array:1 [▼
      0 => {#547 ▼
        +"purchase_price_total_ly": "37"
      }
    ]
  }
]
Illuminate\Support\Collection {#548 ▼
  #items: array:1 [▼
    0 => {#547 ▼
      +"purchase_price_total_ly": "37"
    }
  ]
}

What's the most appropriate way to extract the 37 out of the array in the view?