コード例 #1
0
ファイル: Home.php プロジェクト: komphet5139/ubr
 public function index()
 {
     $members = new User();
     $classes = SetupValue::where('slug', 'like', 'CLASS-TEACHER-%');
     $questions = Question::where('subId', '')->orderBy('id')->get();
     return View('home')->with(compact('members'))->with(compact('classes'))->with(compact('questions'));
 }
コード例 #2
0
ファイル: Member.php プロジェクト: komphet5139/ubr
 public function yeaBooGen(Request $request)
 {
     //dd($request->all());
     if (Auth::user()->CRNo != '00') {
         $date = strtotime(Auth::user()->birthday);
         $birthMonth = SetupValue::where('slug', 'M-' . date('n', $date))->first();
         $yearThai = date("Y", $date) + 543;
         $birthday = date('j', $date) . ' ' . $birthMonth->title . ' ' . $yearThai;
         $name = '#' . Auth::user()->CRNo . ' ' . Auth::user()->name . ' ' . Auth::user()->lastname;
         $proPic = Image::make(Auth::user()->picture)->resize(140, 140);
         $proPic = Image::make(Auth::user()->picture)->resize(140, 140);
         if (Auth::user()->CRNo % 2 == 0) {
             $bg = 'picture/yearbook/y2.jpg';
         } else {
             $bg = 'picture/yearbook/y1.jpg';
         }
         $img = Image::make($bg)->insert($proPic, 'top-left', 100, 188)->text($name, 260, 180, function ($font) {
             $font->file('fonts/ThaiSansNeue-Bold.ttf');
             $font->size(34);
             $font->color('#000');
             $font->align('left');
             $font->valign('top');
         })->text(Auth::user()->studenNo, 237, 335, function ($font) {
             $font->file('fonts/ThaiSansNeue-Bold.ttf');
             $font->size(24);
             $font->color('#000');
             $font->align('right');
             $font->valign('top');
         })->text(Auth::user()->nickname, 315, 335, function ($font) {
             $font->file('fonts/ThaiSansNeue-Bold.ttf');
             $font->size(24);
             $font->color('#000');
             $font->align('left');
             $font->valign('top');
         })->text($birthday, 445, 334, function ($font) {
             $font->file('fonts/ThaiSansNeue-Bold.ttf');
             $font->size(24);
             $font->color('#000');
             $font->align('left');
             $font->valign('top');
         })->text($request->get('aboutMe1'), 270, 240, function ($font) {
             $font->file('fonts/ThaiSansNeue-Bold.ttf');
             $font->size(30);
             $font->color('#000');
             $font->align('left');
             $font->valign('top');
         })->text($request->get('aboutMe2'), 270, 270, function ($font) {
             $font->file('fonts/ThaiSansNeue-Bold.ttf');
             $font->size(30);
             $font->color('#000');
             $font->align('left');
             $font->valign('top');
         })->text($request->get('likeColor'), 167, 389, function ($font) {
             $font->file('fonts/ThaiSansNeue-Bold.ttf');
             $font->size(24);
             $font->color('#1100b7');
             $font->align('left');
             $font->valign('top');
         })->text($request->get('likeSubject'), 187, 419, function ($font) {
             $font->file('fonts/ThaiSansNeue-Bold.ttf');
             $font->size(24);
             $font->color('#1100b7');
             $font->align('left');
             $font->valign('top');
         })->text($request->get('myfriend'), 187, 447, function ($font) {
             $font->file('fonts/ThaiSansNeue-Bold.ttf');
             $font->size(24);
             $font->color('#1100b7');
             $font->align('left');
             $font->valign('top');
         })->text($request->get('myTeacher'), 239, 475, function ($font) {
             $font->file('fonts/ThaiSansNeue-Bold.ttf');
             $font->size(24);
             $font->color('#1100b7');
             $font->align('left');
             $font->valign('top');
         })->text($request->get('tellFriend'), 250, 505, function ($font) {
             $font->file('fonts/ThaiSansNeue-Bold.ttf');
             $font->size(24);
             $font->color('#1100b7');
             $font->align('left');
             $font->valign('top');
         })->text($request->get('tellTeacher'), 268, 533, function ($font) {
             $font->file('fonts/ThaiSansNeue-Bold.ttf');
             $font->size(24);
             $font->color('#1100b7');
             $font->align('left');
             $font->valign('top');
         })->text($request->get('tellSchool'), 268, 563, function ($font) {
             $font->file('fonts/ThaiSansNeue-Bold.ttf');
             $font->size(24);
             $font->color('#1100b7');
             $font->align('left');
             $font->valign('top');
         })->text($request->get('motto'), 339.5, 632, function ($font) {
             $font->file('fonts/ThaiSansNeue-Bold.ttf');
             $font->size(36);
             $font->color('#FFF');
             $font->align('center');
             $font->valign('top');
         });
     }
     if ($request->get('action') == 'save') {
         if (Auth::user()->CRNo != '00') {
             $dir = 'yearbook/class-' . Auth::user()->class . '/room-' . Auth::user()->room;
             if (!file_exists($dir)) {
                 mkdir($dir, 0777, true);
             }
             $millitime = round(microtime(true) * 1000);
             $filename = 'yearbook-' . Auth::user()->class . Auth::user()->room . '-' . Auth::user()->CRNo . '-' . Auth::user()->id . '-' . $millitime . ".jpg";
             $img->save($dir . '/' . $filename);
         }
         $checkYB = Yearbook::where('memberId', Auth::user()->id)->first();
         if (count($checkYB) != 0) {
             if ($checkYB->link != '') {
                 if (file_exists($checkYB->link)) {
                     unlink($checkYB->link);
                 }
             }
         } else {
             $checkYB = new Yearbook();
         }
         if (Auth::user()->CRNo == '00') {
             $checkYB->memberId = Auth::user()->id;
             $checkYB->aboutMe1 = trim($request->get('textTeacher'));
             $checkYB->link = 'none';
             $checkYB->save();
         } else {
             $checkYB->memberId = Auth::user()->id;
             $checkYB->aboutMe1 = $request->get('aboutMe1');
             $checkYB->aboutMe2 = $request->get('aboutMe2');
             $checkYB->likeSubject = $request->get('likeSubject');
             $checkYB->likeColor = $request->get('likeColor');
             $checkYB->myFriend = $request->get('myfriend');
             $checkYB->myTeacher = $request->get('myTeacher');
             $checkYB->tellFriend = $request->get('tellFriend');
             $checkYB->tellTeacher = $request->get('tellTeacher');
             $checkYB->tellSchool = $request->get('tellSchool');
             $checkYB->motto = $request->get('motto');
             $checkYB->link = $dir . '/' . $filename;
             $checkYB->save();
         }
         if (count($checkYB) != 0) {
             $log = new Log();
             $log->memberId = Auth::user()->id;
             $log->detail = 'Update Yearbook,' . $checkYB;
             $log->save();
         } else {
             $log = new Log();
             $log->memberId = Auth::user()->id;
             $log->detail = 'Create Yearbook,' . $checkYB;
             $log->save();
         }
         $updateYstatus = User::find(Auth::user()->id);
         $updateYstatus->yearbook = true;
         $updateYstatus->save();
         return Redirect::route('yearbook');
     }
     return $img->response('jpg');
 }
