Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/durator'
Browse files Browse the repository at this point in the history
Conflicts:
	.gitignore
	app/controllers/AdminController.php
	app/controllers/AnswerController.php
	app/routes.php
  • Loading branch information
ayooby committed Aug 24, 2015
2 parents 535f737 + da47f38 commit 2b78773
Show file tree
Hide file tree
Showing 9 changed files with 127 additions and 6 deletions.
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
33 changes: 33 additions & 0 deletions 0byenqpg.ggt.txt
Original file line number Diff line number Diff line change
@@ -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
#

1 change: 1 addition & 0 deletions app/config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@
'URL' => 'Illuminate\Support\Facades\URL',
'Validator' => 'Illuminate\Support\Facades\Validator',
'View' => 'Illuminate\Support\Facades\View',
'MP3' => 'app\lib\MP3'

),

Expand Down
26 changes: 26 additions & 0 deletions app/controllers/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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
}

/**
Expand Down
46 changes: 46 additions & 0 deletions app/controllers/AnswerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public function postAnswer($question_id)
{

$validate = Validator::make(Input::all(), Answer::$rules);
<<<<<<< HEAD

if ($validate->passes())
{
Expand All @@ -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();
}

Expand Down
10 changes: 7 additions & 3 deletions app/controllers/Mp3Controller.php → app/lib/Mp3.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
class MP3File extends \BaseController
{

namespace app\lib;

class MP3{



protected $filename;
public function __construct($filename)
Expand Down Expand Up @@ -171,4 +175,4 @@ private static function framesize($layer, $bitrate,$sample_rate,$padding_bit)
return intval(((144 * $bitrate*1000)/$sample_rate) + $padding_bit);
}
}
}

4 changes: 2 additions & 2 deletions app/models/Answer.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class Answer extends \Eloquent {
// Add your validation rules here
public static $rules = [
'title' => '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'

];
Expand All @@ -18,4 +18,4 @@ public function question()
return $this->belongsTo('Question');
}

}
}
1 change: 1 addition & 0 deletions app/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

Route::controller('/user' , 'UsersController' );

<<<<<<< HEAD
Route::get('/test/', function(){
phpinfo();
});
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"app/models",
"app/database/migrations",
"app/database/seeds",
"app/tests/TestCase.php"
"app/tests/TestCase.php",
"app/lib"
]
},
"scripts": {
Expand Down

0 comments on commit 2b78773

Please sign in to comment.