Example #1
0
 /**
  * Show the form for creating a new resource.
  *
  * @throws Symfony\Component\HttpKernel\Exception\NotFoundHttpException
  * @return Response
  */
 public function create()
 {
     $cms = Cms::newInstance(['control' => 'create', 'action' => Lang::get('content::messages.add')]);
     $category = $this->getCategory();
     // try to pre-assign an author name
     $author = '';
     $user = \Auth::user()->getAttributes();
     if (isset($user['firstname']) && isset($user['lastname'])) {
         $author = $user['firstname'] . ' ' . $user['lastname'];
     } else {
         if (isset($user['name'])) {
             $author = $user['name'];
         } else {
             if (isset($user['username'])) {
                 $author = $user['username'];
             }
         }
     }
     // create a more-or-less empty article template
     $article = Article::newInstance(['active' => true, 'category_id' => $category->id, 'author' => $author]);
     if ($category && $article) {
         return view('newmarkets\\content::admin.article.edit', compact('article', 'category', 'cms'));
     }
     throw new NotFoundHttpException();
 }