app/Http/Controllers/Admin/LianjieController.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([
            'l_name' => 'required|unique:lianjie',
            'l_wangzhi' =>'required',
        ],[
            'l_name.required'=>'网站名称必填！',
            'l_name.unique'=>'网站名称已存在！',
            'l_wangzhi.required'=>'网址不能为空!',
        ]);
         $post = request()->except(['_token']);
         if ($request->hasFile('l_logo') ){
            $post['l_logo'] = $this->upload('l_logo');
        }
         $res = Lianjie::create($post);
        if($res){
            return redirect('/lianjie');
        }
    }
public function store ( Request $ request ) { $ request -> validate ( [ 'l_name' => 'required|unique:lianjie' , 'l_wangzhi' => 'required' , ] , [ 'l_name.required' => '网站名称必填！', 'l_name.unique' => '网站名称已存在！', 'l_wangzhi.required' => '网址不能为空!', ] ) ; $ post = request ( ) -> except ( [ '_token' ] ) ; if ( $ request -> hasFile ( 'l_logo' ) ) { $ post [ 'l_logo' ] = $ this -> upload ( 'l_logo' ) ; } $ res = Lianjie :: create ( $ post ) ; if ( $ res ) { return redirect ( '/lianjie' ) ; } }
Store a newly created resource in storage.
Store a newly created resource in storage .