How to rename the class or php file in laravel - laravel

I Want to rename my php file so that wherever the name exists or used it's name for some functions in the whole laravel file that also should be changed by the new name.
How do i do that in laravel.?

That's not a task for the Laravel framework. This is a task for your code editor, preferably an IDE like PHPStorm or NetBeans. Most IDEs have a function to refactor things like class names. In the case of PHPStorm you could right-click the class name you want to rename, select Refactor->rename. After that everything's self explanatory.

Related

How to replace actions with html icon on backpackforlaravel

I have created this app with backpack for laravel where the table created by using backpack:build
I need to replace the word actions with an icon from line-awesome for example toolbox
<i class="las la-toolbox"></i>
I tried to add the HTML on the language file
resources/lang/vendor/backpack/en/crud.php but it's not working
In Backpack 4.0 or 4.1, you can change the default buttons any way you see fit by publishing the view file, and making changes to the published file. If Backpack sees a file with the same name & path inside your project, it'll use that one instead of the one in the package.
For example:
if this file exists: resources/views/vendor/backpack/crud/buttons/delete.blade.php
then Backpack will load that one, instead of the normal vendor/backpack/crud/src/resources/views/crud/buttons/delete.blade.php
For reference, you can find all default Backpack buttons here, in the Backpack/CRUD package. Overwriting one is just a matter of creating a file with the same name in the directory I mentioned above.
You can publish a blade file even easier by using this command:
php artisan backpack:publish crud/buttons/delete
Then make any changes you want to it, like removing the text to only leave the icon.
In Backpack 4.2 it is possible that an easier solution will be implemented for this particular need. See this PR for more information. Backpack 4.2 will be released in spring 2021.

How to prevent a new controller from creating a new folder for its views in the Views folder?

I'm writing an ASP.NET MVC 5 application, where folders are organized by feature (ViewModels, Controllers, and Views are grouped together). I was able to override all default folder paths and manage all routing successfully. However, every time I create a new controller, Visual Studio creates a new Views folder and a child folder with controller name, which is a little bit annoying but that's fine.
Now, when I create another controller, I'm getting this error, because Visual Studio created the Views folder again, which is hidden now (excluded from the project). To fix this, I have to include the Views folder in the project and delete it after I create the controller.
Does anybody know any way to prevent this?
Error
There was an error running the selected code generator: 'A file or
folder with the name 'Views' already exists on disk at this location.
Please choose another name.
If this file or folder does not appear in the Solution Explorer, then
it is not currently part of your project. To view files which exist on
disk, but are not in the project, select Show All Files from the
Project menu.
Instead of using visual studio's Add -> Controller which generates the undesired view folder, create your controller using Add -> Class. Name the class conventionally with a Controller suffix and subclass Controller like this MyController : Controller.

Custom Pagination

I'm following the tutorial here in the docs:
Custom Presenters
But where do I place the Zurb Presenter class in my file system and how do I let Laravel know it exists?
There isn't really a defined place to put the actual file so you usually put it wherever feels the most natural to you. I'd probably create a presenters folder within your app folder and put it in there.
To let Laravel know where it is, there are a couple things you can do.
The first is adding it via composer. In your composer.json file, in the autoload classmap section, simply add your folder app/presenters. Then you will want to open up your command line, navigate to your project's directory, and run the command composer dump-autoload. Now it should automatically be loaded via composer.
The other solution would be to open up global.php in your app/start folder and add another entry in the ClassLoser::addDirectories() entry pointing to your new folder.
app_path().'/presenters',

Why is Xcode not prefixing filenames?

When I start an iOS single view application project, the AppDelegate files and ViewController files are not prefixing with the project name like they used to.
files names are as follows when I open a new project:
AppDelegate.h
AppDelegate.m
MainStoryBoard.storyboard
ViewController.h
ViewController.m
Why is this?
You have to add it manually. When you create a new project just fill out the "Class Prefix" field on the screen where you name the project/bundle id/ etc..
Just add your prefix where I wrote "THIS IS THE PREFIX" in the screenshot below
If you want to add a prefix after you've created your project, you can do so in the file inspector on Xcode's right pane:
Personally, I prefer not to prefix class names within an application.
When you are writing code for libraries, or custom classes, or categories, they are recommended, as there aren't namespaces in Objective-C.
But for application classes, I find they are just noise. Looking down a list of files that all have the same three letters in the front makes it just a bit harder to find what I'm looking for.
I mean, are you really going to have more than one class called AppDelegate? I'm all for full and descriptive naming of my classes, but prefixes for all the classes doesn't help me.
If it helps there are a few conventions for writing code. Search and you'll find them. Here are mine, for example.
You don't have to follow them, but pick a style and be consistent with it.
XCode 8 does NOT have the 'Class Prefix' field. It only has 'Product Name' and this does not ripple down to the view controller or the app delegate. I think 8.3 has bugs.
Class Prefix is file & template business. For the sake of organised files in a project it makes sense to have filenames that express their contents.
The workflow to achieve that was actually simplified with the Class Prefix field in the File inspector panel while your project name is active (clicked) in the file browser.
When there is a class prefix set the class name field when creating new files is predefined. That way you can choose file by file (class by class) if you want to use it and class name and file name will result in similar name scheme.

Visual Studio 2010: Folding auto-generated resources behind other files?

I have the following file: Foo.cs with a Foo class inside of it. I can't seem to find the right way to keep my resource files (resx) organized behind their respective files.
If I create a Foo.resx the resource file gets folded away nice and tidy behind the Foo.cs class. This, however, causes issues because the standard custom-tool that generates the code attempts to create another Foo class (Look at the Foo.Designer.cs: internal class Foo { ... }). If my Foo.cs file does not already contain a Foo class, this works fine (no naming collision).
To fix the naming collision I attempted to give it a custom namespace MyProj.Resources and use an alias to identify it: using R = MyProj.Resources.Foo; This still causes issues because the auto-generator has an issue creating a ResourceManager properly.
If I, instead, name it something along the lines of FooResx.resx it does not automatically get folded behind the Foo.cs file. Instead, it resides in the solution explorer right below it. Going into the MSBuild (.csproj) file and adding a <DependentUpon> tag, then Visual Studio neatly tucks away my FooResx.resx file. However, I can't actually use any of the resources from that file because the auto-generated code has an issue creating a ResourceManager properly.
Basically, is there any way to have the Resource files (resx) fold behind a cs file and still work properly using the standard Custom Tool (ResXFileCodeGenerator)?
I do realize that I can always place all my resources into a file within the properties folder: resources.resx. I'm trying to organize them better than that though.
Update:
I decided to manually edit the auto-generated code and make it partial. This allowed the code to compile, but I still ran into the same issue (Issue #2). It seems that if a resource file is folded behind (manually or automatically) another code file then the ResourceManager has trouble finding the *.resource file. This might be an issue I'll have to raise with Microsoft Connect about the ResXFileCodeGenerator tool. It needs to be able to locate the proper *.resource file when folded behind other files.
The solution could be to make your classes and your generated code partial classes - if you look at a .Designer.cs (from a System.Windows.Forms.Form for example) you will discover that it declares something like partial class Foo.
Foo.cs
public partial class Foo
{
}
Foo.Designer.cs
partial class Foo
{
}
Edit
It turns out that StronglyTypedResourceBuilder or PublicResXFileCodeGenerator insists on generating classes with either internal or public access modifier (it can be set in the .resx).
Setting ResXFileCodeGenerator as the CustomTool in the properties of your .resx still doesn't give you the behaviour you'd see in a generated .Desinger.cs of a Form.

Resources