Bagmaz

Bagmaz

Member Since 2 Years Ago

Uppsala

Experience Points 41,790
Experience Level 9

3,210 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed 405
Lessons
Completed
Best Reply Awards 0
Best Reply
Awards
  • start-engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist Created with Sketch.

    Laracasts Evangelist

    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.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

26 May
1 month ago

Bagmaz left a reply on Preview In Browser Notification Mail

Laravel 5.8

https://laravel.com/docs/5.8/notifications#previewing-mail-notifications

Route::get('mail', function () {
    $invoice = App\Invoice::find(1);

    return (new App\Notifications\InvoicePaid($invoice))
                ->toMail($invoice->user);
});

or

https://laravel.com/docs/5.8/telescope

18 Apr
3 months ago

Bagmaz left a reply on How Can I Install Ea-php-cli-lsphp?

@sergiu17

:(

It's weird

-bash: sudo: command not found

I use cPanel via SSH

Bagmaz started a new conversation How Can I Install Ea-php-cli-lsphp?

Can't locate ea_php_cli.pm in @INC (you may need to install the ea_php_cli module) ...

How can I install ea-php-cli-lsphp? in cPanel DOC Note: The ea-php-cli-lsphp package manages this binary. If you can not call this binary, you can install it manually with the following command:

yum install ea-php-cli-lsphp

I get -bash: yum: command not found

:(

How can I fix ...

21 Mar
4 months ago

Bagmaz left a reply on Laravel 5.7 Npm Run Prod ERROR: Code ELIFECYCLE

The problem was solved.

It was unexpected term $icon-size-xl variable.

:(

.icon-xl {
    width: $icon-size-xl;
    height: $icon-size-xl;

    i, svg {
        font-size: $icon-size-xl - .75;
    }

    + .icon-text {
        width: calc(100% - $icon-size-xl - 1);
    }
}
20 Mar
4 months ago

Bagmaz left a reply on Laravel 5.7 Npm Run Prod ERROR: Code ELIFECYCLE

@bobbybouwmann

:(

composer.json

{
    "name": "laravel/laravel",
    "type": "project",
    "description": "The Laravel Framework.",
    "keywords": [
        "framework",
        "laravel"
    ],
    "license": "MIT",
    "require": {
        "php": "^7.1.3",
        "fideloper/proxy": "^4.0",
        "laravel-notification-channels/telegram": "^0.0.5",
        "laravel/framework": "5.7.*",
        "laravel/telescope": "^1.0",
        "laravel/tinker": "^1.0",
        "pusher/pusher-php-server": "~3.0",
        "stripe/stripe-php": "^6.30"
    },
    "require-dev": {
        "barryvdh/laravel-debugbar": "^3.2",
        "beyondcode/laravel-dump-server": "^1.0",
        "filp/whoops": "^2.0",
        "fzaninotto/faker": "^1.4",
        "mockery/mockery": "^1.0",
        "nunomaduro/collision": "^2.0",
        "phpunit/phpunit": "^7.0"
    },
    "config": {
        "optimize-autoloader": true,
        "preferred-install": "dist",
        "sort-packages": true
    },
    "extra": {
        "laravel": {
            "dont-discover": []
        }
    },
    "autoload": {
        "psr-4": {
            "App\": "app/"
        },
        "classmap": [
            "database/seeds",
            "database/factories"
        ],
        "files": [
            "app/Helpers/helper.php"
        ]
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\": "tests/"
        }
    },
    "minimum-stability": "dev",
    "prefer-stable": true,
    "scripts": {
        "post-autoload-dump": [
            "Illuminate\Foundation\ComposerScripts::postAutoloadDump",
            "@php artisan package:discover --ansi"
        ],
        "post-root-package-install": [
            "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "@php artisan key:generate --ansi"
        ]
    }
}

webpack.mix.js

const mix = require('laravel-mix');

mix.js('resources/js/app.js', 'public/js')
    .sass('resources/sass/app.scss', 'public/css').version();

Bagmaz left a reply on Laravel 5.7 Npm Run Prod ERROR: Code ELIFECYCLE

@bobbybouwmann Hi, Thank you, but this doesn't work.

0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node',
1 verbose cli   '/usr/local/bin/npm',
1 verbose cli   'run',
1 verbose cli   'production' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'preproduction', 'production', 'postproduction' ]
5 info lifecycle @~preproduction: @
6 info lifecycle @~production: @
7 warn lifecycle The node binary used for scripts is /var/folders/4m/7skvkbgs0vbgh5_cm8rb91c00000gn/T/yarn--1553096862326-0.144093307982621/node but npm is using /usr/local/bin/node itself. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with.
8 verbose lifecycle @~production: unsafe-perm in lifecycle true
9 verbose lifecycle @~production: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/bagmaz/Sites/deliveryonly/node_modules/.bin:/var/folders/4m/7skvkbgs0vbgh5_cm8rb91c00000gn/T/yarn--1553096862326-0.144093307982621:/Users/bagmaz/Sites/deliveryonly/node_modules/.bin:/Users/bagmaz/.config/yarn/link/node_modules/.bin:/Users/bagmaz/Sites/deliveryonly/node_modules/.bin:/Users/bagmaz/.config/yarn/link/node_modules/.bin:/usr/local/libexec/lib/node_modules/npm/bin/node-gyp-bin:/usr/local/lib/node_modules/npm/bin/node-gyp-bin:/usr/local/bin/node_modules/npm/bin/node-gyp-bin:/usr/local/opt/[email protected]/sbin:/usr/local/opt/[email protected]/bin:/Users/bagmaz/bin:/usr/local/bin:/Users/bagmaz/.composer/vendor/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/bagmaz/Sites/deliveryonly/node_modules/.bin
10 verbose lifecycle @~production: CWD: /Users/bagmaz/Sites/deliveryonly
11 silly lifecycle @~production: Args: [ '-c',
11 silly lifecycle   'cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js' ]
12 silly lifecycle @~production: Returned: code: 1  signal: null
13 info lifecycle @~production: Failed to exec production script
14 verbose stack Error: @ production: `cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js`
14 verbose stack Exit status 1
14 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:301:16)
14 verbose stack     at EventEmitter.emit (events.js:197:13)
14 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
14 verbose stack     at ChildProcess.emit (events.js:197:13)
14 verbose stack     at maybeClose (internal/child_process.js:978:16)
14 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:265:5)
15 verbose pkgid @
16 verbose cwd /Users/bagmaz/Sites/deliveryonly
17 verbose Darwin 18.2.0
18 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "production"
19 verbose node v11.9.0
20 verbose npm  v6.9.0
21 error code ELIFECYCLE
22 error errno 1
23 error @ production: `cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js`
23 error Exit status 1
24 error Failed at the @ production script.
24 error This is probably not a problem with npm. There is likely additional logging output above.
25 verbose exit [ 1, true ]

