app/Http/Controllers/CommentairesController.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([
            'content_com'   => 'required|min:2'
        ]);
        $comment = Commentaire::create([
            'annonce_id'        => $request['annonce_id'],
            'content_com'       => $request['content_com'],
            'user_id'           => Auth::id(),
            'dateComment'       => now(),
            'statut_com'        => 1,
            'typecomment_id'    => 1
        ]);
        if($comment){
            return redirect()->route('annonces.show', $request['annonce_id']);
        }
    }
public function store ( Request $ request ) { $ request -> validate ( [ 'content_com' => 'required|min:2' ] ) ; $ comment = Commentaire :: create ( [ 'annonce_id' => $ request [ 'annonce_id' ] , 'content_com' => $ request [ 'content_com' ] , 'user_id' => Auth :: id ( ) , 'dateComment' => now ( ) , 'statut_com' => 1 , 'typecomment_id' => 1 ] ) ; if ( $ comment ) { return redirect ( ) -> route ( 'annonces.show' , $ request [ 'annonce_id' ] ) ; } }
Store a newly created resource in storage.
Store a newly created resource in storage .