public function search(Request $request)
 {
     $keyword = $request->keyword;
     if (!$keyword) {
         return redirect('/');
     }
     $entries = FileEntry::where("name", "LIKE", "%{$keyword}%")->paginate(15);
     return view('fileentries.search', compact('entries'));
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($path)
 {
     $entry = FileEntry::where('filename', '=', $path)->first();
     if ($entry == null || !Storage::exists($path)) {
         return response('NotFound', 404);
     } else {
         $file = Storage::get($entry->filename);
         return response($file)->header('Content-Type', $entry->mime);
     }
 }
 public function updateCover(Request $request, $id)
 {
     $store = Store::findOrFail($id);
     $file = $request->file('cover');
     $extension = $file->getClientOriginalExtension();
     $filename = 'stores/cover/' . $store->id . '/' . $file->getFilename() . '.' . $extension;
     Storage::disk('local')->put($filename, File::get($file));
     $entry = FileEntry::findOrNew($store->file_entries_id);
     if ($store->file_entries_id != 0) {
         Storage::disk('local')->delete($entry->filename);
     }
     $entry->mime = $file->getClientMimeType();
     $entry->original_filename = $file->getClientOriginalName();
     $entry->filename = $filename;
     $entry->save();
     $store->file_entries_id = $entry->id;
     $store->save();
     return response()->json(['id' => $entry->id]);
 }
Beispiel #4
0
    Route::get('callback', ['as' => 'wechat.callback', 'uses' => 'WechatController@callback']);
});
Route::group(['namespace' => 'Admin', 'prefix' => 'admin', 'middleware' => ['admin.auth', 'acl'], 'is' => 'administrator|assistant'], function () {
    Route::get('stores/{id}/classrooms', 'StoreController@getClassroomsByID');
    Route::post('stores/cover/{id}', 'StoreController@updateCover');
    Route::resource('stores', 'StoreController');
    Route::resource('classrooms', 'ClassroomController');
    Route::get('coaches/export', ['uses' => 'CoachController@exportExcel']);
    Route::resource('coaches', 'CoachController');
    Route::get('courses/list', 'CourseController@scheduleList');
    Route::get('courses/{id}/schedules', 'CourseController@getCourseSchedules');
    Route::get('course/check', 'CourseController@checkCourse');
    Route::post('courses/{id}/schedules', 'CourseController@saveCourseSchedules');
    Route::put('courses/schedules/{id}', 'CourseController@updateCourseSchedule');
    Route::delete('courses/schedules/{id}', 'CourseController@destroyCourseSchedule');
    Route::resource('courses', 'CourseController');
    Route::put('reserves/{id}/verify', ['uses' => 'ReserveController@verify']);
    Route::resource('reserves', 'ReserveController');
    Route::put('users/{id}/audit', ['uses' => 'UserController@audit']);
    Route::get('users/export', ['uses' => 'UserController@exportExcel']);
    Route::put('changePwd', ['uses' => 'UserController@changePwd']);
    Route::resource('users', 'UserController');
    Route::resource('roles', 'RoleController');
    Route::get('/', ['uses' => 'HomeController@getIndex']);
});
Route::controller('admin', 'AdminController');
Route::get('file/{id}', ['as' => 'getfile', function ($id) {
    $entry = FileEntry::find($id);
    $file = Storage::disk('local')->get($entry->filename);
    return (new Response($file, 200))->header('Content-Type', $entry->mime);
}]);
			    donut: {
			        title: "Outlines By Term"
			    }
			});
		</script>
	</div><!-- ./col-sm-6 -->
	
	<div class="col-sm-6">
		
		<p class="lead centered">Outlines Uploaded Per Month</p>
		<br class="clear" />
		
		<?php 
