theUnforgiven

Experience

251,190

44 Best Reply Awards

  • Member Since 4 Years Ago
  • 1342 Lessons Completed
  • 39 Favorites

20th August, 2018

theUnforgiven left a reply on VueJS Online/offline Status • 1 day ago

Anyone?

theUnforgiven left a reply on VueJS Online/offline Status • 1 day ago

So the above I couldn't get to work, my chat app is working all fine now, just need to get the online/offline status of the user.

I opted to use Echo.join but this isn't working as the channel is private, what else can I do to get this working.

Here's the full Chat.vue

<template>
<div>
    <div class="panel-body">
        <div class="panel-heading">
            <h4>{{ subject }} - <small>Chat ID: {{ chatId }}</small></h4>
            <h6></h6>
            <br />
            <div class="input-group">
                <input id="btn-input"
                       type="text"
                       name="message"
                       class="form-control input-md"
                       style="height: 40px;"
                       placeholder="Type your message here..."
                       v-model="newMessage"
                       @keydown="isTyping"
                       @keyup.enter="addMessage"
                >

                <span class="input-group-btn">
                    <button class="btn btn-primary btn-sm" id="btn-chat" @click="addMessage">
                        Send
                    </button>
                </span>
            </div>
            <span class="pull-left typingPeer" v-if="activePeer" v-text="activePeer.name + ' is typing...'"></span>
        </div>


        <ul class="chat">
            <li v-for="message in messages">
                
                <div class="chat-body clearfix">
                    <div class="header chat-header">
                        <strong class="primary-font">
                            <span v-if="online == true"><i class="fa fa-circle text-success"></i></span>
                            <span v-if="online == false"><i class="fa fa-circle text-default"></i></span>

                            <span v-if="message.user.first_name">{{ message.user.first_name }}</span>
                            &nbsp;&nbsp;&nbsp;-&nbsp;
                        </strong>
                        <small class="chat-date" v-if="message.created_at">
                            Posted: {{ message.created_at | formatDate }}
                        </small>
                        <small class="chat-date" v-else>
                            Posted: {{ message.created | formatDate }}
                        </small>

                    </div>
                    <p class="chat-msg">
                        {{ message.message }}
                    </p>
                </div>
            </li>
        </ul>
    </div>

</div>
</template>

<script>
    export default {

        props: ['thread'],

        data() {
            return {
                newMessage: '',
                activePeer: false,
                messages: [],
                typingTimer: false,
                subject: '',
                chatId: '',
                online: false,
            }
        },

        mounted() {

            this.fetchMessages();

            window.Echo.private('chat')
                .listen('.newChat', (e) => {
                    this.messages.unshift({
                        message: e.message.message,
                        user: e.user,
                        created: e.message.created_at                        
                    });
                })
                .listenForWhisper('typing', (e) => {
                    this.activePeer = e;

                    if(this.typingTimer) clearTimeout(this.typingTimer);

                    this.typingTimer = setTimeout(() => {
                        this.activePeer = false;
                    }, 2000);
                })

            window.Echo.join(`chat`)
                .here((users) => {
                    console.log('HERE ' + users);
                    this.online = users.length;
                })
                .joining((user) => {
                    this.online = true;
                    this.$toaster.success(user.first_name+' is joined the chat room');
                })
                .leaving((user) => {
                    this.online = false;
                    this.$toaster.warning(user.first_name+' is leaved the chat room');
                });
        },

        methods: {
            isTyping() {
                window.Echo.private('chat')
                    .whisper('typing', {
                        name: window.Laravel.user.first_name
                    });
            },

            fetchMessages() {
                axios.get('/messages/fetch/' + this.thread).then(response => {
                    // console.log(response.data);
                    this.messages = response.data;
                    this.subject = response.data[0]['subject'];
                    this.chatId = response.data[0]['unique_id'];
               
                });
            },

            addMessage() {
                axios.post('/messages/send/' + this.thread, { message: this.newMessage, user:  window.Laravel.user.first_name });
                this.messages.unshift({
                    message: this.newMessage,
                    user: this.user
                });

                this.activePeer = false;
                this.newMessage = '';
            }
        }
    }
</script>

here's my event:

<?php

namespace NRS\Events;