Bagmaz started a new conversation Laravel 5.7 Npm Run Prod ERROR: Code ELIFECYCLE

17 verbose Darwin 18.2.0
18 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "production"
19 verbose node v11.9.0
20 verbose npm  v6.9.0
21 error code ELIFECYCLE
22 error errno 1
23 error @ production: `cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js`
23 error Exit status 1
24 error Failed at the @ production script.
24 error This is probably not a problem with npm. There is likely additional logging output above.
25 verbose exit [ 1, true ]
15 Mar
4 months ago

Bagmaz started a new conversation Reset Password Translate

How can I translate this?

@lang(
    "If you’re having trouble clicking the \":actionText\" button, copy and paste the URL below\n".
    'into your web browser: [:actionURL](:actionURL)',
    [
        'actionText' => $actionText,
        'actionURL' => $actionUrl,
    ]
)

example sv.json

{
    "If you’re having trouble...": "...",
    "into your web...": "..."
}

How will it be?

10 Feb
5 months ago

Bagmaz left a reply on Withcount() 502 Bad Gateway Nginx/1.15.8

It was my mistake. I used protected $withCount = ['options']; in Option model.

problem solved.

class Option extends Model
{
    protected $fillable = ['name', 'selection_range', 'optional'];

//    protected $withCount = ['options'];

    public function menu()
    {
        return $this->belongsTo(Menu::class);
    }

    public function items()
    {
        return $this->hasMany(Item::class);
    }
}
06 Feb
5 months ago

Bagmaz started a new conversation Withcount() 502 Bad Gateway Nginx/1.15.8

Hi,

When I use withcount(), I get 502 Bad Gateway nginx/1.15.8

Laravel Framework 5.7.21 PHP 7.2.14 Laravel Valet 2.2.1

30 Jan
5 months ago

Bagmaz left a reply on Uncaught DOMException: Failed To Execute 'querySelector'

