app/Http/Controllers/MentorController.php
/**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
Store a newly created resource in storage.
Store a newly created resource in storage .
public function store(Request $request)
    {
        $data = $request->all();
        $rules = [
            "name" => "required|string",
            "profile" => "required|url",
            "profession" => "required|string",
            "email" => "required|email"
        ];
        $validator = Validator::make($data, $rules);
        if ($validator->fails()) {
            return response()->json([
                "status" => "error",
                "message" => $validator->errors()
            ]);
        }
        $mentor = Mentor::create($data);
        return response()->json([
            "status" => "success",
            "data" => $mentor
        ]);
    }
public function store ( Request $ request ) { $ data = $ request -> all ( ) ; $ rules = [ " name " => " required|string " , " profile " => " required|url " , " profession " => " required|string " , " email " => " required|email " ] ; $ validator = Validator :: make ( $ data , $ rules ) ; if ( $ validator -> fails ( ) ) { return response ( ) -> json ( [ " status " => " error " , " message " => $ validator -> errors ( ) ] ) ; } $ mentor = Mentor :: create ( $ data ) ; return response ( ) -> json ( [ " status " => " success " , " data " => $ mentor ] ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .