Welcome, Guest: Join Nairaland / LOGIN! / Trending / Recent / New
Stats: 2,690,204 members, 6,337,851 topics. Date: Monday, 14 June 2021 at 06:32 AM

Laravel Nairaland Corner -- Post Any Laravel Code Issues, Get Solution For FREE - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Laravel Nairaland Corner -- Post Any Laravel Code Issues, Get Solution For FREE (345 Views)

Any Laravel Developer In The House? / Is Airtime Payment The Solution For In App Purchases? / React Native Will Become The Best Solution For Mobile App Development (2) (3) (4)

(1) (Reply) (Go Down)

Laravel Nairaland Corner -- Post Any Laravel Code Issues, Get Solution For FREE by EWSTechSupport: 2:24pm On Jun 09
Laravel PHP Devs in the house,
Junior, Intermediate, Senior.

Post any Laravel Code issues you are having, let's work on it together within 24 hours.
Let's turn this thread to our own StackOverflow for Laravel issues.

Please be as thorough as possible when posting your code issues. If possible, send steps on how we can replicate the problem

All experts are welcomed to drop solutions as I might not always be online to respond to issues.

1 Like

Re: Laravel Nairaland Corner -- Post Any Laravel Code Issues, Get Solution For FREE by Karleb(m): 4:07pm On Jun 09
Oh boy! You are the tech bro I have been looking for. grin

For a start, how do I create and use blade components inside a folder inside the components folder.

As in,

components > Post > store.blade.php

How do I use that store.blade.php component in my view?
Re: Laravel Nairaland Corner -- Post Any Laravel Code Issues, Get Solution For FREE by Nickisindigo(m): 4:58pm On Jun 09
If you have PDF and videos on laravel plz share with me
Re: Laravel Nairaland Corner -- Post Any Laravel Code Issues, Get Solution For FREE by Maj196(m): 5:04pm On Jun 09
Karleb:
Oh boy! You are the tech bro I have been looking for. grin

For a start, how do I create and use blade components inside a folder inside the components folder.

As in,

components > Post > store.blade.php

