|
|
@ -53,7 +53,8 @@ class NewsAndUpdateController extends Controller |
|
|
|
'keyword' => 'required', |
|
|
|
'keyword' => 'required', |
|
|
|
'meta-keyword' => 'nullable', |
|
|
|
'meta-keyword' => 'nullable', |
|
|
|
'status' => 'required', |
|
|
|
'status' => 'required', |
|
|
|
'image' => 'required|file|mimes:jpeg,png,jpg,pdf' |
|
|
|
'image' => 'required|file|mimes:jpeg,png,jpg,pdf', |
|
|
|
|
|
|
|
'thumbnail' => 'required', |
|
|
|
]); |
|
|
|
]); |
|
|
|
if($request->hasFile('image')){ |
|
|
|
if($request->hasFile('image')){ |
|
|
|
$extension = \request()->file('image')->getClientOriginalExtension(); |
|
|
|
$extension = \request()->file('image')->getClientOriginalExtension(); |
|
|
@ -62,14 +63,23 @@ class NewsAndUpdateController extends Controller |
|
|
|
$out_put_path = User::save_image(\request('image'),$extension,$count,$image_folder_type); |
|
|
|
$out_put_path = User::save_image(\request('image'),$extension,$count,$image_folder_type); |
|
|
|
$image_path1 = $out_put_path[0]; |
|
|
|
$image_path1 = $out_put_path[0]; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if($request->hasFile('thumbnail')){ |
|
|
|
|
|
|
|
$extension = \request()->file('thumbnail')->getClientOriginalExtension(); |
|
|
|
|
|
|
|
$image_folder_type = array_search('news_and_update',config('custom.image_folders')); //for image saved in folder |
|
|
|
|
|
|
|
$count = rand(100,999); |
|
|
|
|
|
|
|
$out_put_path = User::save_image(\request('thumbnail'),$extension,$count,$image_folder_type); |
|
|
|
|
|
|
|
$thumbnail_path1 = $out_put_path[0]; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$requestData = $request->all(); |
|
|
|
$requestData = $request->all(); |
|
|
|
if(isset($image_path1)){ |
|
|
|
if(isset($image_path1)){ |
|
|
|
$requestData['image'] = $image_path1; |
|
|
|
$requestData['image'] = $image_path1; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if(isset($thumbnail_path1)){ |
|
|
|
|
|
|
|
$requestData['thumbnail'] = $thumbnail_path1; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$requestData['slug'] = Setting::create_slug($requestData['keyword']); |
|
|
|
$requestData['slug'] = Setting::create_slug($requestData['keyword']); |
|
|
|
$requestData['blog_type'] =1; |
|
|
|
|
|
|
|
$setting = NewsAndUpdate::create($requestData); |
|
|
|
$setting = NewsAndUpdate::create($requestData); |
|
|
|
if(\request('point_title')){ |
|
|
|
if(\request('point_title')){ |
|
|
|
foreach (\request('point') as $index => $value){ |
|
|
|
foreach (\request('point') as $index => $value){ |
|
|
@ -96,7 +106,6 @@ class NewsAndUpdateController extends Controller |
|
|
|
|
|
|
|
|
|
|
|
public function update(Request $request, $id){ |
|
|
|
public function update(Request $request, $id){ |
|
|
|
|
|
|
|
|
|
|
|
// dd(\request()->all()); |
|
|
|
|
|
|
|
$setting =NewsAndUpdate::findorfail($id); |
|
|
|
$setting =NewsAndUpdate::findorfail($id); |
|
|
|
$this->validate(\request(), [ |
|
|
|
$this->validate(\request(), [ |
|
|
|
'description' => 'required', |
|
|
|
'description' => 'required', |
|
|
@ -110,7 +119,7 @@ class NewsAndUpdateController extends Controller |
|
|
|
|
|
|
|
|
|
|
|
if(\request('image')){ |
|
|
|
if(\request('image')){ |
|
|
|
$this->validate(\request(),[ |
|
|
|
$this->validate(\request(),[ |
|
|
|
'image' => 'file|mimes:jpeg,png,jpg,pdf' |
|
|
|
'image' => 'file|mimes:jpeg,png,jpg' |
|
|
|
]); |
|
|
|
]); |
|
|
|
if($request->hasFile('image')){ |
|
|
|
if($request->hasFile('image')){ |
|
|
|
$extension = \request()->file('image')->getClientOriginalExtension(); |
|
|
|
$extension = \request()->file('image')->getClientOriginalExtension(); |
|
|
@ -122,6 +131,17 @@ class NewsAndUpdateController extends Controller |
|
|
|
unlink(public_path().'/'.$setting->image); |
|
|
|
unlink(public_path().'/'.$setting->image); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if($request->hasFile('thumbnail')){ |
|
|
|
|
|
|
|
$extension = \request()->file('thumbnail')->getClientOriginalExtension(); |
|
|
|
|
|
|
|
$image_folder_type = array_search('news_and_update',config('custom.image_folders')); //for image saved in folder |
|
|
|
|
|
|
|
$count = rand(100,999); |
|
|
|
|
|
|
|
$out_put_path = User::save_image(\request('thumbnail'),$extension,$count,$image_folder_type); |
|
|
|
|
|
|
|
$thumbnail_path1 = $out_put_path[0]; |
|
|
|
|
|
|
|
if (is_file(public_path().'/'.$setting->thumbnail) && file_exists(public_path().'/'.$setting->thumbnail)){ |
|
|
|
|
|
|
|
unlink(public_path().'/'.$setting->thumbnail); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -130,7 +150,9 @@ class NewsAndUpdateController extends Controller |
|
|
|
if(isset($image_path1)){ |
|
|
|
if(isset($image_path1)){ |
|
|
|
$requestData['image'] = $image_path1; |
|
|
|
$requestData['image'] = $image_path1; |
|
|
|
} |
|
|
|
} |
|
|
|
$requestData['blog_type'] =1; |
|
|
|
if(isset($thumbnail_path1)){ |
|
|
|
|
|
|
|
$requestData['thumbnail'] = $thumbnail_path1; |
|
|
|
|
|
|
|
} |
|
|
|
$setting->fill($requestData); |
|
|
|
$setting->fill($requestData); |
|
|
|
$setting->save(); |
|
|
|
$setting->save(); |
|
|
|
if(\request('point_title') ){ |
|
|
|
if(\request('point_title') ){ |
|
|
|