Skip to content
This repository has been archived by the owner on Jan 13, 2024. It is now read-only.

Commit

Permalink
Merge pull request #25 from crocodic-studio/5.2
Browse files Browse the repository at this point in the history
bug fix route and improve
  • Loading branch information
fherryfherry authored Aug 24, 2016
2 parents fc51148 + c5eb83f commit 84dff7e
Show file tree
Hide file tree
Showing 5 changed files with 259 additions and 142 deletions.
1 change: 1 addition & 0 deletions src/CRUDBoosterServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public function boot()

require __DIR__.'/routes.php';
require __DIR__.'/helpers/Helper.php';

}

/**
Expand Down
12 changes: 6 additions & 6 deletions src/controllers/CBController.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public function constructor() {

$tablename = ucfirst($this->table);

$this->data['mainpath'] = $this->dashboard = url(config('crudbooster.ADMIN_PATH').'/'.Request::segment(2));
$this->data['mainpath'] = $this->dashboard = mainpath();

Session::put('current_mainpath',$this->data['mainpath']);

Expand Down Expand Up @@ -412,7 +412,7 @@ public function getIndex()
//LISTING INDEX HTML
$priv = $this->data['priv'];
$addaction = $this->data['addaction'];
$mainpath = $this->mainpath();
$mainpath = mainpath();
$title_field = $this->title_field;
$html_contents = array();
foreach($data['result'] as $row) {
Expand Down Expand Up @@ -662,7 +662,7 @@ public function getCurrentDataTables($id) {
}

public function getExportData() {
return redirect($this->mainpath());
return redirect(mainpath());
}

public function postExportData() {
Expand Down Expand Up @@ -936,13 +936,13 @@ public function postAddSave() {
insert_log("Add new data ".$this->arr[$this->title_field]." at ".$this->data['module_name']);

if(Request::get('addmore')) {
return redirect($this->mainpath().'/add?'.$ref_parameter)->with(['message'=>'The data has been added !, please add more...','message_type'=>'success']);
return redirect(mainpath().'/add?'.$ref_parameter)->with(['message'=>'The data has been added !, please add more...','message_type'=>'success']);
}

if(Request::get('referal')) {
return redirect(Request::get('referal'))->with(['message'=>'The data has been added !','message_type'=>'success']);
}else{
return redirect($this->mainpath().'/edit/'.$lastid.'?'.$ref_parameter)->with(['message'=>"The data has been added !",'message_type'=>'success']);
return redirect(mainpath().'/edit/'.$lastid.'?'.$ref_parameter)->with(['message'=>"The data has been added !",'message_type'=>'success']);
}

}
Expand Down Expand Up @@ -1014,7 +1014,7 @@ public function postEditSave($id) {
insert_log("Update data ".$this->arr[$this->title_field]." at ".$this->data['module_name']);

if(Request::get('addmore')) {
return redirect($this->mainpath().'/add?'.$ref_parameter)->with(['message'=>'The data has been added !, please add more...','message_type'=>'success']);
return redirect(mainpath().'/add?'.$ref_parameter)->with(['message'=>'The data has been added !, please add more...','message_type'=>'success']);
}

if(Request::get('referal')) {
Expand Down
38 changes: 38 additions & 0 deletions src/controllers/UploadsController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php namespace crocodicstudio\crudbooster\controllers;

use crocodicstudio\crudbooster\controllers\Controller;
use Illuminate\Support\Facades\Session;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Facades\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\Facades\PDF;
use Illuminate\Support\Facades\Excel;

class UploadsController extends Controller {

public function getFile($folder, $filename) {
$path = storage_path() . DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR . $folder . DIRECTORY_SEPARATOR . $filename;

if(!File::exists($path)) abort(404);

$file = File::get($path);
$type = File::mimeType($path);
$response = Response::make($file, 200);
$response->header("Content-Type", $type);

$seconds_to_cache = 3600 * (24*30);
$gmt_mtime = gmdate('D, d M Y H:i:s', time() ) . ' GMT';
$ts = gmdate("D, d M Y H:i:s", time() + $seconds_to_cache) . " GMT";
$response->header("Expires",$ts);
$response->header("Last-Modified",$gmt_mtime);
$response->header("Pragma","cache");
$response->header("Cache-Control","max-age=$seconds_to_cache, must-revalidate");
return $response;
}
}
Loading

0 comments on commit 84dff7e

Please sign in to comment.