add_Exception_and_config

This commit is contained in:
KarimAldeen 2024-04-04 15:00:24 +03:00
parent a523eb33c6
commit fe163c104c
90 changed files with 80 additions and 4899 deletions

View File

@ -11,7 +11,7 @@ public function rules(): array
{
return [
'key' => 'required|string',
'value' => 'required|string',
'value' => 'required',
'type' => 'nullable|string|in:setting,about_us,contact_us,home',
];
}

View File

@ -11,7 +11,7 @@ public function rules(): array
{
return [
'key' => 'nullable|string',
'value' => 'nullable|string',
'value' => 'nullable',
'type' => 'nullable|string|in:setting,about_us,contact_us,home',
];
}

View File

@ -21,7 +21,7 @@ public function toArray(Request $request): array
'id' => $this->id,
'name' => $this->name,
'description' => $this->description,
'image' => $this->image ? $app_base_url . $this->image : null,
'image' => $this->image ,
];
}
}

View File

@ -22,7 +22,7 @@ public function toArray(Request $request): array
'project_id' => $this->project_id,
'type' => $this->type,
'is_active' => $this->is_active,
'image' => $this->image ? $app_base_url . $this->image : null,
'image' => $this->image,
];
}
}

View File

@ -15,12 +15,11 @@ class ProjectResource extends JsonResource
*/
public function toArray(Request $request): array
{
$app_base_url = Config::get('appSetting.app_base_url');
return [
"id"=> $this->id,
'title' => $this->title,
'description' => $this->description,
'logo' => $this->logo ? $app_base_url . $this->logo : null,
'logo' => $this->logo ,
];
}
}

View File

@ -23,7 +23,7 @@ public function toArray(Request $request): array
'phone' => $this->phone,
'email' => $this->email,
'message' => $this->message,
'attachment' => $this->attachment ? $app_base_url . $this->attachment : null,
'attachment' => $this->attachment ,

View File

@ -21,7 +21,7 @@ public function toArray(Request $request): array
"id"=> $this->id,
'title' => $this->title,
'description' => $this->description,
'image' => $this->image ? $app_base_url . $this->image : null,
'image' => $this->image ,
];
}
}

View File

@ -33,7 +33,11 @@ public function boot(): void
->prefix('api')
->group(base_path('routes/api.php'));
Route::middleware('website')
->group(base_path('routes/website.php'));
Route::middleware('web')
->prefix('web')
->group(base_path('routes/web.php'));
});
}

View File

@ -33,12 +33,12 @@ public function create($data)
public function update($id ,$data)
{
if (isset($data['image']) && !empty($data['image'])) {
$updated_image = ImageService::update_image($data['image'], 'developer');
parent::update($id,array_merge($data, ['image' => $updated_image]));
$Oldimage = Developer::find($id)->image ;
$updated_image = ImageService::update_image($data['image'],$Oldimage, 'developer');
$data['image'] = $updated_image;
}
parent::update($id,$data);
parent::update($id,$data);
}
}

View File

@ -9,24 +9,25 @@
class ImageService
{
public static function upload_image(UploadedFile $new_image, $folder = '')
public static function upload_image(UploadedFile $new_image, $upload_location = '')
{
$upload_location = Config::get('appSetting.upload_location', 'images');
$upload_folder = Config::get('appSetting.upload_folder');
$image_path_without_public = $upload_location . $folder . '/';
$image_path = public_path() . $upload_location . $folder . '/';
$image_name = $folder . '_' . Str::uuid() . '.' . $new_image->getClientOriginalExtension();
$image_path_without_public = $upload_folder . $upload_location . '/';
$image_path = public_path() . $upload_folder . $upload_location . '/';
$image_name = $upload_location . '_' . Str::uuid() . '.' . $new_image->getClientOriginalExtension();
$new_image->move($image_path, $image_name);
return $image_path_without_public . $image_name;
}
public static function update_image(UploadedFile $new_image, $old_image_name, $folder = '')
public static function update_image(UploadedFile $new_image, $old_image_name, $upload_location = '')
{
$upload_location = Config::get('appSetting.upload_location', 'images');
$new_image_path_without_public = $upload_location . $folder . '/';
$new_image_path = public_path() . $upload_location . $folder . '/';
$new_image_name = $folder . '_' . Str::uuid() . '.' . $new_image->getClientOriginalExtension();
$upload_folder = Config::get('appSetting.upload_folder');
$new_image_path_without_public = $upload_folder . $upload_location . '/';
$new_image_path = public_path() . $upload_folder . $upload_location . '/';
$new_image_name = $upload_location . '_' . Str::uuid() . '.' . $new_image->getClientOriginalExtension();
$new_image->move($new_image_path, $new_image_name);
try {
unlink(public_path() . $old_image_name);

View File

@ -5,6 +5,7 @@
use App\Models\Key;
use App\Models\Service;
use App\Services\Base\BaseService;
use GuzzleHttp\Psr7\UploadedFile;
use Illuminate\Http\Client\Request;
class KeyService extends BaseService
@ -34,19 +35,32 @@ public function getallWithfillter($request)
public function create($data)
{
parent::create([
'key' => $data['key'],
'value' => $data['value'],
'type' => $data['type']
]);
if (gettype($data['value']) === "object") {
$image = ImageService::upload_image($data['value'], "key");
parent::create([
'key' => $data['key'],
'value' => $image ,
'type' => $data['type'],
]);
} else {
parent::create([
'key' => $data['key'],
'value' => $data['value'],
'type' => $data['type']
]);
}
return true;
}
public function update($id ,$data)
public function update($id, $data)
{
if (gettype($data['value']) === "object") {
$Oldimage = Key::find($id)->value;
$updated_image = ImageService::update_image($data['value'], $Oldimage, 'key');
$data['value'] = $updated_image;
}
parent::update($id,$data);
}
parent::update($id, $data);
}
}

View File

@ -44,10 +44,12 @@ public function create($data)
public function update($id ,$data)
{
if (isset($data['image']) && !empty($data['image'])) {
$updated_image = ImageService::update_image($data['image'], 'ProjectImage');
parent::update($id,array_merge($data, ['image' => $updated_image]));
$Oldimage = ProjectImage::find($id)->image ;
$updated_image = ImageService::update_image($data['image'],$Oldimage, 'ProjectImage');
$data['image'] = $updated_image;
}
parent::update($id,$data);
parent::update($id,$data);
}
}

