Mastering Laravel: Build Instagram Clone with Livewire
- Description
- Curriculum
- FAQ
- Reviews
Embark on an exciting coding journey with our immersive course as we unravel the magic of web development together. Picture this: we’ll be diving deep into the key features on the Home Page – from the seamless Swipe and Like functionalities to the engaging Stories and the dynamics of Follow/Unfollow. Get ready to immerse yourself in user interaction as we explore Commenting, Saving posts, and effortlessly scrolling through the Home Feed.
But wait, there’s more! We’ll navigate the vast possibilities of Search Functionality, making it easy to connect with users by finding, exploring profiles, and initiating follows. Brace yourself as we step into the Explore Page, unveiling Hover Functionality and diving into interactive engagement with posts and comments.
Hold on tight as we experience the dynamic Reel Page – play, like, save, and take a smooth ride through captivating reels. We won’t stop there; we’ll delve into real-time user interaction with Messages and Notifications, creating an immersive social experience that goes beyond the ordinary.
And guess what? That’s just the beginning of our adventure! Learn to craft stunning posts, incorporating Mixed media posts while considering file size. Explore your profile with tabs for a comprehensive overview of your digital presence.
This is more than a course; it’s a personalized journey into the heart of web development, where we don’t just learn – we actively build and refine our skills together
-
1Install LaravelVideo lesson
-
2Install Breeze Auth PackageVideo lesson
Install Breeze
Add env credentials
Migrate database
npm run dev
Create user
Change the redirect link in RouteServiceProvider
-
3Install LivewireVideo lesson
Install Livewire
Publish livewire config and update 'layout' => 'layouts.app',
Install livewire hot reload from https://christoph-rumpel.com/2022/7/auto-refresh-livewire-components-while-keeping-states-with-vite
-
4Install Daisy UIVideo lesson
Install Daisy UI via NPM
require Daisy Ui in tailwind config,
add themes to light
Go to Daisy ui and get Layout Drawer code
Update layout in 'layouts.app'
Add x-cloak to style
-
5Download Sidebar & Avatar & LogoVideo lesson
We do this to save time from searching for special icons on various websites and repeating same process
Download Avatar , paste it in components folder
Download logo,Create public folder assets and paste logo
Download Sidebar , paste it in layouts folder
-
6RepositoryText lesson
-
7Install Home Component/pageVideo lesson
php artisan make:livewire home
Create auth route group and add '/' url , remove default '/' url
-
8Design story sectionVideo lesson
Install scrollbar hide package
https://github.com/reslear/tailwind-scrollbar-hide
-
9Design Suggestion sectionVideo lesson
-
10Design mobile headerVideo lesson
-
11Make post componentVideo lesson
Create post item
Add post item to home
Create Header
design header with avatar and dots on the right
-
12Create Video PlayerVideo lesson
Video
Create custom x-video component
Add props source
add x-video to item component
-
13Footer sectionVideo lesson
Add icons
Add content
add form
-
14Add swiper js to media sectionVideo lesson
Install swiper.js via npm
Copy swiper template
Initialise swiper.js in alpine x-init
-
15Create Post modelVideo lesson
run the command php artisan make:model Post -mfs
Add fields to table
Add casts and properties and relationships to Model class
Add posts relationship to User model
Add factory
use this link for testing videos 'https://gist.github.com/jsturgis/3b19447b304616f18657'
-
16Create Media ModelVideo lesson
run the command php artisan make:model Post -mfs
Add fields to table
Add casts and properties and relationships to Model class
Add factory
get public test vidoes -(search query) public test videos Github
get photos urls from unsplash
refresh database and seed
-
18Make Create post componentVideo lesson
Install Wire modals package
Make component : php artisan make:livewire post.create
Add button to open create post component in drawer(sidebar)
-
19Design layout and left sideVideo lesson
Add Safelist to Tailwind config.js
Add purge to Tailwind config.js
Add modalMaxWidth() method
Design Header and let side
-
20Design details sideVideo lesson
-
21Add properties and methodsVideo lesson
Download testing vidoes from https://pixabay.com/videos/
Download testing pictures from https://unsplash.com/
Add properties to component
Create submit method and add dd()
Add disabled attr to submit button
add wire models to inputs
submit and test dd()
Add preview to media Dont forget to replace hidden with flex class
Add .mp4 to accepted files in input
-
22Save Post / Reel to DatabaseVideo lesson
add default as false for the following
public $hide_like_view=false;
public $allow_commenting=false;
Add validation for media
Add Temporary url validation in Livewire config Note: validating temp file in component will not work
If neccessary edit the php.ini file to increate the max_uplodad_size
when saving the file to disk
make sure disk is public
!!!!! run command php artisan storage:link to access the file from /storage/media/...
After creating post , go and change order type in home to latest()->get(); in order to view post
-
23Create Post view modal componentVideo lesson
Create inline modal component php artisan make:livewire post.view.modal --inline
Extend modal component
Add properties and methods
get url and push state
Add closeModal listener in home component
Publish wire-elements views php artisan vendor:publish --tag=wire-elements-modal-views
Add custom onclick="Livewire.dispatch('closeModal')" To overlay this will also dispatch closeModal so we can listin in home component
-
24Create view itemVideo lesson
php artisan make:livewire post.view.item
add <livewire:post.view.item :post="$this->post" /> to modal
Create item view layout ,
Use css snap scroll , and show files
-
25DetailsVideo lesson
Copy header from post item
copy footer from post item -add (mt-auto)
-
26Create Comment model with -mfsVideo lesson
run php artisan make:model Comment -mfs
Add fields to table
Add methods/relationship to Comment model
Add relationships to Post model
run php artisan migrate
-
27Fill up Comment FactoryVideo lesson
Comments
Add fields to comments factory
Add ->hasComments(rand(20,50)) to post factory in DatabaseSeeder
refresh database and seed (!!!!important add prepend time() to users email in UserSeeder to avoid duplicate entry errors )
Go to home filter by ->whereHas('comments') to see post with comments and dd($posts->first())
In the post >item add $post->comments->count()
revert the changed in home and add ->with('comments')
Replies
add state function called isReply() to CommentFactory to create comments as replies
add the factory to the Database seeder
refresh database
View the replies in home by dd()
-
29Design comments layoutVideo lesson
Design comments
Add $post->user->name just for testing
-
30Display comments from databaseVideo lesson
Load comments in render();
Replace $post->user->name with $comment->user->name
In the home make sure you add ->latest(); in order to see posts with comments
Add replies
-
31Get Replies and DecendantsVideo lesson
Create partials folder post.view.partials
Create comment.bladel.php file in partials folder
Create reply.blade.php file in partials folder (add subreplies to reply.blade.php)
Add ->whereDoesntHave('parent') in View.Item Livewire componentn
Update code in DatabaseSeeder in order to test sub replies
-
32Add Comment To PostVideo lesson
Create addComment method
Create $body property , change inputText to body
In the form submit button add type="submit"
Add @submit.prevent="$wire.addComment()" in the Form . test it !! with dd()
Add entangled $body and $parent_id
Submit Form and create comment
Add wire:key="{{time()}}" to Form
-
33Add Reply to commentVideo lesson
Remove space between @ and username
Add wire:click="setParent({{$reply->id}})" to reply button in sub comment
add setParent method and inject Comment model
Add wire:click="setParent({{$comment->id}})" to comment reply button
remove the {{'@'.$reply->parent->user->name}} from reply body
-
34Add instant comments to Post ItemVideo lesson
Add body property
Copy addComment() method from post.view.item to post.item component
remove parent_id
rename inputText to body in post.item <form>
make body entangled
add type submit to Button in <form>
add wire:key="{{time()}}" to <form>
Show user's comments on Post Item
-
35Disable commentingVideo lesson
Only how <form>, <trigger button> and auth comments if commenting_is_allowed in POST.ITEM
Also hide all comments and <form> in POST.VIEW.ITEM
Change button title to "Allow Commenting" in Create Item component
-
36Install like packageVideo lesson
Add Overtrue package
Quick review of package
publish migrations
Add Traits to:
Comment (Likeable)
Post(Likeable)
User (Liker)
Migrate table
-
37Add Like to postVideo lesson
create togglePostLike() method in post item
add filled heart if post is liked or not
add wire:ignore to avatar and swiper parent
Show likesCount() to post
Dont forget to also check if post allows to show number of likes
Do the same for post view item
-
38Hide & Show like countVideo lesson
-
40Install Favorites PackageVideo lesson
Install Favorite package from overtrue
Publish migrations and configuration
Add Traits:
Favoriter (User)
Favoriteable(Post)
Migrate table
-
41Toggle FavoritesVideo lesson
Add toggleFavorite() method in Post.Item
In blade add @if( $post->hasBeenFavoritedBy(auth()->user()) )
-
42Install follow packageVideo lesson
Install Follow package from overtrue
Publish migrations and configuration
Add Traits:
Follower (User)
Followable(User)
Migrate table
-
43Toggle Follow UsersVideo lesson
Pass suggestedUsers to Home component
Loop suggestedUsers in home component
Add users name
create toggleFavorites() in Home Livewire Component
Add wire:click="toggleFollow({{$user->id}})"
Add wire:ignore to all avatars in home
-
44Add username to UsersVideo lesson
Add username to users table
Add username to fillable to User model
Add username to UserFactory 'username' => time().fake()->unique()->userName(),
Add username to auth/register.blade.php
Add usernae to RegisteredUserController
php artisan migrate:fresh --seed
-
45Create profile componentVideo lesson
run php artisan make:livewire profile.home
Add profile.home to routes
Prefix the profile route with /profile/{user}
Route::get('/profile/{user}',ProfileHome::class)->name('profile.home');
Add profile link in sidebar link in sidebar
href="{{route('profile.home',auth()->user()->username)}}"
Add Image to profile
Add <x-profile-layout/> to profile.home
-
46Download profile-layoutVideo lesson
1. Add <x-profile-layout/> to profile.home
Pass $user to blade as paramater
Receive $user in @props(['user'])
Make <x-profile-layout/> dynamic
Get user postCount
user FollowersCount
user FollowingCount
Check if user is following or is being followed(Wrap in auth())
Check if auth owns profile , then show different actions
Add toggleFollow
Laslty go to home and add redirect links to users profile
-
47Display User's PostsVideo lesson
Pass $posts to profile.home blade
Create grid style
Listen to closseModal dipached event
loop through posts
Check mime
Add click event to show post with comments(copy from post.item)
-
48Display Reels & Saved PostsVideo lesson
Run commands
php artisan livewire:copy profile.home profile.reels
php artisan livewire:copy profile.home profile.saved
Adjust the correct queries for each of the copied files
Highlight Selected Tab
-
49Create Explore PageVideo lesson
Create component explore
Add route
Route::get('/explore',Explore::class)->name('explore');Add redirect in sidebar (Add wire:navigate)
Show highlighted indicator in sidebar for :
Explore (Add wire:navigate)
Home (Add wire:navigate)
Profile (Add wire:navigate)
-
50Show Explore PostsVideo lesson
Copy show layout from profile.home
Pass posts in explore component
Customize the <ul> class
Show Hover options ( comments count& likes count )
Show corresponding top right icon
For copy icons goto https://iconduck.com/search?query=copy+rounded
Listing to closeModal Dispatched Event
-
51Customize the video componentVideo lesson
Add props for controls
Hide controls if controls is false
Add props for cover
-
52Create Reels ComponentVideo lesson
Create component
php artisan make:livewire reels
Add route
Add link in sidebar( Add wire:navigate)
Highlihgt sidebar
get posts in render()
Add #[On('closeModal')]
-
53Show Posts ReelsVideo lesson
Loop posts in Blade
Design reel element file
For Icon actions ( copy from post.item)
Pass Models to wire:clicks i.e toggleLike({{$post->id}})
Add Action methods ( copy from post.item)
-
54Create Livewire SidebarVideo lesson
Make sidebar as livewire component
php artisan make:livewire components.sidebar
Add new sidebar to layouts.app
Move contents to new sidebar
x-transition.origin.left to drawer
remove <template x-teleport="body">
-
55Add Search FunctionalityVideo lesson
Change background to white , add padding
Add shadow
Add input and title
Add wire:model
Add search method
Add search results
Add class 'overflow-visible z-10' to element with class='drawer-side' (layouts.app)
Make $shrink and $drawer entangled
Add showSearch and showNotifictions
-
56Introduction to BroadcastingVideo lesson
-
57Install pusher and Laravel EchoVideo lesson
Go to Broadcasting in laravel documentation
install pusher server via composer require pusher/pusher-php-server
For the keys we need to create pusher account
Install Laravel echo npm install --save-dev laravel-echo pusher-js
uncomment the Echo instancd in bootstrap.js
Finally in the config/app.php
uncomment the line for AppProvidersBroadcastServiceProvider::class,
-
58Create pusher accountVideo lesson
Create pusher account or login
Create new instagram app in pusher
Copy keys and credentials to .ENV file
!Dont forget to also copy the cluster
Test connection is established in the debug console in pusher.com
-
59Create notification componentVideo lesson
Create component
Add it to Side bar as nested livewire component
Add button to open notfication component
-
60Design notificationsVideo lesson
-
61Create NewFollowerNotificationVideo lesson
Create new notification php artisan make:notification NewFollowerNotification
Pass user model as parameter
add via 'broadcast ' & 'database'
Add implements ShouldBroadcastNow
install database notifications (Go to Laravel broadcasting database notifications)
Go to home & profile.home Add broadcast new follower after toggle follower
Show notifications in database
Show broadcasted notification in debug console
-
62Create PostLikedNotificationVideo lesson
Create new notification php artisan make:notification PostLikedNotification
Pass User $user model & Post $post as parameter
add via 'broadcast ' & 'database'
Add implements ShouldBroadcastNow
Go to post item and notify user after togglePost()
-
63Create NewCommentNotificationVideo lesson
Fix Type in newFollowerNotification!
-
64Prevent Self NotificationsVideo lesson
In Post Item
-
65Show NewFollower NotificationsVideo lesson
Loop through user->notifications ( Also refer to docs in Laravel)
User switch for case copy notification types from database
Get user in @php @endphp
Add routes to links
Show date
Add toggleFollow() Copy from home component
-
66Show PostLiked NotificationsVideo lesson
Show post liked notifications
Create Post Page component
php artisan make:livewire post.view.page --inline
Add contents to page
Add to route to web
Add values to notifications
-
67Show NewComment NotificationsVideo lesson
Add $user and comment in @php @endphp in NewCommentNotification
Use $comment->commentable to access the post on NewCommentNotification
Show post cover for NewCommentNotification and PostLikedNotification
-
68Listen to NotificationsVideo lesson
Open debug console in pusher.com
Add 'receivesBroadcastNotificationsOn()' in User model
add new 'users' channel
Listen to echo notification in blade
-
70Create Chat IndexVideo lesson
Create chat index php artisan make:livewire chat.index
Occasionally refresh Vite component manually in order to update css
Add route to web
Add redirect (with wire:navigate) in Sidebar ( also Add Highlighed icon)
Add x-init in sidebar to make shrink to true
Try to make icons larger w-7 h-7
-
71Create Chat listVideo lesson
Create chat list component php artisan make:livewire chat.chat-list
Download chat-list.blade from resources
Add chat list component to Index
-
72Create Chat MainVideo lesson
Create chat main php artisan make:livewire chat.main --inline
Add route in web.routes
Copy render method from ChatIndex ,! make left side hidden on small screens and show right side
Occasionally Vite component manually in order to update css
Add redirect (with wire:navigate) in Chatlist in Chat List Item
Update Sidebar component with to check if request()->routeIs('chat')||request()->routeIs('chat.main') in x-init & icon hightlist
-
73Create Chat ComponentVideo lesson
Create chat component php artisan make:livewire chat.chat
Add chat component to Main
Download Chat component
External Links May Contain Affiliate Links read more