コード例 #3
0
ファイル: Admin.php プロジェクト: attackpoint10/ubr
 public function setupDel(Request $request)
 {
     $validator = Validator::make($request->all(), ['table' => 'required', 'id' => 'required']);
     if ($validator->fails()) {
         return 'false';
     } else {
         switch (strtolower($request->get('table'))) {
             case 'cate':
                 SetupCate::find($request->get('id'))->delete();
                 SetupKind::where('idCate', $request->get('id'))->delete();
                 SetupValue::where('idCate', $request->get('id'))->delete();
                 break;
             case 'kind':
                 SetupKind::find($request->get('id'))->delete();
                 SetupValue::where('idKind', $request->get('id'))->delete();
                 break;
             case 'value':
                 SetupValue::find($request->get('id'))->delete();
                 break;
         }
         return $request->get('id');
     }
 }
コード例 #4
0
ファイル: Admin.php プロジェクト: komphet5139/ubr
 public function setupDel(Request $request)
 {
     $validator = Validator::make($request->all(), ['table' => 'required', 'id' => 'required']);
     if ($validator->fails()) {
         return 'false';
     } else {
         switch (strtolower($request->get('table'))) {
             case 'cate':
                 SetupCate::find($request->get('id'))->delete();
                 SetupKind::where('idCate', $request->get('id'))->delete();
                 SetupValue::where('idCate', $request->get('id'))->delete();
                 break;
             case 'kind':
                 SetupKind::find($request->get('id'))->delete();
                 SetupValue::where('idKind', $request->get('id'))->delete();
                 break;
             case 'value':
                 SetupValue::find($request->get('id'))->delete();
                 break;
         }
         $log = new Log();
         $log->memberId = Auth::user()->id;
         $log->detail = 'Delete Setup table = ' . strtolower($request->get('table')) . ', id =' . trim($request->get('id'));
         $log->save();
         return $request->get('id');
     }
 }