Robstar

at F9 Web Ltd.

Hire Me

Experience

45,900

5 Best Reply Awards

  • Member Since 3 Years Ago
  • 464 Lessons Completed
  • 3 Favorites

12th December, 2017

Robstar left a reply on Read Value In Modal • 8 hours ago

Also, if you need the raw content you can surround the variable with {{ $message->body }}.

If you do that, Blade with escape the content. To display the content un-escaped (warning, read up about the implications of this) you'll need to do the following: {!! $message->body !!}

Robstar left a reply on Read Value In Modal • 8 hours ago

You're targeting the same modal, #myModal every time.

Whilst creating multiple modals per page is not the ideal solution, if you go down this route each modal will require a unique id.

Ideally, you want a single modal where the content is set using JavaScript. See https://stackoverflow.com/a/10635652

5th December, 2017

Robstar left a reply on 3 Category Tables With Same Structure, How To Manager Them With One Controller, Model, And View Etc At Admin? • 1 week ago

@martinym I'd personally have a single screen. On the screen I'd have some form of drop down where you can select the associated model.

I certainly wouldn't make 3 controllers or different route resources.

ON the relations front you may find https://stackoverflow.com/questions/35100615/using-eloquent-polymorphic-relationships-to-categorise-data-in-laravel helpful.

3rd December, 2017

Robstar left a reply on Having Doubts With The Laracasts Series Steps • 1 week ago

I've come across several. i.e. https://laracasts.com/series/build-project-flyer-with-me - a couple of years old but it's good to watch if you're learning.

There is little point in just watching videos if you're not going to apply those principals afterwards - at the very least try to get the examples from the videos running on your own machine.

If you're struggling there are lots of beginner series available. i.e. https://laracasts.com/series/object-oriented-bootcamp-in-php and https://laracasts.com/series/php-for-beginners

Robstar left a reply on Help My Understanding Of Querying Classes/models • 1 week ago

@Mick79 There is a lot of awesomeness that if you're learning can be a lot of take in. Try getting something up and running first and then refactor - don;t try to do everything in one go imo. For example, whilst you haven't used relationships your code appears to fetch the correct user.

Robstar left a reply on Left Sidebar On Laravel Documentation Dosen't Open Nicely. • 1 week ago

Not sure why Laracasts would be the place to get the Laravel docs "fixed" :)

Robstar left a reply on How To Pass Variable To View From Inside Function If Response()->json() Is Returned? • 1 week ago

Can you paste some console output when you log data to console? The tutorial uses a custom jQuery plugin that has a lot of options.

Robstar left a reply on Creating A Schedule/calendar • 1 week ago

@robrogers3 You'll get lucky to find something written for you that meets all specific requirements. You'll most likely need to write some code! :)

The validation against time slots should really be done server side. i.e. you'd post data to your API which would validate against a form request - see https://laravel.com/docs/5.5/validation#form-request-validation

Robstar left a reply on 3 Category Tables With Same Structure, How To Manager Them With One Controller, Model, And View Etc At Admin? • 1 week ago

Firstly, you have a bad database structure :)

As for your issue (caused by a bad database structure) you could create a factory class that returns a model instance based upon the provided table name.

I personally just have a Polymorphic type setup so categories can be shared across models. Still, that may get a little more complicated depending upon how (or if)you store hierarchy data (i.e. parents/children etc.)

Robstar left a reply on How Do You Test API Limits • 1 week ago

You could try setting the limit lower :) Apache bench is pretty easy to setup and may help.

Robstar left a reply on How To Pass Variable To View From Inside Function If Response()->json() Is Returned? • 1 week ago

@shone83 Are you using something like axios to make ajax calls client side? If so the response may be wrapped with an additional key. i.e:

'data' => [
// existing data 
]

Try logging the ajax response to the console.

Robstar left a reply on Laravel Gmail Setting - Issue • 1 week ago

Also try php artisan config:cache. If that fails delete the cache files within bootstrap/cache.

I haven't used Gmail to send mail for a long time, but I vaguely remember the password is not your regular gmail account password. It's your app password, which is different.

What error do you get when your app attempts to send an email?

29th November, 2017

Robstar left a reply on Model Const • 1 week ago