#x-axis: year
#y axis: 1L, 2L, 3L
$posts_by_month = FileEntry::all()->groupBy(function ($date) {
    return Carbon::parse($date->created_at)->format('Ym');
});
/*
	
Raw Results: 
foreach ($posts_by_month as $data_year_month=>$count_year_month) {
	echo $data_year_month.':'.count($count_year_month).'<br/>';
}
*/
//Create the arrays ($data_year_month for Dec-2015, $count_year_month for sum of created_at per each $data_year_month)
$array_data_year_month = [];
$array_count_year_month = [];
foreach ($posts_by_month as $data_year_month => $count_year_month) {
    // Assign each value to the array outside the foreach loop as you cycle through the foreach loop.
    $array_data_year_month[] = "'" . $data_year_month . "'";
 /**
  * Remove the specified resource from storage.
  *
  * @param int     $id
  * @return Response
  */
 public function delete(Request $request, $id)
 {
     $file = FileEntry::where('id', $id)->where('owner_id', $request->user()->id)->first();
     if (!$file) {
         $sys_notifications[] = array('type' => 'danger', 'message' => 'O arquivo não existe!');
         $request->session()->flash('sys_notifications', $sys_notifications);
         return back()->withInput($request->all());
     }
     if ($file->destroy($id)) {
         // Delete the file
         if (Storage::exists($request->user()->id . '/' . $file->original_filename)) {
             Storage::delete($request->user()->id . '/' . $file->original_filename);
         }
         $this->sys_notifications[] = array('type' => 'success', 'message' => '<strong><i class="fa fa-check"></i></strong> Arquivo excluído com sucesso!');
         $request->session()->flash('sys_notifications', $this->sys_notifications);
         return back()->withInput($request->all());
     } else {
         $this->sys_notifications[] = array('type' => 'danger', 'message' => '<strong><i class="fa fa-warning"></i></strong> Não foi possível excluir o arquivo!');
         $request->session()->flash('sys_notifications', $this->sys_notifications);
         return back()->withInput($request->all());
     }
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request, Validator $validator)
 {
     $data = $request->all();
     // dd($data);
     $data['technical_consult']['owner_id'] = $request->user()->id;
     $data['technical_consult']['color'] = (new Alfred())->randomColor();
     $data['email_message']['date'] = empty($data['email_message']['date']) ? date('Y-m-d') : $data['email_message']['date'];
     $data['email_message']['time'] = empty($data['email_message']['time']) ? date('H:i') : $data['email_message']['time'];
     // CRIA CONSULTA TÉCNICA
     if (isset($data['technical_consult_id']) && $data['technical_consult_id'] > 0) {
         $technical_consult = TechnicalConsult::find($data['technical_consult_id']);
     } else {
         $technical_consult = TechnicalConsult::create($data['technical_consult']);
     }
     if (!$technical_consult) {
         $this->sys_notifications[] = array('type' => 'danger', 'message' => 'Erro ao criar consulta técnica');
         $request->session()->flash('sys_notifications', $this->sys_notifications);
         return back()->withInput($request->all());
     }
     $email_data = $data['email_message'];
     $email_data['date'] = date('Y-m-d H:i:s', strtotime($email_data['date'] . ' ' . $email_data['time'] . ':00'));
     $contact = Contact::find($data['technical_consult']['contact_id']);
     $email_data['to'] = $contact->email;
     $email_data['toname'] = $contact->name;
     $email_data['from'] = $request->user()->email;
     $email_data['subject'] = $data['technical_consult']['title'];
     $email_data['consulta_tecnica_id'] = $technical_consult->id;
     $email_data['owner_id'] = $request->user()->id;
     $email_data['body_html'] = $data['technical_consult']['description'];
     $email_data['body_text'] = strip_tags($data['technical_consult']['description']);
     $email_data['email_message_id'] = $data['email_message_id'] && !empty($data['email_message_id']) ? $data['email_message_id'] : null;
     // CRIA EMAIL MESSAGE
     $email_message = EmailMessage::create($email_data);
     if (!$email_message) {
         $this->sys_notifications[] = array('type' => 'danger', 'message' => $validator->errors()->first());
         $request->session()->flash('sys_notifications', $this->sys_notifications);
         return back()->withInput($request->all());
     }
     // ATTACH FILES
     $files = $request->file('file');
     if ($files[0] != null) {
         $filesupload = (new FileEntryController())->upload($request, false, $email_message->id);
         if ($filesupload['uploaded'] > 0) {
             // $this->sys_notifications[] = array('type' => 'success', 'message' => $filesupload['uploaded'] . ' arquivos anexados');
         }
     }
     $anexos = array();
     if (!empty($filesupload['ids'])) {
         foreach ($filesupload['ids'] as $key => $fileid) {
             $entry = FileEntry::find($fileid);
             $entry->email_message_id = $email_message->id;
             $entry->save();
             $anexos[] = $entry;
         }
     }
     // SEND MAIL
     if ($email_data['type'] == 1) {
         Mail::send('emails.message', ['email_data' => $email_data], function ($message) use($email_data, $anexos, $request, $email_message, $technical_consult) {
             foreach ($anexos as $anexo) {
                 $message->attach(storage_path('app/' . $request->user()->id . '/' . $email_message->id . '/' . $anexo->original_filename));
             }
             $message->from($email_data['from'], 'Consultas Técnicas');
             $message->to($email_data['to'], $email_data['toname'])->subject('Consulta Técnica CT0' . $technical_consult->id);
             $message->bcc('*****@*****.**', $email_data['toname'])->subject('Consulta Técnica CT0' . $technical_consult->id);
         });
     }
     $this->sys_notifications[] = array('type' => 'success', 'message' => 'Nova consulta técnica registrada com sucesso!');
     $request->session()->flash('sys_notifications', $this->sys_notifications);
     return redirect('obras/');
     return back()->withInput($request->all());
 }
 public function year()
 {
     $year_2009 = FileEntry::where('year', '=', 2009)->get();
     $year_2010 = FileEntry::where('year', '=', 2010)->get();
     $year_2011 = FileEntry::where('year', '=', 2011)->get();
     $year_2012 = FileEntry::where('year', '=', 2012)->get();
     $year_2013 = FileEntry::where('year', '=', 2013)->get();
     $year_2014 = FileEntry::where('year', '=', 2014)->get();
     $year_2015 = FileEntry::where('year', '=', 2015)->get();
     $year_2016 = FileEntry::where('year', '=', 2016)->get();
     $count_year_2009 = FileEntry::where('year', '=', 2009)->count();
     $count_year_2010 = FileEntry::where('year', '=', 2010)->count();
     $count_year_2011 = FileEntry::where('year', '=', 2011)->count();
     $count_year_2012 = FileEntry::where('year', '=', 2012)->count();
     $count_year_2013 = FileEntry::where('year', '=', 2013)->count();
     $count_year_2014 = FileEntry::where('year', '=', 2014)->count();
     $count_year_2015 = FileEntry::where('year', '=', 2015)->count();
     $count_year_2016 = FileEntry::where('year', '=', 2016)->count();
     $join_get_full_name = DB::table('file_entries')->join('users', 'users.email', '=', 'file_entries.submitting_user_email')->select('users.user_first_name', 'users.user_last_name')->take(1)->get();
     return view('browse.year', compact('year_2009', 'year_2010', 'year_2011', 'year_2012', 'year_2013', 'year_2014', 'year_2015', 'year_2016', 'count_year_2009', 'count_year_2010', 'count_year_2011', 'count_year_2012', 'count_year_2013', 'count_year_2014', 'count_year_2015', 'count_year_2016', 'join_get_full_name'));
 }
 public function __construct()
 {
     $entries = FileEntry::latest()->take(10)->get();
     View::share('entries', $entries);
 }
Beispiel #10
0
 public function subscriptioncallback(Request $request)
 {
     if ($request->has('hub_mode')) {
         if ($request->get('hub_mode') == 'subscribe') {
             print $request->get('hub_challenge');
             exit(1);
         }
     } else {
         $objects = $request->json()->all();
         foreach ($objects as $object) {
             $instagram = new InstagramAPI();
             $instagramAccount = InstagramAccount::where('instagram_id', $object['object_id'])->first();
             if ($instagramAccount->isSupplier()) {
                 $instagram->setAccessToken($instagramAccount->access_token);
                 $media = $instagram->getUserMedia($instagramAccount->instagram_id, 1);
                 if ($media->meta->code == 200) {
                     foreach ($media->data as $singleMedia) {
                         $isKoalaProduct = false;
                         foreach ($singleMedia->tags as $tag) {
                             if ($tag == 'koalabazaar') {
                                 $isKoalaProduct = true;
                             }
                         }
                         if ($isKoalaProduct && $singleMedia->type == 'image' && ProductsInstagram::where('id', '=', $singleMedia->id)->first() == null) {
                             $caption = null;
                             if (isset($singleMedia->caption)) {
                                 $caption = $singleMedia->caption->text;
                             }
                             $product = new Product();
                             $product->supplier_id = $instagramAccount->instagramable->id;
                             $product->title = $caption;
                             $product->description = $caption;
                             $file = new FileEntry();
                             $status = $file->storeFromUrl($singleMedia->images->standard_resolution->url, $instagramAccount->instagramable->id, 'product');
                             if ($status) {
                                 $product->image = $file->filename;
                             } else {
                                 $product->image = null;
                             }
                             if ($caption == null) {
                                 $product->price = null;
                                 $product->currency_unit_id = null;
                             } else {
                                 $text = mb_strtolower($caption, 'UTF-8');
                                 $units = CurrencyUnit::all();
                                 $estimatedPrice = null;
                                 $currencyUnit = null;
                                 foreach ($units as $unit) {
                                     $firstOccurence = stripos($text, $unit->unit_short_name);
                                     if ($firstOccurence) {
                                         for ($i = $firstOccurence - 1; $i >= 0; $i--) {
                                             $charAt = substr($text, $i, 1);
                                             if (is_numeric($charAt) || $charAt == '.') {
                                                 $estimatedPrice = $charAt . $estimatedPrice;
                                             } else {
                                                 $i = 0;
                                             }
                                         }
                                         $currencyUnit = $unit->id;
                                         break;
                                     }
                                 }
                                 if ($estimatedPrice) {
                                     $product->price = $estimatedPrice;
                                     $product->currency_unit_id = $currencyUnit;
                                 } else {
                                     $product->price = null;
                                     $product->currency_unit_id = null;
                                 }
                             }
                             if ($product->price == null || $product->currency_unit_id == null) {
                                 $product->is_active = false;
                             } else {
                                 $product->is_active = true;
                             }
                             $product->save();
                             foreach ($singleMedia->tags as $tag) {
                                 $relatedCategories = Category::where('keywords', 'LIKE', '%' . mb_strtolower($tag, 'UTF-8') . '%')->get();
                                 foreach ($relatedCategories as $relatedCategory) {
                                     if ($product->categories()->where('id', $relatedCategory->id)->first()) {
                                     } else {
                                         $product->categories()->attach($relatedCategory);
                                     }
                                 }
                             }
                             $productInstagram = new ProductsInstagram();
                             $productInstagram->product_id = $product->id;
                             $productInstagram->url = $singleMedia->link;
                             $productInstagram->id = $singleMedia->id;
                             $productInstagram->image_url = $singleMedia->images->standard_resolution->url;
                             $productInstagram->caption = $caption;
                             $productInstagram->created_on_instagram = date('Y-m-d h:i:sa', $singleMedia->created_time);
                             $productInstagram->save();
                         }
                     }
                 }
             }
         }
     }
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request, Validator $validator)
 {
     $data = $request->all();
     if (!isset($data['email_message']['project_id'])) {
         return 'Informe a obra';
     }
     $obra = Obra::find(@$data['email_message']['project_id']);
     $data['technical_consult']['cod'] = $obra->consultas_tecnicas->max('cod') + 1;
     switch (@$data['email_message']['type']) {
         case 0:
             // CRIA ACONTECIMENTO
             $technical_consult = ConsultaTecnica::create($data['technical_consult']);
             // CRIA EMAIL MESSAGE
             $email_message = new EmailMessage();
             break;
         case 2:
             // REGISTRAR RETORNO
             $technical_consult = ConsultaTecnica::find($data['technical_consult']['id']);
             // CRIA EMAIL MESSAGE
             $email_message = new EmailMessage();
             $email_message->email_message_id = $data['email_message']['email_message_id'];
             break;
         default:
             // CRIA CONSULTA TÉCNICA
             $technical_consult = new ConsultaTecnica();
             $technical_consult->owner_id = $request->user()->id;
             $technical_consult->color = (new Alfred())->randomColor();
             $technical_consult->project_id = @$data['technical_consult']['project_id'];
             $technical_consult->project_stage_id = @$data['technical_consult']['project_stage_id'];
             $technical_consult->project_discipline_id = @$data['technical_consult']['project_discipline_id'];
             $technical_consult->title = @$data['technical_consult']['title'];
             $technical_consult->cod = $data['technical_consult']['cod'];
             $technical_consult->save();
             // CRIA EMAIL MESSAGE
             $email_message = new EmailMessage();
             break;
     }
     if (isset($data['email_message']['date'])) {
         $date = str_replace('/', '-', $data['email_message']['date']);
     } else {
         $date = date('Y-m-d');
     }
     $data['email_message']['date'] = empty($data['email_message']['date']) ? date('Y-m-d') : date('Y-m-d', strtotime($date));
     $data['email_message']['time'] = empty($data['email_message']['time']) ? date('H:i') : $data['email_message']['time'];
     $email_message->date = date('Y-m-d H:i:s', strtotime($data['email_message']['date'] . ' ' . $data['email_message']['time']));
     // DADOS PARA O CORPO DO EMAIL
     $email_data = $data['email_message'];
     $email_data['obra'] = $technical_consult->project->title;
     $email_data['subject'] = $technical_consult->title;
     $email_data['consulta_tecnica_id'] = $technical_consult->formattedCod('CT #');
     $email_data['etapa'] = $technical_consult->projectstage ? $technical_consult->projectstage->title : '';
     $email_data['disciplina'] = $technical_consult->projectdiscipline ? $technical_consult->projectdiscipline->title : '';
     $email_data['body_html'] = $email_data['description'];
     // dd($email_data);
     $contatos = array();
     $email_data_to['contato_emails'] = array();
     $email_message->type = null !== @$email_data['type'] ? $email_data['type'] : 1;
     if (null == @$email_data['to']) {
         $email_data['to'] = EmailMessage::find($email_message->email_message_id)->to;
         $email_data['to'] = explode(',', @$email_data['to']);
     }
     foreach ($email_data['to'] as $contato_id) {
         $contato = Contato::find($contato_id);
         if (null !== $contato) {
             $contatos[] = $contato;
             $email_data_to['contato_emails'][] = $contato->email;
         }
     }
     $email_message->to = implode(',', $email_data_to['contato_emails']);
     $email_message->from = $request->user()->email;
     $email_message->subject = $email_data['subject'];
     $email_message->consulta_tecnica_id = $technical_consult->id;
     $email_message->owner_id = $request->user()->id;
     $email_message->body_html = $email_data['description'];
     $email_message->rating = @$email_data['rating'];
     $email_message->private = null === @$email_data['private'] ? false : true;
     // SALVA EMAIL MESSAGE
     $email_message->save();
     if (!$technical_consult) {
         $this->sys_notifications[] = array('type' => 'danger', 'message' => 'Erro ao adicionar consulta técnica');
         $request->session()->flash('sys_notifications', $this->sys_notifications);
         return back()->withInput($request->all());
     }
     if (!$email_message) {
         $this->sys_notifications[] = array('type' => 'danger', 'message' => $validator->errors()->first());
         $request->session()->flash('sys_notifications', $this->sys_notifications);
         return back()->withInput($request->all());
     }
     // ENVIAR EMAIL
     if ($email_message->type == 1 && "on" == @$data['sendnow']) {
         // ATTACH FILES
         $files = $request->file('file');
         if ($files[0] != null) {
             $filesupload = (new FileEntryController())->upload($request, false, $email_message->id);
             if ($filesupload['uploaded'] > 0) {
                 // $this->sys_notifications[] = array('type' => 'success', 'message' => $filesupload['uploaded'] . ' arquivos anexados');
             }
         }
         $anexos = array();
         if (!empty($filesupload['ids'])) {
             foreach ($filesupload['ids'] as $key => $fileid) {
                 $entry = FileEntry::find($fileid);
                 $entry->email_message_id = $email_message->id;
                 $entry->save();
                 $anexos[] = $entry;
             }
         }
         // SEND MAIL TO ME
         if (null !== @$data['sendtome']) {
             $email_data['bcc'] = $request->user()->email;
         }
         // PROCESS THE JOB
         $this->dispatch(new SendEmail($email_data, $anexos, $request, $email_message, $technical_consult, $contatos));
         // return view('emails.message', compact('email_data', 'anexos', 'request', 'email_message', 'technical_consult', 'contatos'));
         $this->sys_notifications[] = array('type' => 'success', 'message' => 'E-mail enviado!');
     }
     $this->sys_notifications[] = array('type' => 'success', 'message' => 'Consulta Técnica registrada com sucesso!');
     $request->session()->flash('sys_notifications', $this->sys_notifications);
     return redirect('obras/' . $technical_consult->project_id);
 }