Merge pull request #139 from nakazawakan/backend

12月1日の修正
このコミットが含まれているのは:
chankan77 2021-12-01 17:50:31 +09:00 committed by GitHub
コミット b746e7dba8
この署名に対応する既知のキーがデータベースに存在しません
GPGキーID: 4AEE18F83AFDEB23
10個のファイルの変更82行の追加79行の削除

ファイルの表示

@ -1,4 +1,4 @@
APP_NAME=Laravel
APP_NAME=KIKIkan
APP_ENV=local
APP_KEY=
APP_DEBUG=true

ファイルの表示

@ -1,4 +1,4 @@
APP_NAME=Laravel
APP_NAME=KIKIkan
APP_ENV=local
APP_KEY=
APP_DEBUG=true

ファイルの表示

@ -10,8 +10,6 @@ use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Storage;
use Image;
use App\Models\Child;
use App\Models\FatherRelation;
use App\Models\MeetingApprovals;
@ -159,11 +157,7 @@ class ChildrenController extends Controller {
if (!is_null($r->image)) {
$image = base64_decode(substr($r->image, strpos($r->image, ',') + 1));
Storage::disk('private')->put($filename, $image);
$quality = 1;
$img = Image::make('/work/storage/app/private/'.$filename)->encode('jpg', $quality);
$img->orientate();
$img->save('/work/storage/app/private/'.$filename);
$this->fiximg($filename);
}
$child->fill($insert);
@ -419,11 +413,7 @@ class ChildrenController extends Controller {
$image = base64_decode(substr($r->image, strpos($r->image, ',') + 1));
Storage::disk('private')->put($filename, $image);
$quality = 1;
$img = Image::make('/work/storage/app/private/'.$filename)->encode('jpg', $quality);
$img->orientate();
$img->save('/work/storage/app/private/'.$filename);
$this->fiximg($filename);
$child = Child::find((int)$child_id);
if (!is_null($child->image) && $child->image != '/assets/default/avatar.jpg') {

ファイルの表示

@ -11,11 +11,11 @@ use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Facades\Storage;
use Image;
use App\Models\Father;
use App\Models\FatherRelation;
use App\Models\EmailActivation;
use App\Models\Meeting;
use App\Models\MeetingImage;
use App\Models\MeetingApprovals;
use App\Mail\FathersForgetPasswordMail;
@ -156,7 +156,7 @@ class FathersController extends Controller {
$validate = Validator::make($r->all(), [
'token' => 'required',
'password' => 'required|min:8|max:72|confirmed',
'company' => 'max:100',
'company' => 'required|max:100',
'image' => 'image_size|image_meme',
'profile' => 'max:1000',
'tel' => 'required|unique:fathers|numeric|starts_with:0|tel_size',
@ -180,11 +180,7 @@ class FathersController extends Controller {
$filename = $this->uuidv4().'.jpg';
$image = base64_decode(substr($r->image, strpos($r->image, ',') + 1));
Storage::disk('private')->put($filename, $image);
$quality = 1;
$img = Image::make('/work/storage/app/private/'.$filename)->encode('jpg', $quality);
$img->orientate();
$img->save('/work/storage/app/private/'.$filename);
$this->fiximg($filename);
}
try {
@ -354,11 +350,7 @@ class FathersController extends Controller {
$image = base64_decode(substr($r->image, strpos($r->image, ',') + 1));
Storage::disk('private')->put($filename, $image);
$quality = 1;
$img = Image::make('/work/storage/app/private/'.$filename)->encode('jpg', $quality);
$img->orientate();
$img->save('/work/storage/app/private/'.$filename);
$this->fiximg($filename);
$father = Father::find((int)$father_id);
if (!is_null($father->image) && $father->image != '/assets/default/avatar.jpg') {
@ -517,13 +509,38 @@ class FathersController extends Controller {
}
public function withdrawal (Request $r) {
$images = [];
$pdfs = [];
try {
// DBに入ります。
DB::beginTransaction();
$father = Father::find((int)$r->father_id);
$rel = FatherRelation::where('father_id', (int)$r->father_id);
$meet = Meeting::where('father_id', (int)$r->father_id);
if ($meet->count() > 0) {
foreach ($meet->get() as $n) {
$meim = MeetingImage::where('meeting_id', (int)$n->id);
$oldpdf = str_replace('/files/', '', $n->pdf);
$pdfs[] = $oldpdf;
if ($meim->count() > 0) {
foreach ($meim->get() as $m) {
$oldimg = str_replace('/files/', '', $m->image);
$images[] = $oldimg;
}
}
}
}
$img = $father->image;
$father->delete();
$rel->delete();
$meet->delete();
$meim->delete();
if (!is_null($img)) {
$img = str_replace('/files/', '', $father->image);
@ -535,39 +552,29 @@ class FathersController extends Controller {
}
}
Session::forget($this->getGuard());
DB::commit();
} catch (\Throwable $e) {
// 失敗
Log::critical($e->getMessage());
DB::rollback();
return ['status_code' => 400, 'error_messages' => ['親の削除に失敗しました。']];
}
// 成功
return ['status_code' => 200, 'success_messages' => ['親の削除に成功しました。']];
}
public function delete ($father_id) {
try {
// DBに入ります。
DB::beginTransaction();
$father = Father::find((int)$father_id);
$img = $father->image;
$father->delete();
if (!is_null($img)) {
$img = str_replace('/files/', '', $father->image);
if (!Storage::disk('private')->exists($img)) {
Log::warning($img.'というパスは不正です。');
}
else {
Storage::disk('private')->delete($img);
if (!empty($pdfs)) {
foreach ($pdfs as $p) {
if (!Storage::disk('private')->exists($p)) {
Log::warning($p.'というパスは不正です。');
}
else {
Storage::disk('private')->delete($p);
}
}
}
Session::forget($this->getGuard());
if (!empty($images)) {
foreach ($images as $g) {
if (!Storage::disk('private')->exists($g)) {
Log::warning($g.'というパスは不正です。');
}
else {
Storage::disk('private')->delete($g);
}
}
}
Session::forget('fathers');
DB::commit();
} catch (\Throwable $e) {
// 失敗

ファイルの表示

@ -8,8 +8,6 @@ use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Storage;
use Image;
use App\Models\MeetingImage;
class MeetingImagesController extends Controller {
@ -52,10 +50,7 @@ class MeetingImagesController extends Controller {
$fname[] = $filename;
$image = base64_decode(substr($img, strpos($img, ',') + 1));
Storage::disk('private')->put($filename, $image);
$quality = 1;
$imag = Image::make('/work/storage/app/private/'.$filename)->encode('jpg', $quality);
$img->orientate();
$imag->save('/work/storage/app/private/'.$filename);
$this->fiximg($filename);
$insert = [
'meeting_id' => (int)$r->meeting_id,

ファイルの表示

@ -9,8 +9,6 @@ use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Storage;
use Image;
use App\Models\Meeting;
use App\Models\MeetingImage;
use App\Models\MeetingApprovals;
@ -122,10 +120,7 @@ class MeetingsController extends Controller {
$fnames[] = $fname;
$image = base64_decode(substr($img, strpos($img, ',') + 1));
Storage::disk('private')->put($fname, $image);
$quality = 1;
$imag = Image::make('/work/storage/app/private/'.$fname)->encode('jpg', $quality);
$imag->orientate();
$imag->save('/work/storage/app/private/'.$fname);
$this->fiximg($filename);
$imgname = '/files/'.$fname;

ファイルの表示

@ -7,6 +7,7 @@ use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Support\Facades\Log;
use Image;
class Controller extends BaseController
{
@ -160,4 +161,24 @@ class Controller extends BaseController
return false;
}
}
public function fiximg ($filename, $quality=1) {
$img = Image::make('/work/storage/app/private/'.$filename)->encode('jpg', $quality);
$img->orientate();
if ($img->width() < $img->height() && $img->width() > 400) {
$img->resize(400, null, function ($constraint) {
$constraint->aspectRatio();
$constraint->upsize();
});
}
else if ($img->height() < $img->width() && $img->height() > 400) {
$img->resize(400, null, function ($constraint) {
$constraint->aspectRatio();
$constraint->upsize();
});
}
$img->save('/work/storage/app/private/'.$filename);
return $filename;
}
}

ファイルの表示

@ -5,25 +5,25 @@ KIKIkanサービスの会員登録のご案内です。
KIKIkanシステムのご利用ありがとうございます。
※本登録完了後にホーム画面もしくはブックマークに登録してください。
※本登録完了後にホーム画面もしくはブックマークに登録してください。<br />
ログインする際に利用します。
下記URLにアクセスし、必要情報をご入力頂き
下記URLにアクセスし、必要情報をご入力頂き<br />
ユーザー登録を完了してください。
@component('mail::button', ['url' => url('/').'/p-account/register/'.$token])
{{ url('/') }}/p-account/register/{{ $token }}
@endcomponent
なお、URLの有効期限は8時間となります。
なお、URLの有効期限は8時間となります。<br />
URLの有効期限を過ぎると、再登録が必要になりますので、ご注意ください。
※このメールに心当たりがない場合は下記のメールにご連絡ください。
■□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□■
KIKIkan運営事務局
56@zotman.jp
KIKIkan運営事務局<br />
56@zotman.jp<br />
{{ url('/') }}/
■□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□■

ファイルの表示

@ -1,11 +1,7 @@
<tr>
<td class="header">
<a href="{{ $url }}" style="display: inline-block;">
@if (trim($slot) === 'Laravel')
<img src="{{ $url }}/assets/img/common/logo.png" class="logo" alt="KIKIkan">
@else
{{ $slot }}
@endif
</a>
</td>
</tr>

ファイルの表示

@ -114,7 +114,6 @@ img {
.logo {
height: 75px;
max-height: 75px;
width: 75px;
}
/* Body */