binshops / laravel-blog

Laravel Blog Package/ Laravel CMS. Easiest way to add a blogging system to your Laravel website. Laravel Blog.
https://www.binshops.com
MIT License
429 stars 134 forks source link

Issue when listing all blogs #23

Closed Naveedali1234 closed 3 years ago

Naveedali1234 commented 3 years ago

i can add the posts successfully but now i am facing another issue when showing all the blog posts on homepage on this url en/blog. i can see the below error:

Too few arguments to function HessamCMS\Models\HessamPostTranslation::url(), 0 passed in /var/www/html/ski_pro_web/vendor/hessam/laravel-blogger/src/Models/HessamPostTranslation.php on line 129 and exactly 1 expected (View: /var/www/html/ski_pro_web/resources/views/vendor/hessamcms/partials/index_loop.blade.php)

samberrry commented 3 years ago

@Naveedali1234 which version of laravel are you using?

Naveedali1234 commented 3 years ago

i am using laravel ^6.0

samberrry commented 3 years ago

@Naveedali1234 please add this line echo $lang->locale;

at the end of handle method in "DetectLanguage.php" file within 'Middelware' dir , before return.. and access the url again. then give me a screenshot please.

samberrry commented 3 years ago

I want to know that does it get filled? I mean the lang locale

Naveedali1234 commented 3 years ago

i resolved the issue in following way:

In Models/HessamPostTranslation.php we have the following method:

public function search_result_page_url() { return $this->url(); }

but the url() method expects atleast one parameter called locale and in url() method i made the parameter optional and it worked as below:

public function url($loacle='') { return route("hessamcms.single", [$loacle, $this->slug]); }

samberrry commented 3 years ago

yes it works, but your post URLs will be wrong. The locale is required to detect language. But I do not know why your $locale is empty. If you find why, we can easily fix it many thanks

Naveedali1234 commented 3 years ago

let me send a screenshot by printing the result as you asked.

Naveedali1234 commented 3 years ago

i think it's showing the locale en , please see it on top left.

image

samberrry commented 3 years ago

yes you are right, it's showing.. let me check it in more detail

Naveedali1234 commented 3 years ago

i think it's just because of the reason which i mentioned before. maybe i am wrong.

samberrry commented 3 years ago

the that was a partial solution, that solves the problem but generates links without locales (for example "en", "fr"). And we need these locales No worry, I will fix it

Naveedali1234 commented 3 years ago

okay thank you @vhessam

samberrry commented 3 years ago

thanks you too Naveed