This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Parse.Cloud.run("totalRevenue").then(function(response) { | |
console.log(JSON.stringify(response)); | |
}).catch(function(error) { | |
console.error("Error fetching total revenue: " + error.message); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Parse.Cloud.define('totalRevenue', async (request) => { | |
const Purchase = Parse.Object.extend('Purchase'); | |
const query = new Parse.Query(Purchase); | |
query.include('product'); | |
const purchases = await query.find({ useMasterKey: true }); | |
let totalRevenue = 0; | |
for (let purchase of purchases) { | |
const product = purchase.get('product'); | |
if (product && product.get('price')) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Purchase = Parse.Object.extend("Purchase"); | |
const query = new Parse.Query(Purchase); | |
query.find().then(function(purchases) { | |
console.log("Successfully retrieved purchases:"); | |
console.log(purchases); | |
}).catch(function(error) { | |
console.error("Error while fetching purchases:"); | |
console.log(error); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Illuminate\Support\Facades\Gate; | |
Gate::guessPolicyNamesUsing(function (string $modelClass) { | |
// Provide the name of the model’s policy class… | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Providers; | |
use App\Models\Post; | |
use App\Policies\PostPolicy; | |
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use App\Policies\PostPolicy; | |
use Illuminate\Support\Facades\Gate; | |
/** | |
* Register all authorization and authentication services. | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use App\Models\Post; | |
use App\Models\User; | |
use Illuminate\Support\Facades\Gate; | |
/** | |
* Register all authorization and authentication services. |
NewerOlder