Laravel Nova - output forms on front end? - laravel

I am building a system that uses Laravel Nova for managing resources.
There are a couple of instances where I want non-admin users to be able to create resources. The ideal solution would be to define the resource in Nova and embed Nova's own create form on the front end of the site.
Has anyone done anything similar, or have any suggestions how to go about this?

I believe you can use the same endpoints that Nova is using.
For example to get all the fields of a resource:
GET updating fields:
http://{url}/nova-api/{resource}/{id}/?editing=true&editMode=update
GET creation fields:
http://{resource}/nova-api/{resource}/creation-fields?editing=true&editMode=create=
After the user has filled out the fields, you can use this endpoint to save the new values:
PUT:
http://{url}/nova-api/{resource}/{id}

Related

strapi how to limit content added by user

I don't want users to add more than 3 content.
Example: I want to have demo users which will be able to add just 3 items in to things to do.
Payed customers will add with out any limit.
Is there a way to stop users adding new content after 3 content?
I need Roles with limited create content permissions.
Note: we'll be using api endpoint to add content
I couldn't find a way.
Solution: was to limit users from updating content in front-end.
https://strapi.io/documentation/3.0.0-beta.x/content-api/api-endpoints.html#create-an-entry
Thanks to #jim-laurie

Laravel limiting access to route

I am trying to implement a basic image fetch system for my website. Already created a route that returns me the image.
what concerns me is that i want that route to be only accessible by certain controllers.
Tried to search it and found out passport might be viable option but it's pretty complex for this app. Are there any possible options ?
EDIT:
Sorry for providing insufficient information. I want the route to be accessible only by CONTROLLERS, not by anyone who enters the route url to address bar. Like using it as an api maybe.
There several ways to achieve that, you can use middleware, you can consider using packages like entrust which also require you to have some knowledge about using middleware. or use laravel Auth
create a table add all the routes in that table and then check the allowed route in AppService provider.
$routename = Request::route()->getName();
$allowed_route = AllowedRoutes::where("route","=",$routename)->count();
if($allowed_route == 0)
exit();

How to "connect" Laravel project with Craft 3 CMS Website

I've developed an app which fetches data from an API based on Laravel 5.5. The marketing landingpage of the app is based on Craft CMS Version 3. The marketing website and the API and the databases of both systems are running on the same server.
I want to generate landingpages for each row of table X of the Laravel database.
www.website.com/awesome-landingpage-about-{slug}
What is the best approach to realize this?
I don't want to fetch the data directly from Laravel's database
I don't want to synchronize the Craft CMS database with the Laravel (add/remove the rows from the laravel's database as entries to Craft)
It would be awesome to be able to have an entry-type "Landingpage" where we can optionally create a landingpage, referencing to an ID of the laravel table and add additional content for the landingpages.
Would be a JSON-API from Laravel to Craft CMS Plugin a good performant idea?
One option would be to use a Dynamic Route and just fetch the data from 127.0.0.1 (because same server) from the template file? Or is there a smarter way in Craft CMS?
Let's start of by:
"I don't want to fetch the data directly from Laravel's database"
I'm assuming you don't want to write code in CraftCMS to access another project's database. Good. IF you plan on having them do seperate jobs and use Laravel API for fetching data alone, let it handle it's own database.
"I don't want to synchronize the Craft CMS database with the Laravel (add/remove the rows from the laravel's database as entries to Craft)"
So, this is my question:
You want to be able to create landing pages based of Laravel's rows alone or based of Laravel's database row's and CraftCMS's?
It all comes down to how well you want to abstract both frameworks.
I would probably tell laravel to accept requests from authenticated user (a CraftCMS User) or from localhosts (from within the machine alone) and I'd create endpoints to add/remove/edit/get data at my disposal. I'd then fetch rows from Laravel and combine with my own (assume I'm the CMS).
Even in an intranet network, the request to tell laravel to access the database is longer than to access the database from CraftCMS, so you should expect a dependency between the two projects.
For point 3, you'll have to store information on each database about something. On CraftCMS's to store at least the ID's it's going to request to laravel and laravel will have to get an endpoint where it can insert new stuff, if you're planning on having additional content there.
I'm not entirely sure if I got the idea you're trying to show when you say "add additional content for the landing pages" but I'd try to keep it simple and abstract it's uses, Laravel to store this 'information' that the CMS shouldn't handle in the first place (or you can work out some extra tables and import them to the other database).
Impact performance? Depends on the ammount of data you've got

How do I change the index page in a CodeIgniter anchor?

So, I have two different applications in my CodeIgniter installation. One is admin, the other is frontend. I basically just copied the index file, renamed it "admin.php", and changed the application directory to "application/admin". I then changed the application directory in index.php to "application/frontend".
What I would like to do is create a link on the frontend application that takes you to the admin application. The variable config['index_page'] in the frontend application is set to "index.php" and in the admin application it's set to "admin.php".
Is there a way to set the url helper to use "admin.php" instead of "index.php"?
You don't need to do that way.
you should make or use an authentication library and you set different roles for different
users.
you just after login can put the redirection to your admin controller.
and for other users and viewers you can redirect them to any other controllers.
for viewers you can just use something like this:
Code:
if(!$this->m_auth->is_logged_in())
{
$this->viewers();
}
else
{
$this->users();
}
In your users function you just check different roles and redirect according.
I think you are missing some codeigniter concept, and you are trying to do it the normal way, i suggest you to read this article , you will how you can use MY_Controller as same concept of front controller and how you will be able to give every use specific roles
another way is to use a ready made authentication library as #medhi said
I would recommend Tank Authentication or Ion Auth
I

Where to configure routes and paths in Ruby on Rails?

Probably a noob question but I'm new to Rails and building my first app as a project to complete my apprenticeship.
I have four pages listing contact, account, billing plan and call information. Each have that standard edit, show and create functions.
I have a table that pulls information from FreeAgent using the API, It just lists basic information (price, due date etc.) I want to create another page so when the user clicks on the invoice they go to another page containing a PDF and more information.
So instead of the path being /accounts/'user id' I want it to be /accounts/'user id'/invoice
Do I need to create another controller or just define a new method in the accounts controller?
Cheers
Arran
I suggest you read the RoR Guide on Routing first, especially the section on nested resources.
Your routes in routes.rb probably look something like this:
resources :accounts
resources :invoices
The aforementioned guide will teach you that you should define the routes like this instead:
resources :accounts do
resources :invoices
end
which will give you these routes
verb route action
------------------------------------------------
GET /accounts/:account_id/invoices index
GET /accounts/:account_id/invoices/new new
POST /accounts/:account_id/invoices create
GET /accounts/:account_id/invoices/:id show
and so on ...

Resources