Beispiel #1
0
 public function __construct()
 {
     $id = @$_GET['id'];
     $this->article = Article::find($id);
     if (!$this->article) {
         //Find first article
         $all = Article::all();
         $this->article = reset($all);
     }
 }
 public function __construct()
 {
     $id = '';
     if (isset($_POST['id'])) {
         $id = $_POST['id'];
     } else {
         if (isset($_GET['id'])) {
             $id = $_GET['id'];
         }
     }
     if ($id) {
         $this->article = Article::find($id);
     } else {
         $this->article = new Article();
     }
     if (isset($_POST['title'])) {
         $this->article->title = $_POST['title'];
         $this->article->body = $_POST['body'];
         $this->save();
     }
 }