app/Http/Controllers/SectionsController.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)
    {
        $request->validate([
            'section_name'=>'required|unique:sections|max:255',
            'description'=>'required',
        ],[
            'section_name.required'=>'اسم القسم مطلوب',
            'section_name.unique'=>'القسم موجود بالفعل',
            'description.required'=>'الوصف مطلوب',
        ]
    );
        $input = $request->all();
        $sec_name = sections::where('section_name','=', $input['section_name'] )->exists();
        if($sec_name){
            session()->flash('Error','القسم موجود بالفعل');
            return redirect('/sections');
        }else{
            sections::create([
                'section_name' => $request->section_name,
                'description' => $request->description,
                'created_by' => Auth::user()->name,
            ]);
            session()->flash('Add','تم أضافة القسم');
            return redirect('/sections');
        }
    }
public function store ( Request $ request ) { $ request -> validate ( [ 'section_name' => 'required|unique:sections|max:255' , 'description' => 'required' , ] , [ 'section_name.required' => 'اسم القسم مطلوب', 'section_name.unique' => 'القسم موجود بالفعل', 'description.required' => 'الوصف مطلوب', ] ) ; $ input = $ request -> all ( ) ; $ sec_name = sections :: where ( 'section_name' , '=' , $ input [ 'section_name' ] ) -> exists ( ) ; if ( $ sec_name ) { session ( ) -> flash ( 'Error' , 'القسم موجود بالفعل'); return redirect ( '/sections' ) ; } else { sections :: create ( [ 'section_name' => $ request -> section_name , 'description' => $ request -> description , 'created_by' => Auth :: user ( ) -> name , ] ) ; session ( ) -> flash ( 'Add' , 'تم أضافة القسم'); return redirect ( '/sections' ) ; } }
Store a newly created resource in storage.
Store a newly created resource in storage .