4,420 experience to go until the next level!
In case you were wondering, you earn Laracasts experience when you:
Earned once you have completed your first Laracasts lesson.
Earned once you have earned your first 1000 experience points.
Earned when you have been with Laracasts for 1 year.
Earned when you have been with Laracasts for 2 years.
Earned when you have been with Laracasts for 3 years.
Earned when you have been with Laracasts for 4 years.
Earned when you have been with Laracasts for 5 years.
Earned when at least one Laracasts series has been fully completed.
Earned after your first post on the Laracasts forum.
Earned once 100 Laracasts lessons have been completed.
Earned once you receive your first "Best Reply" award on the Laracasts forum.
Earned if you are a paying Laracasts subscriber.
Earned if you have a lifetime subscription to Laracasts.
Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.
Earned once you have achieved 500 forum replies.
Earned once your experience points passes 100,000.
Earned once your experience points hits 10,000.
Earned once 1000 Laracasts lessons have been completed.
Earned once your "Best Reply" award count is 100 or more.
Earned once your experience points passes 1 million.
Earned once your experience points ranks in the top 50 of all Laracasts users.
Earned once your experience points ranks in the top 10 of all Laracasts users.
Replied to Writing Query Inside Map
@deekshith I saw your question this morning. When you look at it it is a monnster query that only waits to break ;-)
Try moving your counts to relations first:
$catcorrectCount = UserAnswer::join('questions','user_answers.question_id','=','questions.question_id')->where('questions.test_id',$test_id)->where('questions.language',$user_tests_det->test_language)->where('user_answers.user_test_id',$user_test_id)->where('questions.question_category',$category->question_category_id)->whereRaw('user_answers.user_answer = questions.correct_option')->count();
Should become just:
UserAnswer::catcorrect()->count();
That would be a good start for me.
Replied to Font Awesome Not Displaying In Vue
Quick google:
https://stackoverflow.com/questions/59114993/how-to-use-font-awesome-5-icons-in-laravel-6
Shows that you missed osme of the steps
Replied to Change Connection Right After Login
Hey @johnw65
What how do you connect to your oracle database in first place? How do you establish that you actually have a connection?
Replied to How To Access The Relationships Via Models In Laravel 8 Inertia
@samar92 You need to show more of your code, please.
Do you call this in a vue component? I so you should fetch all the data before passing it to vue, so in your controller.
Replied to Info Frontend / Backend / Api Structure
I feel your pain as you try to make sense of all of it ;-)
Ok one by one:
What is front end - this is what users see and interact with. It should hold no logic and only display data to users and get data from users.
What is backed? It is something like an admin panel where you do "stuff" with what users expect you to do eg. moderate, generate etc.
Your code. Now this is where magic happens. The code you write will in the end generate frontend, generate your backend if needed and also handle API.
Ok so what is API then? Well, imagine it is a front end but without all those nice html and css. In fact if you go to any of the functions in your app and at the end instead of
return view('welcome');
you do this or any other data you want:
return User::all();
You will get proper json response which is exactly what you expect from API.
5 Address of the backend - everyone can know it. You just secure it with something like Laravel Fortify.
6 File storage - look at answer 3.
7 S3 - nothing to do with any of it. You can use it or not, it has nothing to do with mobile apps or your app.
Hope that points you in the right direction!
Replied to How To Code For Validating Multiple Data With Similar Parameter In Compact Way For Laravel API?
Hey @nikunj001
The only ok way I saw to do this was to decode json to array and then validate the data. There is no nice "laravel" way to do it straight away with json as far as I'm aware.
Replied to How To Display Data On Edit Livewire One Modal CRUD
@anonymouse703 so you are using livewire with vuejs as a front end right?
The answer will be you do it exactly the same as with alpinejs:
Replied to View Website Using IP Address In Forge
@peterdickins did you ever checked cloudflare? You can register your domain there and then let cloudflare handle all of your dns stuff. The beauty of it is that any change to IP will be more less visible immediately everywhere in the world.
Oh and it is free for basic usage ;-)
Enjoy!
Replied to All Jquery Resources Are Ok But Dropdown Doesn't Work
You need to import that .js into your app.blade.php
in order to work.
Or mix it in with Laravel Mix
Replied to Date Casting In Query
In your model use:
protected $casts = [
'min_date' => 'date',
];
instead of:
protected $casts = [
'min_date' => 'datetime',
];
Awarded Best Reply on Need To Track And Monitor Oracle DB Connection
@johnw65 Laravel can work with Oracle but it is not as straight forward as it might seem.
Oracle instance has users table but to use this credentials to log into you web app is will be quite tricky as you have to know what hashing mechanism was used and etc.
It will be much simpler to use emails of users and generate passwords for them.
Why your uses have direct access to database anyway?
Awarded Best Reply on Session Timeout - Alert User
@johnw65 if session expires then next refresh will redirect to login page. This is how it works. You could in theory show a timer to the user by checking his session when he enters/refreshes the website.
But the question is: "Why bother doing it?"
If you really have to do it then set session lifetime to some crazy value in config/session.php
:
'lifetime' => env('SESSION_LIFETIME', 120),
525600
would be a year.
Replied to Livewire Telephone Input
Hey @joeseph chen
I use this package for my phone dilemmas: https://github.com/Propaganistas/Laravel-Phone
It also has validation helper so you could validate your phone using it and livewire validation logic.
I'm not too sure if you even need to use alpinejs in that case, you can skip the whole country selection to be honest, just validate like this:
$m->to = PhoneNumber::make($a->user->phone, ['UK', 'DE', 'FR'])->formatE164();
It works quite well for me.
Replied to Setting Correct Value In Mail Settings To Send Email Using Smtp Server
Hey @enthusiast14
An easy way to test if your emails are working is to use this app:
It has its own email settings that can be easily implemented. This way you will check if your app actually works and sends emails.
Then when you have that verified, switch it with your smtp credentials. This should get you on the right track.
Replied to Www Prefix On Subdomain
Hey @lasota
You could use build in forge redirects but this is not the correct way to handle this.
You should use your DNS records to do this. I use Cloudflare for it and it should look like this:
CNAME
record for www.subdomain
pointing to subdomain.domain.com
A
record for subdomain.domain.com
pointing to your forge IP.
Hope it helps!
PS. I'm not too sure about this part: www.subdomain
or fullwww.subdomain.domain.com
for CNAME, it works just for www
for TLD
Awarded Best Reply on Darkmode Flickering
Have a look how alpinejs deals with it:
https://github.com/alpinejs/alpine#x-cloak
It is due to you changing property of a DOM element after it is being loaded. With cloak you apply all changes to it and only after everything is done, you display it. This removes flickering.
Hope it helps!
Replied to Unable To Get JSON Response Via Web Hooks API.
@bipin_1611 did you ever hear about Postman? Have a look at this link:
https://developer.squareup.com/docs/testing/postman
First set up your postman, then download squareup collection (all of the API endpoints already configured), then test it with postman so you are sure everything works as expected, then transfer that to Laravel.
It is much easier to troubleshoot that way.
Also the easiest way to access API in laravel is to use Http client:
https://laravel.com/docs/master/http-client#request-data
use Illuminate\Support\Facades\Http;
$response = Http::post('http://example.com/users', [
'name' => 'Steve',
'role' => 'Network Administrator',
]);
and then your json will be here:
$response->json();
Hope it helps!
Replied to Laravel Redirection To Email/verify With SSL
@adamantyn Can you show the contents of that file?
Awarded Best Reply on [InvalidArgumentException] Package Digikraaft/laravel-paystack-subscription Has A PHP Requirement Incompatible With Your PHP Version, PHP Extensions And Composer Version
Have a look at this file: https://github.com/digikraaft/laravel-paystack-subscription/blob/v1.0.0/composer.json
This is the "oldest" file he has but it is from June 2020 so this package was developed only for Laravel 7 and lately updated to Laravel 8. It says it all in the file:
"require": {
"php": "^7.4",
"ext-json": "^7.4",
"digikraaft/paystack-php": "^1.0",
"dompdf/dompdf": "^0.8.5",
"guzzlehttp/guzzle": "^6.5",
"illuminate/contracts": "^7.15",
"illuminate/database": "^7.15",
"illuminate/http": "^7.15",
"illuminate/notifications": "^7.15",
"illuminate/routing": "^7.15",
"illuminate/support": "^7.15",
"illuminate/view": "^7.15",
"nesbot/carbon": "^2.35",
"symfony/http-kernel": "^5.1"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.16",
"orchestra/testbench": "^5.0",
"phpunit/phpunit": "^9.0",
"psalm/plugin-laravel": "^1.2",
"vimeo/psalm": "^3.11"
},
So you are still using older version of php.
You do not have ext-json
installed
Update your composer to version 2
Hope it helps!
How about the other errors?
Paste here the whole error please
Replied to Session Timeout - Alert User
@johnw65 if session expires then next refresh will redirect to login page. This is how it works. You could in theory show a timer to the user by checking his session when he enters/refreshes the website.
But the question is: "Why bother doing it?"
If you really have to do it then set session lifetime to some crazy value in config/session.php
:
'lifetime' => env('SESSION_LIFETIME', 120),
525600
would be a year.
Have a look at this file: https://github.com/digikraaft/laravel-paystack-subscription/blob/v1.0.0/composer.json
This is the "oldest" file he has but it is from June 2020 so this package was developed only for Laravel 7 and lately updated to Laravel 8. It says it all in the file:
"require": {
"php": "^7.4",
"ext-json": "^7.4",
"digikraaft/paystack-php": "^1.0",
"dompdf/dompdf": "^0.8.5",
"guzzlehttp/guzzle": "^6.5",
"illuminate/contracts": "^7.15",
"illuminate/database": "^7.15",
"illuminate/http": "^7.15",
"illuminate/notifications": "^7.15",
"illuminate/routing": "^7.15",
"illuminate/support": "^7.15",
"illuminate/view": "^7.15",
"nesbot/carbon": "^2.35",
"symfony/http-kernel": "^5.1"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.16",
"orchestra/testbench": "^5.0",
"phpunit/phpunit": "^9.0",
"psalm/plugin-laravel": "^1.2",
"vimeo/psalm": "^3.11"
},
So you are still using older version of php.
You do not have ext-json
installed
Update your composer to version 2
Hope it helps!
Replied to Dashboard Display Content Depending On User Type
@malbe This is what you are looking for: https://laravel.com/docs/master/authorization
Please note that Authentication
<> Authorization
You can be authenticated to use app but not authorised to see some content eg. part of your dashboard.
Hope it helps!
Replied to Darkmode Flickering
Have a look how alpinejs deals with it:
https://github.com/alpinejs/alpine#x-cloak
It is due to you changing property of a DOM element after it is being loaded. With cloak you apply all changes to it and only after everything is done, you display it. This removes flickering.
Hope it helps!
Replied to Laravel Redirection To Email/verify With SSL
@adamantyn Whats the version of your app?
Do you have this class in your app?
App\Http\Controllers\Auth\LoginController.php
Replied to Laravel Redirection To Email/verify With SSL
Hey @adamantyn
First thing I notice is this:
public function boot()
{
/* Force SSL routes */
if($this->app->environment('production')) {
\URL::forceScheme('https');
}
}
No need for that either if you use forge it will automatically redirect to https when you generate your cert, if you use cloudflare - the same thing. No need to have it in your code.
Second thing I notice is that you do not need this:
Route::group(['middleware' => 'web'], function () {
This is what the documentation says:
Out of the box, Laravel comes with web and api middleware groups that contain common middleware you may want to apply to your web and API routes. Remember, these middleware group are automatically applied by your application's App\Providers\RouteServiceProvider service provider to routes within your corresponding web and api route files
And the last one:
Route::middleware('verified')->group(function () {
/* Route for the Home page */
Route::get('/', '[email protected]')->name('welcome');
You are telling your app to redirect visitor to be verified before he can access '/'
This is why your app redirects to :
https://example.com/email/verify
Awarded Best Reply on Formatting Data For Charts
@uniqueginun first generate all the dates that you need, then replace the ones that actually have values in that array. This way you will have complete array with values where they exist.
Awarded Best Reply on How To Create Custom Data Structure?
Have a look at this: https://github.com/spatie/data-transfer-object
Replied to Formatting Data For Charts
@uniqueginun first generate all the dates that you need, then replace the ones that actually have values in that array. This way you will have complete array with values where they exist.
Replied to How To Keep Selected Value In Dropdown After Submit In Laravel
<option value="pending">Pending</option>
Replied to Too Many Redirects On Localhost
Obviously you have created a loop. A very good way to diagnose this would be to use this new debugger:
It will show you all requests one my one if you put it in the AppServiceProvider.
Replied to How To Create Custom Data Structure?
Have a look at this: https://github.com/spatie/data-transfer-object
Awarded Best Reply on Livewire Maths - Calculate A Live Total
Each time you will update wire:model
it will call render()
method in livewire component. So just put your calculation in there and it will update each time you update variables.
public function render()
{
$this->result = $var1 + $var2 + $var3;
return view('foo');
}
Store the result in public
property on your livewire component, those properties are the available in the view like this:
public $var1;
public var2;
public var3;
public $result;
in the view:
{{$result}}
Replied to How To Keep Selected Value In Dropdown After Submit In Laravel
This is what you are looking for:
https://laravel.com/docs/master/requests#retrieving-old-input
Replied to Livewire Maths - Calculate A Live Total
Each time you will update wire:model
it will call render()
method in livewire component. So just put your calculation in there and it will update each time you update variables.
public function render()
{
$this->result = $var1 + $var2 + $var3;
return view('foo');
}
Store the result in public
property on your livewire component, those properties are the available in the view like this:
public $var1;
public var2;
public var3;
public $result;
in the view:
{{$result}}
Replied to Image Intervention: Can't Write Image Data To Path
@marinario I have been confused by this issue so many times. I have this in one of my apps and it works:
$imgResize->save('public/'.$filename));
So when you do
'public'
it will default to
'storage/app/public/'
Try if it works.
Replied to Image Intervention: Can't Write Image Data To Path
Hey @marinario
Its issue that pops up every so often.
First check if you did php artisan storage:link
Second double check your paths, there must be a mistake in there.
I also had this issue with using valet secure
when the local link was https
but I was trying to save to http
path
Replied to How To Manage Application Settings
This will be one of more advanced solutions:
https://freek.dev/1828-store-strongly-typed-settings-in-a-laravel-app
Replied to Prevent Livewire To Constantly Refresh Page, But Still Update Data Values
@bgass does your counter increment on every self refresh of the page?
public function render() {
$this->get_tool();
$this->renderCount++;
return view( 'livewire.toolbox' );
}
It looks like it should if it is livewire which is refreshing your page.
Replied to Prevent Livewire To Constantly Refresh Page, But Still Update Data Values
If Livewire loops usually it is due to not knowing to which element it should relate. Try adding wire:key
to your div. Have a look here: https://laravel-livewire.com/docs/2.x/troubleshooting
So in your case:
<div wire:key="foo">
<input autofocus type="search"
wire:key="bar"
wire:model.debounce.500ms="input_value"
placeholder="Entrer un code..."
class="border rounded p-3 focus:outline-none focus:shadow-outline-blue w-full" >
<p>Counts: {{ $renderCount }}</p>
<div>
@includeIf($current_page)
</div>
</div>
And see it it helps
Replied to Laravel + Docker + Windows
Did you see official packages:
https://laravel.com/docs/master/sail
not docker but a VM: https://laravel.com/docs/master/homestead
Replied to Admin Send Messages To Users
It depends how you imagine this functionality to work.
The simplest Idea I have is simply using Cache. You can store it forever you can store it for some time and then display to the user if it exists.
https://laravel.com/docs/master/cache#storing-items-in-the-cache
Having said that this is probably too simple to be true.
Other then that you could use database table and mark if user read the announcement etc.
There are probably many more ways to do it.