use Illuminate\Broadcasting\Channel;
use Illuminate\Contracts\Broadcasting\ShouldBroadcastNow;
use Illuminate\Queue\SerializesModels;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Broadcasting\PresenceChannel;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use NRS\Models\Message;
use NRS\Models\User\User;

class MessageSent implements ShouldBroadcast
{
    use Dispatchable, InteractsWithSockets, SerializesModels;

   /**
     * User that sent the message
     *
     * @var User
     */
    public $user;
    /**
     * Message details
     *
     * @var Message
     */
    public $message;
    /**
     * Create a new event instance.
     *
     * @return void
     */
    public function __construct(User $user, Message $message)
    {
        $this->user = $user->first_name . ' ' . $user->last_name;
        $this->message = $message;
    }

    public function broadcastAs()
    {
        return 'newChat';
    }

    /**
     * Get the channels the event should broadcast on.
     *
     * @return Channel|array
     */
    public function broadcastOn()
    {
        return new PrivateChannel('chat');
    }
}

then within my view I'm calling the Vue as, just to get the thread ID based on segment.

<chat-form thread="{{ Request::segment(2) }}"></chat-form>

So it's just the part

  window.Echo.join(`chat`)
                .here((users) => {
                    console.log('HERE ' + users);
                    this.online = users.length;
                })
                .joining((user) => {
                    this.online = true;
                    this.$toaster.success(user.first_name+' is joined the chat room');
                })
                .leaving((user) => {
                    this.online = false;
                    this.$toaster.warning(user.first_name+' is leaved the chat room');
                });

That I am unable to get working, to show whether or not the user is online or not.

Hope someone can help me

17th August, 2018

theUnforgiven left a reply on VueJS Online/offline Status • 4 days ago

@ejdelmonico Thanks! Yeah that may give me some starting point. Will have a go with that. :)

16th August, 2018

theUnforgiven left a reply on VueJS Online/offline Status • 5 days ago

Anyone?

theUnforgiven started a new conversation VueJS Online/offline Status • 5 days ago

So I have built a small chat feature within my app, but now I want to know how I can get the status of the person, i.e online/offline.

This is the Vue I have currently and ideally want something like Slack offers where if someone is offline gives you the option to send notification if the user is offline, or just leave it if they don't send straight away.

<template>
<div>
    <div class="panel-body">
        <div class="panel-heading">
            <h4>{{ subject }} - <small>Chat ID: {{ chatId }}</small></h4>
            <h6></h6>
            <br />
            <div class="input-group">
                <input id="btn-input"
                       type="text"
                       name="message"
                       class="form-control input-md"
                       style="height: 40px;"
                       placeholder="Type your message here..."
                       v-model="newMessage"
                       @keydown="isTyping"
                       @keyup.enter="addMessage"
                       @keyup="whisper()">

                <span class="input-group-btn">
                    <button class="btn btn-primary btn-sm" id="btn-chat" @click="addMessage">
                        Send
                    </button>
                </span>
            </div>
            <span class="pull-left typingPeer" v-if="activePeer" v-text="activePeer.name + ' is typing...'"></span>
        </div>


        <ul class="chat">
            <li v-for="message in messages">

                <div class="chat-body clearfix">
                    <div class="header chat-header">
                        <strong class="primary-font">
                            <i class="fa fa-user-circle"></i> <span>{{ message.sender }}</span>&nbsp;&nbsp;&nbsp;-&nbsp;
                        </strong>
                        <small class="chat-date" v-if="message.created_at">
                            Posted: {{ message.created_at | formatDate }}
                        </small>
                        <small class="chat-date" v-else>
                            Posted: {{ message.created | formatDate }}
                        </small>

                    </div>
                    <p class="chat-msg">
                        {{ message.message }}
                    </p>

                </div>
            </li>
        </ul>
    </div>

</div>
</template>

