app/Http/Controllers/AnimalController.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([
            'name' => 'required',
            'breed' => 'required',
            'location' => 'required',
            'chip' => 'required|numeric|digits_between:6,8',
            'user_id' => 'numeric'
        ]);
        $animal = new Animal;
        $animal->name = $request->name;
        $animal->breed = $request->breed;
        $animal->location = $request->location;
        $animal->chip = $request->chip;
        $animal->user_name = auth()->user()->name;
        $animal->save();
        return redirect()->route('animal.index')->with('success', 'Project created successfully.');
    }
public function store ( Request $ request ) { $ request -> validate ( [ 'name' => 'required' , 'breed' => 'required' , 'location' => 'required' , 'chip' => 'required|numeric|digits_between:6,8' , 'user_id' => 'numeric' ] ) ; $ animal = new Animal ; $ animal -> name = $ request -> name ; $ animal -> breed = $ request -> breed ; $ animal -> location = $ request -> location ; $ animal -> chip = $ request -> chip ; $ animal -> user_name = auth ( ) -> user ( ) -> name ; $ animal -> save ( ) ; return redirect ( ) -> route ( 'animal.index' ) -> with ( 'success' , 'Project created successfully.' ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .
// Animal::create($request->all());