128 lines
4.3 KiB
PHP
128 lines
4.3 KiB
PHP
<?php
|
|
|
|
namespace App\Services\Admin;
|
|
|
|
use App\Models\ManageAboutUs;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\Validator;
|
|
|
|
/**
|
|
* Class ManageAboutUsService.
|
|
*/
|
|
class ManageAboutUsService {
|
|
|
|
public function view_about_us() {
|
|
$about_us = ManageAboutUs::all();
|
|
return $about_us;
|
|
}
|
|
|
|
public function edit_about_us($id) {
|
|
$about_us = ManageAboutUs::find($id);
|
|
return $about_us;
|
|
}
|
|
|
|
public function update_about_us(Request $request) {
|
|
|
|
// dd($request);
|
|
$about_us = ManageAboutUs::find($request->edit_about_us_id);
|
|
|
|
if($request->file('main_about_us_image')){
|
|
$rules = [
|
|
'main_about_us_image' => 'required|file|max:400', // 400 KB
|
|
];
|
|
|
|
$validator = Validator::make($request->all(),$rules);
|
|
|
|
if ($validator->fails()) {
|
|
if ($request->expectsJson()) {
|
|
return false;
|
|
}
|
|
}
|
|
else {
|
|
$file_one = $request->file('main_about_us_image');
|
|
$ext = $file_one->extension();
|
|
$file_name_main_image = time() . '.' . $ext;
|
|
$path = public_path() . '/uploads/about_us';
|
|
$file_one->move($path, $file_name_main_image);
|
|
$about_us->main_image = $file_name_main_image;
|
|
}
|
|
}
|
|
|
|
if($request->file('about_us_middle_image')){
|
|
$rules = [
|
|
'about_us_middle_image' => 'required|file|max:400', // 400 KB
|
|
];
|
|
|
|
$validator = Validator::make($request->all(),$rules);
|
|
|
|
if ($validator->fails()) {
|
|
if ($request->expectsJson()) {
|
|
return false;
|
|
}
|
|
}
|
|
else {
|
|
$file_two = $request->file('about_us_middle_image');
|
|
$ext = $file_two->extension();
|
|
$file_name_middle_image = time() . '.' . $ext;
|
|
$path = public_path() . '/uploads/about_us';
|
|
$file_two->move($path, $file_name_middle_image);
|
|
$about_us->middel_image = $file_name_middle_image ;
|
|
}
|
|
}
|
|
|
|
if($request->file('about_us_footer_first_image')){
|
|
$rules = [
|
|
'about_us_footer_first_image' => 'required|file|max:400', // 400 KB
|
|
];
|
|
|
|
$validator = Validator::make($request->all(),$rules);
|
|
|
|
if ($validator->fails()) {
|
|
if ($request->expectsJson()) {
|
|
return false;
|
|
}
|
|
}
|
|
else {
|
|
$file_three = $request->file('about_us_footer_first_image');
|
|
$ext = $file_three->extension();
|
|
$file_name_first_image = time() . '.' . $ext;
|
|
$path = public_path() . '/uploads/about_us';
|
|
$file_three->move($path, $file_name_first_image);
|
|
$about_us->aboutus_first_image = $file_name_first_image ;
|
|
}
|
|
}
|
|
|
|
if($request->file('about_us_footer_last_image')){
|
|
$rules = [
|
|
'about_us_footer_last_image' => 'required|file|max:400', // 400 KB
|
|
];
|
|
|
|
$validator = Validator::make($request->all(),$rules);
|
|
|
|
if ($validator->fails()) {
|
|
if ($request->expectsJson()) {
|
|
return false;
|
|
}
|
|
}
|
|
else {
|
|
$file_four = $request->file('about_us_footer_last_image');
|
|
$ext = $file_four->extension();
|
|
$file_name_last_image = time() . '.' . $ext;
|
|
$path = public_path() . '/uploads/about_us';
|
|
$file_four->move($path, $file_name_last_image);
|
|
$about_us->aboutus_last_image = $file_name_last_image;
|
|
}
|
|
}
|
|
|
|
$about_us->about_us_title = $request->input('about_us_title');
|
|
$about_us->video_url = $request->input('about_us_video_url');
|
|
$about_us->description = $request->input('about_us_desc');
|
|
$about_us->about_us_first_image_title = $request->input('about_us_first_image_title');
|
|
$about_us->about_us_last_image_title = $request->input('about_us_footer_second_image_title');
|
|
|
|
$about_us->save();
|
|
return $about_us;
|
|
}
|
|
|
|
}
|