<script>
    export default {

        props: ['thread', 'user'],

        data() {
            return {
                newMessage: '',
                activePeer: false,
                messages: [],
                typingTimer: false,
                subject: '',
                chatId: ''
            }
        },

        mounted() {

            this.fetchMessages();

            this.listen();

            window.Echo.private('chat')
                .listen('.newChat', (e) => {
                    this.messages.unshift({
                        message: e.message.message,
                        sender: e.message.sender,
                        recipient: e.message.recipient_name,
                        created: e.message.created_at
                    });
                })
                .listenForWhisper('typing', (e) => {
                    this.activePeer = e;

                    if(this.typingTimer) clearTimeout(this.typingTimer);

                    this.typingTimer = setTimeout(() => {
                        this.activePeer = false;
                    }, 2000);
                });
        },

        methods: {
            isTyping() {
                window.Echo.private('chat')
                    .whisper('typing', {
                        name: window.Laravel.user.first_name
                    });
            },

            fetchMessages() {
                axios.get('/messages/fetch/' + this.thread).then(response => {
                    this.messages = response.data;
                    this.subject = response.data[0]['subject'];
                    this.chatId = response.data[0]['unique_id'];
                });
            },

            addMessage() {
                axios.post('/messages/send/' + this.thread, { message: this.newMessage });

                this.activePeer = false;
                this.newMessage = '';
            }
        }
    }
</script>

So based on the above, how best could I achieve this online/offline status?

12th August, 2018

theUnforgiven left a reply on Error Message Adding A Message [stumped] • 1 week ago

Within my controller I fire of the broadcast like so:

public function sendMessage(Request $request)
{
        $user = user();

        $message = $user->messages()->create([
            'message' => $request->input('message')
        ]);

        broadcast(new MessageSent($message))->toOthers();
}

But again not sure why the listener isn't firing and updating in realtime.

theUnforgiven left a reply on Error Message Adding A Message [stumped] • 1 week ago

So I have the event passing through to pusher as shown above, but the listener isn't listening and therefore not updating the list or showing in real-time on the screen.

Can any of you lovely people, help me out?

11th August, 2018

theUnforgiven left a reply on Error Message Adding A Message [stumped] • 1 week ago

The event is now like so:

class MessageSent implements ShouldBroadcast
{
    use Dispatchable, InteractsWithSockets, SerializesModels;



    /**
     * Message details
     *
     * @var Message
     */
    public $message;

    /**
     * Create a new event instance.
     *
     * @param Message $message
     */
    public function __construct(Message $message)
    {
        $this->message = $message;

        $this->dontBroadcastToCurrentUser();
    }


    /**
     * Get the channels the event should broadcast on.
     *
     * @return Channel|array
     */
    public function broadcastOn()
    {
        return new PrivateChannel('chat');
    }
}

It did have the user on as Eloquent i think within the constructor method, but I guess that was causing the problem, so removed it for now and all seems to be sending the APIMessage to Pusher. My only other problem now is that the event isn't pushing in realtime.

Pusher shows as:

{
  "message": {
    "id": 74,
    "user_id": 103,
    "message": "qwerty",
    "created_at": "2018-08-11 21:35:40",
    "updated_at": "2018-08-11 21:35:40"
  }
}

And I have an Echo listener as follows:

Echo.private('chat')
            .listen('MessageSent', e => {
                this.messages.push(e.message.message);
            });

But again this isn't pushing in realtime and therefore not updating the list or showing to the other user.

theUnforgiven left a reply on Error Message Adding A Message [stumped] • 1 week ago

No nothing, and just says to refer to docs, but I can't for the life of me figure out why

theUnforgiven left a reply on Error Message Adding A Message [stumped] • 1 week ago

Should just be an individual message, which having just checked yes it's a single message. I wonder if its the user object.

theUnforgiven left a reply on Error Message Adding A Message [stumped] • 1 week ago

Ok fixed that, but that now produces another error, something relating to Pusher I believe The data content of this event exceeds the allowed maximum (10240 bytes)

theUnforgiven left a reply on Error Message Adding A Message [stumped] • 1 week ago

Not sure I follow you @tykus

theUnforgiven started a new conversation Error Message Adding A Message [stumped] • 1 week ago

Hi all,

I'm building a chat section within my app, here the Vue I have:

ChatForm:

<template>
    <div class="panel-footer">
        <form method="POST" v-on:submit.prevent="addMessage" :action="post_url">
            <div class="input-group">
                <input id="btn-input"
                       type="text"
                       name="message"
                       class="form-control input-md"
                       style="height: 40px;"
                       placeholder="Type your message here..."
                       v-model="newMessage">

                <span class="input-group-btn">
                    <button class="btn btn-primary btn-sm" type="submit">
                        Send
                    </button>
                </span>
            </div>
        </form>
    </div>
