Exemplo n.º 1
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     $transaction = Transaction::findOrFail($id);
     $accounts = Account::all()->where('user_id', Auth::user()->id)->lists('name', 'id');
     $categories = Category::all()->where('user_id', Auth::user()->id)->lists('name', 'id');
     $subcategories = Subcategory::all()->where('user_id', Auth::user()->id)->lists('name', 'id');
     $entities = Entity::all()->where('user_id', Auth::user()->id)->lists('name', 'id');
     return view('transactions.edit', compact('transaction'), array('accounts' => $accounts, 'categories' => $categories, 'subcategories' => $subcategories, 'entities' => $entities));
 }
Exemplo n.º 2
0
 /**
  * Crea mi usuario administrador con 3 categorias y 3 cuentas.
  *
  * @return void
  */
 public function run()
 {
     $faker = Faker\Factory::create();
     $user = factory(vixit\User::class)->create(['id' => '1', 'email' => '*****@*****.**', 'password' => '1234', 'first_name' => 'Nery', 'last_name' => 'Brugnoni', 'birthdate' => '1992-09-24', 'type' => 'admin']);
     Category::create(array('name' => 'Alimentos', 'description' => $faker->text(100), 'user_id' => 1));
     Category::create(array('name' => 'Vehículos', 'description' => $faker->text(100), 'user_id' => 1));
     Category::create(array('name' => 'Mascotas', 'description' => $faker->text(100), 'user_id' => 1));
     Subcategory::create(array('name' => 'Carnes', 'description' => $faker->text(100), 'category_id' => 1, 'user_id' => 1));
     Subcategory::create(array('name' => 'Verduras', 'description' => $faker->text(100), 'category_id' => 1, 'user_id' => 1));
     Subcategory::create(array('name' => 'Harinas', 'description' => $faker->text(100), 'category_id' => 1, 'user_id' => 1));
     Account::create(array('name' => 'Efectivo', 'starting_balance' => 500, 'current_balance' => 500, 'notes' => $faker->text(100), 'user_id' => 1));
     Account::create(array('name' => 'Tarjeta  de Crédito', 'starting_balance' => $faker->randomFloat(2), 'current_balance' => $faker->randomFloat(2), 'notes' => $faker->text(100), 'user_id' => 1));
     Account::create(array('name' => 'Tarjeta de Débito', 'starting_balance' => $faker->randomFloat(2), 'current_balance' => $faker->randomFloat(2), 'notes' => $faker->text(100), 'user_id' => 1));
     Entity::create(array('name' => 'Supermercado xx', 'city' => 'Villa María', 'user_id' => 1));
     Entity::create(array('name' => 'Panadería #1', 'city' => 'Villa María', 'user_id' => 1));
     Entity::create(array('name' => 'Tienda NB', 'city' => 'Villa María', 'user_id' => 1));
 }
Exemplo n.º 3
0
 public static function filterAndPaginate($name, $user_id)
 {
     return Subcategory::name($name)->where('user_id', $user_id)->orderBy('id', 'ASC')->paginate();
 }
Exemplo n.º 4
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id, Request $request)
 {
     $subcategory = Subcategory::findOrFail($id);
     $subcategory->delete();
     $message = $subcategory->name . ' was deleted successfully!';
     if ($request->ajax()) {
         return response()->json(['id' => $subcategory->id, 'message' => $message]);
     }
     Session::flash('message', $message);
     return redirect()->route('subcategories.index');
 }
Exemplo n.º 5
0
| 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.
|
*/
Route::group(['middleware' => 'web'], function () {
    Route::auth();
    Route::get('/', 'HomeController@index');
    Route::get('/home', 'HomeController@index');
    Route::get('transactions/charts/{year?}', ['uses' => 'TransactionsController@charts']);
    //    Route::get('transactions/charts', 'TransactionsController@charts\2016');
    Route::resource('transactions', 'TransactionsController');
    Route::resource('accounts', 'AccountsController');
    Route::resource('categories', 'CategoriesController');
    Route::resource('subcategories', 'SubcategoriesController');
    Route::resource('entities', 'EntitiesController');
    Route::get('/user/profile', 'UsersController@index');
});
//n6:1801161422> agrego grupo admin
Route::group(['middleware' => ['web', 'vixit\\Http\\Middleware\\AdminMiddleware'], 'prefix' => 'admin', 'namespace' => 'Admin'], function () {
    //n6:1501162356> agrego ruta del tipo recurso
    Route::resource('users', 'UsersController');
});
Route::get('api/dropdown/subcategories', function () {
    $id = Illuminate\Support\Facades\Input::get('category_id');
    $subcategories = \vixit\Subcategory::where('category_id', $id);
    return $subcategories->lists('name', 'id');
});