Call to undefined function _() - laravel

I am having trouble with this error,
ErrorException (E_ERROR)
Call to undefined function _() (View: C:\Codes\web-is\resources\views\layouts\client.blade.php)
and it is pointing in this code
<title><?php echo e(_('This is title')); ?></title>
I think it is in the _() of Laravel helper, but it should be working right.
I really do not know what is going on, there is a live server that working fine with the code. I just tried to clone the repo to my laptop and install necessary requirements such as PHP, IIS is my web server. I also sure that PHP extensions are installed, I can see it in phpinfo().
Any help will be appreciated. Thank you.

The default Laravel helper function to get translation string is __(), not _(). Note the two, double underscores __.
See this link; https://github.com/laravel/framework/blob/8.x/src/Illuminate/Foundation/helpers.php#L820

Related

some laravel route not changing to https

There are some my route not going to HTTPS in my Javascript code
loadSettingTable("{{ route('setting.table.data.datatable') }}");
they become like this, so my datatable can't be load because mixed content.
loadSettingTable("http://*****.com/admin/data-setting-table/datatable");
but my css and JS file already become HTTPS.
I already give this on my AppServiceProvider and ENV
//AppServiceProvider.php on Boot
if(env('REDIRECT_HTTPS')) {
$url->formatScheme('https');
URL::forceScheme('https');
}
//.ENV
REDIRECT_HTTPS=true
But some of it work fine with this code, why my code with route name not giving https?
loadTableRealCommSumAgent("/agent/commissions-summary-member-ajax");
I found the error myself, but don't really know why this error happens on my production server not staging server. I remove $url->formatScheme('https'); because it giving some error on production but not always and it's fixed my problem.

Laravel 5.2 testing always returning 404

guys,
I'm having this issue to create my firsts tests on my project. I already try almost everything, search in forums, but I can't resolve this problem. Every page that I try to access using get in my test is always returning 404.
public function testExample()
{
$user = factory(User::class)->make();
$this->actingAs($user)->get('/book-original');
$this->assertResponseOk();
}
There was 1 failure:
1) FileTest::testExample Expected status code 200, got 404.
I'm using a separeted .env.testing file, but try to setup my .env file same as the testing, in case the Laravel is ignoring the testing and reading the main one, but the result is the same.
I try to use the $baseUrl and .env's APP_URL with http://localhost and my IP and try to use the return value from php artisan serve command, in my case, http://localhost:8000, but in both cases the error persists.
Important: I used php artisan config:cache every time I changed the configs.
I'm already lost. Has someone a hint to help here?
Thanks so much.

Laravel error: Sorry, the page you are looking for could not be found

I need to update a website from a colleague to just add a LDAP connexion.
I use EasyPHP devserver 17.0 with php 7.1.3 and MySQL 5.7.17.
I've read a lot of docs etc to be started and to recover the site in local as it is working actually.
Everything was working so I began to add a login form etc... but when I tried to test a link from the website, it return me the error "Sorry, the page you are looking for could not be found". So I began to search on forums I found some results about routes etc and everything I've tested didn't worked.
So, I decide to use the backup from the website as it was when I juste restore it in local(I precise link to other page and everything was working). I check the link and again, "Sorry, the page you are looking for could not be found". I decide to try another developement tool and download XAMP, exactly same error. I tried with Wamp, Laragon always same error.
In the apache conf mod_rewrite is enabled.
My laravel framework version is: 5.5.39
So my folder look like:
Laravel 5.5.39
The content of routes > web.php:
Route::get('/', function () {
return view('welcome');
})->name('welcome');
// Holidays
Route::get('/holidays/create', 'HolidayController#create')->name('holidays.create');
Route::post('/holidays', 'HolidayController#store')->name('holidays.store');
Route::get('/holidays/{holiday}/delete', 'HolidayController#destroy')->name('holidays.destroy');
Route::get('/holidays/{holiday}/edit', 'HolidayController#edit')->name('holidays.edit');
Route::post('/holidays/{holiday}', 'HolidayController#update')->name('holidays.update');
// Leave types
Route::get('/types/create', 'TypeController#create')->name('types.create');
Route::post('/types', 'TypeController#store')->name('types.store');
Route::get('/types/{type}/delete', 'TypeController#destroy')->name('types.destroy');
Route::get('/types/{type}/edit', 'TypeController#edit')->name('types.edit');
Route::post('/types/{type}', 'TypeController#update')->name('types.update');
// Users
Route::resource('users', 'UserController');
Route::get('/births', 'UserController#getAllBirths')->name('births');
// Leaves
Route::get('/calendar', 'LeaveController#index')->name('calendar');
Route::post('/leaves', 'LeaveController#store')->name('leaves.store');
Route::post('/leaves/{leave}', 'LeaveController#update')->name('leaves.update');
Route::get('/leaves/{leave}/delete', 'LeaveController#delete')->name('leaves.delete');
Route::get('/leaves', 'LeaveController#getAll')->name('leaves');
Route::get('/config', 'ConfigController#index')->name('config');
// Stats
Route::get('/statistics', 'StatsController#index')->name('stats.index');
Auth::routes();
I don't know what I could do but please ask me if you need more information to help me.
If it can help; gitLab link from the site I'm trying to restore: https://gitlab.com/balsigergil/btplan
To fix the problem I had to change the VirutalHost DocumentRoot so the root is the public directory.
DocumentRoot "C:/Users/sadm-m263733/Desktop/EasyPHP-Devserver-17/eds-www/siteBTPlan/public"

smarty not working in codeigniter

I installed Smarty in Codeigniter and it's not really working. Here is what I did:
I followed this instructions:
http://sunwebexpert.com/books/detail/PHP/integrating-smarty-and-codeigniter.html
But I also put another file in the library: parser.php which is a library to do parsing (I've used it before with smarty and worked well)
the on Codeigniter's autoload.php wrote this:
$autoload['libraries'] = array('parser','smarty');
On main controller I wrote this function to test:
public function index()
{
$this->data['d'] = 2;
$this->parser->parse('base/test.tpl', $this->data);
}
but the result is no error display and I see the variable 'd' as it is wrote in the template:
{$d}
So I have two questions:
Why can't I see the variable value if I installed smarty as I did before in other projects?
How can I enable to see errors if there are?
The problem is that in codeigniter, there is a built-in library called Parser. That's why this may cause conflict with your library name. Try to rename your library name or use built-in library.
Here is how to display error on codeigniter.
Hope it will be useful for you.

ion_auth library syntax error, unexpected ','

i am using ion auth library in codeigniter when i integrated it and accessing from localhost it showing me error as mentioned in image.
when i opened the library code line 141 the code is:
$user = $this->where($identifier, 'ion_auth'), $identity)->where('active', 1)->users()->row(); //changed to get_user_by_identity from email
now my question is the ) symbol after 'ion_auth' is ok or wrong? when i removes this library code works fine.
This has been fixed. Please pull the latest code from github.
I am not sure what you are trying to do, assuming you are the one who modified the library.
$this->where($identifier, 'ion_auth'), $identity)
The where method call is terminated by the parenthesis that follows 'ion_auth'.
This would be legal
$this->where($identifier, 'ion_auth') ->where('active', 1)->users()->row();
Assuming that is what you want.
this issue was exist when i downloaded library but later after mentioning here Ben Edmunds has updated code and now the correct code is
$user = $this->where($identifier, $identity)->where('active', 1)->users()->row();
at line 141 which is working for me.

Resources