</template>

<script>
    export default {
        props: ['user', 'post_url'],

        data() {
            return {
                newMessage: ''
            }
        },

        methods: {
            sendMessage() {
                this.$emit('MessageSent', {
                    user: this.user,
                    message: this.newMessage
                });

                this.newMessage = ''
            }
        }
    }
</script>
ChatMessage

<template>
<div>
    <div class="panel-body">
        <ul class="chat">
            <li class="left clearfix" v-for="message in messages">
                <div class="chat-body clearfix">
                    <div class="header">
                        <strong class="primary-font">
                            <!--{{ message.user.first_name }}-->
                        </strong>
                    </div>
                    <p>
                        {{ message.message }}
                    </p>
                </div>
            </li>
        </ul>
    </div>

</div>
</template>

<script>
    export default {

        props: ['user'],

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

        mounted() {
            this.fetchMessages();

            Echo.private('chat')
                .listen('MessageSent', (e) => {
                    this.messages.push({
                        message: e.message.message,
                        user: e.user
                    });
                });
        },

        methods: {
            fetchMessages() {
                axios.get('/messages/fetch').then(response => {
                    console.log(response.data);
                    this.messages = response.data;
                });
            },

            addMessage(message) {
                axios.post('/messages/send', message ).then(response => {
                    console.log(response.data);
                });
                this.messages.push(this.newMessage);
            },
            
        }
    };
</script>

Then within my blade I call:

<chat-messages :user="{{ user() }}"></chat-messages>
                <chat-form
                        post_url="{{ route('message.send') }}"
                ></chat-form>

but upon trying to add a message I get the following error:

vendor.js:42819 [Vue warn]: Property or method "addMessage" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.

found in

---> <ChatForm> at /Users/lee/code/cr/resources/assets/js/components/ChatForm.vue
       <Root>
warn @ vendor.js:42819
warnNonPresent @ vendor.js:44093
get @ vendor.js:44136
submit @ app.js:32256
invoker @ vendor.js:44185
fn._withTask.fn._withTask @ vendor.js:44020
app.js:32256 Uncaught TypeError: _vm.addMessage is not a function
    at submit (app.js:32256)
    at invoker (vendor.js:44185)
    at HTMLFormElement.fn._withTask.fn._withTask (vendor.js:44020)

not sure why or what this could be, everything else is working just not the posting of a new message, can anyone lend a hand tia :)

7th August, 2018

theUnforgiven left a reply on Models Within Models Directory • 2 weeks ago

Awesome, I knew there would be a simple way. I just couldn't find anything within the docs to relate to this. Thanks dude.

theUnforgiven started a new conversation Models Within Models Directory • 2 weeks ago

Hi all,

I've taken over a app and the developers before me have put all the models within a models directory rather than just within the app directory. My question is how can I get the artisan command to make a new model within this models directory? As it currently just creates a new model within the app directory and I have to manually move it.

5th August, 2018

theUnforgiven left a reply on Font Awesome Unable To Work Laravel 5.5 • 2 weeks ago

Why not reference from the CDN direct and then <i class="fa fa-facebook"></i> will just work.

31st July, 2018

theUnforgiven left a reply on Image Upload & Draggable Positioning, Like Facebook • 3 weeks ago

@claydog - Sorry I didn't no. We opted for a different solution.

30th July, 2018

theUnforgiven left a reply on Vue-instant Search, Algolia • 3 weeks ago

Anyone willing to advise?

theUnforgiven started a new conversation Vue-instant Search, Algolia • 3 weeks ago

Hi all,

I’ve easily implemented the vue-instant search which works great, however I wish to know the following as I am unable to find reference within the documentation.

I only want the results to show when a user start typing (currently shows them all) I want the result to be a clickable item to add it to the input, so I can later use this as a POST request from within my form.

Can someone either help/advise on this or point my in the right direction to where I can find this info out . Many thanks.

19th July, 2018

theUnforgiven left a reply on 401 Unauthenticated Error [HELP] • 1 month ago

So now within the APiController I've just extended the BaseController instead, and is still working.

