app/Http/Controllers/Admin/PagesController.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(PageRequest $request)
    {
        $page = new Pages();
        if ($request->hasFile('page_image')) {
            if ($request->page_image != '') {
                $image       = $request->file('page_image');
                $filename    = $image->getClientOriginalName();
                $image_resize = Image::make($image->getRealPath());
                $image_resize->resize(500, 500, function ($constraint) {
                    $constraint->aspectRatio();
                })->save(public_path('storage/pages/' . $filename));
                $page->page_image = $filename;
            }
        }
        $page->page_title = $request->page_title;
        $page->page_slug = Str::slug($request->page_title, '-');
        $page->page_description = $request->page_description;
        $page->page_seo_title = $request->page_seo_title;
        $page->page_seo_description = $request->page_seo_description;
        $page->page_seo_keyword = $request->page_seo_keyword;
        $page->save();
        return redirect(route('admin.pages.index'))->with('success', 'Page successfully added.');
    }
public function store ( PageRequest $ request ) { $ page = new Pages ( ) ; if ( $ request -> hasFile ( 'page_image' ) ) { if ( $ request -> page_image != '' ) { $ image = $ request -> file ( 'page_image' ) ; $ filename = $ image -> getClientOriginalName ( ) ; $ image_resize = Image :: make ( $ image -> getRealPath ( ) ) ; $ image_resize -> resize ( 500 , 500 , function ( $ constraint ) { $ constraint -> aspectRatio ( ) ; } ) -> save ( public_path ( 'storage/pages/' . $ filename ) ) ; $ page -> page_image = $ filename ; } } $ page -> page_title = $ request -> page_title ; $ page -> page_slug = Str :: slug ( $ request -> page_title , '-' ) ; $ page -> page_description = $ request -> page_description ; $ page -> page_seo_title = $ request -> page_seo_title ; $ page -> page_seo_description = $ request -> page_seo_description ; $ page -> page_seo_keyword = $ request -> page_seo_keyword ; $ page -> save ( ) ; return redirect ( route ( 'admin.pages.index' ) ) -> with ( 'success' , 'Page successfully added.' ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .