Canvas: Allow guest to view all post

Created on 5 May 2019  路  5Comments  路  Source: austintoddj/canvas

Hi,

Apologize if newbie question asked, newbie hobbyist trying to develop something here.

I am thinking to make a personal blog as portfolio and came across Canvas, it is awesome, clean and it works.

bumped into few errors like defaultStringLength and MariaDB not support JSON, managed to solve it.

and I am lost as my objective is to allow visitor to see all published posts without require to Login but not able edit anything.

I can see middleware in vendor\cnvs\canvas\config\canvas.php
also routes mention that initial xx.xx.xx.com/canvas using StatsController
but I have no clue how to modify to achieve my objective.

Could shed some light on how could I achieve that?

Thanks in advance!

question

All 5 comments

Glad you like it!

As far as your objective is concerned, are you saying that you'd like visitors to be able to access the /canvas routes but not able to create/edit/delete things?

The middleware you're seeing is simply verifying that authenticated users are accessing Canvas, since the user id is stored in the posts table to notate authorship.

If you wouldn't mind re-wording your question, perhaps I could be of more help.

Hi Austin,
Thanks for the patients and my apology for the confusion, Let me rephrase my words

The goal is just like blogs on blogspot / wordpress where:

  • Author require to access /login and login to publish / create / modify / delete posts.
  • Visitor can access 127.0.0.1:8000/ and see all the posts in canvas with no login required

Conclusion:
2 types of user:

  • Visitor, No login required, No permission to do anything, Only view all the posts
  • Author, login required, Can do anything (actually there will be only 1 author which is me)

I have no clue on how to achieve to only use Middleware when someone access 127.0.0.1:8000/login
but all Posts are visible to all visitors with no login required

I only manage to do some changes on the routes and views to fit my personal requirement.

So would be very appreciate if you shed some light on how to do so.

Thanks
Regards

Ah, I think I see where you're going. Correct me if I'm wrong..

Canvas has a built-in Artisan command to generate routes, views, and a controller which makes the posts(published), tags, and topics visible to non-authenticated users. In simpler terms, it generates a frontend.

Check the documentation section here and simply run php artisan canvas:setup and you'll be able to visit http://your-app.test/blog to see the content you've created with Canvas.

Does that answer your question?

Thanks for the prompt response, let me check and test it out first!
Appreciate for the advise!!
Come back to you if I am still stuck!!

Thanks Austin!!

Hi Austin,

It works as you describe!!
Apologize for overlooked the php artisan canvas:setup in documentation!

The blog looks awesome!!

Thanks!! Kudos to yall!!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

karlmonson picture karlmonson  路  10Comments

floriangaerber picture floriangaerber  路  9Comments

connecteev picture connecteev  路  4Comments

reliq picture reliq  路  4Comments

austintoddj picture austintoddj  路  10Comments