Hoàn thiện tất cả các trường hợp ☝️👆

Controller

TestController

<?php
namespace App\Http\Controllers;
use App\Models\Comment;
use App\Models\Commentms;
use App\Models\Country;
use App\Models\User;
use App\Models\Phone;
use App\Models\Post;
use App\Models\Role;
use App\Models\Video;
use Illuminate\Http\Request;
class TestController extends Controller
{
  /**
   * Display a listing of the resource.
   *
   * @return \Illuminate\Http\Response
   */
  public function index($id)
  {
    // $user = User::find($id);
    // /**
    //  * Get the phone associated with the user.
    //  */
    // $phone = $user->phone;
    // dd($phone->phone);
    // $comments = Post::find($id)->comments;
    // foreach ($comments as $comment) {
    //   echo "<pre>";
    //   var_export($comment->comment);
    //   echo "</pre>";
    // }
    // $user = User::find($id);
    // foreach ($user->roles as $role) {
    //   echo $role->name . "<br/>";
    // }
    // $user = User::find($id);
    // $userimage = $user->image;
    // echo $userimage->url;
    // $post          = Post::find($id);
    // $comments = $post->commentms;
    // foreach ($comments  as $key => $comment) {
    //   echo $comment->body . "<br/>";
    // }
    // $video          = Video::find($id);
    // $comments = $video->commentms;
    // foreach ($comments  as $key => $comment) {
    //   echo $comment->body . "<br/>";
    // }
    // $tag = Post::find($id);
    // $tags = $tag->tags;
    // dd($tags);
    // $tag = Video::find($id);
    // $tags = $tag->tags;
    // dd($tags);
    $country = Country::find($id);
    foreach ($country->posts as $key => $post) {
      echo $post->name . "<br/>";
    }
  }
  public function index2($id)
  {
    // $phone = Phone::find($id);
    // /**
    //  * Get the phone associated with the user.
    //  */
    // $name = $phone->user;
    // dd($name->name);
    // $post = Comment::find($id)->post;
    // echo '<pre>';
    // echo "id and name => " . $post->id . " and " . $post->name;
    // echo '<pre>';
    $role = Role::find($id);
    foreach ($role->users as $user) {
      echo $user->name . "<br/>";
    }
  }
}

Models

Comment

Commentms

Country

Image

Phone

Post

Role

RoleUser

Tag

Tagable

User

Video

Factories

CommentFactory

CommentmsFactory

CountryFactory

ImageFactory

PhoneFactory

PostFactory

RoleFactory

RoleUserFactory

TagableFactory

TagFactory

UserFactory

VideoFactory

Migrations

create_users_table

create_phones_table

create_posts_table

create_comments_table

create_roles_table

create_role_users_table

create_images_table

create_commentms_table

create_videos_table

create_tagables_table

create_tags_table

create_countries_table

Seeders

DatabaseSeeder

Routes

web

file-archive
102KB

Last updated