@REACHED - ``` fetchCalender() { let self = this; let calendar = $('#calendar'); calendar.fullCalendar('destroy'); calendar.fullCalendar({ viewRender: function (view, element) { if (view.name != 'month') { $(element).find('.fc-scroller').perfectScrollbar(); } }, header: { left: this.header.left, center: this.header.center, right: this.header.right, }, timeFormat: 'H:mm', slotDuration: '00:15:00', minTime: '06:00:00', maxTime: '22:00:00', defaultDate: this.today, defaultView: this.defaultView, eventRender: function(eventObj, $el) { if (eventObj.paid) { $el.find(".fc-time").append($("<span class="fa fa-money pl-1">")); }

                    if (eventObj.canceled) {
                        $el.find(".fc-time").append($("<span class=\"fa fa-calendar-times-o pl-1\"></span>"));
                    }

                    if (eventObj.bookedOnline) {
                        $el.find(".fc-time").append($("<span class=\"fa fa-wifi pl-1\"></span>"));
                    }
                },
                events: `/admin/booking/time/personnel/${self.booking.hairdresser.personnel}`,
                selectable: true,
                selectHelper: true,
                select: function(start, end) {
                    let dateAndTime = moment(start);
                    self.booking.selectedDate = dateAndTime.format("YYYY/MM/DD");
                    self.booking.startTime = dateAndTime.format("HH:mm");
                    self.booking.endTime = moment(end).format("HH:mm");
                    self.checkOldData();
                    $('#adminCalendarModal').modal('show');
                },
                eventClick: function (event) {
                    self.selectedBookingId = event.id;
                    $('#bookingShowModal').modal('show');
                },
            });
        },

Bagmaz left a reply on Uncaught DOMException: Failed To Execute 'querySelector'

@REACHED - ``` <button type="button" class="btn btn-primary" :disabled="selectedPersonnel === 'all'" @click="activeAllCalendar">All <button type="button" class="btn btn-primary" v-for="personnel in activePersonnel" @click="getSelectedPersonnel(personnel)" :disabled="selectedPersonnel === personnel.personnel" > {{ personnel.name }}

