This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
translate(key) { | |
let res = key.split('.').reduce((a, b) => a[b], t.data) | |
return res ? localStorage.getItem('translation') == 2 ? res[1] : res[0] : 'Translation not found' | |
} | |
//if you want to call tranlsate function from anywhere of your Vue application, you can use mixins | |
Vue.mixin({ | |
methods: { | |
translate(key) { | |
let res = key.split('.').reduce((a, b) => a[b], t.data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//args: API url, commit name, params (qs), headers | |
export function query(url, commit, params, headers = null) { | |
//build new url | |
const q = new URL(process.env.VUE_APP_API + url) | |
//if params exists then append it to URL with URLSearchParams | |
if (params) { | |
q.search = new URLSearchParams(params).toString() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Http\Controllers; | |
class PostController extends Controller | |
{ | |
//i recommend to use shortened version like sid, hid and tid | |
protected array $ids = [ | |
'some_id', | |
'hello_id', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Exceptions; | |
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; | |
class Handler extends ExceptionHandler | |
{ | |
public function register() | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Http\Middleware; | |
use Closure; | |
use Illuminate\Support\Facades\Cache; | |
class CacheQuery | |
{ | |
public function handle($request, Closure $next) |