diff --git a/.gitignore b/.gitignore index 352698a..1f28f46 100644 --- a/.gitignore +++ b/.gitignore @@ -48,9 +48,18 @@ $RECYCLE.BIN/ # Windows shortcuts *.lnk +<<<<<<< HEAD /bootstrap/compiled.php /vendor composer.phar composer.lock *.mp3 +======= +vendor/ + +#Media Files +*.mp3 +*.ogg +*.mp4 +>>>>>>> origin/durator diff --git a/0byenqpg.ggt.txt b/0byenqpg.ggt.txt new file mode 100644 index 0000000..2e013d7 --- /dev/null +++ b/0byenqpg.ggt.txt @@ -0,0 +1,33 @@ +Merge remote-tracking branch 'origin/durator' + +Conflicts: + .gitignore + app/controllers/AdminController.php + app/controllers/AnswerController.php + app/routes.php +# +# It looks like you may be committing a merge. +# If this is not correct, please remove the file +# .git/MERGE_HEAD +# and try again. + + +# Please enter the commit message for your changes. Lines starting +# with '#' will be ignored, and an empty message aborts the commit. +# On branch master +# Your branch is ahead of 'origin/master' by 1 commit. +# (use "git push" to publish your local commits) +# +# All conflicts fixed but you are still merging. +# +# Changes to be committed: +# modified: .gitignore +# modified: app/config/app.php +# modified: app/controllers/AdminController.php +# modified: app/controllers/AnswerController.php +# renamed: app/controllers/Mp3Controller.php -> app/lib/Mp3.php +# modified: app/models/Answer.php +# modified: app/routes.php +# modified: composer.json +# + diff --git a/app/config/app.php b/app/config/app.php index a762311..d2fbd6b 100644 --- a/app/config/app.php +++ b/app/config/app.php @@ -191,6 +191,7 @@ 'URL' => 'Illuminate\Support\Facades\URL', 'Validator' => 'Illuminate\Support\Facades\Validator', 'View' => 'Illuminate\Support\Facades\View', + 'MP3' => 'app\lib\MP3' ), diff --git a/app/controllers/AdminController.php b/app/controllers/AdminController.php index a07d562..60aa6af 100644 --- a/app/controllers/AdminController.php +++ b/app/controllers/AdminController.php @@ -50,6 +50,7 @@ public function store() $name = time() . "-" . $audio->getClientOriginalName(); $avatar = $audio->move("./answers/",$name); +<<<<<<< HEAD $answer = new Answer; $answer->title=Input::get('title'); $answer->info=Input::get('info'); @@ -63,6 +64,31 @@ public function store() $answer->save(); return Redirect::route('answer.admin.index'); +======= + $audio = Input::file('audio'); + $name = time() . "-" . $audio->getClientOriginalName(); + $avatar = $audio->move("./answers/",$name); + + $answer= new Answer; + $answer->title=Input::get('title'); + $answer->info=Input::get('info'); + $answer->audio=$name; + if (Auth::check()){ + $answer->user_id=Auth::id(); + }else{ + $answer->user_id=0; + } + $answer->save(); + return Redirect::route('answer.admin..index'); + + + } + + return Redirect::back()->withErrors($validate)->withInput(); + + + +>>>>>>> origin/durator } /** diff --git a/app/controllers/AnswerController.php b/app/controllers/AnswerController.php index e067fa7..04513c9 100644 --- a/app/controllers/AnswerController.php +++ b/app/controllers/AnswerController.php @@ -40,6 +40,7 @@ public function postAnswer($question_id) { $validate = Validator::make(Input::all(), Answer::$rules); +<<<<<<< HEAD if ($validate->passes()) { @@ -62,6 +63,51 @@ public function postAnswer($question_id) return Redirect::action('QuestionController@index'); } +======= + + if ($validate->passes()){ + + //get file from input + $audio = Input::file('audio'); + + //get file's temporary path in server + $file_temporary_path = $audio->getPathname(); + + //create MP3 Object + $audio_file = new MP3( $file_temporary_path ); + + $duration = $audio_file->getDuration(); + + #Do same thing in 1 line: + #$duration = with(new MP3($audio->getPathname()))->getDuration(); + + //check if audio is less than/equal to 120 Seconds, then save it! + if ($duration <= 120){ //seconds + + $name = time() . '-' . $audio->getClientOriginalName(); + + //Move file from temporary folder to PUBLIC folder. + //PUBLIC folder because we want user have access to this file later. + $avatar = $audio->move( public_path() . '/answers/', $name); + + $answer= new Answer; + $answer->title=Input::get('title'); + $answer->info=Input::get('info'); + $answer->audio = $name; + + if (Auth::check()){ + $answer->user_id=Auth::id(); + }else{ + $answer->user_id=0; + } + + $answer->save(); + } + + return Redirect::action('AnswerController@index'); + } + +>>>>>>> origin/durator return Redirect::back()->withErrors($validate)->withInput(); } diff --git a/app/controllers/Mp3Controller.php b/app/lib/Mp3.php similarity index 99% rename from app/controllers/Mp3Controller.php rename to app/lib/Mp3.php index 3707f46..6f3f75b 100644 --- a/app/controllers/Mp3Controller.php +++ b/app/lib/Mp3.php @@ -1,6 +1,10 @@ 'required|between:3,60|unique:answers,title', - 'audio' => 'required|mimes:mpga,aac,ogg|max:2000', + 'audio' => 'required|mimes:mpga,aac,ogg', 'info' => 'required|max:100' ]; @@ -18,4 +18,4 @@ public function question() return $this->belongsTo('Question'); } -} \ No newline at end of file +} diff --git a/app/routes.php b/app/routes.php index d83c120..8055afd 100644 --- a/app/routes.php +++ b/app/routes.php @@ -27,6 +27,7 @@ Route::controller('/user' , 'UsersController' ); +<<<<<<< HEAD Route::get('/test/', function(){ phpinfo(); }); diff --git a/composer.json b/composer.json index 3e1a52d..c68d079 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,8 @@ "app/models", "app/database/migrations", "app/database/seeds", - "app/tests/TestCase.php" + "app/tests/TestCase.php", + "app/lib" ] }, "scripts": {