To add onto the answer from @ChristophHarms sometimes enumerators are useful see https://stackoverflow.com/questions/254514/php-and-enumerations. With PHP you'll require http://php.net/manual/en/class.splenum.php.

15th November, 2017

Robstar left a reply on Failed To Install With Composer • 3 weeks ago

I think the lack of replies relate to the fact you seem to have copied your whole console :)

A quick glance over your wall of text indicates your system is unable extract files on the cli. I'm also not convinced composer is installed correctly and has the correct permissions on your server. I'd try removing the current composer install and starting again if possible.

Have you tried clearing the composer cache directory or ran a composer install without cache?

Whilst it doesn't help here, I always find using CentOS causes issues. Everything always run much more smoothly with Ubuntu.

Have you tried Forge too - that seriously eliminates issues like this and allows you to spend time developing as opposed to things like this thread.

Without Googling any of this it's hard to say :/

Robstar left a reply on Laravel Pagination Error • 3 weeks ago

@Cheers02 This is covered in the documentation, see https://laravel.com/docs/5.5/pagination#displaying-pagination-results

i.e.

{{ $users->fragment('foo')->links() }}

would create links like:

/users/?page=2#foo

Robstar left a reply on Mysql Setup, Whithout Messing With DesktopServer • 3 weeks ago

@vayu Well the "error" you mentioned was due to you trying to install Homestead in a folder with an existing Vagrant box. Simply install Homestead in an empty folder. The majority of issues with Homestead installation seem to relate to old/incompatible versions of Vagrant or VIrtual box being used.

Laradock (http://laradock.io) is also very good, which uses Docker.

Robstar left a reply on Package Auto Discovery Not Working • 3 weeks ago

After running composer install Laravel should automatically discover packages for you. Alternatively, you can run php artisan package:discover directly.

If you do see no output you probably need to run composer self-update, as I believe the package discovery process requires a more recent version of composer.

The above resolved my issue last night anyway :)

Robstar left a reply on Data Modelling And Business Rules • 3 weeks ago

You'd most likely end up with a pivot table consisting of the booking_id and table_id columns. However, you could also store the table_id on the booking table (this would limit the number of tables per booking to one, which may or may not be desirable).

You'd restrict bookings on the application side but could also restrict it at the database level using a compound primary key on the pivot table.

For application level side have a read of https://laravel.com/docs/5.5/eloquent-relationships

Robstar left a reply on How To Execute Content From Protected Models To Homepage||Protected Route? • 3 weeks ago

@splendidkeen Always take time to read the documentation.

For example:

Robstar left a reply on Mysql Setup, Whithout Messing With DesktopServer • 3 weeks ago

