/** * Store a newly created resource in storage. * * @param Request $request * @return Response */ public function store(Request $request) { $maestro = Maestro::create($request->all()); $telefono = new Telefono(); $telefono->numero_telefono = $request['numero_telefono']; $telefono->maestro_id = $maestro->id; $telefono->save(); return redirect('/maestros')->with('message', 'store'); }
/** * Store a newly created resource in storage. * * @param Request $request * @return Response */ public function store(Request $request) { $estudiante = Estudiante::create($request->all()); $telefono = new Telefono(); $telefono->numero_telefono = $request['numero_telefono']; $telefono->estudiante_id = $estudiante->id; $telefono->save(); return redirect('/estudiantes')->with('message', 'store'); }
/** * Store a newly created resource in storage. * * @param Request $request * @return Response */ public function store(Request $request) { $estudiante = Estudiante::create($request->all()); $carbon = new Carbon(); $date = $carbon->now()->year - 2000; $codigo = $estudiante->id + 100; $estudiante->codigo = "est-" . $codigo . "" . $date; $estudiante->save(); $telefono = new Telefono(); $telefono->numero_telefono = $request['numero_telefono']; $telefono->estudiante_id = $estudiante->id; $telefono->save(); return redirect('/estudiantes')->with('message', 'store'); }
/** * Run the database seeds. * * @return void */ public function run() { DB::table('estudiante')->delete(); DB::table('maestro')->delete(); DB::table('genero')->delete(); DB::table('curso')->delete(); Genero::create(['genero' => 'Fenemino']); Genero::create(['genero' => 'Masculino']); $faker = Faker::create(); foreach (range(1, 20) as $index) { $estudiante = new Estudiante(); $estudiante->codigo = $faker->numerify('est-####'); $estudiante->nombre_estudiante = $faker->firstName; $estudiante->apellido_estudiante = $faker->lastName; $estudiante->fecha_nacimiento = $faker->date($format = 'Y-m-d', $max = 'now'); $estudiante->direccion = $faker->address; $estudiante->correo = $faker->email; $estudiante->genero_id = 1; $estudiante->save(); $telefono = new Telefono(); $telefono->numero_telefono = $faker->phoneNumber; $telefono->estudiante_id = $estudiante->id; $telefono->save(); } foreach (range(1, 20) as $index) { $maestro = new Maestro(); $maestro->codigo = $faker->numerify('cat-####'); $maestro->nombre_maestro = $faker->firstName; $maestro->apellido_maestro = $faker->lastName; $maestro->fecha_nacimiento = $faker->date($format = 'Y-m-d', $max = 'now'); $maestro->direccion = $faker->address; $maestro->correo = $faker->email; $maestro->genero_id = 1; $maestro->save(); $telefono = new Telefono(); $telefono->numero_telefono = $faker->phoneNumber; $telefono->maestro_id = $maestro->id; $telefono->save(); } foreach (range(1, 20) as $index) { $curso = new Curso(); $curso->codigo = $faker->numerify('C-####'); $curso->nombre_curso = $faker->word; $curso->descripcion = $faker->sentence($nbWords = 6); $curso->fecha_inicio = $faker->date($format = 'Y-m-d', $max = 'now'); $curso->fecha_fin = $faker->date($format = 'Y-m-d', $max = 'now'); $curso->max_estudiantes = $faker->numberBetween($min = 10, $max = 30); $curso->save(); } }
/** * Store a newly created resource in storage. * * @param Request $request * @return Response */ public function store(Request $request) { $maestro = Maestro::create($request->all()); $carbon = new Carbon(); $date = $carbon->now()->year - 2000; $codigo = $maestro->id + 100; $maestro->codigo = "cat-" . $codigo . "" . $date; $maestro->save(); $telefono = new Telefono(); $telefono->numero_telefono = $request['numero_telefono']; $telefono->maestro_id = $maestro->id; $telefono->save(); return redirect('/maestros')->with('message', 'store'); }