Exemplo n.º 1
0
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     // validate
     // read more on validation at http://laravel.com/docs/validation
     $rules = array('judul' => 'required', 'deskripsi' => 'required', 'upah_max' => 'required|numeric', 'upah_min' => 'required|numeric', 'kategori' => 'required');
     $validator = Validator::make(Input::all(), $rules);
     // process the login
     if ($validator->fails()) {
         return Redirect::to('job/' . $id . '/edit')->withErrors($validator)->withInput(Input::except('password'));
         // TODO: Check
     } else {
         // store
         $updated_job = Job::find($id);
         $updated_job->judul = Input::get('judul');
         $updated_job->deskripsi = Input::get('deskripsi');
         $updated_job->upah_max = Input::get('upah_max');
         $updated_job->upah_min = Input::get('upah_min');
         $updated_job->save();
         $updated_category = JobCategory::where('job_id', $id)->first();
         $updated_category->category_id = Input::get('kategori');
         $updated_category->save();
         // redirect
         Session::flash('message', 'Successfully updated job!');
         return Redirect::to('job/' . $id);
     }
 }
Exemplo n.º 2
0
<?php

Route::group(['namespace' => 'App\\Http\\Controllers', 'middleware' => ['web', 'throttle']], function () {
    //'prefix'=>'api/v1',
    Route::group(['prefix' => 'admin', 'middleware' => ['auth', 'admin'], 'namespace' => 'Admin'], function () {
        Route::resource('job_tags', 'JobTagController', ['only' => ['index', 'show', 'create', 'store', 'edit', 'update', 'destroy']]);
        Route::resource('jobs', 'JobController', ['only' => ['index', 'show', 'create', 'store', 'edit', 'update', 'destroy']]);
        Route::resource('job_categories', 'JobCategoryController', ['only' => ['index', 'show', 'create', 'store', 'edit', 'update', 'destroy']]);
        Route::post('jobs/{jobs}/upload', ['as' => 'admin.jobs.upload', 'uses' => 'JobController@upload']);
        Route::get('jobs/{jobs}/image-upload', ['as' => 'admin.jobs.image-upload', 'uses' => 'JobController@getUpload']);
    });
});
View::composer('*', function ($view) {
    $job_categories = \App\JobCategory::where('parent_id', '=', 0)->get();
    //
    if (!$job_categories) {
        $job_categories = [];
    }
    $job_tags = \App\JobTag::with('jobs')->get();
    if (!$job_tags) {
        $job_tags = [];
    }
    $view->with(compact('job_categories', 'job_tags'));
});