Exemplo n.º 1
0
 /**
  * Determine if a page exists based on it's url.
  * @param string $url Page URL.
  * @return bool
  */
 public static function exists($url)
 {
     try {
         $page = WikiPage::where('url', $url)->firstOrFail();
         return true;
     } catch (Exception $e) {
         return false;
     }
 }
Exemplo n.º 2
0
 public function create()
 {
     $data = Request::only('title', 'content', 'url');
     $url = $this->canonicalUrl($data['url']);
     if (WikiPage::exists($url)) {
         return redirect()->route('wiki.page.view', $url);
     }
     $valid = WikiPage::valid($data);
     if ($valid === true) {
         $page = WikiPage::create($data);
         $url = $page->url;
         return redirect()->route('wiki.page.view', $url);
     } else {
         return response($valid, 500);
     }
 }