Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Schema::create('cursos', function (Blueprint $table) {
- $table->bigIncrements('id')->unsigned();;
- $table->bigInteger('categoria_id')->unsigned();
- $table->bigInteger('dono_id')->unsigned();
- $table->string('nome');
- $table->string('descricao');
- $table->float('valor');
- $table->string('imagem');
- $table->timestamps();
- });
- Schema::create('aulas', function (Blueprint $table) {
- $table->bigIncrements('id');
- $table->bigInteger('curso_id')->unsigned();
- $table->string('nome');
- $table->text('descricao');
- $table->time('duracao');
- $table->string('link');
- $table->timestamps();
- });
- Schema::table('aulas', function (Blueprint $table) {
- $table->foreign('curso_id')->references('id')->on('cursos');
- });
- [...]
- public function aulas()
- {
- return $this->hasMany('appAula', 'curso_id', 'id');
- }
- [...]
- public function curso()
- {
- return $this->belongsTo('appCurso', 'curso_id', 'id');
- }
- Route::prefix('usuario')->namespace('Usuario')->group(function () {
- [...]
- Route::prefix('curso')->group(function(){
- Route::get('/{cursoid}/aula/{aulaid}', 'CursosController@aulas')->name('curso.aula');
- });
- });
- public function aulas($cursoid,$aulaid)
- {
- $curso = Curso::findOrFail($cursoid);
- $aula = Aula::findOrFail($aulaid);
- $aulas = $curso->aulas;
- return view('usuario.aula',compact('curso','aulas','aula'));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement