Dynamic Folder per customer - laravel

I've a problem I don't know the solution.
I want when a user click a button (which i have design) it will call the controller method. In this method
I want to create a folder if it doesn't exist already in my view directory.
Copy a file into that new created directory which is a blade file.
Return that blade file with some data.
I've tried some methods but it doesn't work.
I'm unable to create the file inside the view and then copy the blade file into it.

Related

How to create a subfolder inside controller and view folders in codeigniter?

I wanted to create a folder named 'schoollevel' inside controller and view folder to create a separate module containing login function and profile views to provide another login functionality for some users. The 'schoollevel' contains all the files for login and profile view. Can anyone suggest how to do this ? I want the control to go to the separate folder.
Its Easy to create folder in controller and view in codeigniter.
Folder name : school
1.create a login controller
application->controller->school->Login.php
create a login view
application->view->school->login.php
Now, How to call view file
Inside login controller in the index() function add
this to call login.php view
$this->load->view('school/login');
I hope this help you!

Laravel 5 Filesystem: Create a Folder in a Folder

I'm programming a Filesystem Web App with Laravel at the moment and I can create folders and upload files. Now I want that when you are in a folder that you can create a new folder in the actual folder, so a folder in a folder.
Is there a way that you can save the actual path of the folder (maybe in a hidden text field or something) so the app know where you actual are and create a folder in a folder?
Assume that you are in the folder /foo/bar in your app interface, you can reflect your current location in a URL parameter, for example.
Something like this:
http://localhost/filesystem.php?current_path=/foo/bar
or if you have the URL rewriting enabled on your server:
http://localhost/filesystem/foo/bar
Now, you just need to retrieve the current_path parameter value in your controller's method and use it as you want.
And when you click on the baz subfolder in /foo/bar, update your URL parameter: ...?current_path=/foo/bar/baz. It's that simple.

Laravel 4 - Accessing Folders

I am new to Laravel 4, and I come from a Zend Framework background. I'd like to create a folder app/forms and keep all my forms there. How can I refer to the form in the controller and within the view.blade files?
By default, the root of the view files folder is app/views so if you create a folder in views like app/views/forms then you may refer the form by it's name from a controller like:
$form = View::make('forms.formfile');
Here, formfile is the name of the file that contains the form and it could be formfile.blade.php and to refer/include the form file from a view you may use #include:
// In a blade view file
#include('forms.form1')
Assume that, form1 is a blade view inside the forms folder and saved as form1.blade.php, you may also use sub-folders inside the forms folder, for example in views/forms/user folder you may keep a view named index.blade.php and use it like:
// From a controller
$userForm = View::make('forms/user/index');
From a view file: (folders are separated by .)
#include('forms.user.index') // file: app/views/forms/user/index.blade.php
You can also nest views in the controller, check the manual for more.
From the standpoint of Laravel, HTML forms (and all presentation related things ) belongs to app/views/ folder. Exceptions are package specific views. For example some commands has their own stubs and views and they are usually stored inside package.
Laravel is very flexibile, and you can move things around and create new folders and namespaces. You just have to tell composer that you are changing Laravel default structure, and dumpautoload. That is if you only want to create new folder with internal reference. If you want something with more scope and visibility you'll have to bind that to container, so that will be visible inside whole application.
You are coming from the Zend world, so I can understand that you want to move some of Zend "flavour" to Laravel. Although is it possible, I would really recommend you to take some time and learn how Laravel works. There are some great ideas and design inside. Of course, Zend has its own quality, but hey - this is Laravel :)

Load views based on REQUEST_URI

I want to create a setup where I can load views from a view folder based on the first part of the REQUEST_URI.
domain/folder1/ to load views from views/folder1 folder
domain/folder2/ to load views from views/folder2 folder
How would i set it up for it to work automatically? Can i modify the view path at a certain part of the lifecycle?
Thats not how you should do it. The router shouldnt call the view directly (nor the user in your case). Create a controller and asign the views with its data there.

In Laravel, what folder should I put a non-public data.json file?

I have another system that will drop in a data.json file somewhere onto my Laravel site/folder structure.
I want only Laravel to be able to be able to read the json file (i.e. a user can't see it by typing a url into a browser).
Where should this file go?
I'm currently torn between putting it in application/models folder or application/[new folder]. My webroot is set to the public folder, so you can't access the application folder via a browser.
If it is in there, I'm assuming I will be able to read it within php but not javascript (which is okay).
Just create a new folder in the app/ directory. Thats not visible to outsiders. Everything visible is in the public folder, as you said. If you create a new folder you can autoload it by setting up composer.json.

Resources