Esempio n. 1
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     factory(App\Project::class, 20)->create()->each(function ($project) {
         $max = rand(5, 10);
         for ($i = 0; $i < $max; $i++) {
             $project->goal()->save(factory(App\Goal::class)->make());
         }
         $max = rand(5, 10);
         for ($i = 0; $i < $max; $i++) {
             $project->reward()->save(factory(App\Reward::class)->make());
         }
         $max = rand(5, 20);
         for ($i = 0; $i < $max; $i++) {
             $project->payment()->save(factory(App\Payment::class)->make());
         }
         $max = rand(5, 20);
         for ($i = 0; $i < $max; $i++) {
             $project->comment()->save(factory(App\Comment::class)->make(['type' => 1]));
         }
         $max = rand(5, 20);
         for ($i = 0; $i < $max; $i++) {
             $project->updates()->save(factory(App\Content::class)->make(['type' => 3]));
         }
     });
     $payments = App\Payment::where('value', 0)->get();
     foreach ($payments as $p) {
         $project = App\Project::find($p->project_id);
         $reward = $project->reward()->orderBy(DB::raw('RAND()'))->take(1)->first();
         $p->value = $reward->value;
         $p->reward_id = $reward->id;
         $p->save();
     }
     $comments = App\Comment::where('type', 1)->where('reply_id', 1)->get();
     foreach ($comments as $c) {
         $parents = App\Comment::where('type', 1)->where('item_id', $c->item_id)->orderByRaw("RAND()")->first();
         if ($parents) {
             $c->reply_id = $parents->id;
             $c->save();
         }
     }
 }
Esempio n. 2
0
<?php

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
Route::get('/', function () {
    return view('welcome');
});
/*
Route::bind('tasks', function($value, $route) {
	return App\Task::whereSlug($value)->first();
});
Route::bind('projects', function($value, $route) {
	return App\Project::whereSlug($value)->first();
});
*/
Route::bind('tasks', function ($value, $route) {
    return App\Task::find($value)->first();
});
Route::bind('projects', function ($value, $route) {
    return App\Project::find($value)->first();
});
Route::resource('projects', 'ProjectsController');
Route::resource('projects.tasks', 'TasksController');