@vayu - just follow the advice output by the command (it's not a Homestead error btw). Homestead needs to installed into it's own directory, something which I believe the documentation advises - see https://laravel.com/docs/5.5/homestead

Robstar left a reply on API Version Control In Header • 3 weeks ago

Personally I'd use a factory class here, which I guess would end up somewhat similar to the "api version class" mentioned earlier.

Robstar left a reply on No Users Found • 3 weeks ago

You could also do:

$user = User::latest()->get();

13th November, 2017

Robstar left a reply on Use Laravel Scout Without Algolia • 4 weeks ago

@addorange Scout is intended to accept drivers. Apart from Agolia, there is TNT Search (https://github.com/teamtnt/laravel-scout-tntsearch-driver). There is even a MySql driver available at https://github.com/YABhq/laravel-scout-mysql-driver.

In summary, Scout needs a driver and will not work without one.

The Scout service provider, calls an "EngineManager" class (see https://github.com/laravel/scout/blob/3.0/src/EngineManager.php), which determines what driver to use. In particular see https://github.com/laravel/scout/blob/3.0/src/EngineManager.php#L53-L60 which fetches the driver from your scout config file.

9th November, 2017

Robstar left a reply on Controller Questions • 1 month ago

If you're starting with Laravel have a read about the basics first:

View: https://laravel.com/docs/5.3/views Passing data to views: https://laravel.com/docs/5.3/views#passing-data-to-views Resource controllers: https://laravel.com/docs/5.3/controllers#resource-controllers Eloquent: https://laravel.com/docs/5.3/eloquent

7th November, 2017

Robstar left a reply on Missing Required Client Configuration Options: Region While Trying To Implement S3 • 1 month ago

What value are you using for the "region" key?

I did come across a small change yestday when up[grading to Laravel 5.5 from 5.4. It seems to .env variable names have changes. They are now https://github.com/laravel/laravel/blob/master/config/filesystems.php#L58-L64

Robstar left a reply on Laravel Validation • 1 month ago

Depends upon how you made the ajax request - do you have some code to show as there are lots of ways to display validation errors?

There's an example at http://itsolutionstuff.com/post/laravel-5-ajax-request-validation-exampleexample.html

If you open Chrome dev tools and watch the ajax request you should see some Json returned from the server - you need to parse this client side.

10th October, 2017

Robstar left a reply on Models Directory • 2 months ago

Make a "Models" directory and place your models there. Simple :)

15th August, 2017

Robstar left a reply on Getting All Rows From The DB Into An Array • 3 months ago

The findOrFail() returns the first result only or throws an exception. See https://laravel.com/docs/5.4/eloquent#retrieving-single-models

As ypou

10th August, 2017

Robstar left a reply on Add/Update Cache Control Metadata On S3 Objects • 4 months ago

@Laraveldeep Have just noticed you said you need to do this for thousands of files. If that's the case use the aws-cli - it's quicker and cheaper than individual request from your application.

Robstar left a reply on Passing DB To Blade Template • 4 months ago

Back on topic, you at least need to show us (within proper code blocks) relevant Controllers and anything else relevant like View Composers.

I'm not use if the following will work, but it will helps show you what data is available to Blade:

{{ dd(get_defined_vars()['__data']) }}

However, it's probably easier to just show us the controller where you're creating all the variables in question.

Robstar left a reply on Passing DB To Blade Template • 4 months ago

@PolMac - I think @tykus means place code within code blocks :)

8th August, 2017

Robstar left a reply on Add/Update Cache Control Metadata On S3 Objects • 4 months ago

I've only recently discovered that the following works:

's3' => [
            'driver' => 's3',
            'key' => env('AWS_KEY'),
            'secret' => env('AWS_SECRET'),
            'region' => env('AWS_REGION'),
            'bucket' => env('AWS_BUCKET'),
            'options' => [
                'CacheControl' => 'max_age=31536000'
            ],
        ],

Robstar left a reply on Unique Validation For Translation Table • 4 months ago

Sounds like it'd be quicker to create your own validation rile. See https://laravel.com/docs/5.4/validation#custom-validation-rules

7th August, 2017

Robstar left a reply on Validate Validation Rules • 4 months ago

I'm over thinking it probably. For the time being I'll just catch the exception without using form requests. There must be a way to do this though :/

6th August, 2017

Robstar left a reply on Validate Validation Rules • 4 months ago

@Snapey I can do this and catch the error:

try {
    $this->validate(request(), [
        'value' => 'email|kjdsafhkjsahdfk|string'
     ]);
} catch (\BadMethodCallException $ex) {
    // Bad rules string
}

However, that only works in the controller and not in my form request class as I'd like. It's certainly a start as it stops my app from blowing up :)

Robstar left a reply on Validate Validation Rules • 4 months ago

@jlrdw Yep, I know, hence the thread :)

Robstar left a reply on Validate Validation Rules • 4 months ago

@Snapey If you follow the validation service provider & look for the validateAttribute function, it's not immediately obvious how I'd catch the exception thrown.

There isn't really the time to implement a UI for this - maybe in the next round of changes.

Robstar left a reply on Validate Validation Rules • 4 months ago

Within the FormRequest:

if ($this->has('rules')) {
      $rules['value'] = $this->get('rules')
}

The value field is the the setting value.

It's very flaky as it's entirely reliant upon the user entering in valid, validation rules. I don't trust the client :)

Robstar left a reply on Using Mailgun Inbound Email Routing • 4 months ago

I believe Mailgun send attachments as a multipart file.

For each attachment there should be a url similar to https://api.mailgun.net/v2/domains/<<<YOUR_DOMAIN>>>>/messages/<<LONG_STRING>>>/attachments/0 that conatins the file. Note you'll need to use your Mailgun API credentials to access this url as it is password protected.

Mailgun allows you to attach custom keys and values to each message. See https://documentation.mailgun.com/en/latest/user_manual.html#attaching-data-to-messages

