app/Http/Controllers/ArticlesController.php
/**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
Show the form for creating a new resource.
@return \Illuminate\Http\Response
Show the form for creating a new resource . @return \ Illuminate \ Http \ Response
public function create()
    {
        $categories=Category::all();
        $user_id = auth()->user()->id;
        $user = User::find($user_id);
        if($user->role == 'admin')
        {
            return view('articles.create')->with('categories',$categories);
        }
        return redirect('/articles')->with('error','Samo admin može kreirati artikle');
    }
public function create ( ) { $ categories = Category :: all ( ) ; $ user_id = auth ( ) -> user ( ) -> id ; $ user = User :: find ( $ user_id ) ; if ( $ user -> role == 'admin' ) { return view ( 'articles.create' ) -> with ( 'categories' , $ categories ) ; } return redirect ( '/articles' ) -> with ( 'error' , 'Samo admin može kreirati artikle') ; }
Show the form for creating a new resource.
Show the form for creating a new resource .
//dohvacanje katergorija //provjera je li admin