PATH:
home
/
lab2454c
/
omvstudio.com
/
app
/
Http
/
Controllers
/
Admin
<?php namespace App\Http\Controllers\Admin; use App\Http\Controllers\Controller; use App\Models\HomeConfigWork; use Illuminate\Http\Request; use Str; use Storage; class HomeConfigWorkController extends Controller { /** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $home_config_works = HomeConfigWork::orderByDesc('created_at')->paginate(10); return view('admin.home_workflow.list',compact('home_config_works')); } /** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function create() { return view('admin.home_workflow.create'); } /** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { //prx($request->all()); $values = $request->validate([ 'title'=>'required|string|unique:categories,title', "content"=>'nullable|string|max:15000', "image"=>'nullable|mimes:png,jpeg,gif,svg|max:5000', ]); $homeConfigWork = new HomeConfigWork; $homeConfigWork->fill($request->except('image')); $homeConfigWork->slug = Str::slug($values['title']); if ($request->hasFile('image')) { $image_name = $request->file('image'); $ext = $image_name->extension(); $image_filename = uniqid().'.'.$ext; $image_name->storeAs('public/home_works/',$image_filename); $homeConfigWork->image = $image_filename; } $result = $homeConfigWork->save(); if ($result) { return redirect()->back()->with('success','Record has been successfully created!!'); } else{ return redirect()->back()->with('error','Unable to create record!!'); } } /** * Display the specified resource. * * @param \App\Models\HomeConfigWork $homeConfigWork * @return \Illuminate\Http\Response */ public function show(HomeConfigWork $homeConfigWork) { // } /** * Show the form for editing the specified resource. * * @param \App\Models\HomeConfigWork $homeConfigWork * @return \Illuminate\Http\Response */ public function edit(HomeConfigWork $homeConfigWork) { //prx($homeConfigWork); return view('admin.home_workflow.edit',compact('homeConfigWork')); } /** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param \App\Models\HomeConfigWork $homeConfigWork * @return \Illuminate\Http\Response */ public function update(Request $request, HomeConfigWork $homeConfigWork) { $values = $request->validate([ 'title'=>'required|string|unique:home_config_works,title,'.$homeConfigWork->id, "content"=>'nullable|string|max:15000', "image"=>'nullable|mimes:png,jpeg,gif,svg|max:5000', ]); $homeConfigWork->fill($request->except('image')); $homeConfigWork->slug = Str::slug($values['title']); if ($request->hasFile('image')) { if (Storage::exists('public/home_works/'.$homeConfigWork->image)) { Storage::delete('public/home_works/'.$homeConfigWork->image); } $image_name = $request->file('image'); $ext = $image_name->extension(); $image_filename = uniqid().'.'.$ext; $image_name->storeAs('public/home_works/',$image_filename); $homeConfigWork->image = $image_filename; } $result = $homeConfigWork->save(); if ($result) { return redirect()->back()->with('success','Record has been successfully updated!!'); } else{ return redirect()->back()->with('error','Unable to update record!!'); } } /** * Remove the specified resource from storage. * * @param \App\Models\HomeConfigWork $homeConfigWork * @return \Illuminate\Http\Response */ public function destroy(HomeConfigWork $homeConfigWork) { $homeConfigWork->delete(); if (Storage::exists('public/home_works/'.$homeConfigWork->tab_content_image)) { Storage::delete('public/home_works/'.$homeConfigWork->tab_content_image); } return redirect()->route('home-config-work.index')->with('success', 'Record deleted been succesfully!!'); } public function status($status,$id,Request $request){ $homeConfigWork = HomeConfigWork::find($id); $homeConfigWork->status=$status; $homeConfigWork->update(); return redirect()->route('home-config-work.index')->with('success','Status has been updated successfully'); } }
[-] CategoryController.php
[edit]
[-] MovieController_bkp.php
[edit]
[-] PageBannerController.php
[edit]
[+]
..
[-] UserController.php
[edit]
[-] SiteSettingController.php
[edit]
[-] AdminProfileController.php
[edit]
[-] MusicController.php
[edit]
[-] PageController.php
[edit]
[-] HomeConfigWorkController.php
[edit]
[-] MovieController.php
[edit]
[-] ContactController.php
[edit]
[-] FaqController.php
[edit]
[-] LoginController.php
[edit]
[-] MusicManiaController.php
[edit]
[-] ReviewController.php
[edit]
[-] MediaController.php
[edit]
[-] DashboardController.php
[edit]
[-] EntertainController.php
[edit]
[-] MenuController.php
[edit]
[-] SportController.php
[edit]