SHARE
TWEET

Untitled

a guest Jun 16th, 2019 47 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Schema::create('cursos', function (Blueprint $table) {
  2.     $table->bigIncrements('id')->unsigned();;
  3.     $table->bigInteger('categoria_id')->unsigned();
  4.     $table->bigInteger('dono_id')->unsigned();
  5.     $table->string('nome');
  6.     $table->string('descricao');
  7.     $table->float('valor');
  8.     $table->string('imagem');
  9.     $table->timestamps();
  10. });
  11.      
  12. Schema::create('aulas', function (Blueprint $table) {
  13.    $table->bigIncrements('id');
  14.    $table->bigInteger('curso_id')->unsigned();
  15.    $table->string('nome');
  16.    $table->text('descricao');
  17.    $table->time('duracao');
  18.    $table->string('link');
  19.    $table->timestamps();
  20. });
  21.      
  22. Schema::table('aulas', function (Blueprint $table) {
  23.     $table->foreign('curso_id')->references('id')->on('cursos');
  24. });
  25.      
  26. [...]
  27.     public function aulas()
  28.     {
  29.         return $this->hasMany('appAula', 'curso_id', 'id');
  30.     }
  31.      
  32. [...]
  33. public function curso()
  34. {
  35.     return $this->belongsTo('appCurso', 'curso_id', 'id');
  36. }
  37.      
  38. Route::prefix('usuario')->namespace('Usuario')->group(function () {
  39.         [...]
  40.         Route::prefix('curso')->group(function(){
  41.             Route::get('/{cursoid}/aula/{aulaid}', 'CursosController@aulas')->name('curso.aula');
  42.         });
  43.     });
  44.      
  45. public function aulas($cursoid,$aulaid)
  46.     {
  47.         $curso = Curso::findOrFail($cursoid);
  48.         $aula = Aula::findOrFail($aulaid);
  49.         $aulas = $curso->aulas;
  50.         return view('usuario.aula',compact('curso','aulas','aula'));
  51.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top