Skip to content

Instantly share code, notes, and snippets.

View dev-lav's full-sized avatar

Fatoni dev-lav

View GitHub Profile
{
"type": "object",
"properties": {
"status_code": {
"type": "integer"
},
"data": {
"type": "object",
"properties": {
"id": {
<?php
public static function validatorForCreation(NovaRequest $request)
{
return Validator::make($request->all(), static::rulesForCreation($request), [], self::$attributes)
->after(function ($validator) use ($request) {
static::afterValidation($request, $validator);
static::afterCreationValidation($request, $validator);
});
}
<?php
public static function validatorForUpdate(NovaRequest $request)
{
return Validator::make($request->all(), static::rulesForUpdate($request), [], ['code' => 'Kode Bank'])
->after(function ($validator) use ($request) {
static::afterValidation($request, $validator);
static::afterUpdateValidation($request, $validator);
});
}
<?php
public static function validatorForCreation(NovaRequest $request)
{
return Validator::make($request->all(), static::rulesForCreation($request), [], ['code' => 'Kode Bank'])
->after(function ($validator) use ($request) {
static::afterValidation($request, $validator);
static::afterCreationValidation($request, $validator);
});
}
<?php
// this code is in nova service provice
//
public function boot()
{
\Laravel\Nova\Fields\Field::macro('readOnly', function(){
$this->withMeta(['extraAttributes' => [
'readonly' => true,
'disabled' => true
<?php
// this code is in nova resource
public function fields(Request $request)
{
return [
Text::make('SomethingReadOnly')->withMeta(['extraAttributes' => [
'readonly' => true,
'disabled' => true
@dev-lav
dev-lav / laravel-nova-authorized.php
Last active August 29, 2022 05:00
laravel-nova-authorized.php
<?php
// add this code on your nova resource
public function authorizedToUpdate(Request $request)
{
return false;
}
public function authorizedToDelete(Request $request)
@dev-lav
dev-lav / gist:a0515d687add77c59be4f7c8d74be8cc
Created November 10, 2018 09:38
search-test-postman.js
var response = pm.response.json();
const paramsString = request.url.split('?')[1];
const eachParamArray = paramsString.split('&');
let params = {};
eachParamArray.forEach((param) => {
const key = param.split('=')[0];
const value = param.split('=')[1];
Object.assign(params, {[key]: value});
});
tests["Status code is 200"] = responseCode.code === 200;
tests["Response body has attribute name"] = responseBody.has("name");
tests["Response body has attribute brand"] = responseBody.has("brand");
tests["Response body has attribute price"] = responseBody.has("price");
tests["Response body has attribute picture"] = responseBody.has("picture");
@dev-lav
dev-lav / response-format-mockup-e-commerce.json
Created August 11, 2018 10:08
response-format-mockup-e-commerce
{
"data": [{
"name": "Argentina Authentic Jersey 2018",
"brand": "Adidas",
"price": "$130",
"picture": "https://www.goalinn.com/f/13669/136697631/adidas-argentina-away-jersey-s-s.jpg"
},
{
"name": "Brazil Authentic Jersey 2018",
"brand": "Nike",