View File

@ -38,8 +38,9 @@ public function create($data)
public function update($id ,$data)
{
if (isset($data['logo']) && !empty($data['logo'])) {
$updated_logo = ImageService::update_image($data['logo'], 'Project');
parent::update($id,array_merge($data, ['logo' => $updated_logo]));
$Oldlogo = Project::find($id)->logo ;
$updated_logo = ImageService::update_image($data['logo'],$Oldlogo, 'Project');
$data['logo'] = $updated_logo;
}
parent::update($id,$data);

View File

@ -31,8 +31,9 @@ public function create($data)
public function update($id ,$data)
{
if (isset($data['image']) && !empty($data['image'])) {
$updated_image = ImageService::update_image($data['image'], 'contactUs');
parent::update($id,array_merge($data, ['image' => $updated_image]));
$Oldimage = Service::find($id)->image ;
$updated_image = ImageService::update_image($data['image'],$Oldimage, 'service');
$data['image'] = $updated_image;
}
parent::update($id,$data);

View File

@ -1,5 +1,5 @@
<?php
return [
'upload_location' => '/assets/',
'upload_folder' => '/assets/',
'app_base_url' => 'http://127.0.0.1:8000',
];

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

View File

@ -1,3 +0,0 @@
# https://www.robotstxt.org/robotstxt.html
User-agent: *
Disallow:

View File

@ -1,3 +0,0 @@
# https://www.robotstxt.org/robotstxt.html
User-agent: *
Disallow:

View File

@ -1,3 +0,0 @@
# https://www.robotstxt.org/robotstxt.html
User-agent: *
Disallow:

View File

@ -1,3 +0,0 @@
# https://www.robotstxt.org/robotstxt.html
User-agent: *
Disallow:

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

View File

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

View File

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

View File

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

View File

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

View File

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

File diff suppressed because one or more lines are too long

View File

@ -1,3 +0,0 @@
# https://www.robotstxt.org/robotstxt.html
User-agent: *
Disallow:

View File

@ -1,3 +0,0 @@
# https://www.robotstxt.org/robotstxt.html
User-agent: *
Disallow:

View File

@ -1,3 +0,0 @@
# https://www.robotstxt.org/robotstxt.html
User-agent: *
Disallow:

File diff suppressed because one or more lines are too long

View File

@ -1,3 +0,0 @@
# https://www.robotstxt.org/robotstxt.html
User-agent: *
Disallow:

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

19
routes/website.php Normal file
View File

@ -0,0 +1,19 @@
<?php
use App\Http\Controllers\Dashboard\QuotationController;
use App\Http\Controllers\website\ContactUsController;
use App\Http\Controllers\website\DeveloperController;
use App\Http\Controllers\website\KeyController;
use App\Http\Controllers\website\ServiceController;
use App\Http\Controllers\website\ProjectController;
use Illuminate\Support\Facades\Route;
Route::get('/project', [ProjectController::class, 'index']);
Route::get('/service', [ServiceController::class, 'index']);
Route::get('/developer', [DeveloperController::class, 'index']);
Route::get('/contact_us', [ContactUsController::class, 'index']);
Route::get('/quotation', [QuotationController::class, 'index']);
Route::get('/key', [KeyController::class, 'index']);