theUnforgiven left a reply on 401 Unauthenticated Error [HELP] • 1 month ago

And I have no idea why that is there within the base controller, this is a app I have recently undertaken

theUnforgiven left a reply on 401 Unauthenticated Error [HELP] • 1 month ago

Which if I comment that out it does work now.

theUnforgiven left a reply on 401 Unauthenticated Error [HELP] • 1 month ago

No traits and it extends the base controller which does have:

 public function __construct()
    {
        $this->middleware('auth');
    }

theUnforgiven left a reply on 401 Unauthenticated Error [HELP] • 1 month ago

API Controller as no middleware on it and has many methods but the one of interest is here:

class ApiController extends Controller
{
public function sendSMS(Request $request)
    {
        try {
            $client = new \MessageBird\Client('XXXXXXXXX');
            $message = new \MessageBird\Objects\Message();
            $message->originator = 'MessageBird';
            $message->recipients = '44750000000';
            $message->body = 'This is a test message.';
            $MessageResult = $client->messages->create($Message);
           /// var_dump($MessageResult);
            return response()->json([
                'success' => true, 
                'response' => $MessageResult
            ]);
        } catch (\MessageBird\Exceptions\AuthenticateException $e) {
            // That means that your accessKey is unknown
            echo 'wrong login';
        } catch (\MessageBird\Exceptions\BalanceException $e) {
            // That means that you are out of credits, so do something about it.
            echo 'no balance';
        } catch (\Exception $e) {
            echo $e->getMessage();
        }
    }


}

The beginning of the routes file is as follows:

<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

// Homepage route.
Route::get('/', function() {
    return redirect('login');
});

/* MessageBird API */
Route::any('mobile/messagebird', '[email protected]')->name('sendsms');

// Auth routes.
Auth::routes();

theUnforgiven left a reply on 401 Unauthenticated Error [HELP] • 1 month ago

Kernel:

<?php

namespace App\Http;

use Illuminate\Foundation\Http\Kernel as HttpKernel;

class Kernel extends HttpKernel
{
    /**
     * The application's global HTTP middleware stack.
     *
     * These middleware are run during every request to your application.
     *
     * @var array
     */
    protected $middleware = [
        \Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
        \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
        \App\Http\Middleware\TrimStrings::class,
        \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
        \App\Http\Middleware\TrustProxies::class,
    ];

    /**
     * The application's route middleware groups.
     *
     * @var array
     */
    protected $middlewareGroups = [
        'web' => [
            \App\Http\Middleware\EncryptCookies::class,
            \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
            \Illuminate\Session\Middleware\StartSession::class,
            // \Illuminate\Session\Middleware\AuthenticateSession::class,
            \Illuminate\View\Middleware\ShareErrorsFromSession::class,
            \App\Http\Middleware\VerifyCsrfToken::class,
            \Illuminate\Routing\Middleware\SubstituteBindings::class,
        ],

        'api' => [
            'throttle:60,1',
            'bindings',
        ],
    ];

    /**
     * The application's route middleware.
     *
     * These middleware may be assigned to groups or used individually.
     *
     * @var array
     */
    protected $routeMiddleware = [
        'auth'                    => \Illuminate\Auth\Middleware\Authenticate::class,
        'auth.basic'              => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
        'bindings'                => \Illuminate\Routing\Middleware\SubstituteBindings::class,
        'can'                     => \Illuminate\Auth\Middleware\Authorize::class,
        'guest'                   => \App\Http\Middleware\RedirectIfAuthenticated::class,
        'throttle'                => \Illuminate\Routing\Middleware\ThrottleRequests::class,
        'isVerified'              => \App\Http\Middleware\IsVerified::class,
        'isNotVerified'           => \App\Http\Middleware\IsNotVerified::class,
        'verifyRegisterType'      => \App\Http\Middleware\VerifyRegisterType::class,
        'verifyRegistrationStage' => \App\Http\Middleware\VerifyRegistrationStage::class,
        'isPartOfAgency'          => \App\Http\Middleware\IsPartOfAgency::class,
        'isEmployed'              => \App\Http\Middleware\IsEmployed::class,
        'isAdmin'                 => \App\Http\Middleware\IsAdmin::class,
        'vagrant'                 => \App\Http\Middleware\RedirectIfNotPartOfCompany::class,
        'hasNotRequested'         => \App\Http\Middleware\HasNotRequested::class,
        'isTenant'                => \App\Http\Middleware\IsTenant::class,
        'hasAcceptedTos'          => \App\Http\Middleware\HasAcceptedTos::class,
        'isSubscribed'            => \App\Http\Middleware\IsSubscribed::class,
        'isBranchManager'         => \App\Http\Middleware\IsBranchManager::class
    ];
}

