Member Since 4 Months Ago
4,090 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.
Commented on Laravel Sail
As of now, Laravel Sail is made to bring an easy setup for the docker based development environment. Not ready for Production.
Replied to How Translate This SQL Query To Eloquent?
Your query itself will produce a wrong result. Especially DISTINCT(bu_logged.rating)
. It will behave wrong if more than one logged-in user provides the same rating.
Replied to How To Use Queue Events With Laravel Horizon?
Laravel Horizon is a wrapper around the Queue worker. So both should behave the same. You have to check whether you are missing something else.
Replied to How To Use Queue Events With Laravel Horizon?
If you added any try-catch block around your code, then the queue won't get any exception. So it won't be announced as failed. So for testing, first through an exception manually. And check whether you are getting the failing event triggered.
Replied to Account Information Not Uploading Data Laravel 8 /jetstream
More information needed. Like screenshots/content of what you are facing.
Replied to Laravel Get Visitor's IP, Location, And City
Since the first one itself will through error. Remove the Location::get($whoIsIp); And check the $position2 again.
Replied to Laravel Get Visitor's IP, Location, And City
You have to import the Facade of the Location class. Instead of Stevebauman\Location\Location
.
Replied to How To Make Menu Active On Sublink?
First thing, make use of the named route. By naming your route, you can change your URL anytime without affecting any lines of code in the project.
You have to check it in the array, like {{ in_array(url()->current(), [$menu->url, $menu2->url, $menu3->url]) }}
Another way of using Javascript.
<div id="test">
<div class="btn active">Active Url</div>
<div class="btn">Inactive</div>
<div class="btn">Inactive</div>
<div class="btn">Inactive</div>
</div>
<script>
// Element is the main menu. And the childNodes is the Sub Menu here. But calling this within a function on page load it will add the 'active-menu' class in the main menu if any submenu contains 'active' class in it.
let element = document.getElementById('test');
let length = element.childNodes.length;
for(i=0; i < length; i++) {
if (element.childNodes[i].className.includes('active')) {
element.classList.add('active-menu');
}
}
</script>
Replied to Can't View Site With IP Or Domain
The following applies only to forge
,
Only the default site can be accessed through the IP.
For any other sites in that machine. You can only access it using the domain name. No other way.
If you want to access it with IP. Create a site with default as the site name. And place your code in that.
For those 2 sites. You should have a domain as same as the site name. Otherwise, only one default site is possible.
Replied to Change App.blade.php Destination (Jetstream)
You can make your own if you want. By using php artisan make:component AppLayout
Reference for components documentation, https://laravel.com/docs/8.x/blade#components
For the view file. You can alter it in the render method of the created class.
For default scaffoldings for authentication. Starting from Laravel 8, you have to use install Laravel jetstream. Then follow the steps mentioned in the Jetstream documentation.
Reference for jetStream documentation, https://jetstream.laravel.com/
If you don't like working more with JS. Make use of livewire. It's really easy to develop in that. And the development will take only half the time on comparing with when you develop the things in the usual way.
Reference for Livewire documentation, https://laravel-livewire.com/docs/2.x/quickstart Reference for Livewire Screencast, https://laravel-livewire.com/screencasts/installation
Make use of the screencast first for the livewire. Then jump into the livewire documentation.
Even though all the episodes in the Livewire screencast is not free. But it will help you to get the basic idea of the Livewire!
using Livewire: Required Zero JS (No JS script need to write by ourselves, livewire will take care of that) for achieving dynamic forms, button actions or anything which you achieve through ajax.
Replied to How To Keep Value Of Selected Option After Form Submission
A select should only contain one name at the select tag. Not in the options. If you check that structure and fix it. Your code will work perfectly!
Replied to Change App.blade.php Destination (Jetstream)
That is mapped in the app\View\Components
folder -> AppLayout
class. Inside that, there is a render()
method. You can specify the default layout file on that.
Replied to 1 Instance Of Laravel With Multiple Subdomains
I have a really good experience with that. We can do something like,
www.website.com
will only load the routes from the routes/web.php
file.
admin.website.com
will only load the routes from the routes/admin.php
file.
Use can configure this in the RouteServiceProvider
.
For that, I need to know which version of Laravel you are using?
Replied to How To Use Laravel Eloquent For Multiple Joins
You can Eager load them. Check out the documentation. It will help!
https://laravel.com/docs/8.x/eloquent-relationships#eager-loading
Replied to Load/ Save Automatically A XML File
Why do you want to store it in .XML
file? And for PHP it is the laziest way to load the data. Since it has to read all the files.
You can throw the content in the database using a text column. Then you can read it using a query and show it in the view as a history. And you can add additional fields like timestamps etc. So that you can able to show the user when this version is created. Even the user can give it a name called let's call it the title field. And the user can search through the versions using that title and able to filter it like when it is created or the user can select a date range to see what are the versions are created between that date range. (Simply useful in the future).
If you have any other usage for storing it in a .XML
file, kindly let me know. So that I can guide you.
If no need for storing it in a file. Only for version thing. Then I recommended Going to a DB table is the best way!
Awarded Best Reply on I Can't Retrieve Files From Storage
Go to your public folder on the base directory and delete the existing storage shortcut file created previously. Then run the php artisan storage:link
again. This will do the trick!
Replied to Class 'Illuminate\Support\Env' Not Found
Are you using this class directly anywhere in your project code? Make use of env()
instead of that.
Replied to Authentication
You can share your partial code, like what you have changed. So that I can help better!
Replied to I Can't Retrieve Files From Storage
Go to your public folder on the base directory and delete the existing storage shortcut file created previously. Then run the php artisan storage:link
again. This will do the trick!
Replied to SQLSTATE[42S01]: Base Table Or View Already Exists
Due to an error in the migration step. That table password_resets
has been created already. Go to your database and delete that table and try running the migration command again!
Awarded Best Reply on Delete Data With Bootstrap Modal Window Confirm In Laravel
@oxbir There is a mistake, the code which I shared contains repeated lines on the modal code. So that Id has been coming twice. Please make use of the following code.
@extends('Admin.master')
@section('content')
<div class="col-md-10 p-5 pt-2">
<h3><i class="fas fa-tachometer-alt ml-2"></i>Categories</h3>
<hr>
<a href="{{ route('categories.create') }}" class="btn btn-primary mb-3">
<i class="fas fa-plus-square"></i>
Add new a category
</a>
<div class="table-responsive">
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>#</th>
<th>Name</th>
<th>Date</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
@foreach($categories as $category)
<tr>
<td>{{ $category->id }}</td>
<td>{{ $category->name }}</td>
<td>{{ $category->created_at }}</td>
<td>
<div class="btn-group btn-group-sm">
<a href="{{ route('categories.edit', $category->id) }}"
class="btn btn-primary">ویرایش</a>
<button type="button" class="btn btn-danger"
onclick="loadDeleteModal({{ $category->id }}, `{{ $category->name }}`)">حذف
</button>
</div>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
<div class="modal fade" id="deleteCategory" data-backdrop="static" tabindex="-1" role="dialog"
aria-labelledby="deleteCategory" aria-hidden="true">
<div class="modal-dialog modal-sm" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">This action is not reversible.</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
Are you sure you want to delete <span id="modal-category_name"></span>?
<input type="hidden" id="category" name="category_id">
</div>
<div class="modal-footer">
<button type="button" class="btn bg-white" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-danger" id="modal-confirm_delete">Delete</button>
</div>
</div>
</div>
</div>
@endsection
@section('script')
<script>
function loadDeleteModal(id, name) {
$('#modal-category_name').html(name);
$('#modal-confirm_delete').attr('onclick', `confirmDelete(${id})`);
$('#deleteCategory').modal('show');
}
function confirmDelete(id) {
$.ajax({
url: '{{ url('categories') }}/' + id,
type: 'post',
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
},
data: {
'_method': 'delete',
},
success: function (data) {
// Success logic goes here..!
$('#deleteCategory').modal('hide');
},
error: function (error) {
// Error logic goes here..!
}
});
}
</script>
@endsection
Replied to Delete Data With Bootstrap Modal Window Confirm In Laravel
@oxbir There is a mistake, the code which I shared contains repeated lines on the modal code. So that Id has been coming twice. Please make use of the following code.
@extends('Admin.master')
@section('content')
<div class="col-md-10 p-5 pt-2">
<h3><i class="fas fa-tachometer-alt ml-2"></i>Categories</h3>
<hr>
<a href="{{ route('categories.create') }}" class="btn btn-primary mb-3">
<i class="fas fa-plus-square"></i>
Add new a category
</a>
<div class="table-responsive">
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>#</th>
<th>Name</th>
<th>Date</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
@foreach($categories as $category)
<tr>
<td>{{ $category->id }}</td>
<td>{{ $category->name }}</td>
<td>{{ $category->created_at }}</td>
<td>
<div class="btn-group btn-group-sm">
<a href="{{ route('categories.edit', $category->id) }}"
class="btn btn-primary">ویرایش</a>
<button type="button" class="btn btn-danger"
onclick="loadDeleteModal({{ $category->id }}, `{{ $category->name }}`)">حذف
</button>
</div>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
<div class="modal fade" id="deleteCategory" data-backdrop="static" tabindex="-1" role="dialog"
aria-labelledby="deleteCategory" aria-hidden="true">
<div class="modal-dialog modal-sm" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">This action is not reversible.</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
Are you sure you want to delete <span id="modal-category_name"></span>?
<input type="hidden" id="category" name="category_id">
</div>
<div class="modal-footer">
<button type="button" class="btn bg-white" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-danger" id="modal-confirm_delete">Delete</button>
</div>
</div>
</div>
</div>
@endsection
@section('script')
<script>
function loadDeleteModal(id, name) {
$('#modal-category_name').html(name);
$('#modal-confirm_delete').attr('onclick', `confirmDelete(${id})`);
$('#deleteCategory').modal('show');
}
function confirmDelete(id) {
$.ajax({
url: '{{ url('categories') }}/' + id,
type: 'post',
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
},
data: {
'_method': 'delete',
},
success: function (data) {
// Success logic goes here..!
$('#deleteCategory').modal('hide');
},
error: function (error) {
// Error logic goes here..!
}
});
}
</script>
@endsection
Replied to Connection To MS SQLServer
Check whether the drivers have been reflected by calling phpinfo()
in your PHP code and loading that file in the browser. Then if you can find the sqlsrv driver installed, then it's nothing wrong with the installation. If it's not showing, then there is an issue with the installation.
Also, make sure that you have downloaded and added those .dll
files to the folder where other extensions are located.
Because Installing PHP won't have the sqlsrv dll extensions as pre-installed.
Replied to Delete Data With Bootstrap Modal Window Confirm In Laravel
@oxbir You can make use of the following code,
@extends('Admin.master')
@section('content')
<div class="col-md-10 p-5 pt-2">
<h3><i class="fas fa-tachometer-alt ml-2"></i>Categories</h3>
<hr>
<a href="{{ route('categories.create') }}" class="btn btn-primary mb-3">
<i class="fas fa-plus-square"></i>
Add new a category
</a>
<div class="table-responsive">
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>#</th>
<th>Name</th>
<th>Date</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
@foreach($categories as $category)
<tr>
<td>{{ $category->id }}</td>
<td>{{ $category->name }}</td>
<td>{{ $category->created_at }}</td>
<td>
<div class="btn-group btn-group-sm">
<a href="{{ route('categories.edit', $category->id) }}"
class="btn btn-primary">ویرایش</a>
<button type="button" class="btn btn-danger"
onclick="loadDeleteModal({{ $category->id }}, `{{ $category->name }}`)">حذف
</button>
</div>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
<div class="modal fade" id="deleteCategory" data-backdrop="static" tabindex="-1" role="dialog"
aria-labelledby="deleteCategory" aria-hidden="true">
<div class="modal-dialog modal-sm" role="document">
<div class="modal fade" id="deleteCategory" data-backdrop="static" tabindex="-1" role="dialog"
aria-labelledby="deleteCategory" aria-hidden="true">
<div class="modal-dialog modal-sm" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">This action is not reversible.</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
Are you sure you want to delete <span id="modal-category_name"></span>?
<input type="hidden" id="category" name="category_id">
</div>
<div class="modal-footer">
<button type="button" class="btn bg-white" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-danger" id="modal-confirm_delete">Delete</button>
</div>
</div>
</div>
</div>
</div>
</div>
@endsection
@section('script')
<script>
function loadDeleteModal(id, name) {
$('#modal-category_name').html(name);
$('#modal-confirm_delete').attr('onclick', `confirmDelete(${id})`);
$('#deleteCategory').modal('show');
}
function confirmDelete(id) {
$.ajax({
url: '{{ url('categories') }}/' + id,
type: 'post',
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
},
data: {
'_method': 'delete',
},
success: function (data) {
// Success logic goes here..!
$('#deleteCategory').modal('hide');
},
error: function (error) {
// Error logic goes here..!
}
});
}
</script>
@endsection
Replied to Delete Data With Bootstrap Modal Window Confirm In Laravel
There is no #delete
id I could find in the blade file. And you didn't add any ajax. It looks like a form submit. If you can share which way you are trying to achieve the delete functionality. I can help.