Ejemplo n.º 1
0
<?php

namespace sns\filter;

\Klass::bind(__NAMESPACE__ . '\\Base', ['overviews' => function () {
    return ['sns/overview/fixed-header'];
}]);
trait Base
{
    use \sns\filter\Login;
}
Ejemplo n.º 2
0
<?php

namespace sns\filter;

\Klass::bind(__NAMESPACE__ . '\\Crud', ['views' => function () {
    return ['sns/view/crud'];
}]);
trait Crud
{
    protected abstract function model();
    public function index($request)
    {
        return $this->crudIndex($request);
    }
    public function see($request)
    {
        return $this->crudSee($request);
    }
    public function add($request)
    {
        return $this->crudAdd($request);
    }
    public function edit($request)
    {
        return $this->crudEdit($request);
    }
    public function drop($request)
    {
        return $this->crudDrop($request);
    }
    public function dropAll($request)
Ejemplo n.º 3
0
<?php

namespace mongo\feature;

\Klass::bind(__NAMESPACE__ . '\\Timestamp', ['beforeValidate' => function () {
    $date = new \DateTime();
    $this->created = $this->created ?? $date;
    $this->updated = $date;
}]);
trait Timestamp
{
}
Ejemplo n.º 4
0
Archivo: Db.php Proyecto: tany/php-note
<?php

namespace sys\filter;

\Klass::bind(__NAMESPACE__ . '\\Db', ['views' => function () {
    return ['sys/view/db/main'];
}, 'overviews' => function () {
    return ['sns/overview/fixed-drawer'];
}]);
trait Db
{
}
// function Db__breadcrumbs() {
//     return function($request) {
//         //$this->overviews = ['sns/overview/fixed-header'];
//         $crumbs = [[$url = "/.sys/db/", 'Database']];
//         if ($db = $this->request->db) {
//             $crumbs[] = [$url = "{$url}{$db}/", $db];
//         }
//         if ($coll = $this->request->coll) {
//             $crumbs[] = [$url = "{$url}{$coll}/", $coll];
//         }
//         return $crumbs;
//     };
// }
Ejemplo n.º 5
0
<?php

namespace mongo\feature;

\Klass::bind(__NAMESPACE__ . '\\SequenceId', ['schema' => function () {
    return ['_id' => ['type' => 'integer']];
}, 'beforeSave' => function () {
    if ($this->_id === null) {
        $this->_id = $this->nextId();
    }
}]);
trait SequenceId
{
    public function nextId()
    {
        if (isset($this->_id)) {
            return;
        }
        $command = ['findAndModify' => 'sequence', 'query' => ['_id' => "{$this->collectionName()}._id"], 'update' => ['$inc' => ['seq' => 1]], "upsert" => true, "new" => true];
        $cursor = $this->connect()->command($this->dbName(), $command);
        return current($cursor->toArray())->value->seq;
    }
}
Ejemplo n.º 6
0
<?php

namespace sns\filter;

\Klass::bind(__NAMESPACE__ . '\\LoginRequired', ['before' => function ($request) {
    return $this->requireLogin();
}]);
trait LoginRequired
{
}