app/Http/Controllers/Admin/leavesController.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(LeavesValidator $request)
    {
        $data = $request->all();
        Leaves::create($data);
        $email = DB::table('users')->where('role', '1')->select('email')->get();
        Mail::to($email)->send(new LeaveApplyMail());
        if($data){
        if (Auth::user()->role_id == 1) {
            return redirect()->route('leaves.index')->with('success', 'Leave has been applied Successfully');
        } else {
            return redirect()->route('employeeLeaveView')->with('success', 'Leave has been applied Successfully');
        }
    } else {
        return redirect()->back()->with('error', 'Oops!!! some error occurred');
    }
    }
public function store ( LeavesValidator $ request ) { $ data = $ request -> all ( ) ; Leaves :: create ( $ data ) ; $ email = DB :: table ( 'users' ) -> where ( 'role' , '1' ) -> select ( 'email' ) -> get ( ) ; Mail :: to ( $ email ) -> send ( new LeaveApplyMail ( ) ) ; if ( $ data ) { if ( Auth :: user ( ) -> role_id == 1 ) { return redirect ( ) -> route ( 'leaves.index' ) -> with ( 'success' , 'Leave has been applied Successfully' ) ; } else { return redirect ( ) -> route ( 'employeeLeaveView' ) -> with ( 'success' , 'Leave has been applied Successfully' ) ; } } else { return redirect ( ) -> back ( ) -> with ( 'error' , 'Oops!!! some error occurred' ) ; } }
Store a newly created resource in storage.
Store a newly created resource in storage .