I am using laravel version 5.2 and I am trying to make it a PWA. For long hours of searching google and stackoverflow I can't find any suitable guides that will help me to make my laravel 5.2 app a PWA.. Can anyone help me? Please Ive been trying for a weeks already. I also tried creating my own service worker and manifest but the dynamic URL is the problem it doesn't render anything it just return to 127.0.0.1/dashboard . I am still on my localhost so PWA is supported by it.
Your problem can is on the route, you need create a specific route to your manifest.json and to your worker.js. This is an example to manifest.json:
Route::get('/manifest.json', 'YourController#Action')->name('manifest');
In controller action you need response a json.
return response()->json([
'name' => 'name',
'short_name' => 'short name',
'start_url' => '/',
'display' => 'standalone',
'theme_color' => '#000000',
'background_color' => '#000000'
]);
How reference you can see this repository https://github.com/silviolleite/laravel-pwa
Related
I have made a config test.php
return [
'name' => 'Testname',
'street' => 'Teststraße',
'street_number' => '69',
'zip' => '42077',
'city' => 'Winterfell',
'telephone' => '0123456789',
'email' => 'hsw#hsw.hsw'
];
created a ConfigServiceProvider:
public function register()
{
config([
'config/test.php'
]);
}
but in my test.blade.php I can access the contents only via
{{config('test.0.name')}}
There has got to be a better, easier way for this right? The data is supposed to be used in multiple blades. Yet the ".0." feels so unnecessary.
I am new to PHP and Laravel, and I am using PHP 8.1 and Laravel 9.14.
Thanks in advance!
#######################
Edit: In my case I had the problem, that my cache wasn't cleared "php artisan config:cache" thanks to #matheenulla for hinting at that!. Thats why I tried the route with the ServiceProvider. I hope this may help someone in the future!
You don't need to create a service provider to use your config, unless you want it to be in some other location (in case you are creating a custom Laravel package), so you may delete your ConfigServiceProvider. In fact, you're just using config wrong:
{{config('test.0.name')}}
should be:
{{config('test.name')}}
I am trying to send an sms once a user signs up but it keep getting:
"Class 'Nexmo\\Laravel\\Facades\\Nexmo' not found"
I have this at the top of my controller file:
use Nexmo\Laravel\Facades\Nexmo;
I also have this in my config/app.php file
'Nexmo' => Nexmo\Laravel\Facades\Nexmo::class,
Im still getting an error, does anyone or has the same problem. I know its a class type error but why if I have added the right class and im using it appropriately.
Also, here is my code implementation:
Nexmo::message()->send([
'to' => '1122334455', //not actually using this number
'from' => 'Test',
'text' => 'Hey, test this digit code',
'text' => $request->user()->activation_token
]);
Update 1:
I have done php artisan vendor:publish and published the nexmo config file but it sill gives the error above.
Add Nexmo\Laravel\NexmoServiceProvider to the providers array in your config/app.php:
'providers' => [
// Other service providers...
Nexmo\Laravel\NexmoServiceProvider::class,
],
Thanks guys for answers/suggestions
Some reason it is working now? I did all the suggestions/answers and it did not work, did some other stuff (not working on this) and it suddenly works?
Thanks guys :)
If I found out what I did to make it work I will update this answer.
Found the answer:
Found out when I run php artisan vendor:publish it gives a list to publish or something and i'm guessing I did not do the one that specifically publishes Nexmo. Still should've worked though because I did the one that will publish everything. Anyways that published the Nexmo file in config folder. Somehow that is what made everything else work, that and probably a combination of answer/suggestions
Anyways thanks guys for your help!!
First of all, the Nexmo documentation did not mention about to use with Laravel but there are as a additional package you need to use if you used with Laravel.
There are are a simple solution.You need to install a additional package that already provide by Nextmo to use with Laravel.Just install below one.I hope this will help u.
composer require nexmo/laravel
try it
$nexmo = app('Nexmo\Client');
$nexmo->message()->send([
'to' => 'yournumber',
'from' => 'yournumber',
'text' => "message"
]);
I have created a simple application in YII2 and it is working fine at my local machine but giving me Not Found (#404) "Page Not Found" error on live server.
Local URL: http://localhost:8080/basicapp/web/index.php?r=adminPanel%2Fstatemaster%2Findex
Live URL: http://XXXX.com/web/index.php?r=adminPanel%2Fstatemaster%2Findex
I am not using pretty URL, and didn't change in web.php. just added module info in the file. Code Snippet:
'modules' => [
'adminpanel' => [
'class' => 'app\admin\adminpanel',
],
'studentPanel' => [
'class' => 'app\Student\dashboard',
],
],
I can provide detial, whatever is required.
If anyone have similar problem, Just change your naming of models and controllers.
In my problem, model and controller names were like StateMasterController etc but it should be StatemasterController, mind the M.
It works for me, may be this can help you.
Thanks
I use the laravel (4.2) plugin (https://github.com/dimsav/laravel-translatable) and i was wondering if anyone knows how to dynamically adjusts "fallback locale".
I have tried this but still not work:
App::make('config')->set('translatable.fallback_locale', 'sl');
Thanks for answer!
====
I have found solution...
Config::set('translatable::fallback_locale', 'sl');
According to documentation here https://github.com/dimsav/laravel-translatable#documentation you can set your fallback locale in your configuration.
return [
'use_fallback' => true,
'fallback_locale' => 'sl',
];
I am using Laravel 5 to generate a PDF from a subscription generated from Cashier. The docs say this is as simple as calling:
return $user->downloadInvoice($invoice->id, [
'vendor' => 'Your Company',
'product' => 'Your Product',
]);
Unfortunately I'm getting an odd error:
No hint path defined for [cashier]
The code I am actually using is as follows:
Route::get('billing/invoices/download/{id}', function($id){
$user = Auth::user();
//$invoice = $user->invoices()->find($id);
return $user->downloadInvoice($id, [
'vendor' => 'Certify Me',
//'product' => $invoice->lines->data[0]['plan']->name,
'product' => 'Subscription',
]);
});
The docs make me assume that the PDF is automatically generated. I'd then assume I could override the PDF layout if I chose to.
I just ran into this (L5.1, Cashier 6.0). This seems to be caused by the service provider not being correctly loaded.
Here is how I fixed it:
Check that you have added the correct service provider, at the time of writing that is Laravel\Cashier\CashierServiceProvider to your config/app.php
If it still doesn't work, go run php artisan config:clear to make sure that the service provider is picked up.
Happy invoicing!
I'm going to resurrect this beast.
I had a similar issue because the service provider was not loaded. If you checkout CashierServiceProvider you'll see it adds the necessary 'namespace' for the 'cashier' prefixed views.
public function boot()
{
$this->loadViewsFrom(__DIR__.'/../../views', 'cashier');
$this->publishes([
__DIR__.'/../../views' => base_path('resources/views/vendor/cashier'),
]);
}
Add Laravel\Cashier\CashierServiceProvider to your config/app.php file and inside the providers key.
For anyone who runs across this like we did.