app/Http/Controllers/StudentController.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()
    {
        $response = Gate::inspect('create', new Student());
        if (!$response->allowed()) {
            session()->flash('permission', $response->message());
            return redirect()->route('student');
        }
        return view('student.create', ['classes' => Classes::all()]);
    }
public function create ( ) { $ response = Gate :: inspect ( 'create' , new Student ( ) ) ; if ( ! $ response -> allowed ( ) ) { session ( ) -> flash ( 'permission' , $ response -> message ( ) ) ; return redirect ( ) -> route ( 'student' ) ; } return view ( 'student.create' , [ 'classes' => Classes :: all ( ) ] ) ; }
Show the form for creating a new resource.
Show the form for creating a new resource .
//        if(!auth()->user()->can('create', new Student())){ //            session()->flash('permission', 'Chỉ có user mang id 1,2 mới có quyền này thôi'); //            return redirect()->route('student'); //        } //