Skip to content

Instantly share code, notes, and snippets.

@EricMcWinNer
Created January 11, 2021 00:28
Show Gist options
  • Save EricMcWinNer/d2102ef974ebc49488269970a1c426e9 to your computer and use it in GitHub Desktop.
Save EricMcWinNer/d2102ef974ebc49488269970a1c426e9 to your computer and use it in GitHub Desktop.
<?php
namespace App\Http\Controllers;
use App\Models\Broker;
class RandomController extends Controller {
public function getWallet(){
$broker = Broker::find(1); // Get a Broker Instance
$wallet = $broker->wallet; // Get the Wallet that this Broker has
// Do whatever with it
return response(['wallet' => $wallet], 200);
}
public function getWalletOwner() {
$wallet = Wallet::find(1); // Get a Wallet instance
$owner = $wallet->walletable; // Get whatever owns this wallet, whether it's a Broker or Company;
// Do whatever with it
return response(['owner' => $owner], 200);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment