1. Go to this page and download the library: Download prewk/seriquent 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/ */
prewk / seriquent example snippets
use Illuminate\Database\Eloquent\Model;
class Foo extends Model {
public static function getBlueprint() {
return ["name", "bars", "qux"];
}
public function bars() { return $this->hasMany("Bar"); }
public function qux() { return $this->belongsTo("Qux"); }
}
class Bar extends Model {
public static function getBlueprint() {
return ["foo", "bazs"];
}
public function foo() { return $this->belongsTo("Foo"); }
public function bazs() { return $this->morphMany("Baz", "bazable"); }
}
class Baz extends Model {
public static function getBlueprint() {
return ["bazable"];
}
public function bazable() { return $this->morphTo(); }
}
class Qux extends Model {
protected $casts = ["data" => "json"];
public static function getBlueprint() {
return ["foo", "bazs", "data"];
}
public function foo() { return $this->hasOne("Foo"); }
public function bazs() { return $this->morphMany("Baz", "bazable"); }
}
use Prewk\Seriquent;
// The factory helper method
$seriquent = Seriquent::make();
// Deserialize from Foo with id 5
$serialization = $seriquent->serialize(Foo::findOrFail(5));
// Save to disk
file_put_contents("serialization.json", json_encode($serialization));
// Load from disk
$serialization = json_decode(file_get_contents("serialization.json"), true);
// Deserialize into database
$results = $seriquent->deserialize($serialization);
// $results is an <internal @id> => <database id> associative array
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.