theUnforgiven left a reply on 401 Unauthenticated Error [HELP] • 1 month ago

RouteServiceProvider

<?php

namespace App\Providers;

use Illuminate\Support\Facades\Route;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;

class RouteServiceProvider extends ServiceProvider
{
    /**
     * This namespace is applied to your controller routes.
     *
     * In addition, it is set as the URL generator's root namespace.
     *
     * @var string
     */
    protected $namespace = 'App\Http\Controllers';

    /**
     * Define your route model bindings, pattern filters, etc.
     *
     * @return void
     */
    public function boot()
    {
        //

        parent::boot();
    }

    /**
     * Define the routes for the application.
     *
     * @return void
     */
    public function map()
    {
        $this->mapApiRoutes();

        $this->mapWebRoutes();

        //
    }

    /**
     * Define the "web" routes for the application.
     *
     * These routes all receive session state, CSRF protection, etc.
     *
     * @return void
     */
    protected function mapWebRoutes()
    {
        Route::middleware('web')
             ->namespace($this->namespace)
             ->group(base_path('routes/web.php'));
    }

    /**
     * Define the "api" routes for the application.
     *
     * These routes are typically stateless.
     *
     * @return void
     */
    protected function mapApiRoutes()
    {
        Route::prefix('api')
             ->middleware('api')
             ->namespace($this->namespace)
             ->group(base_path('routes/api.php'));
    }
}

theUnforgiven left a reply on 401 Unauthenticated Error [HELP] • 1 month ago

Still the same, redirect to login

theUnforgiven left a reply on 401 Unauthenticated Error [HELP] • 1 month ago

I meant ungrouped as in not within any prefix or have any middleware attached to it.

Within Kernel it looks like:

'web' => [
            \App\Http\Middleware\EncryptCookies::class,
            \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
            \Illuminate\Session\Middleware\StartSession::class,
            // \Illuminate\Session\Middleware\AuthenticateSession::class,
            \Illuminate\View\Middleware\ShareErrorsFromSession::class,
            \App\Http\Middleware\VerifyCsrfToken::class,
            \Illuminate\Routing\Middleware\SubstituteBindings::class,
        ],

theUnforgiven left a reply on 401 Unauthenticated Error [HELP] • 1 month ago

So I setup a basic form:

 <form action="{{ route('sendsms') }}" method="post">
                        <div class="form-group">
                            <label for="tel" class="sr-only">Mobile Number</label>
                            <input id="mob" type="tel" class="form-control" name="mob" placeholder="Mobile Number" value="{{ old('tel', session()->get('company.basic.data.mob')) }}" >
                            <button class="btn btn-xs btn-primary" data-toggle="modal" data-target="#verifyModal">Verify</button>
                            
                        </div>
                        <button type="submit">Send</button>
                    </form>

Pointing to a route a the top of the web routes files, so totally un-grouped.

Route::any('mobile/messagebird', '[email protected]')->name('sendsms');

But still redirects to /login

theUnforgiven left a reply on 401 Unauthenticated Error [HELP] • 1 month ago

Yes even with a conventional form it redirect to the login page, so the people who set this up before me did this, question is how do I get around this now?

theUnforgiven left a reply on 401 Unauthenticated Error [HELP] • 1 month ago

Yes that would explain the 302 code, so that's not right at all then. Guess I'll try in the conventional form way, rather than ajax, although it would need to be ajax.

theUnforgiven left a reply on 401 Unauthenticated Error [HELP] • 1 month ago

Yes I was going to do that, but then moved the route into my register route group and now I get a 302 response, but still doesn't show anything :(

theUnforgiven left a reply on 401 Unauthenticated Error [HELP] • 1 month ago