Why not use a key titled something like attachment-NUMBER with the value being the full path http://site.co.uk/file.png (or say the AWS s3 path).

Have you tried bin.mailgun.net? It's very useful for web hooks which are annoying to debug. See http://blog.mailgun.com/product-update-new-postbin-for-debugging-webhooks/

Robstar left a reply on How To Save Dynamic Input Data Into Database As Json ? • 4 months ago

You could store the raw JSon object using the newer json column type in Mysql. However, the best course is to store each record in a related table.

Robstar started a new conversation Validate Validation Rules • 4 months ago

So, I have a client that's been reading about Laravel validation rules.

They currently have a settings screen that manages a very basic store of keys and values. i.e. "max free samples" = 10, "login attempts" = 5 etc.

They came up with a pretty interesting idea.

For each setting, they'd like to use any of the Laravel built in rules and type these in themselves. Now, when they create a setting they'd enter the key, value and populate a rules field. i.e.

Key = Max of something
Value = 100
Rules = required|integer|max:500

I've already implemented this and everything works. However, at the moment it's very dependent upon the client following the Larvel Docs. If they were to enter in a invalid rules a BadMethodCall exception is thrown - which due to the fact I'm using form requests and the way the Validation instance is bound to the ioc, isn't immediately obvious how I can catch this.

To save some time, is anyone aware of a good package that can validate the validation rules. i.e. required|email would be valid, whereas requireddd|asijdha would of course be invalid. There is also the issues of rules with parameters like between:10,20.

Thanks

3rd August, 2017

Robstar left a reply on Call To Undefined Method Laravel\Section::_start() • 4 months ago

Try clearing your view cache: php artisan view:clear.

In these situations it's always worthwhile running a command along the lines of the following too:

php artisan cache:clear && php artisan clear-compiled && php artisan config:cache && php artisan route:cache && php artisan optimize

Robstar left a reply on Laravel 5 Password Reset Not Working • 4 months ago

For me the password reset form was working and generating a new password.

However, I was unable to login using the password I set. I'm sure there's a better fix than this, but here is my "solution". The issue was that the password being "bcrypted" twice - once by the Eloquent mutator on the user model and once via the "resetPassword" method at Illuminate\Foundation\Auth.

Override the method "resetPassword" in your own reset controller. Change it from:

protected function resetPassword($user, $password)
    {
        $user->forceFill([
            'password' => bcrypt($password),
            'remember_token' => str_random(60),
        ])->save();

        $this->guard()->login($user);
    }

to

protected function resetPassword($user, $password)
    {
        $user->forceFill([
            'password' => $password,
            'remember_token' => str_random(60),
        ])->save();

        $this->guard()->login($user);
    }

13th July, 2017

Robstar left a reply on Adapting Font Type And Size In Text Boces • 4 months ago

Are you using the SAAS or flat CSS version of Bootstrap? If the former, you'd simply need to change a SAAS variable.

10th July, 2017

Robstar left a reply on Problem In Updating Data Into Mysql • 5 months ago

Assuming your database structure and models are setup correctly, try to isolate the problem. For example, does the following work:

$validIdFromYourDatabase = 1;
$crud = Category::find($validIdFromYourDatabase);
$crud->name = 'Hardcoded name';
$crud->status = 1;
$crud->save();

Also, add a method to your form html i.e:

<form method="POST" ....

Robstar left a reply on How To Find The Correct Path To Download File In Laravel • 5 months ago

As you're using the public disk driver you need to symlink by running php artisan storage:link

See https://laravel.com/docs/5.4/filesystem#the-public-disk

You can then reference your file via asset('storage/file.txt')

Robstar left a reply on Problem In Updating Data Into Mysql • 5 months ago

You really need to give us more to go on if you expect any form of useful reply :) At the very least, show us your code and database structure. Were there any errors etc.

For future reference I'd recommend reading https://stackoverflow.com/help/how-to-ask :)

Robstar left a reply on How To Block When Someone Paste A Link From My Api • 5 months ago

@coustas Then the simplest way is token auth. If using Lumen it takes a few moments at most to setup.

When setup, the user would need to pass a header, containing an API token (i.e. from your users table) to use the endpoint. If finer grain control is required then you'd need to use permissions/roles for the auth'd user.

Edit Your Profile
Update

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