Skip to content

Commit

Permalink
Laravel pint
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmetarsiv committed Jun 10, 2024
1 parent eb3f4ec commit 3bfb290
Show file tree
Hide file tree
Showing 190 changed files with 799 additions and 966 deletions.
1 change: 0 additions & 1 deletion app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ class Kernel extends ConsoleKernel
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
Expand Down
2 changes: 1 addition & 1 deletion app/Excel/Exports/UsersExport.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class UsersExport implements FromView
public function view(): View
{
return view('exports.users', [
'users' => User::where('type', User::Normal)->with('info')->whereRelation('info','companyId',companyId())->get()
'users' => User::where('type', User::Normal)->with('info')->whereRelation('info', 'companyId', companyId())->get(),
]);
}
}
15 changes: 3 additions & 12 deletions app/Excel/Imports/UserImport.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,13 @@
class UserImport implements ToModel, WithHeadingRow
{
/**
* @param array $row
*
* @return User|null
*/
public function model(array $row)
{
return self::userStore($row);
}

/**
* @param $row
*/
public function userStore($row): void
{
DB::transaction(function () use ($row) {
Expand All @@ -43,15 +38,11 @@ public function userStore($row): void
});
}

/**
* @param $row
* @param $id
*/
public function userInfoStore($row, $id): void
{
$period = Period::where('title',$row['donem'])->first();
$month = Month::where('title',$row['ay'])->first();
$group = Group::where('title',$row['sinif'])->first();
$period = Period::where('title', $row['donem'])->first();
$month = Month::where('title', $row['ay'])->first();
$group = Group::where('title', $row['sinif'])->first();

$info = new UserInfo();
$info->status = 1;
Expand Down
2 changes: 1 addition & 1 deletion app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function register()
'file' => $e->getFile(),
'line' => $e->getLine(),
'code' => $e->getCode(),
]
],
])->concat(collect($e->getTrace())->take(5))->toArray();
Log::channel('slack')->error($e->getMessage(), $errorLog);
});
Expand Down
32 changes: 18 additions & 14 deletions app/Helpers/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,14 @@
use App\Models\AppointmentSetting;
use App\Models\Company;
use App\Models\Invoice;
use App\Models\QuestionChoiceKey;
use App\Models\TestQuestion;
use App\Models\UserAnswer;
use Carbon\Carbon;
use Carbon\CarbonInterval;
use Carbon\CarbonPeriod;
use Illuminate\Support\Str;

function ignoreDateCheck($date): bool
{
return (bool)AppointmentSetting::where('ignore_date', $date)->where('companyId', companyId())->first();
return (bool) AppointmentSetting::where('ignore_date', $date)->where('companyId', companyId())->first();
}

function companyId(): int
Expand All @@ -30,39 +27,43 @@ function currentMounth(): array
{
$result = CarbonPeriod::create(Carbon::now()->format('d-m-Y'), '1 day', Carbon::now()->addMonth()->format('d-m-Y'));
foreach ($result as $dt) {
$months[] = [$dt->format("Y-m-d") => ignoreDateCheck($dt->format("Y-m-d"))];
$months[] = [$dt->format('Y-m-d') => ignoreDateCheck($dt->format('Y-m-d'))];
}

return $months;
}

function invoiceDiffDate($id): int
{
$invoice = Invoice::select('end_date')->where('companyId', $id)->orderBy('id', 'desc')->first();
$end = Carbon::parse($invoice->end_date);

return $end->diffInDays(Carbon::now());
}

function invoiceStatus($id): bool
{
$invoice = Invoice::select('status')->where('companyId', $id)->orderBy('id', 'desc')->first();

return $invoice->status == 0;
}

function companyLogo(): string
{
return '/storage/' . auth()->user()->info->companyInfo->logo;
return '/storage/'.auth()->user()->info->companyInfo->logo;
}

function imagePath($path): string
{
return '/storage/' . $path;
return '/storage/'.$path;
}

function totalPoint($correct, $length): int
{
if ($correct && $length) {
return 100 / $length * $correct;
}

return 0;
}

Expand All @@ -71,14 +72,16 @@ function resultStatus($point): string
if ($point) {
return $point >= 70 ? 'Başarılı' : 'Başarısız';
}

return 0;
}

function examTime($questionLength): string
{
if ($questionLength == 50) {
return 45 . ' dakika';
return 45 .' dakika';
}

return CarbonInterval::seconds($questionLength * 60)->cascade()->forHumans();
}

Expand All @@ -87,6 +90,7 @@ function getSubdomainLogo()
$url = \request()->getHttpHost();
$subdomain = explode('.', $url)[0];
$companyLogo = Company::where('subdomain', $subdomain)->with('info')->first();

return $companyLogo->info->logo ?? null;
}

Expand All @@ -95,16 +99,17 @@ function getSubdomainCompanyName()
$url = \request()->getHttpHost();
$subdomain = explode('.', $url)[0];
$company = Company::where('subdomain', $subdomain)->first();

return $company->title ?? null;
}

