/**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($slug)
 {
     $work = Work::where('slug', $slug)->firstOrFail();
     $morePosts = Post::take(3)->orderBy("created_at", "desc")->get();
     $moreWorks = Work::where('slug', '!=', $work->slug)->take(3)->orderBy("created_at", "desc")->get();
     return view('works.show', compact("work", "moreWorks", "morePosts"));
 }
Ejemplo n.º 2
0
 public static function checkIfExists($text)
 {
     $work = Work::where('work_type_description', '=', $text)->first();
     if (!is_null($work)) {
         appGlobals::existsMessage(appGlobals::getWorkTableName(), $work->work_type_description, $work->id);
     }
     return $work;
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $works = \App\Work::where('status', 'active')->get()->toArray();
     $status = array('active', 'inactive');
     for ($i = 0; $i < 100; $i++) {
         $copy = new \App\Copy();
         $copy->work_id = $works[array_rand($works)]['id'];
         $copy->number = $i + 1;
         $copy->status = $status[array_rand($status)];
         $copy->save();
     }
 }
Ejemplo n.º 4
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     //
     $input = $request->all();
     $userId = Auth::user()['id'];
     $work = Work::where('user_id', $userId)->first();
     //判断是否已经存在记录
     if ($work == null) {
         $id['user_id'] = $userId;
         Work::create($id);
     }
     $work = Work::where('user_id', $userId)->first();
     //判断来自第几个项目信息页面
     if ($input['info_id'] == '1') {
         $name = $input['name'];
         $big_class = $input['big_class'];
         $small_class = $input['small_class'];
         $a = DB::update('update work set name=?,big_class=?,small_class=? where user_id=?', [$name, $big_class, $small_class, $userId]);
         return redirect('/work/create/2');
     }
     if ($input['info_id'] == '2') {
         $aim = $input['aim'];
         $brief = $input['brief'];
         $detailed = $input['detailed'];
         $a = DB::update('update work set aim=?,brief=?,detailed=? where user_id=?', [$aim, $brief, $detailed, $userId]);
         return redirect('/work/create/3');
     }
     if ($input['info_id'] == '3') {
         //判断请求中是否存在文件,如果存在则保存文件,否则存储为null
         if ($request->hasFile('materials') && $request->hasFile('document')) {
             $fileName1 = 'document' . '_' . $userId;
             $fileName2 = 'materials' . '_' . $userId;
             $path1 = 'file/document/';
             $path2 = 'file/materials';
             $request->file('document')->move($path1, $fileName1 . '.pdf');
             $request->file('materials')->move($path2, $fileName2 . '.pdf');
             $document_address = $fileName1;
             $materials_address = $fileName2;
             $a = DB::update('update work set document_address=?,materials_address=? where user_id=?', [$document_address, $materials_address, $userId]);
         }
         return redirect('/work/create/4');
     }
     if ($input['info_id'] == '4') {
         //判断请求中是否存在文件,如果存在则保存文件,否则存储为null
         if ($request->hasFile('image') && $request->hasFile('video')) {
             $fileName1 = 'image' . '_' . $userId;
             $fileName2 = 'video' . '_' . $userId;
             $path1 = 'file/image/';
             $path2 = 'file/video/';
             $request->file('image')->move($path1, $fileName1 . '.jpg');
             $request->file('video')->move($path2, $fileName2 . '.mp4');
             $image_address = $fileName1;
             $video_address = $fileName2;
             $a = DB::update('update work set image_address=?,video_address=? where user_id=?', [$image_address, $video_address, $userId]);
         }
     }
     //存储作品后设置作品状态为schoolwait
     //根据userId获取workId
     $work = Work::where('user_id', $userId)->first();
     $workId = $work['id'];
     //根据workId 设置WorkStatus
     $workStatus['work_id'] = $workId;
     $workStatus['status'] = 'schoolWait';
     WorkStatus::create($workStatus);
     //填写完成所有资料,跳转到填写成功的页面
     return redirect('/work/storeSuccess');
 }
Ejemplo n.º 5
0
 public function index()
 {
     return view('website.index')->with('categories', Category::orderBy('position', 'ASC')->get())->with('works', Work::orderBy('position', 'ASC')->get())->with('homeWorks', Work::where('display_home', true)->orderBy('position', 'ASC')->get());
 }
Ejemplo n.º 6
0
Route::get('auth/logout', 'Auth\\AuthController@getLogout');
Route::group(['namespace' => 'Admin', 'prefix' => 'admin', 'middleware' => 'auth'], function () {
    // Routes screens
    Route::resource('/users', 'UsersController');
    Route::resource('/loans', 'LoansController');
    Route::resource('/renew-loan-items', 'RenewLoanItemsController');
    Route::resource('/return-loan-items', 'ReturnLoanItemsController');
});
Route::group(['namespace' => 'Api', 'prefix' => 'api', 'middleware' => 'auth'], function () {
    // Routes services
    Route::resource('/users', 'UsersController');
    Route::resource('/loans', 'LoansController');
    Route::resource('/copies', 'CopiesController');
});
Route::get('/add-fake-copies', function () {
    $works = \App\Work::where('status', 'active')->get()->toArray();
    $status = array('active', 'inactive');
    for ($i = 1; $i < 50; $i++) {
        try {
            DB::beginTransaction();
            $copy = new \App\Copy();
            $copy->work_id = $works[array_rand($works)]['id'];
            $copy->number = $i;
            $copy->status = $status[array_rand($status)];
            $copy->save();
            DB::commit();
        } catch (Exception $e) {
            DB::rollBack();
        }
    }
    return array('ok');
 public function revertAssignedWork(RevertAssignedWorkRequest $request)
 {
     if ($request->revert == 1) {
         $work = Work::where('id', '=', $request->work_id)->first();
         if ($work->created_by == $this->currentUser->getId()) {
             /**
              * İŞİ GERİ ÇEKİLİNCE
              */
             $departmentWork = DepartmentWork::where('id', '=', $work->last_department_work_id)->first();
             $departmentWithSenior = Department::where('id', '=', $departmentWork->department_id)->with('senior')->first();
             $seniorUser = $departmentWithSenior->senior[0];
             $username = $seniorUser->first_name . " " . $seniorUser->last_name;
             $username = mb_convert_case($username, MB_CASE_TITLE, 'utf-8');
             CommonController::mailSendNotQueue('IS TAKIP SISTEMI', [$seniorUser->email], ['fullname' => $username, 'message' => 'Departmanınıza açılan "' . $work->title . '" başlıklı iş geri
                 alınmıştır. Lütfen ' . $this->currentUser->first_name . ' ' . $this->currentUser->last_name . ' ile irtibata geçiniz. '], 'emails.work-mail-template');
             CommonController::sendSms('RHPOZTFYAY', $seniorUser->phone, 'Departmanınızdaki "' . $work->title . '" başlıklı iş geri
             alınmıştır.Lütfen ' . $this->currentUser->first_name . ' ' . $this->currentUser->last_name . '  ile irtibata geçiniz.');
             $work->last_department_work_id = null;
             $work->save();
         } else {
             $workDepartment = DepartmentWork::where('id', '=', $work->last_department_work_id)->first();
             $userWork = UserWork::where('id', '=', $workDepartment->last_user_work_id)->first();
             $user = User::where('id', '=', $userWork->assigned_to)->first();
             $username = $user->first_name . " " . $user->last_name;
             $username = mb_convert_case($username, MB_CASE_TITLE, 'utf-8');
             CommonController::mailSendNotQueue('IS TAKIP SISTEMI', [$user->email], ['fullname' => $username, 'message' => 'Size acılan "' . $work->title . '" başlıklı iş geri alınmıştır.
                  Lütfen departman lideriniz ile irtibata geçiniz. '], 'emails.work-mail-template');
             CommonController::sendSms('RHPOZTFYAY', $user->phone, 'Size açılmış  "' . $work->title . '" başlıklı iş geri alınmıştır.
             Lütfen departman lideri ile irtibata geçiniz.');
             $workDepartment->last_user_work_id = null;
             $workDepartment->accepted = null;
             $workDepartment->save();
         }
         return response()->json(['success' => true, 'messages' => 'İş Geri Alma İşlemi Başarılı', 'revert' => true, 'work_id' => $work->id]);
     } else {
         return response()->json(['success' => true, 'messages' => 'İş Geri Alma İşlemi Başarılı', 'revert' => false]);
     }
 }
Ejemplo n.º 8
0
 /**
  * Get slug for certain Work. If does not exist fails(404).
  * Else returning view for certain Work.
  * @param $slug
  */
 public function show($slug)
 {
     $work = \App\Work::where(['slug' => $slug])->firstOrFail();
 }
Ejemplo n.º 9
0
 /**
  * Deleting certain Work
  * TODO Delete Gallery
  * TODO Are u sure u want to delete?
  * @param $id
  * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
  */
 public function delete($id)
 {
     $work = \App\Work::where(['id' => $id])->first();
     $work->videos()->forceDelete();
     $work->forceDelete();
     //Delete Gallery TODO
     return redirect(url('/admin/works/' . $work->type->slug));
 }
Ejemplo n.º 10
0
    $type = 'Lunch';
    $description = 'Lunch break';
    if (is_null($taskType = TaskType::checkIfExists($type))) {
        // get $client->id
        $client = Client::where('name', '=', 'Kendra Scott')->first();
        $taskType = new TaskType();
        $taskType->type = $type;
        $taskType->description = $description;
        $taskType->client_id = $client->id;
        $taskType->save();
    }
});
Route::get('add_timeCard_data', function () {
    $date = '2015-11-09';
    // get $work->id
    $work = Work::where('work_type_description', '=', 'The catalog view is performing too slowly.')->first();
    // get $timeCardFormat->id
    $timeCardFormat = TimeCardFormat::where('description', '=', 'Day of week starts on SAT and ends on SUN')->first();
    $timeCard = new TimeCard();
    $timeCard->work_id = $work->id;
    $timeCard->time_card_format_id = $timeCardFormat->id;
    if (!is_null($timeCard = TimeCard::checkIfExists($timeCard))) {
        $timeCardHoursWorked = new TimeCardHoursWorked();
        $timeCardHoursWorked->work_id = $work->id;
        $timeCardHoursWorked->date_worked = $date;
        $timeCardHoursWorked->dow = "MON";
        if (is_null(TimeCardHoursWorked::checkIfDateWorkedDowExists($timeCardHoursWorked))) {
            $timeCardHoursWorked->hours_worked = 8.0;
            $timeCardHoursWorked->time_card_id = $timeCard->id;
            $timeCardHoursWorked->save();
        }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     if ($this->currentUser->hasAccess('wts.management.edit')) {
         DB::transaction(function () use($id) {
             $work = Work::where('id', '=', \Crypt::decrypt($id))->first();
             if ($work->file != '') {
                 \File::delete(public_path() . "/uploads/works-files/" . $work->file);
             }
             $work->delete();
         });
         return response()->json($this->deleteResponseMessage);
     } else {
         abort(403, $this->accessForbidden);
     }
 }