Default blade directives in Laravel/Lumen - laravel

Where can I find the default blade directives folder?
I was looking for the #forelse to take as example, but I couldn't find it.
Does anyone know where they are defined in Lumen/Laravel?
note: I'm using Lumen framework, but I think it's quite similar to Laravel in this question, so I'm tagging both.
EDIT:
Due to the imprecision, I'll explain better my intention.
Basically, I'm creating a directive exactly the same as #forelse, but with 2 or 3 further information.
For that reason, I came to ask about the location since I haven't found by myself.

They're defined in the Illuminate\View\Compilers namespace in the BladeCompiler.
See Illuminate/View/Compilers/BladeCompiler.php
Specifically you'll need the compileForelse method if that's the one you want as an example.

Related

Laravel 5.7+, How to use helper functions within Blade templates smartly

Since Laravel 5.7, the majority of global Helper functions (specifically the ones related with "Arrays & Objects" and "Strings") are now based on Facades (using Illuminate\Support\Str and Illuminate\Support\Arr classes) instead of being defined as "normal" helper functions, as they were before 5.7 (see difference with previous Laravel 5.6 docs).
Does it really mean that we are not allowed to use them anymore directly within our Blade views? If we do, they have to be obviously prefixed with its full path in any case, resulting in a dirtier Blade views...
Is not this change counter-productive?
EDIT:
Made some googling and found this article that confirms the situation.
Also, I have seen that in 5.8.17 it is planned to include Arr and Str aliases by default within config/app.php (link).
In the meanwhile, I proceed to register Arr and Str aliases in my config/app.php config file to avoid the full path issue.
Thanks

I tried every way to use css in blade,but I failed,I need help!any tips or idea is ok

my project code is: https://github.com/xsmyqf/hyhj.git
I was wrong to visit "localhost/hyhj/public/user/login".I failed to try every way to use css in blade,I need help,It seems that blade system did not give any response now.I want to know why I cannot use css in blade?notice that I have seen Using CSS in Laravel views? ,and I tried the way in it,but it did not give any response!that is my headache,and when I tried to use in blade,it did not give any response at all,I am crazy about this,It have wasted a day time,Must I substitute the blade with smarty?ah...
Your blade files need to be named with *.blade.php. You called View::make('hello') and your file is called hello.php, try naming it hello.blade.php

How to access values from a configuration file stored in subdirectory?

Accessing config values at run-time in Laravel 4 is done using its Config class:
Config::get('app.timezone');
To organize the config files, I'd like to put them into different sub-directories.
For example:
/config/users/ -> for user specific configuration
/config/auth/ -> authentication related
and so on...
I read an elder Tutorial (Laravel v3) from Dayle Rees him stating that it's possible with the following:
$option = Config::get('ourconfig.sub.directory.size');
Tried it out with no luck. According to Jason Lewis it was never supported.
Then I've had a look at the Laravel 4 API and found load() and getRequire() (more related functions can be found here).
However, I couldn't find a way to grab sub-dir config values in L4.
So,
Is this possible with Laravel 4?
…and, if so, how?
A solution to your problem that works for me is:
Config::get('subdir/file.key');
Did you try this one yet or are you looking for more complex method?

Laravel 4: Fluent changes?

I read that Laravel 4 is not going to change much on the surface, saying that much of the old code would be compatible.
I try to use Fluent's insert_get_id like it says in the docs, but the function doesn't exist.
Am I doing it wrong? If not, are there more changes in Fluent and / or Eloquent?
Laravel 4 has been changed to become PSR-1 complaint and as such is now camelCased instead of snake_cased. Try changing to insertGetId().
I believe functions went from underscores to camelCase... try insertGetId

Sorting a view by dropdown

Hey, i've been looking around for a ajax dropdown sorter for my Views in Drupal.
Unfortunatly, i haven't found alot of usefull information about this subject.
Can anyone tell me if theres a solution already available or can help me started on a custom module by telling me which hooks i should use?
I had a similar issue. Unfortunately I wasn't able to sort the data from the database which is by far the best way. I was however able to take the data and sort it with PHP using a preprocessor function. Depending on the name of your view, setup a function similar to the following:
function templatename_preprocess_name_of__view(&$vars)
{
//Super sweet sorting code goes here
}
The name of your view needs to follow the name of the template file that it is driven by, if there isn't on you should create one. Make sure to change dashes to underscores in your function name. Hope this is helpful. If you find a way to do it from the DB I'm all ears because that would be super awesome.

Resources