public function searchShow($id) { $tutorial = Tutorial::find($id); $qa = Qa::find($id); if ($tutorial) { return Redirect::action('TutorialsController@show', $tutorial->id); } if ($qa) { return Redirect::action('QasController@show', $qa->id); } }
public function run() { $faker = Faker::create(); $users = User::all(); $qa = Qa::firstOrFail(); $tutorial = Tutorial::firstOrFail(); foreach (range(1, 50) as $index) { $user = $users->random(); Comment::create(['content' => $faker->sentence, 'user_id' => $user->id, 'qa_id' => $qa->id]); } foreach (range(1, 50) as $index) { $user = $users->random(); Comment::create(['content' => $faker->sentence, 'user_id' => $user->id, 'tutorial_id' => $tutorial->id]); } }
public function run() { $qas = Qa::all(); $tags = Tag::lists('id'); $last = count($tags) - 1; foreach ($qas as $qa) { $qa->tags()->attach($tags[rand(0, $last)]); } foreach ($qas as $qa) { $qa->tags()->attach($tags[rand(0, $last)]); } foreach ($qas as $qa) { $qa->tags()->attach($tags[rand(0, $last)]); } }
public function run() { $users = User::all(); $faker = Faker::create(); foreach (range(1, 5) as $index) { $user = $users->random(); Qa::create(['question' => "Why Is The Blazer Not Shifting Into 4-wheel Drive?", 'content' => "I need fuel. Go ahead, quick, get in the car. Time machine, I haven't invented any time machine. Safe now, everything's let lined. Don't you lose those tapes now, we'll need a record. Wup, wup, I almost forgot my luggage. Who knows if they've got cotton underwear in the future. I'm allergic to all synthetics. Never? Unroll their fire.", 'image' => '/uploaded/stockimage.png', 'user_id' => $user->id, 'video' => '/uploaded/traffic.mov']); } foreach (range(1, 5) as $index) { $user = $users->random(); Qa::create(['question' => "Water Leak", 'content' => "I need fuel. Go ahead, quick, get in the car. Time machine, I haven't invented any time machine. Safe now, everything's let lined. Don't you lose those tapes now, we'll need a record. Wup, wup, I almost forgot my luggage. Who knows if they've got cotton underwear in the future. I'm allergic to all synthetics. Never? Unroll their fire.", 'image' => '/uploaded/stockimage.png', 'user_id' => $user->id, 'video' => '/uploaded/traffic.mov']); } foreach (range(1, 5) as $index) { $user = $users->random(); Qa::create(['question' => "What is that sound?", 'content' => "I need fuel. Go ahead, quick, get in the car. Time machine, I haven't invented any time machine. Safe now, everything's let lined. Don't you lose those tapes now, we'll need a record. Wup, wup, I almost forgot my luggage. Who knows if they've got cotton underwear in the future. I'm allergic to all synthetics. Never? Unroll their fire.", 'image' => '/uploaded/stockimage.png', 'user_id' => $user->id, 'video' => '/uploaded/traffic.mov']); } foreach (range(1, 5) as $index) { $user = $users->random(); Qa::create(['question' => "Why does my AC smell like gas when I'm going over 45mph?", 'content' => "I need fuel. Go ahead, quick, get in the car. Time machine, I haven't invented any time machine. Safe now, everything's let lined. Don't you lose those tapes now, we'll need a record. Wup, wup, I almost forgot my luggage. Who knows if they've got cotton underwear in the future. I'm allergic to all synthetics. Never? Unroll their fire.", 'image' => '/uploaded/stockimage.png', 'user_id' => $user->id, 'video' => '/uploaded/traffic.mov']); } foreach (range(1, 5) as $index) { $user = $users->random(); Qa::create(['question' => "Why do my tires smell like burned rubber coming out of a start?", 'content' => "I need fuel. Go ahead, quick, get in the car. Time machine, I haven't invented any time machine. Safe now, everything's let lined. Don't you lose those tapes now, we'll need a record. Wup, wup, I almost forgot my luggage. Who knows if they've got cotton underwear in the future. I'm allergic to all synthetics. Never? Unroll their fire.", 'image' => '/uploaded/stockimage.png', 'user_id' => $user->id, 'video' => '/uploaded/traffic.mov']); } foreach (range(1, 5) as $index) { $user = $users->random(); Qa::create(['question' => "How do I change my windshield wipers?", 'content' => "I need fuel. Go ahead, quick, get in the car. Time machine, I haven't invented any time machine. Safe now, everything's let lined. Don't you lose those tapes now, we'll need a record. Wup, wup, I almost forgot my luggage. Who knows if they've got cotton underwear in the future. I'm allergic to all synthetics. Never? Unroll their fire.", 'image' => '/uploaded/stockimage.png', 'user_id' => $user->id, 'video' => '/uploaded/traffic.mov']); } foreach (range(1, 5) as $index) { $user = $users->random(); Qa::create(['question' => "What is that weird thump I hear from the rear of the car?", 'content' => "I need fuel. Go ahead, quick, get in the car. Time machine, I haven't invented any time machine. Safe now, everything's let lined. Don't you lose those tapes now, we'll need a record. Wup, wup, I almost forgot my luggage. Who knows if they've got cotton underwear in the future. I'm allergic to all synthetics. Never? Unroll their fire.", 'image' => '/uploaded/stockimage.png', 'user_id' => $user->id, 'video' => '/uploaded/traffic.mov']); } foreach (range(1, 5) as $index) { $user = $users->random(); Qa::create(['question' => "What is the average air speed velocity of a laden swallow?", 'content' => "I need fuel. Go ahead, quick, get in the car. Time machine, I haven't invented any time machine. Safe now, everything's let lined. Don't you lose those tapes now, we'll need a record. Wup, wup, I almost forgot my luggage. Who knows if they've got cotton underwear in the future. I'm allergic to all synthetics. Never? Unroll their fire.", 'image' => '/uploaded/stockimage.png', 'user_id' => $user->id, 'video' => '/uploaded/traffic.mov']); } foreach (range(1, 5) as $index) { $user = $users->random(); Qa::create(['question' => "What is wrong with my exhaust system?", 'content' => "I need fuel. Go ahead, quick, get in the car. Time machine, I haven't invented any time machine. Safe now, everything's let lined. Don't you lose those tapes now, we'll need a record. Wup, wup, I almost forgot my luggage. Who knows if they've got cotton underwear in the future. I'm allergic to all synthetics. Never? Unroll their fire.", 'image' => '/uploaded/stockimage.png', 'user_id' => $user->id, 'video' => '/uploaded/traffic.mov']); } }
public function vote($id) { $qa = Qa::findOrFail($id); // +1 or -1 $voteValue = Input::get('vote'); $vote = Vote::firstOrNew(['user_id' => Auth::id(), 'voteable_id' => $id, 'voteable_type' => 'Qa']); $vote->vote = $voteValue; $vote->save(); return Redirect::back(); }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public function loadModel($id) { $model = Qa::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }