mirror of
https://github.com/cp6/my-idlers.git
synced 2024-11-16 15:33:44 +01:00
Fixed providers cache
Fixed providers cache
This commit is contained in:
parent
d3125170e6
commit
1251fae0df
@ -43,7 +43,7 @@ class DomainsController extends Controller
|
|||||||
|
|
||||||
public function create()
|
public function create()
|
||||||
{
|
{
|
||||||
$Providers = Providers::all();
|
$Providers = Providers::allProviders();
|
||||||
return view('domains.create', compact('Providers'));
|
return view('domains.create', compact('Providers'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ class ProvidersController extends Controller
|
|||||||
{
|
{
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
$providers = Providers::all();
|
$providers = Providers::allProviders();
|
||||||
return view('providers.index', compact(['providers']));
|
return view('providers.index', compact(['providers']));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,7 +31,7 @@ class ProvidersController extends Controller
|
|||||||
'name' => $request->provider_name
|
'name' => $request->provider_name
|
||||||
]);
|
]);
|
||||||
|
|
||||||
Cache::forget('all_providers');
|
Cache::forget('providers');
|
||||||
|
|
||||||
return redirect()->route('providers.index')
|
return redirect()->route('providers.index')
|
||||||
->with('success', 'Provider Created Successfully.');
|
->with('success', 'Provider Created Successfully.');
|
||||||
@ -65,7 +65,7 @@ class ProvidersController extends Controller
|
|||||||
|
|
||||||
$items->delete();
|
$items->delete();
|
||||||
|
|
||||||
Cache::forget('all_providers');
|
Cache::forget('providers');
|
||||||
|
|
||||||
return redirect()->route('providers.index')
|
return redirect()->route('providers.index')
|
||||||
->with('success', 'Provider was deleted Successfully.');
|
->with('success', 'Provider was deleted Successfully.');
|
||||||
|
@ -28,7 +28,7 @@ class ResellerController extends Controller
|
|||||||
|
|
||||||
public function create()
|
public function create()
|
||||||
{
|
{
|
||||||
$Providers = Providers::all();
|
$Providers = Providers::allProviders();
|
||||||
$Locations = Locations::all();
|
$Locations = Locations::all();
|
||||||
return view('reseller.create', compact(['Providers', 'Locations']));
|
return view('reseller.create', compact(['Providers', 'Locations']));
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,7 @@ class ServerController extends Controller
|
|||||||
|
|
||||||
public function create()
|
public function create()
|
||||||
{
|
{
|
||||||
$Providers = Providers::all();
|
$Providers = Providers::allProviders();
|
||||||
$Locations = Locations::all();
|
$Locations = Locations::all();
|
||||||
$Os = OS::allOS();
|
$Os = OS::allOS();
|
||||||
return view('servers.create', compact(['Providers', 'Locations', 'Os']));
|
return view('servers.create', compact(['Providers', 'Locations', 'Os']));
|
||||||
|
@ -28,7 +28,7 @@ class SharedController extends Controller
|
|||||||
|
|
||||||
public function create()
|
public function create()
|
||||||
{
|
{
|
||||||
$Providers = Providers::all();
|
$Providers = Providers::allProviders();
|
||||||
$Locations = Locations::all();
|
$Locations = Locations::all();
|
||||||
return view('shared.create', compact(['Providers', 'Locations']));
|
return view('shared.create', compact(['Providers', 'Locations']));
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,8 @@ namespace App\Models;
|
|||||||
|
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Support\Facades\Cache;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
class Providers extends Model
|
class Providers extends Model
|
||||||
{
|
{
|
||||||
@ -12,4 +14,11 @@ class Providers extends Model
|
|||||||
protected $fillable = ['name'];
|
protected $fillable = ['name'];
|
||||||
|
|
||||||
protected $table = 'providers';
|
protected $table = 'providers';
|
||||||
|
|
||||||
|
public static function allProviders(): array
|
||||||
|
{
|
||||||
|
return Cache::remember("providers", now()->addMonth(1), function () {
|
||||||
|
return DB::table('providers')->get()->toArray();
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,9 +16,7 @@ class ProvidersSelect extends Component
|
|||||||
*/
|
*/
|
||||||
public function render()
|
public function render()
|
||||||
{
|
{
|
||||||
$all_providers = Cache::rememberForever('all_providers', function () {
|
$all_providers = Providers::allProviders();
|
||||||
return Providers::all();
|
|
||||||
});
|
|
||||||
return view('components.providers-select', [
|
return view('components.providers-select', [
|
||||||
'providers' => $all_providers
|
'providers' => $all_providers
|
||||||
]);
|
]);
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
<div class="input-group-prepend"><span class="input-group-text">{{ $title ??'Provider'}}</span></div>
|
<div class="input-group-prepend"><span class="input-group-text">{{ $title ??'Provider'}}</span></div>
|
||||||
<select class="form-control" name="{{$name ?? 'provider_id'}}">
|
<select class="form-control" name="{{$name ?? 'provider_id'}}">
|
||||||
@foreach ($providers as $provider)
|
@foreach ($providers as $provider)
|
||||||
<option value="{{ $provider['id'] }}" {{(isset($current) && (string)$current === (string)$provider['id'])? 'selected' : ''}}>
|
<option value="{{ $provider->id }}" {{(isset($current) && (string)$current === (string)$provider->id)? 'selected' : ''}}>
|
||||||
{{ $provider['name'] }}
|
{{ $provider->name }}
|
||||||
</option>
|
</option>
|
||||||
@endforeach
|
@endforeach
|
||||||
</select>
|
</select>
|
||||||
|
Loading…
Reference in New Issue
Block a user