function htmlTagFragmentation($request): array
{
$data = strip_tags($request->content, '<td>');
$domdoc = new \DOMDocument();
$domdoc->loadHTML('<?xml encoding="utf-8" ?>'. $data);
$domdoc->loadHTML('<?xml encoding="utf-8" ?>'.$data);
$users = $domdoc->getElementsByTagName('td');
$arr = array();
$arr = [];
foreach ($users as $user) {
array_push($arr, $user->nodeValue);
}
Expand All @@ -114,16 +119,15 @@ function htmlTagFragmentation($request): array
foreach ($arr as $user) {
if ($index == 2) {
$userArr[$arrIndex]['tc'] = $user;
}
else if ($index == 3) {
} elseif ($index == 3) {
$surname = Str::afterLast($user, ' ');
$name = Str::replaceLast($surname, '', $user);
$userArr[$arrIndex]['name'] = $name;
$userArr[$arrIndex]['surname'] = $surname;
$arrIndex++;
}
else if ($index == 16)
} elseif ($index == 16) {
$index = 0;
}
$index++;
}

Expand Down
2 changes: 1 addition & 1 deletion app/Http/Constants/NormalExam.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class NormalExam
1 => 12, // İlk Yardım
2 => 23, // Trafik Çevre
3 => 9, // Araç Tekniği
4 => 6 // Trafik Adabı
4 => 6, // Trafik Adabı
];

const TIME = 2700;
Expand Down
7 changes: 3 additions & 4 deletions app/Http/Constants/ResponseMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@

class ResponseMessage
{

public static function SuccessMessage(): array
{
return [
'status' => true,
'title' => __('response-message.success_title'),
'message' => __('response-message.success_message')
'message' => __('response-message.success_message'),
];
}

Expand All @@ -19,7 +18,7 @@ public static function ErrorMessage(): array
return [
'status' => false,
'title' => __('response-message.error_title'),
'message' => __('response-message.error_message')
'message' => __('response-message.error_message'),
];
}

Expand All @@ -36,7 +35,7 @@ public static function CouponMessage(): array
{
return [
'status' => false,
'title' => __('response-message.coupon_title'),
'title' => __('response-message.coupon_title'),
'message' => __('response-message.coupon_message'),
];
}
Expand Down
11 changes: 5 additions & 6 deletions app/Http/Controllers/API/QuestionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use App\Http\Controllers\Controller;
use App\Http\Resources\QuestionResource;
use App\Models\Question;
use App\Models\UserAnswer;
use App\Services\QuizService;
use Illuminate\Http\Request;

Expand All @@ -20,25 +19,26 @@ public function index(QuizService $questionService)
{
$questions = Question::with('choice')->get();
$questionService->testStore($questions);

return QuestionResource::collection($questions);
}

/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(QuizService $questionService, Request $request)
{
$questionService->userAnswerStore($request);

return response()->json('success');
}

/**
* Display the specified resource.
*
* @param int $id
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($id)
Expand All @@ -49,8 +49,7 @@ public function show($id)
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
Expand All @@ -61,7 +60,7 @@ public function update(Request $request, $id)
/**
* Remove the specified resource from storage.
*
* @param int $id
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id)
Expand Down
2 changes: 2 additions & 0 deletions app/Http/Controllers/Admin/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@ public function getAdminDashboard()
public function getProfile()
{
$user = User::find(auth()->id());

return view('admin.profile', compact('user'));
}

public function updateProfile(Request $request, GlobalService $globalService)
{
try {
$globalService->userUpdate($request, auth()->id());

return response(ResponseMessage::SuccessMessage());
} catch (\Exception $ex) {
return response(ResponseMessage::ErrorMessage());
Expand Down
9 changes: 4 additions & 5 deletions app/Http/Controllers/Admin/CarTypeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public function __construct(CarTypeService $carTypeService)
public function index()
{
$types = CarType::all();

return view('admin.car-type.index', compact('types'));
}

Expand All @@ -41,13 +42,13 @@ public function create()
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
try {
$this->carTypeService->store($request);

return response(ResponseMessage::SuccessMessage());
} catch (\Exception $ex) {
return response(ResponseMessage::ErrorMessage());
Expand All @@ -57,7 +58,6 @@ public function store(Request $request)
/**
* Show the form for editing the specified resource.
*
* @param \App\Models\CarType $car_type
* @return \Illuminate\Http\Response
*/
public function edit(CarType $car_type)
Expand All @@ -68,14 +68,13 @@ public function edit(CarType $car_type)
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param \App\Models\CarType $car_type
* @return \Illuminate\Http\Response
*/
public function update(Request $request, CarType $car_type)
{
try {
$this->carTypeService->update($car_type->id, $request);

return response(ResponseMessage::SuccessMessage());
} catch (\Exception $ex) {
return response(ResponseMessage::ErrorMessage());
Expand All @@ -85,13 +84,13 @@ public function update(Request $request, CarType $car_type)
/**
* Remove the specified resource from storage.
*
* @param \App\Models\CarType $car_type
* @return \Illuminate\Http\Response
*/
public function destroy(CarType $car_type)
{
try {
$this->carTypeService->destroy($car_type->id);

return response(ResponseMessage::SuccessMessage());
} catch (\Exception $ex) {
return response(ResponseMessage::ErrorMessage());
Expand Down
Loading

0 comments on commit 3bfb290

Please sign in to comment.