How do I use that store.blade.php component in my view?
Just right click and create new file naming it (store.blade.php) inside the Post subfolder. Components > Post. To call the file from a controller for example. Just return it under the method like (return view (components.post.store).
Re: Laravel Nairaland Corner -- Post Any Laravel Code Issues, Get Solution For FREE by Karleb(m): 8:36pm On Jun 09
Maj196:
Just right click and create new file naming it (store.blade.php) inside the Post subfolder. Components > Post. To call the file from a controller for example. Just return it under the method like (return view (components.post.store).

What I specifically wanted was how to use components that is in a directory in the components folder. Components and not just any other view because it is reusable.

Anyway I got my answer using the documentation. After creating it in a components > Post > store.blade.php, you'll do <x-Post.store /> to use it.

Did you know today's Laravel 10th birthday?
Re: Laravel Nairaland Corner -- Post Any Laravel Code Issues, Get Solution For FREE by EWSTechSupport: 12:01am On Jun 10
Karleb:
Oh boy! You are the tech bro I have been looking for. grin

For a start, how do I create and use blade components inside a folder inside the components folder.

As in,

components > Post > store.blade.php

How do I use that store.blade.php component in my view?

Just saw your message.
Once your component file is set up on your components folder in the resources > views folder, you can access it anywhere by doing

<x-componentname/>

If you have a folder inside the components folder, you can access it by

<x-foldername.componentname/>
Re: Laravel Nairaland Corner -- Post Any Laravel Code Issues, Get Solution For FREE by EWSTechSupport: 12:07am On Jun 10
@ mods:
mukina2, lalasticlala, Mynd44
Can you guys pin this thread to the top of this programming section so that Laravel devs can find it faster.

Laravel is one of the most popular framework for PHP in the world and this thread will bring together experts and newbies.

Thank you.
Re: Laravel Nairaland Corner -- Post Any Laravel Code Issues, Get Solution For FREE by Maj196(m): 12:14am On Jun 10
Karleb:


What I specifically wanted was how to use components that is in a directory in the components folder. Components and not just any other view because it is reusable.

Anyway I got my answer using the documentation. After creating it in a components > Post > store.blade.php, you'll do <x-Post.store /> to use it.

Did you know today's Laravel 10th birthday?
Oh, sorry I use Vue for the frontend mostly. Yes I know it's the 10th birthday. Awesome framework, yea?
Re: Laravel Nairaland Corner -- Post Any Laravel Code Issues, Get Solution For FREE by promisedeco(m): 9:56am On Jun 10
Pls, I need a very comprehensive laravel video. Any recommendations
Re: Laravel Nairaland Corner -- Post Any Laravel Code Issues, Get Solution For FREE by EWSTechSupport: 11:02am On Jun 10
promisedeco:
Pls, I need a very comprehensive laravel video. Any recommendations

Follow and Watch Laravel Daily on YouTube
https://youtube.com/channel/UCTuplgOBi6tJIlesIboymGA

1 Like

Re: Laravel Nairaland Corner -- Post Any Laravel Code Issues, Get Solution For FREE by promisedeco(m): 8:25pm On Jun 10
EWSTechSupport:


Follow and Watch Laravel Daily on YouTube
https://youtube.com/channel/UCTuplgOBi6tJIlesIboymGA
Thanks boss
Re: Laravel Nairaland Corner -- Post Any Laravel Code Issues, Get Solution For FREE by Karleb(m): 8:45pm On Jun 10
Laravel Jetstream vs breeze, which do you use and why?
Re: Laravel Nairaland Corner -- Post Any Laravel Code Issues, Get Solution For FREE by JFOD: 7:19pm On Jun 11
promisedeco:
Pls, I need a very comprehensive laravel video. Any recommendations

laracasts (some videos are not free tho).

Laravel Daily (as suggested by someone) is also good.

Non video
The documentation is okay too

1 Like

Re: Laravel Nairaland Corner -- Post Any Laravel Code Issues, Get Solution For FREE by EWSTechSupport: 7:19pm On Jun 11
Karleb:
Laravel Jetstream vs breeze, which do you use and why?

Breeze - Simplicity
U?
Re: Laravel Nairaland Corner -- Post Any Laravel Code Issues, Get Solution For FREE by Tribers: 10:17am On Jun 12
how can I add post view count in my laravel 8 I'm using breeze
Re: Laravel Nairaland Corner -- Post Any Laravel Code Issues, Get Solution For FREE by Karleb(m): 12:12pm On Jun 12
EWSTechSupport:


Breeze - Simplicity
U?

Breeze or UI to avoid tailwind wahala.
Re: Laravel Nairaland Corner -- Post Any Laravel Code Issues, Get Solution For FREE by Karleb(m): 12:18pm On Jun 12
Tribers:
how can I add post view count in my laravel 8 I'm using breeze

There are packages to solve this but one simple way you can do this is increment the view_count column in the post table every time the page is opened or refreshed.

Something like in the picture in your show method.

Re: Laravel Nairaland Corner -- Post Any Laravel Code Issues, Get Solution For FREE by EWSTechSupport: 5:26am On Jun 13
Tribers:
how can I add post view count in my laravel 8 I'm using breeze

If you have a posts table, and you are looking at having detailed statistics about post views, you might need to setup a new table for post_views. Then reference the posts table id there. You may wish to track IP address of the viewer, and other information. Your question is a bit broad. If you need detailed help, I will point you to a video to watch
Re: Laravel Nairaland Corner -- Post Any Laravel Code Issues, Get Solution For FREE by Tribers: 6:37am On Jun 13
EWSTechSupport:


If you have a posts table, and you are looking at having detailed statistics about post views, you might need to setup a new table for post_views. Then reference the posts table id there. You may wish to track IP address of the viewer, and other information. Your question is a bit broad. If you need detailed help, I will point you to a video to watch
I guess I will need the video
Re: Laravel Nairaland Corner -- Post Any Laravel Code Issues, Get Solution For FREE by EWSTechSupport: 12:27am
Tribers:
I guess I will need the video

Sorry couldn't find the video I was looking for.
Check my snippet below to understand
Image 1 shows a simple migration table for blog posts
Image 2 shows a simple migration table for blog post views
Image 3 shows the blog post and blog post views relationship in the model (one to many)
Image 4 shows the blog post views and blog post relationship in the inverse model (many to one)

After u have setup your models and relationship,
In your Blog Posts controller Show method you can store a new count record for the post_views table so that a new record is created each time the post is being viewed.
To do that inside the show method we can say

$new_view_count = new BlogPostView;
$new_view_count->views = 1;
$new_view_count->blog_post_id = $post_id;
$new_view_count->save();

where $post_id is the id of the post in your show method

Re: Laravel Nairaland Corner -- Post Any Laravel Code Issues, Get Solution For FREE by EWSTechSupport: 12:37am
There are packages on github that can help you achieve the same objective.
One advantage of separating the views table from your posts table is you don't want to be updating the views column on the posts table each time your post is being viewed and also with a separate table you can log additional information like visitors ip, device, browser, etc

EWSTechSupport:


Sorry couldn't find the video I was looking for.
Check my snippet below to understand
Image 1 shows a simple migration table for blog posts
Image 2 shows a simple migration table for blog post views
Image 3 shows the blog post and blog post views relationship in the model (one to many)
Image 4 shows the blog post views and blog post relationship in the inverse model (many to one)

After u have setup your models and relationship,
In your Blog Posts controller Show method you can store a new count record for the post_views table so that a new record is created each time the post is being viewed.
To do that inside the show method we can say

$new_view_count = new BlogPostView;
$new_view_count->views = 1;
$new_view_count->blog_post_id = $post_id;
$new_view_count->save();

where $post_id is the id of the post in your show method
Re: Laravel Nairaland Corner -- Post Any Laravel Code Issues, Get Solution For FREE by Tribers: 6:31am
EWSTechSupport:
There are packages on github that can help you achieve the same objective.
One advantage of separating the views table from your posts table is you don't want to be updating the views column on the posts table each time your post is being viewed and also with a separate table you can log additional information like visitors ip, device, browser, etc

thanks for this

(1) (Reply)

How To Create Web 2.0 Backlinks That Actually Work For SEO / How Do I Recover My Locked Twitter Account. / Mobile App Developer Needed.

Viewing this topic: Tribers and 1 guest(s)

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2021 Oluwaseun Osewa. All rights reserved. See How To Advertise. 102
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.