/** * Store a newly created resource in storage. * * @return Response */ public function store(Requests\CreateProjectRequest $response) { // $data = $response->all(); //dd ($data); $projects = new \App\Project($data); //dd($customers); $projects->save(); return redirect('admin/project'); }
public function postCreate(Request $request) { $this->validate($request, ['title' => 'required|max:50', 'year' => 'required', 'month' => 'required', 'day' => 'required']); $year = $request->year; $month = $request->month; $day = $request->day; $user = \Auth::user(); $project = new \App\Project(); $project->user_id = $user->id; $project->title = $request->title; $project->due_date = Carbon::createFromDate($year, $month, $day); $project->save(); \Session::flash('flash_message', 'Your project was added!'); return redirect('/projects'); }
public function run() { DB::table('projects')->delete(); $faker = Faker\Factory::create(); for ($k = 0; $k < 20; $k++) { App\Project::create(['status' => "N", 'text' => $faker->paragraph(4), 'title' => $faker->name(), 'manager_id' => 3, 'client_id' => $faker->numberBetween(4, 5)]); } }
public function run() { App\Project::truncate(); App\Client::truncate(); App\Backlog::truncate(); factory(App\Project::class, 20)->create(); factory(App\Client::class, 10)->create(); factory(App\Backlog::class, 100)->create(); }
/** * Tests creating a project * * @return void */ public function testCreateProject() { $this->visit('/project/create')->seePageIs('/login'); $this->assertTrue(file_exists($this->testImage)); // Create and retrieve good project $this->tryCreateProject($this->user, 'Test Project', 'Create test please work', 'This is not the body you are looking for. This is not the body you are looking for. This is not the body you are looking for. This is not the body you are looking for. This is not the body you are looking for. ', $this->testImage)->seePageIs('/project/Test Project'); $entry = App\Project::where('title', '=', 'Test Project')->first(); $this->assertTrue($entry != null); $this->seePageIs($entry->getSlug()); // Check if image exists $imagePath = $this->baseImagePath . '/projects/product' . $entry->id . '.jpg'; $this->assertTrue(file_exists($imagePath)); // Delete project (using model's delete function) $entry->delete(); $this->assertTrue(!file_exists($imagePath)); }
/** * Run the migrations. * * @return void */ public function up() { Schema::create('projects', function (Blueprint $table) { $table->increments('id'); $table->string('name'); // $table->enum('status', ['new', 'process', 'complete', 'cancelled'])->default('new'); $table->enum('status', array_keys(App\Project::getStatus()))->default('0'); $table->date('plan_started_at'); $table->date('plan_finished_at'); $table->date('real_started_at'); $table->date('real_finished_at'); $table->float('price'); $table->boolean('is_archive')->default(FALSE); $table->integer('customer_id')->unsigned()->nullable(); $table->foreign('customer_id')->references('id')->on('customers'); }); }
/** * 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(); } } }
'auth' => 'Auth\AuthController', 'password' => 'Auth\PasswordController' ]); interface BarInterface{} class Baz{} class Bar implements BarInterface{} App::bind('BarInterface' , 'bar'); Route::get('bar', function(BarInterface $bar){ dd($bar); }); Route::get('foo', 'FooController@foo'); Route::get('apitest/twitter/{message}' , 'ApiTestController@twitter'); Route::resource('users','UserController'); Route::get('user/profile','MemberController@profile'); Route::put('user/profile','MemberController@saveprofile'); */ Route::model('tasks', 'Task'); Route::model('projects', 'Project'); // Use slugs rather than IDs in URLs 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::resource('projects', 'ProjectsController'); Route::resource('projects.tasks', 'TasksController');
|-------------------------------------------------------------------------- | Application Routes |-------------------------------------------------------------------------- | | This route group applies the "web" middleware group to every route | it contains. The "web" middleware group is defined in your HTTP | kernel and includes session state, CSRF protection, and more. | */ function rand_str() { return hash('sha256', substr(str_shuffle(sha1(rand(0, 999999999))), 0, rand(20, 45))); } Route::group(['middleware' => ['web']], function () { Route::get('/', function () { $top_projects = App\Project::limit(6)->orderBy('total_pledged', 'desc')->get(); return view('welcome', compact('top_projects')); }); Route::get('/about', function () { return view('about'); }); Route::group(['prefix' => 'account', 'middleware' => 'auth'], function () { Route::get('/', function (Request $r) { $user_pledges = $r->user()->u_pledges()->with('project')->get(); $user = auth()->user(); return view('account', compact('user_pledges', 'user')); }); }); Route::group(['prefix' => 'wallet'], function () { Route::post('withdraw', 'WalletController@withdraw'); Route::get('generate', 'WalletController@generate');
public function testInitializeStoring() { $user = factory(App\User::class, 'active')->make(); $this->actingAs($user)->visit('/top10_yandex')->type('Test Project', 'project_name')->type('кошки', 'query[0]')->check('set_dog')->press('Получить Top 10')->seeInDatabase('projects', ['name' => 'Test Project', 'user_id' => $user->id])->seeInDatabase('queries', ['text' => 'кошки'])->assertEquals(App\Project::where('name', 'Test Project')->first()->id, App\Query::where('text', 'кошки')->first()->project_id); }
$factory->define(App\Project::class, function (Faker\Generator $faker) { $usrArray = App\User::all()->lists('id')->toArray(); $ctgArray = App\Category::all()->lists('id')->toArray(); return ['user_id' => $faker->randomElement($usrArray), 'category_id' => $faker->randomElement($ctgArray), 'description' => $faker->paragraph]; }); $factory->define(App\SocialActivity::class, function (Faker\Generator $faker) { $usrArray = App\User::all()->lists('id')->toArray(); $act = ['followed', 'unfollowed']; return ['subject_id' => $faker->randomElement($usrArray), 'object_id' => $faker->randomElement($usrArray), 'activity' => $faker->randomElement($act)]; }); $factory->define(App\Recruitment::class, function (Faker\Generator $faker) { $prjArray = App\Project::all()->lists('id')->toArray(); return ['project_id' => $faker->randomElement($prjArray)]; }); $factory->define(App\Roadmap::class, function (Faker\Generator $faker) { $prjArray = App\Project::all()->lists('id')->toArray(); return ['project_id' => $faker->randomElement($prjArray), 'description' => $faker->paragraph]; }); $factory->define(App\Goal::class, function (Faker\Generator $faker) { $rdmArray = App\Roadmap::all()->lists('id')->toArray(); return ['roadmap_id' => $faker->randomElement($rdmArray), 'description' => $faker->paragraph]; }); $factory->define(App\Task::class, function (Faker\Generator $faker) { //masih harus diubah spy dapetnya cmn user yg terlibat ke project $usrArray = App\User::all()->lists('id')->toArray(); $glArray = App\Goal::all()->lists('id')->toArray(); $status = ['Completed', 'Ongoing']; return ['goal_id' => $faker->randomElement($glArray), 'user_id' => $faker->randomElement($usrArray), 'status' => $faker->randomElement($status)]; }); $factory->define(App\RecruitmentTransaction::class, function (Faker\Generator $faker) { $rcArray = App\Recruitment::all()->lists('id')->toArray();
| */ Route::get('/', function () { return abort(404); }); Route::get('{name}', function ($name) { if ($data['project'] = \App\Project::where(['name' => $name])->first()) { return \View::make('recordList', $data); } else { return dd('No project found'); } }); Route::post('{projectName}', function (Request $request, $projectName) { $project = \App\Project::where(['name' => $projectName])->first(); if (!$project) { $project = new \App\Project(); $project->name = $projectName; $project->save(); } $record = new \App\Record(); $record->project_id = $project->id; if ($request->has('data')) { $record->data = $request->data; } if ($record->save()) { return \Response::make('Record saved', 200); } else { abort(500); } }); /*
| 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('/', 'PainelController@index'); // Authentication routes... Route::get('auth/login', 'Auth\\AuthController@getLogin'); Route::post('auth/login', 'Auth\\AuthController@postLogin'); Route::get('auth/logout', 'Auth\\AuthController@getLogout'); // Registration routes... Route::get('auth/register', 'Auth\\AuthController@getRegister'); Route::post('auth/register', 'Auth\\AuthController@postRegister'); Route::get('painel', 'PainelController@index'); Route::get('tasks/create', 'TasksController@create'); Route::get('tasks', 'TasksController@index'); Route::get('profile/edit/{id}', 'ProfileController@edit'); // Rotas para alterar senha Route::get('profile/password', 'ProfileController@getPassword'); Route::post('profile/password', 'ProfileController@postPassword'); Route::model('tasks', 'Task'); Route::model('projects', 'Project'); Route::bind('tasks', function ($value, $route) { return App\Task::whereId($value)->first(); }); Route::bind('projects', function ($value, $route) { return App\Project::whereId($value)->first(); }); Route::resource('projects', 'ProjectsController'); Route::resource('projects.tasks', 'TasksController'); Route::resource('profile', 'ProfileController');
Route::get('slicer/create', 'SlicerController@create'); Route::get('slicer/{slicer}/destroy', 'SlicerController@destroy'); Route::patch('slicer/{slicer}', 'SlicerController@update'); Route::get('slicer/{slicer}', 'SlicerController@show'); Route::get('slicer/{slicer}/edit', 'SlicerController@edit'); Route::get('slicer/{slicer}/setting', 'SlicerSettingController@slicer_index'); Route::get('slicer/{slicer}/setting/create', 'SlicerSettingController@create'); Route::post('slicer/{slicer}/setting', 'SlicerSettingController@store'); Route::get('slicersetting', 'SlicerSettingController@index'); Route::get('slicersetting/{slicersetting}/destroy', 'SlicerSettingController@destroy'); Route::patch('slicersetting/{slicersetting}', 'SlicerSettingController@update'); Route::get('slicersetting/{slicersetting}', 'SlicerSettingController@show'); Route::get('slicersetting/{slicersetting}/edit', 'SlicerSettingController@edit'); Route::get('stl/{filename}', function ($filename) { $path = storage_path("app/" . $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); return $response; }); View::composer('layouts.menu', function ($view) { $view->with('menu_projects', App\Project::all()); }); View::composer('layouts.menu', function ($view) { $view->with('menu_slicer', App\Slicer::all()); }); });
<?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');
}); $factory->define(App\User::class, function (Faker\Generator $faker) { return ['name' => $faker->name, 'email' => $faker->email, 'password' => bcrypt(str_random(10)), 'remember_token' => str_random(10), 'profile_image_id' => createImage(), 'cover_image_id' => createImage(), 'location_country' => $faker->country, 'location_region' => $faker->city, 'company' => $faker->company, 'description' => 'I am creative geek based in XY. Love Apple, Starbucks coffee and Moleskine notebooks. Check out my profile!']; }); $factory->define(App\Project::class, function (Faker\Generator $faker) { return ['title' => $faker->firstNameFemale, 'owner_id' => function () { return App\User::all()->random()->id; }, 'description' => $faker->realText(100), 'is_public' => $faker->boolean(), 'views' => $faker->numberBetween(0, 1000), 'likes' => $faker->numberBetween(0, 1000)]; }); $factory->define(App\Comment::class, function (Faker\Generator $faker) { return ['content' => $faker->realText(60), 'user_id' => function () { return App\User::all()->random()->id; }, 'project_id' => function () { return App\Project::all()->random()->id; }]; }); $factory->define(App\Color::class, function (Faker\Generator $faker) { return ['name' => $faker->word, 'rgb_hex' => $faker->hexColor]; }); $factory->define(App\Texture::class, function (Faker\Generator $faker) { return ['name' => $faker->word, 'image_id' => createImage()]; }); $factory->define(App\Font::class, function (Faker\Generator $faker) { return ['myfonts_id' => $faker->numberBetween(0, 1000)]; }); $factory->define(App\Tag::class, function (Faker\Generator $faker) { return ['name' => $faker->word]; }); $factory->define(App\Notification::class, function (Faker\Generator $faker) {