@36864 yeah, me too!

theUnforgiven left a reply on 401 Unauthenticated Error [HELP] • 1 month ago

Even adding a dd() and removing all the MessageBird code along with adding

headers: {
      'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
},

To the ajax this still shows as unauthenticated

theUnforgiven left a reply on 401 Unauthenticated Error [HELP] • 1 month ago

Sorry my bad, I thought i Had

message: "", exception: "Symfony\Component\HttpKernel\Exception\HttpException",…}
exception
:
"Symfony\Component\HttpKernel\Exception\HttpException"
file
:
"/Users/lee/code/cr/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php"
line
:
203
message
:
""
trace
:
[{,…}, {file: "/Users/lee/code/cr/app/Exceptions/Handler.php", line: 85, function: "render",…},…]
0
:
{,…}
1
:
{file: "/Users/lee/code/cr/app/Exceptions/Handler.php", line: 85, function: "render",…}
2
:
{file: "/Users/lee/code/cr/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php", line: 83,…}
3
:
{file: "/Users/lee/code/cr/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php", line: 55,…}
4
:
{,…}
5
:
{file: "/Users/lee/code/cr/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", line: 151,…}
6
:
{file: "/Users/lee/code/cr/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php", line: 53,…}
7
:
{,…}
8
:
{file: "/Users/lee/code/cr/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", line: 151,…}
9
:
{file: "/Users/lee/code/cr/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php", line: 53,…}
10
:
{,…}
11
:
{file: "/Users/lee/code/cr/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", line: 151,…}
12
:
{file: "/Users/lee/code/cr/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php", line: 53,…}
13
:
{,…}
14
:
{file: "/Users/lee/code/cr/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", line: 151,…}
15
:
{file: "/Users/lee/code/cr/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php", line: 53,…}
16
:
{file: "/Users/lee/code/cr/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", line: 104,…}
17
:
{file: "/Users/lee/code/cr/vendor/laravel/framework/src/Illuminate/Routing/Router.php", line: 667,…}
18
:
{file: "/Users/lee/code/cr/vendor/laravel/framework/src/Illuminate/Routing/Router.php", line: 642,…}
19
:
{file: "/Users/lee/code/cr/vendor/laravel/framework/src/Illuminate/Routing/Router.php", line: 608,…}
20
:
{file: "/Users/lee/code/cr/vendor/laravel/framework/src/Illuminate/Routing/Router.php", line: 597,…}
21
:
{file: "/Users/lee/code/cr/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php",…}
22
:
{file: "/Users/lee/code/cr/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php", line: 30,…}
23
:
{file: "/Users/lee/code/cr/vendor/barryvdh/laravel-debugbar/src/Middleware/InjectDebugbar.php",…}
24
:
{file: "/Users/lee/code/cr/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", line: 151,…}
25
:
{file: "/Users/lee/code/cr/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php", line: 53,…}
26
:
{file: "/Users/lee/code/cr/vendor/fideloper/proxy/src/TrustProxies.php", line: 57,…}
27
:
{file: "/Users/lee/code/cr/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", line: 151,…}
28
:
{file: "/Users/lee/code/cr/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php", line: 53,…}
29
:
{,…}
30
:
{file: "/Users/lee/code/cr/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", line: 151,…}
31
:
{file: "/Users/lee/code/cr/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php", line: 53,…}
32
:
{,…}
33
:
{file: "/Users/lee/code/cr/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", line: 151,…}
34
:
{file: "/Users/lee/code/cr/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php", line: 53,…}
35
:
{,…}
36
:
{file: "/Users/lee/code/cr/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", line: 151,…}

theUnforgiven left a reply on 401 Unauthenticated Error [HELP] • 1 month ago

I removed the api part and now get

message: "", exception: "Symfony\Component\HttpKernel\Exception\HttpException",…}
exception
:
"Symfony\Component\HttpKernel\Exception\HttpException"
file
:
"/Users/lee/code/cr/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php"

theUnforgiven left a reply on 401 Unauthenticated Error [HELP] • 1 month ago

I’m not using the Api routes either this is just within the web routes with no middleware

theUnforgiven started a new conversation 401 Unauthenticated Error [HELP] • 1 month ago

Hi all,

