1. Go to this page and download the library: Download abronin/laravel-parse library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
namespace App;
use Parziphal\Parse\ObjectModel;
class Post extends ObjectModel
{
}
// Instantiate with data
$post = new Post(['title' => 'Some Title']);
// Create
$post = Post::create(['title' => 'Some Title', 'acl' => $acl]);
// Get objectId
echo $post->id; // EWFppWR4qf
echo $post->id(); // EWFppWR4qf
// Update
$post->title = 'New Title';
$post->save();
// or
$post->update(['foo' => true]);
// Find or fail
$post = Post::findOrFail($id);
// Delete is like Eloquent's delete: it will delete the object
$post->delete();
// To remove a key (ParseObject's `delete` method), use `removeKey`
$post->removeKey($someKey);
// Create a pointer object
$pointer = Post::pointer($postId);
use Parziphal\Parse\ObjectModel;
class Post extends ObjectModel
{
public function categories()
{
return $this->belongsToMany(Category::class);
}
public function user()
{
return $this->belongsTo(User::class);
}
}
// Having the above class where categories() is a `belongsToMany` relation,
// the class Category would have a posts() relation of type `hasManyArray`:
class Category extends ObjectModel
{
public function posts()
{
return $this->hasManyArray(Post::class);
}
}
// This would be the User class:
class User extends ObjectModel
{
public function posts()
{
return $this->hasMany(Post::class);
}
}
// Relate a post with a category (belongsToMany):
$post->categories()->save($someCategory);
// Relate a category with posts (inverse of above, hasManyArray):
$category->posts()->save($post);
$category->posts()->create($arrayWithPostData);
// Relate a post with a user (belongsTo):
$post->user = $user;
$post->save();
// Relate a use with a post (inverse of above, hasMany):
$user->posts()->create($arrayWithPostData);
// Note that `get` is like Eloquent Builder's `get`, which executes the query,
// and not like ParseQuery's `get` which finds an object by id.
$posts = Post::where('createdAt', '<=', $date)->descending('score')->get();
$posts = Post::where([
'creator' => $user,
'title' => $title
])
->containedIn('foo', $foos)
->get();
$post = Post::firstOrCreate($data);
// Load relations (ParseQuery::
// In objects, pass a second parameter when instantiating:
$post = new Post($data, true);
// or use the setter method:
$post->useMasterKey(true);
// Passing an anonymous function will set useMasterKey to true,
// then execute the function, then useMasterKey will be set to false.
$post->useMasterKey(function($post) {
$post->increment('views')->save();
});
// When creating queries, pass as parameter:
$query = Post::query(true);
// or use the setter method:
$query->useMasterKey(true);
// Other object methods that accept a $useMasterKey value are:
$post = Post::create($data, true);
$posts = Post::all(true);
// To configure a single model to _always_ use master key, define
// a protected static property `$defaultUseMasterKey`:
class Post extends ObjectModel
{
protected static $defaultUseMasterKey = true;
}
// Finally, you can make all models use master key with this:
Parziphal\Parse\ObjectModel::setDefaultUseMasterKey(true);
namespace App;
use Parziphal\Parse\Auth\UserModel;
class User extends UserModel
{
}
trait AuthenticatesWithFacebook
{
protected $apiResponse = ['ok' => true];
public function logInOrRegisterWithFacebookApi(Request $request);
public function logInOrRegisterWithFacebookRedirect(Request $request);
public function registerWithFacebookApi(Request $request);
public function registerWithFacebookRedirect(Request $request);
public function registerAny(Request $request);
public function logoutApi(Request $request);
// For logout with redirection simply use logout().
}