application/Controllers/AjaxControllers/Write.php
/**
     * Live load drafts
     * Fetch drafts by model and format contents
     * Format datetime to d/m H:i format
     * 
     * @route true
     * @param int $lastId - Last draft id recieved by user
     */
Live load drafts
Fetch drafts by model and format contents
Format datetime to d/m H:i format

@route true
@param int $lastId - Last draft id recieved by user
Live load drafts Fetch drafts by model and format contents Format datetime to d / m H : i format @route true @param int $lastId - Last draft id recieved by user
public function loadDrafts(int $lastId) {
        $drafts = $this->writeModel->fetchDrafts($this->draftsOnPage, $lastId);
        $data = [];
        $data['status'] = 500;
        $data['last_id'] = 0;
        foreach($drafts as $draft) {
            $data['status'] = 200;
            $data['last_id'] = $draft->id;
            $draft->title = Str::stripNewLines($draft->title);
            $draft->tagline = Str::stripNewLines($draft->tagline);
            $draft->content = Html::getChars($draft->content);
            $draft->created_at = Str::formatEpoch(strtotime($draft->created_at), "d/m H:i");
            $draft->last_edited = Str::formatEpoch(strtotime($draft->last_updated), "d/m H:i");
        }
        $data['drafts'] = $drafts;
        echo json_encode($data);
    }
public function loadDrafts ( int $ lastId ) { $ drafts = $ this -> writeModel -> fetchDrafts ( $ this -> draftsOnPage , $ lastId ) ; $ data = [ ] ; $ data [ 'status' ] = 500 ; $ data [ 'last_id' ] = 0 ; foreach ( $ drafts as $ draft ) { $ data [ 'status' ] = 200 ; $ data [ 'last_id' ] = $ draft -> id ; $ draft -> title = Str :: stripNewLines ( $ draft -> title ) ; $ draft -> tagline = Str :: stripNewLines ( $ draft -> tagline ) ; $ draft -> content = Html :: getChars ( $ draft -> content ) ; $ draft -> created_at = Str :: formatEpoch ( strtotime ( $ draft -> created_at ) , " d/m H:i " ) ; $ draft -> last_edited = Str :: formatEpoch ( strtotime ( $ draft -> last_updated ) , " d/m H:i " ) ; } $ data [ 'drafts' ] = $ drafts ; echo json_encode ( $ data ) ; }
Live load drafts
 Fetch drafts by model and format contents
 Format datetime to d/m H:i format
Live load drafts Fetch drafts by model and format contents Format datetime to d / m H : i format