Skip to content

Instantly share code, notes, and snippets.

Avatar
💻
Check out BestOfLaravel.com

Adi SK skadimoolam

💻
Check out BestOfLaravel.com
View GitHub Profile
View console.php
<?php
use Illuminate\Support\Facades\Storage;
use App\Models\Post;
Artisan::command('generate:feed', function () {
$this->info("Generating RSS Feed");
// It is important that you sort by the latest post
$posts = Post::where('published', true)->latest()->get();
@skadimoolam
skadimoolam / checkbox.blade.php
Last active Feb 8, 2020
Customizable form partials for Laravel - https://laravelcollections.com
View checkbox.blade.php
@php
$d = $d ?? null; // default value
@endphp
<div class="form-group row">
<label for="{{ $n }}" class="col-sm-4 col-form-label text-md-right"><b>{{ $l }}</b></label>
<div class="col-md-8">
<input id="{{ $n }}" type="checkbox" class="form-control" name="{{ $n }}" value="1" @if(old($n, $d) == '1') checked @endif>
@if ($errors->has($n))
<small class="text-danger">{{ $errors->first($n) }}</small>
View controller.php
public function index(Request $request)
{
$sortBy = 'id';
$orderBy = 'desc';
$perPage = 20;
$q = null;
if ($request->has('orderBy')) $orderBy = $request->query('orderBy');
if ($request->has('sortBy')) $sortBy = $request->query('sortBy');
if ($request->has('perPage')) $perPage = $request->query('perPage');
View UsersController.php
class UsersController
{
// ......
public function index(Request $request) {
$edit = null;
// We check if the edit parameter is set, if so we find the user with that ID
// This $edit variable can be used in our template
if ($request->has('edit')) $edit = User::where('id', $request->query('edit'))->first();
View app.pcss
@tailwind base;
@tailwind components;
@tailwind utilities;
.field {
@apply .rounded .border .py-2 .px-3 .text-gray-800;
}
.field-label {
@apply .mb-2 .uppercase .font-bold .text-lg .text-gray-900;
@skadimoolam
skadimoolam / profiles.json
Last active Mar 24, 2020
Windows Terminal Configuration
View profiles.json
{
"$schema": "https://aka.ms/terminal-profiles-schema",
"defaultProfile": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
"requestedTheme" : "system",
"launchMode":"maximized",
"profiles":
{
"defaults": {
View .env
# Add the domain name of your choice
SITE_URL=myapp.com
View Helpers.php
<?php
if (! function_exists('say_hi')) {
function say_hi($name) {
return 'Hi ' . $name;
}
}
@skadimoolam
skadimoolam / newConfig.php
Created Jun 20, 2020
A simple way to write new Laravel config file dynamically | More info at https://simplestweb.in
View newConfig.php
<?php
$rawSettings = json_decode($request->get('settings'), true);
if ($rawSettings == null) abort(500);
config(['settings' => $rawSettings]);
$text = '<?php return ' . var_export(config('settings'), true) . ';';
file_put_contents(config_path('settings.php'), $text);
View AppServiceProvider.php
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.