app/Http/Controllers/Admin/LanguagesController.php
// STORE A LANGUAGE IN DB AFTER VALIDATION
STORE A LANGUAGE IN DB AFTER VALIDATION
STORE A LANGUAGE IN DB AFTER VALIDATION
public function save(LanguageRequest $request)
    {
        try {
            if (!$request->has('lang-stat')) {
                $langStatus = array_merge(  
                    $request->all(),        
                    [
                        'status' => 0       
                    ]
                )['status'];                
            } else {
                $langStatus = intval(
                    $request->input('lang-stat')
                );
            }
            Language::create([
                'name'      => $request->input('lang-name'),    
                'abbr'      => $request->input('lang-abbr'),    
                'direction' => $request->input('lang-dire'),    
                'status'    => $langStatus                      
            ]);
            return redirect()->route('admin.languages')->with([
                'success' => 'Stored Successfully'
            ]);
        } catch (\Throwable $th) {
            return redirect()->route('admin.languages')->with([
                'error' => 'Something went terribly wrong'
            ]);
        }
    }
public function save ( LanguageRequest $ request ) { try { if ( ! $ request -> has ( 'lang-stat' ) ) { $ langStatus = array_merge ( $ request -> all ( ) , [ 'status' => 0 ] ) [ 'status' ] ; } else { $ langStatus = intval ( $ request -> input ( 'lang-stat' ) ) ; } Language :: create ( [ 'name' => $ request -> input ( 'lang-name' ) , 'abbr' => $ request -> input ( 'lang-abbr' ) , 'direction' => $ request -> input ( 'lang-dire' ) , 'status' => $ langStatus ] ) ; return redirect ( ) -> route ( 'admin.languages' ) -> with ( [ 'success' => 'Stored Successfully' ] ) ; } catch ( \ Throwable $ th ) { return redirect ( ) -> route ( 'admin.languages' ) -> with ( [ 'error' => 'Something went terribly wrong' ] ) ; } }
STORE A LANGUAGE IN DB AFTER VALIDATION
STORE A LANGUAGE IN DB AFTER VALIDATION
// Language::create($request->except(['_token'])); // PENDEING STATUS CHECK // SET THE STATUS VALUE TO BE ZERO // MERGE THE REQUEST AS A COLLECTION TO AN ARRAY // REQUEST COLLECTION // ADD STATUS OF ZERO TO THE CREATED ARRAY // RETRIEVE THE VALUE OF THE STATUS KEY FROM THE PREVIOUS ARRAY // $langStatus = $request->merge(['status' => 0])['status'];    // DOES THE SAME OPERATION. // CONVERT THE HTML STRING STATUS VALUE TO BE AN INTEGER VALUE // CREATE NEW LANGUAGE ROW // LANGUAGE TABLE COLUMNS // LANGUAGE NAME // LANGUAGE ABBREVIATION // LANGUAGE DIRECTION // LANGUAGE STATUS // REDIRECT TO LANGUAGES MAIN TABLE VIEW WITH SUCCESS MESSAGE // REDIRECT TO LANGUAGES MAIN TABLE VIEW WITH ERROR MESSAGE