/** * Execute the console command. * * @return mixed */ public function handle() { $posts = Post::all(['slug', 'updated_at']); $works = Work::all(['slug', 'updated_at']); $this->sitemap = new Sitemap(public_path('sitemap.xml')); $this->comment('Starting generating the Sitemap...'); // Home $this->addItem(config('app.url') . '/', 0.9); // Resume $this->addItem(config('app.url') . '/resume', 0.8); // Blog index $this->addItem(config('app.url') . '/blog', 0.8); // Works index $this->addItem(config('app.url') . '/works', 0.8); // @codeCoverageIgnoreStart // Blog posts foreach ($posts as $post) { $this->addItem(config('app.url') . '/blog/' . $post->slug, 0.7); } // Works items foreach ($works as $work) { $this->addItem(config('app.url') . '/works/' . $work->slug, 0.7); } // @codeCoverageIgnoreEnd $this->sitemap->write(); $this->comment('Sitemap generated successfully!'); }
/** * Bootstrap any application services. * * @return void */ public function boot() { WorkCategory::saving(function ($workCategory) { if ($workCategory->position > 0) { return true; } $workCategory->position = WorkCategory::max('position') + 1; return $workCategory; }); Work::saving(function ($work) { if ($work->position > 0) { return true; } $work->position = Work::max('position') + 1; return $work; }); Image::deleted(function ($image) { if (file_exists($image->path)) { unlink($image->path); } if (file_exists($image->thumbnail)) { unlink($image->thumbnail); } return true; }); }
/** * Display the specified resource. * * @param int $id * @return Response */ public function show($slug) { $post = Post::where('slug', $slug)->firstOrFail(); $moreWorks = Work::orderByRaw('RAND()')->take(3)->get(); $morePosts = Post::where('slug', '!=', $post->slug)->orderByRaw('RAND()')->take(3)->get(); return view('posts.show', compact("post", "moreWorks", "morePosts")); }
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() { // clear table \App\Work::truncate(); // add 1st row \App\Work::create(['user_id' => 1, 'title' => 'Software Engineer', 'company' => 'Google Inc']); // add 2nd row \App\Work::create(['user_id' => 1, 'title' => 'System Administrator', 'company' => 'IBM', 'start' => \Carbon\Carbon::createFromDate(2010, 01, 10)->toDateTimeString(), 'end' => \Carbon\Carbon::createFromDate(2014, 07, 22)->toDateTimeString()]); }
public function getMore($excludes) { $excludes = explode("SEPARATOR", $excludes); $whereString = ""; foreach ($excludes as $exclude) { $whereString = $whereString . "slug != ? AND "; } $whereString = substr($whereString, 0, -5); $works = Work::whereRaw($whereString, $excludes)->take(3)->orderBy("created_at", "desc")->get(); return view("works.ajax")->with("works", $works); }
/** * 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(); } }
/** * Run the database seeds. * * @return void */ public function run() { DB::table('tags')->truncate(); factory(App\Tag::class, 10)->create(); $posts = Post::all(); foreach ($posts as $post) { $tags = Tag::orderByRaw('RAND()')->take(rand(1, 5))->get(['id']); $post->tags()->sync($tags); } $works = Work::all(); foreach ($works as $work) { $tags = Tag::orderByRaw('RAND()')->take(rand(1, 5))->get(['id']); $work->tags()->sync($tags); } }
public function getWorks($parCategory) { // Retrieve offset param $offset = Input::get('offset'); // Try to get current category by slug $category = Category::where('slug', $parCategory)->get()->first(); // If not found try by id if (is_null($category)) { $category = Category::find($parCategory); } // Retrieve all works $works = is_null($category) ? Work::all() : $category->works; // Return the view return view('front.works', compact('works')); }
public function run() { $faker = Faker\Factory::create(); for ($i = 0; $i < 15; $i++) { $work['title'] = $faker->name; $work['intro_text'] = $faker->sentence($words = rand(10, 15)); $work['lead'] = $faker->sentence($words = rand(10, 20)); $work['content'] = $faker->sentence($words = rand(20, 40)); $work['slug'] = $this->makeSlug($work['title']); $work['is_visible'] = 1; $work['is_featured'] = rand(0, 1); $work['gallery_id'] = 1; $work['type_id'] = rand(1, 5); \App\Work::create($work); } }
/** * Register any other events for your application. * * @param \Illuminate\Contracts\Events\Dispatcher $events * @return void */ public function boot(DispatcherContract $events) { parent::boot($events); // register the ProjectObserver class. Client::observe(new ClientObserver()); // register the ProjectObserver class. Project::observe(new ProjectObserver()); // register the WorkTypeObserver class. WorkType::observe(new WorkTypeObserver()); // register the TimeCardFormatObserver class. TimeCardFormat::observe(new TimeCardFormatObserver()); // register the WorkObserver class. Work::observe(new WorkObserver()); // register the TimeCardObserver class. TimeCard::observe(new TimeCardObserver()); // register the TimeCardHoursWorkedObserver class. TimeCardHoursWorked::observe(new TimeCardHoursWorkedObserver()); // register the TaskTypeObserver class. TaskType::observe(new TaskTypeObserver()); // register the TaskObserver class. Task::observe(new TaskObserver()); }
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()); }
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');
/** * Display the specified resource. * * @param Request $request * @param CV $cv * @return \Illuminate\Http\Response */ public function show(Request $request, CV $cv) { // Get the cv sections. $sections = $cv->sections()->get(); // Build empty subsections. $workSection = array(); $languageSection = array(); $educationSection = array(); $hobbySection = array(); $skillSection = array(); // For each section, determine it's type, and append it's data to the corresponding subsection. foreach ($sections as $section) { $w = Work::whereSectionId($section->id)->get(['name', 'location', 'title', 'description', 'start_date', 'end_date'])->toArray(); $l = Language::whereSectionId($section->id)->get(['name', 'level', 'creditation'])->toArray(); $e = Education::whereSectionId($section->id)->get(['name', 'location', 'title', 'description', 'start_date', 'end_date'])->toArray(); $h = Hobby::whereSectionId($section->id)->get(['text'])->toArray(); $s = Skill::whereSectionId($section->id)->get(['name', 'level', 'description'])->toArray(); if (count($w) != 0) { array_push($workSection, $w); } if (count($l) != 0) { array_push($languageSection, $l); } if (count($e) != 0) { array_push($educationSection, $e); } if (count($h) != 0) { array_push($hobbySection, $h); } if (count($s) != 0) { array_push($skillSection, $s); } } return view('pages.cvs.show', ['cv' => $cv, 'user' => $request->user(), 'workSection' => $workSection, 'languageSection' => $languageSection, 'educationSection' => $educationSection, 'hobbySection' => $hobbySection, 'skillSection' => $skillSection]); }
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]); } }
/** * 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(); }
/** * 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); } }
/** * Remove the specified resource from storage. * * @param int $id * * @return \Illuminate\Http\Response */ public function destroy($id) { Work::destroy($id); return back(); }
/** * 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)); }
/** * 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'); }
/** * Display a listing of the resource. * * @return Response */ public function index() { $works = Work::orderBy('created_at', 'DESC')->take(3)->get(); $posts = Post::orderBy('created_at', 'DESC')->take(3)->get(); return view('index', compact(['works', 'posts'])); }
$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 RedirectResponse */ public function destroy(int $id) : RedirectResponse { if (Work::destroy($id) > 0) { return Redirect::back()->with('message', ucfirst(trans('back/work.success_deleted'))); } else { return Redirect::back()->with('message', ucfirst(trans('back/work.error_deleted'))); } }
/** * Displays table of the resources for admin * * @return Response */ public function manage() { $works = Work::all(); return view('works.manage', compact('works')); }