app/Console/Commands/Requests/leaveAction.php
/**
     * Execute the console command.
     *
     * @return mixed
     */
Execute the console command.
@return mixed
Execute the console command . @return mixed
public function handle()
    {
        $request_id = $this->argument('request_id');
        $status = $this->argument('status');
        $approvalRequest = ApprovalRequests::find($request_id);
        $leaveRequest = LeaveRequests::find($approvalRequest->model_request_id);
        $output = array();
        switch ($status) {
            case 'accept':
                  $approvalRequest->update([
                    'approval_status' => 'approved',
                  ]);
                   $leaveRequest->status = 'approved';
                   $leaveRequest->save();
              $this->sendEmail($leaveRequest->employee_id,'approved');
                break;
            case 'reject':
                    $approvalRequest->update([
                      'approval_status' => 'declined',
                    ]);
                   $leaveRequest->status = 'declined';
                   $leaveRequest->rejection_comments = $approvalRequest->rejection_comments;
                   $leaveRequest->save();
                   $this->sendEmail($leaveRequest->employee_id,'declined');
               break;
            default:
                break;
        }
    }
public function handle ( ) { $ request_id = $ this -> argument ( 'request_id' ) ; $ status = $ this -> argument ( 'status' ) ; $ approvalRequest = ApprovalRequests :: find ( $ request_id ) ; $ leaveRequest = LeaveRequests :: find ( $ approvalRequest -> model_request_id ) ; $ output = array ( ) ; switch ( $ status ) { case 'accept' : $ approvalRequest -> update ( [ 'approval_status' => 'approved' , ] ) ; $ leaveRequest -> status = 'approved' ; $ leaveRequest -> save ( ) ; $ this -> sendEmail ( $ leaveRequest -> employee_id , 'approved' ) ; break ; case 'reject' : $ approvalRequest -> update ( [ 'approval_status' => 'declined' , ] ) ; $ leaveRequest -> status = 'declined' ; $ leaveRequest -> rejection_comments = $ approvalRequest -> rejection_comments ; $ leaveRequest -> save ( ) ; $ this -> sendEmail ( $ leaveRequest -> employee_id , 'declined' ) ; break ; default : break ; } }
Execute the console command.
Execute the console command .
// code...