Having a totally brain freeze here...I'm trying to post to the MessageBird API to send an SMS using Ajax.

$("#mob").on('focusout', function(e){
                e.preventDefault();

                $.ajax({
                    type: 'POST',
                    url: '/api/mobile/messagebird',
                    data: {'number': mob },
                    dataType: 'json',
                    success: function (data) {
                        console.log('Success');
                    },
                    error: function (data) {
                        console.log('An error occurred.');
                        console.log(data);
                    },
                });
            });

And my controller looks like:

public function sendSMS(Request $request)
    {
        try {
            $client = new \MessageBird\Client('key from env');
            $message = new \MessageBird\Objects\Message();
            $message->originator = 'MessageBird';
            $message->recipients = '44750000000';
            $message->body = 'This is a test message.';
            $MessageResult = $client->messages->create(json_encode($Message));
           /// var_dump($MessageResult);
            return response()->json([
                'success' => true, 
                'response' => json_encode($MessageResult)
            ]);
        } catch (\MessageBird\Exceptions\AuthenticateException $e) {
            // That means that your accessKey is unknown
            echo 'wrong login';
        } catch (\MessageBird\Exceptions\BalanceException $e) {
            // That means that you are out of credits, so do something about it.
            echo 'no balance';
        } catch (\Exception $e) {
            echo $e->getMessage();
        }
    }

But I keep seeing "Unauthenticated." and I'm not sure why. Can someone kindly help me out please. By the way I have the CSRF except set also so this shouldn't interfere.

5th July, 2018

theUnforgiven left a reply on User With Many Relationships, Loop Within Job Class • 1 month ago

Yes your post helped debug the issue, but also you mentioned the key => value within the loop so I see that as a valid answer.

theUnforgiven left a reply on User With Many Relationships, Loop Within Job Class • 1 month ago

Which now also seems to working, I can see the output within the log file.

theUnforgiven left a reply on User With Many Relationships, Loop Within Job Class • 1 month ago

Still as in its still bytes exhausted sort of error.

Job queue is clear and failed jobs table is also clear now, so will try again,

theUnforgiven left a reply on User With Many Relationships, Loop Within Job Class • 1 month ago

@36864 - I'm still getting:

local.ERROR: App\Jobs\CheckVerificationStatus has been attempted too many times or run too long. The job may have previously timed out.

theUnforgiven left a reply on User With Many Relationships, Loop Within Job Class • 1 month ago

During the loop, the bytes exhausted error occurs.

theUnforgiven left a reply on User With Many Relationships, Loop Within Job Class • 1 month ago

@Cronix Thanks for a good shout, but I'm getting the following error now:

In HasRelationships.php line 555:

  Allowed memory size of 134217728 bytes exhausted (tried to allocate 266240
  bytes)

This is based on the following within the job class.

$user = User::has('tenancies')->get();
foreach($user as $u) {
            \Log::info($u);
}

4th July, 2018

theUnforgiven started a new conversation User With Many Relationships • 1 month ago

Hey all,

I have a bunch of users that will all have or may not have have a tenancy (rental on a property) and is a belongsTo relationship.

So my question is, I've created a job that I need to check every day if they have a tenancy or not, then after 21 days it should fire of an email to admin user.

Any suggestions on how best to achieve this?

3rd July, 2018

theUnforgiven left a reply on Docusign Type System • 1 month ago

???

theUnforgiven left a reply on Docusign Type System • 1 month ago

Anyone willing to shed some light on this issue i'm having?

theUnforgiven left a reply on Docusign Type System • 1 month ago

Anyone have any ideas on this?

2nd July, 2018

theUnforgiven left a reply on Docusign Type System • 1 month ago

So, I got the PDF to HTML all working and now showing the HTML version within a view file. I now need to be able to add "tags" or pieces of content in certain places within the PDF.

`For example:` within the pdf it will say address, so I need a way to either insert a tag for the address or auto fill the address field from the db, likewise for other things like rent amount, persons name and so on.

Each PDF will have the same sort of text, so how best can I achieve this? Search for the text via JS or something then insert a tag etc?

28th June, 2018

theUnforgiven left a reply on Filesystem, S3 Something Not Right • 1 month ago

@Cronix - I see now, my bad That will be the issue.

Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.