import moment from 'moment'; import 'moment/locale/sv'; import 'fullcalendar'; import 'fullcalendar/dist/locale/sv'; import BookingShow from './BookingShow.vue';
export default {
    name: "admin-calendar",

    components: { BookingShow },

    data() {
        return {                
            activePersonnel : [],                
            selectedPersonnel: 'all',
    booking: {
                hairdresser: [],
            },
        }
    },

    mounted() {
        this.getActivePersonnel();
    },

    methods: {
        getActivePersonnel() {
            axios.get('/admin/personnel').then(response => this.activePersonnel = response.data);
        },

        getSelectedPersonnel($personnel) {
            this.booking.hairdresser = $personnel;
            this.getPersonnelWebService();
            this.fetchCalender();
            this.selectedPersonnel = $personnel.personnel;
        },
    }
}
```

Bagmaz started a new conversation Uncaught DOMException: Failed To Execute 'querySelector'

Help

<button type="button"
                            class="btn btn-primary"
                            v-for="personnel in activePersonnel"
                            @click="getSelectedPersonnel(personnel)"
                            :disabled="selectedPersonnel === personnel.personnel"
>
    {{ personnel.name }}
</button>
                                
methods: {
    getSelectedPersonnel($personnel) {
                this.booking.hairdresser = $personnel;
                this.getPersonnelWebService();
                this.fetchCalender();
                this.selectedPersonnel = $personnel.personnel;
            },

    //...
}

Uncaught DOMException: Failed to execute 'querySelector' on 'Document': 'http://example.com' is not a valid selector.

Where is my mistake?

20 Jan
6 months ago

Bagmaz left a reply on Vue Momentjs Update Relative Time In Real Time

Try this

mounted() {
    function ago() {
        moment().fromNow();

        setTimeout(ago, 1000);
    },

    ago()
}

Bagmaz started a new conversation Laravel 5.7 Vue Js .default

In Laravel 5.7

Vue.component('example-component', require('./components/ExampleComponent.vue').default);

What is ".default" ?

Vue.component('waiting', require('./components/Waiting'));

When I use component without .default the component doesn't work.

26 Jun
1 year ago

Bagmaz left a reply on Vuejs Deep Watch

Problem solved

watch: {
    'data.additionalServices': {
        handler: function (val, oldVal) {
            this.someFunction();
        },
        deep: true
    },
},

Bagmaz started a new conversation Vuejs Deep Watch

I want to use watch , when additionalServices is changed, Only additionalServices is changed trigger some function

This is my data

data() {
    return {
        data: {
            service: [],
            additionalServices: [],
            personnel: [],
        },
    }
},

watch: {
    data: {
        handler: function (val, oldVal) {
            console.log(val);
            console.log(oldVal);
            this.someFunction();
        },
        deep: true
    },
},

Help me :(

20 Jun
1 year ago

Bagmaz left a reply on Laravel Translation In Vue

@aurawindsurfing Thank you, I'll check.

16 Jun
1 year ago

Bagmaz left a reply on Laravel Translation In Vue

@aurawindsurfing

Hi!

I know, but I need Array Lang...

I use this

In Vue

data() {
    return {
        transArr: []
    }
},

created() {
    axios.get('/admin/calendar/trans')
        .then(response => {
            this.transArr = response.data;
        });
},

In Controller

public function transArray()
{
    return json_encode([
        'Hairdresser' => trans('w.Hairdresser'),
        'Description' => trans('w.Description'),
        'User' => trans('w.User'),
        'Guest' => trans('w.Guest'),
        'New' => trans('w.New'),
        'Search' => trans('w.Search'),
        'Select' => trans('w.Select'),
        'Service' => trans('w.Service'),
        'Name' => trans('w.Name'),
        'Email' => trans('w.Email'),
        'MobileNumber' => trans('w.Mobile number'),
        'Cancel' => trans('w.cancel'),
        'Save' => trans('w.Save'),
    ]);
}

In Template

<div class="row">
    <div class="col-12">
        <div class="form-group">
            <label>
                {{ transArr.Description }}
            </label>
            <textarea class="form-control"
                      rows="4"
                      name="description"
                      :placeholder="transArr.Description + ' ...'"
                      v-model="booking.description"
            ></textarea>
        </div>
    </div>
</div>

But it's not clean :(

10 Jun
1 year ago

Bagmaz started a new conversation Laravel Translation In Vue

How to use Laravel translation in Vue?

:(

07 Apr
1 year ago

Bagmaz left a reply on What Is "defer"?

@rin4ik Thank you.

When I use "defer" for both, it's working.

<script src="{{ mix('js/app.js') }}" defer></script>
<script src="{{ asset('js/assets/swipe.js') }}" defer></script>

Is it correct?

Bagmaz started a new conversation What Is "defer"?

Hi, What is defer in Laravel 5.6 ?

<!-- Scripts -->
    <script src="{{ mix('js/app.js') }}" defer></script>

When I use "defer", I get an error

Uncaught ReferenceError: $ is not defined at swipe.js:1

$(".carousel").swipe({
    swipe: function (event, direction, distance, duration, fingerCount, fingerData) {
        if (direction == 'left') $(this).carousel('next');
        if (direction == 'right') $(this).carousel('prev');
    },
    allowPageScroll: "vertical"
});

And when I delete defer

<!-- Scripts -->
    <script src="{{ mix('js/app.js') }}"></script>

My code work. What is "defer" and how can I use?

19 Mar
1 year ago

Bagmaz left a reply on Theme In HTML E-mail

Hi, @DarkHarden Sorry my english is bad, And actually I don't know what you want exactly. But I think you have two way, 1: Use markdown 2: Use notification

I think this will be helpful for you.

https://laracasts.com/series/whats-new-in-laravel-5-3/episodes/9

Bagmaz left a reply on Fullcalendar.io Event Click And Pass Data To Vuejs Data

Hi, @m-rk

When I click nothing happens, And when I call a method I get an error.

 eventClick(event, jssEvent, view) {
                    this.eventId = event.id;
                    this.showAppointment(event.id);
                },

Uncaught TypeError: this.showAppointment is not a function

methods: {
            showAppointment(id) {
                return alert(id);
            },
        },

Bagmaz started a new conversation Fullcalendar.io Event Click And Pass Data To Vuejs Data

data() {
            return {
                eventId: '',
                header: {
                    left: 'month,agendaWeek,agendaDay',
                    center: 'title',
                    right: 'prev,next,today'
                },
                defaultView: 'agendaWeek',
                today: new Date(),
                businessHours: [
                    {
                        dow: [0],
                        start: '12:00',
                        end: '17:00'
                    },
                    {
                        dow: [1, 2, 3, 4, 5],
                        start: '10:00',
                        end: '19:00'
                    },
                    {
                        dow: [6],
                        start: '10:00',
                        end: '17:00'
                    }
                ],
                hairdressers: [],
                selected: this.user,
            }
        },
mounted() {
            $('#calendar').fullCalendar({
                viewRender: function (view, element) {
                    // We make sure that we activate the perfect scrollbar when the view isn't on Month
                    if (view.name != 'month') {
                        $(element).find('.fc-scroller').perfectScrollbar();
                    }
                },
                header: {
                    left: this.header.left,
                    center: this.header.center,
                    right: this.header.right,
                },
                businessHours: this.businessHours,
                slotDuration: '00:05:00',
                minTime: '09:50:00',
                maxTime: '19:10:00',
                defaultDate: this.today,
                defaultView: this.defaultView,
                events: '/user/' + this.user + '/kalender/appointments',
                eventClick(event, jssEvent, view) {
                    this.eventId = event.id;
                },
            });
        },
18 Mar
1 year ago
16 Mar
1 year ago

Bagmaz started a new conversation Warning: Accessing PropTypes Via The Main React Package Is Deprecated. Use The Prop-types Package From Npm Instead.

What is this error?

Warning: Accessing PropTypes via the main React package is deprecated. Use the prop-types package from npm instead.

content.js:5025

14 Mar
1 year ago

Bagmaz started a new conversation Has Value Between Array Values Or Has Time Between Array Times

Hi, How can I solve this problem?

$times = [
    [
        start => "10:00:00",
        end => "10:45:00"
    ],
    [
        start => "12:00:00",
        end => "14:00:00"
    ],
    ...
]
$start = '10:30:00';

How can I use if $start has between array $times return false and if not return true?

Something like array_has() but array_has() for equal $key, I want if is between, return false.

02 Mar
1 year ago

Bagmaz left a reply on How To Pass User On Form Request?

@rin4ik : I don't know :D, I don't like this style.

Bagmaz started a new conversation How To Pass User On Form Request?

Hi

This is my FromRequest


class PasswordRequest extends FormRequest
{
    protected $redirect = '/konto/#passwordReset';

    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        $user = auth()->user();
        return [
            'oldPassword' => ['required', 'string', new PasswordCheck($user)],
            'password' => 'required|string|min:6|confirmed',
        ];
    }
}

And this is for PasswordCheck


class PasswordCheck implements Rule
{
    /**
     * @var User
     */
    protected $user;

    /**
     * Create a new rule instance.
     *
     * @param User $user
     */
    public function __construct(User $user)
    {
        $this->user = $user;
    }

    /**
     * Determine if the validation rule passes.
     *
     * @param  string  $attribute
     * @param  mixed  $value
     * @return bool
     */
    public function passes($attribute, $value)
    {
        return Hash::check($value, $this->user['password']);
    }

    /**
     * Get the validation error message.
     *
     * @return string
     */
    public function message()
    {
        return 'Lösenordet matchar inte.';
    }
}

It's work $user = auth()->user(); But I think it's not good.

Does anyone have a better solution?

27 Feb
1 year ago

Bagmaz left a reply on How Can I Use Flash Message After Axios Post?

@mdeorue In the controller return is return response('success', 204).

How can I use flash message? I can't us with('flash', 'message ...'), Do you have a suggestion?

Bagmaz left a reply on How Can I Use Flash Message After Axios Post?

@coder_uzb Me too but my question is how can store the message on session, I use window.location.href="/path", When the response is success I want use redirect and flash message

Bagmaz started a new conversation How Can I Use Flash Message After Axios Post?

axios.post(`/online/booking/user/${this.currentUser}`, this.data)
                    .then(response => {
                        window.location.href="/profile" ;
                        flash('success message ...');
                    })
                    .catch(error => this.errors = error.response.data.errors);

25 Feb
1 year ago

Bagmaz left a reply on Axios.post() Returns Status Code 500 When Hosted On A Network

https://github.com/axios/axios

axios.post('/user', { firstName: 'Fred', lastName: 'Flintstone' }) .then(function (response) { console.log(response); }) .catch(function (error) { console.log(error); });

axios({ method: 'post', url: '/user/12345', data: { firstName: 'Fred', lastName: 'Flintstone' } });

10 Feb
1 year ago

Bagmaz left a reply on Validate Encrypted

@Snapey : Sorry, My english language is bad, I don't know what's you meaning.

I have a column on table, And this must be encrypted, When i want to create or update the column this must be unique value.

Bagmaz left a reply on Validate Encrypted

Yes, I know but whenever you want check unique item in table you must be check all row.

This is for my case

    protected $pn;
    protected $user;
    protected $status;

    /**
     * Personal identity number rule instance.
     *
     * @param User $user
     * @param $status
     */
    public function __construct(User $user, $status)
    {
        $this->pn = Hairdresser::all()->pluck('personal_identity_number', 'user_id');
        $this->user = $user;
        $this->status = $status;
    }

    /**
     * Determine if the validation rule passes.
     *
     * @param  string  $attribute
     * @param  mixed  $value
     * @return bool
     */
    public function passes($attribute, $value)
    {
        if ($this->status) {
            foreach ($this->pn as $key => $item) {
                if (decrypt($item) === $value) {
                    if ($key !== $this->user['id']) {
                        return false;
                    }
                }
            }
        } elseif (!$this->status){
            foreach ($this->pn as $item) {
                if (decrypt($item) === $value) {
                    return false;
                }
            }
        }

        return true;
    }

This can be dynamic, But now it's ok for me

Bagmaz left a reply on Validate Encrypted

The problem was solved.

https://laravel.com/docs/5.6/validation#custom-validation-rules

I used Custom Validation Rules In custom rules I use "decrypt()" and then use validate

02 Jan
1 year ago

Bagmaz left a reply on Validate Encrypted

@tykus : I need this information to show the customer and I have handled it, But I think this is a dirty way.

Sorry my english is bad, And I can't explain it clearly.

If my field name is the code

$examples = Example::all();

        foreach ($examples as $example) {
            if (decrypt($example->code) == $input['code']) {
                return back()->with('flash', 'warning ...');
            }
        }

I check this table to avoid duplicate information.

Bagmaz left a reply on Validate Encrypted

@tykus : I don't know what is hash_hmac, I use encrypt() for store and dencrypt() for show.

Bagmaz left a reply on Validate Encrypted

@tykus : At the moment I used native function, I must use foreach() and check every single record, I think this is not good. However, I have to use it.

Thanks for your response.

Bagmaz started a new conversation Validate Encrypted

How can i validate encrypted unique data?

Table

$table->string('example')->unique();

Validation

$input = $request->validate([
            'example' => 'required|string|unique:examples',
        ]);

Store

$example = new Example;
$example->example = encrypt($input['example']);
$example->save();
21 Dec
1 year ago
14 Oct
1 year ago

Bagmaz started a new conversation Sweet Alert2 With Vue

Hi, Sorry my english is bad.

I used sweet alert2 and Vue and made a flash message, this works for me but i want to know if there is better way to create a flash message.

session('flash', '@type Here your text message');

Types:

@success @warning @info @error

Vue:

<template></template>

<script>
    export default {
        props: ['message'],
        data() {
            return {
                type: '',
                body: '',
                btn_types: {
                    error:   'btn-danger',
                    success: 'btn-success',
                    info:    'btn-info',
                    warning: 'btn-warning',
                },
            }
        },

        created() {
            if (this.message) {
                this.body = this.message.replace(/@([\w\-]+)/, '');
                this.type = this.message.match(/@([\w\-]+)/)[1];
                this.flash(this.body, this.type, this.btn_types[this.type]);
            }
        },

        methods: {
            flash(body, type, btn) {
                swal({
                    text: body,
                    buttonsStyling: false,
                    confirmButtonClass: "btn " + btn,
                    type: type,
                });
            }
        }
    }
</script>

11 Oct
1 year ago

Bagmaz left a reply on Log In With Username Or Email In Laravel 5...

Hi, in Laravel 5.5 its easy

 protected $redirectTo = '/profile'; // option
/**
 * Create a new controller instance.
 *
 * @return void
 */
public function __construct()
{
    $this->middleware('guest')->except('logout');
}

public function username()
{
    $field = filter_var(request()->input('login'), FILTER_VALIDATE_EMAIL) ? 'email' : 'username';
    request()->merge([$field => request()->input('login')]);
    return $field;
} </code></pre>
02 Aug
1 year ago

Bagmaz left a reply on Can't Write Image Data To Path

sorry, my english is bad,

this path must be valid

you can use

$photo_manager = new ImageManager();

\File::makeDirectory($YourPath);

    $image = $manager->make($photo)->encode('jpg')
    ->resize(123, 123 function ($c) {
        $c->aspectRatio();
    });
    $canvas = Image::canvas(123,123);
    $canvas->insert($image, 'center');
    $canvas->save(public_path('uploads/'.Config::get('images.full_size').$filename));

    return $canvas;