dmhamilt

Experience

8,470

1 Best Reply Awards

  • Member Since 1 Year Ago
  • 72 Lessons Completed
  • 0 Favorites

19th January, 2018

dmhamilt left a reply on Very Slow PHPUnit Tests Using PHP7.2 Or PHP7.1. • 9 months ago

Have you tried turning off broadcasting

in .envadd/change BROADCAST_DRIVER=log

3rd January, 2018

dmhamilt left a reply on Broadcasting Over Pusher - Event Listener Do Not Receive Anything... • 9 months ago

check the errors at pusher. I have had issues exceeding the size limitation.

24th September, 2017

dmhamilt left a reply on Run Php Commands From Sublime On Vagrant And Windows • 1 year ago

I have since moved to phpstorm.

20th September, 2017

dmhamilt left a reply on AWS S3 Turn Server Side Encryption (SSE) When Uploading • 1 year ago

The trick is to create an AWS client and then use putObject to store the file.

http://docs.aws.amazon.com/aws-sdk-php/v3/api/api-s3-2006-03-01.html#putobject

$filename=$request->file('upload')->getFilename();
        $file_ext=$request->file('upload')->clientExtension();
        $path="files/".$this->user->customer->id.'/'.$filename.'_'.str_random(15).'.'. $file_ext;

        $client = new \Aws\S3\S3Client([
            'version' => 'latest',
            'region' => env('AWS_REGION'),
        ]);

        $result = $client->putObject([
            'ACL' => 'private',
            'Bucket' => env('AWS_BUCKET'), // REQUIRED
            'Key' => $path, // REQUIRED
            'ServerSideEncryption' => 'AES256',
            'SourceFile'=> $request->file('upload'),
            'StorageClass' => 'STANDARD',

        ]);

dmhamilt started a new conversation AWS S3 Turn Server Side Encryption (SSE) When Uploading • 1 year ago

I am trying to upload a file and turn on SSE with Amazon AWS

$request->file('upload')->store("files/{$this->user->id}");

Is there a way to pass this in the headers x-amz-server-side-encryption ?

AWS states it needs to be in the headers to turn on encryption.

http://docs.aws.amazon.com/AmazonS3/latest/dev/SSEUsingRESTAPI.html

I have also started to play around with writing my own interface but I am not familiar with how to tie this into my fileController. This looks like it needs to go in the view on a form.

        $client = new \Aws\S3\S3Client([
            'version' => 'latest',
            'region' => env('AWS_REGION'),
        ]);
        $bucket = env('AWS_BUCKET');

        // Set some defaults for form input fields
        $formInputs = ['acl' => 'public-read'];

        // Construct an array of conditions for policy
        $options = [
            ['acl' => 'public-read'],
            ['bucket' => $bucket],
            ['starts-with', '$key', 'user/eric/'],
        ];

        // Optional: configure expiration time string
        $expires = '+2 hours';

        $postObject = new \Aws\S3\PostObjectV4(
            $client,
            $bucket,
            $formInputs,
            $options,
            $expires
        );

        // Get attributes to set on an HTML form, e.g., action, method, enctype
        $formAttributes = $postObject->getFormAttributes();

        // Get form input fields. This will include anything set as a form input in
        // the constructor, the provided JSON policy, your AWS Access Key ID, and an
        // auth signature.
        $formInputs = $postObject->getFormInputs();

How do I use this and where do I place the x-amz-server-side-encryption?

dmhamilt left a reply on Make Amazon S3 Files Private • 1 year ago

@spekkionu I have followed the aws-sdk instructions and successfully created a preassigned url to a file. However when I use that url in a file path it fails. IF I use it as a hyper link it works.

 $s3Client = new \Aws\S3\S3Client([
            'region' => 'us-east-1',
            'version' => 'latest',
        ]);
        $cmd = $s3Client->getCommand('GetObject', [
            'Bucket' => 'example',
            'Key' => $file->path,
        ]);
        $request = $s3Client->createPresignedRequest($cmd, '+20 minutes');

        // Get the actual presigned-url
        $presignedUrl = (string)$request->getUri();

This works

       return '<a href='.$presignedUrl. ' > download </a>';

This fails stating file not found

        return response()->file($presignedUrl);

2nd September, 2017

dmhamilt started a new conversation Run Php Commands From Sublime On Vagrant And Windows • 1 year ago

I would like to run code sniffer and the artisan package Jeffery Way uses in sublime. However i can't figure out how to make it work. All of those generate a 'php' is not recognized as an internal or external command, operable program or batch file.

or do nothing.

I am running homestead and not wamp.

30th August, 2017

dmhamilt started a new conversation UX Layout Tool • 1 year ago

Are there any suggestions for a UX Layout tool that integrates with Laravel?

I'm looking for something similar to sketchapp https://www.sketchapp.com/

13th July, 2017

dmhamilt left a reply on Resource Not Type Casting • 1 year ago

in my web.php

Route::get('Tasks/create','[email protected]');
Route::get('Tasks','[email protected]');
Route::get('Tasks/{task}/edit','[email protected]');
Route::get('Tasks/{task}','[email protected]');
Route::patch('Tasks/{task}','[email protected]');
Route::post('Tasks','[email protected]');
Route::delete('Tasks/{task}','[email protected]');

I have since just worked without type casting - so we can close this question;

24th June, 2017

dmhamilt left a reply on Resource Not Type Casting • 1 year ago

That is how I had it working. I called out each route for update, edit, index, delete, etc. That is a lot of extra typing for not much benefit. Calling the routes with resource trims that down, with the exception of Type Casting. Which I am puzzled why it does not work.

23rd June, 2017

dmhamilt left a reply on Resource Not Type Casting • 1 year ago

yes.

The non-resource route

Route::patch('Tasks/{task}', '[email protected]');

The migration for tasks

 public function up()
    {
        Schema::create('tasks', function (Blueprint $table) {
            $table->increments('id');
            $table->timestamps();
            $table->string('name');

dmhamilt started a new conversation Resource Not Type Casting • 1 year ago

I tried using the route:resource to save time making routes.

Route::resource('Tasks', 'TaskController');

Most everything is fine until I come to trying to type cast the data.

I usually have in the past done this

  public function update(Request $request, Task $task)
    {
        $data=$task;

Now I must do this, and its probably a bit more secure

  public function update(Request $request, $task)
    {

        $data=Auth::user()->tasks()->findOrFail($task);

My question is why did type cast not work? If I use

 public function update(Request $request, Task $task)

with Route:resource $task comes out null.

20th June, 2017

dmhamilt left a reply on New Laravel Project Not Working On Ubutnu Server • 1 year ago

Well it was not the document rot but looking at it get me to the issue.

the 000_default.conf file was missing some items.

    Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted

This is the entire file.

<VirtualHost *:80>
        ServerAdmin [email protected]
        DocumentRoot /var/www/test/public

        <Directory /var/www/test/public>
            Options Indexes FollowSymLinks
            AllowOverride All
            Require all granted

            RewriteEngine On
            RewriteBase /var/www/test/public
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

dmhamilt started a new conversation New Laravel Project Not Working On Ubutnu Server • 1 year ago

I have built a Ubutnu server running Apache2 and Laravel. My local server works fine, but when I push the files and try test the address, I get :

Not Found

The requested URL /login was not found on this server.

Apache/2.4.18 (Ubuntu) Server at 10.1.10.64 Port 80

notice the url switches to /login, so it does find the index and requires login

Below are my routes

+--------+----------+----------------------------------+------------------+------------------------------------------------------------------------+--------------+
| Domain | Method   | URI                              | Name             | Action                                                                 | Middleware   |
+--------+----------+----------------------------------+------------------+------------------------------------------------------------------------+--------------+
|        | GET|HEAD | /                                |                  | App\Http\Controllers\[email protected]                              | web,auth     |
|        | GET|HEAD | ProcessSteps                     |                  | App\Http\Controllers\[email protected]                       | web,auth     |
|        | POST     | ProcessSteps                     |                  | App\Http\Controllers\[email protected]                       | web,auth     |
|        | GET|HEAD | ProcessSteps/{process_step}      |                  | App\Http\Controllers\[email protected]                        | web,auth     |
|        | PATCH    | ProcessSteps/{process_step}      |                  | App\Http\Controllers\[email protected]                      | web,auth     |
|        | DELETE   | ProcessSteps/{process_step}      |                  | App\Http\Controllers\[email protected]                     | web,auth     |
|        | GET|HEAD | ProcessSteps/{process_step}/edit |                  | App\Http\Controllers\[email protected]                        | web,auth     |
|        | GET|HEAD | Users                            |                  | App\Http\Controllers\[email protected]                              | web,auth     |
|        | PATCH    | Users/{user}                     |                  | App\Http\Controllers\[email protected]                             | web,auth     |
|        | GET|HEAD | Users/{user}/edit                |                  | App\Http\Controllers\[email protected]                               | web,auth     |
|        | GET|HEAD | api/user                         |                  | Closure                                                                | api,auth:api |
|        | GET|HEAD | home                             |                  | App\Http\Controllers\[email protected]                              | web,auth     |
|        | POST     | login                            |                  | App\Http\Controllers\Auth\[email protected]                        | web,guest    |
|        | GET|HEAD | login                            | login            | App\Http\Controllers\Auth\[email protected]                | web,guest    |
|        | POST     | logout                           | logout           | App\Http\Controllers\Auth\[email protected]                       | web          |
|        | GET|HEAD | logout                           |                  | App\Http\Controllers\Auth\[email protected]                       | web          |
|        | POST     | password/email                   | password.email   | App\Http\Controllers\Auth\[email protected]  | web,guest    |
|        | GET|HEAD | password/reset                   | password.request | App\Http\Controllers\Auth\[email protected] | web,guest    |
|        | POST     | password/reset                   |                  | App\Http\Controllers\Auth\[email protected]                | web,guest    |
|        | GET|HEAD | password/reset/{token}           | password.reset   | App\Http\Controllers\Auth\[email protected]        | web,guest    |
|        | GET|HEAD | register                         | register         | App\Http\Controllers\Auth\[email protected]      | web,guest    |
|        | POST     | register                         |                  | App\Http\Controllers\Auth\[email protected]                  | web,guest    |
+--------+----------+----------------------------------+------------------+------------------------------------------------------------------------+--------------+

I have: allowed apache modification of htaccess chmod 777 for storage, bootstrap, and public

What did I forget to do?

dmhamilt left a reply on Are You All Using Vagrant ? • 1 year ago

i'd recommend building a linux based box for development. While i still use windows 10 and vagrant, i have wasted lots of hours and brain cells duct taping it together.

6th June, 2017

dmhamilt left a reply on Looking For Component Repository • 1 year ago

I can't find anything that will export data or make pdfs.

dmhamilt left a reply on Looking For Component Repository • 1 year ago

I think this may be the best resource.

https://github.com/vuejs/awesome-vue

dmhamilt started a new conversation Looking For Component Repository • 1 year ago

I am looking for a website where I can find Vue components. I have found a few but most of them have very few components and not many mroe than the examples off vuejs.org.

I am currently looking for a data table that is filtered, sortable, column dragable, and exports to multiple file formats including pdf.

Thanks

dmhamilt left a reply on Finding It Hard To Post Data To Database Using Vue Js And Axios Ajax Api • 1 year ago

this is a sample snippet this goes in the methods section.

update() {
                axios.patch('/Examples/' + this.example.id, this.payload)
                        .then(response => {
                            Event.fire('updated');
                        })
                        .catch(error => {
                            console.error(error);
                        });
            },


remove() {
                axios.delete('/Examples/' + this.example.id)
                        .then(response => {
                            Event.fire('updated');
                        })
                        .catch(error => {
                            console.error(error);
                        });
            },

add() {
                axios.post('/Examples/',  this.payload)
                        .then(response => {
                            Event.fire('updated');
                        })
                        .catch(error => {
                            console.error(error);
                        });
            },

payload is the data you want to submit to the server.

Tip make sure you return a json variable that contains status=200. otherwise certain browsers won't handle the ajax well.

I use a 2 level vue component strategy. The first "list" level adds new records and refreshes all the records within the collection. The second level has methods to update and delete a single record. The updated event triggers the collection to refresh the data.

Hope this helps

30th May, 2017

dmhamilt left a reply on Cross-env Not Found On Npm Run Dev • 1 year ago

I have tried lots of solutions and finally got windows 10 to create symbolic links, which is the root of most of window users issues heartache.

First turn on Windows 10 Developer. ''Search for Developer in Settings'' change it to Developer.

Secondly make sure you have permission to make symbolic links.

local security policy \ local polices \ user right assignment\ create symbolic link
'''
Note: put your user name in all lowercase and check names. Oddly this worked for me. But spelling it with mixed case did not.

Lastly 
When you open git bash, run it as administrator. Now this is a point of frustration because I often forget. So make it default to open as admin. Make a shortcut on the desktop for git bash. right click on the shortcut \ properties\ advance and check run as administrator.

Reboot the machine and you should be much better off.

If somebody know how to paste screen shots please let me know. I cant get them in here.





28th May, 2017

dmhamilt left a reply on Seeding Pivot Tables • 1 year ago

There are a few ways to seed them. If you are creating dummy data, and you already have the two independent tables defined, I'd use the factory.

In database\factories

$factory->define(App\ModelAB::class, function (Faker\Generator $faker) {
    return [
'model_a_id' => App\ModelA::all()->random()->id,
'model_b_id' => App\ModelB::all()->random()->id,
    ];
});

You will have to call the factory for ModelAB from one of the seeders. Note run the Model_AB seeder after you already ran the seeder for Model_A and Model_B

class model_ab_seeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {

    factory(App\ModelAB::class, 5)->create();

    }
}

18th May, 2017

dmhamilt left a reply on [5.4] Npm Run Watch Not Working • 1 year ago

I had to change mywatch because of symlinks,

This required me to change my watch-poll ''' "x-dev": "node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",

"x-watch": "node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",

"x-watch-poll": "npm run x-watch -- --watch-poll"

'''

I made "x-watch" because we had a guy developing on a mac and didn't need this fix.

dmhamilt left a reply on Cross-env Not Found On Npm Run Dev • 1 year ago

Stretsh your solution fixed my npm run dev problem but for watch it runs but doesn't sense file changes. Any ideas?

dmhamilt left a reply on Npm Run Dev - With Errors • 1 year ago

are you running windows? I find that alternating bewteen npm install and npm install --no-bin-links will solve most problems. If you already have that up, try deleting the node_modules folder and reinstalling npm. This take a while but it solve several problems.

I have the cross-env issues. It has to do with symlinks not working on windows OS. I tried running from Bash on Ubutnu on Windows, but that did not help. I have tried running as administrator, and that does not help.

You can bypass the "NODE_ENV" issue. Change you package.json file

{
  "private": true,
  "scripts": {
    "dev": "node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
    "watch": "node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
    "watch-poll": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --watch-poll --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
    "hot": "node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
    "production": "node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
  },

12th May, 2017

dmhamilt left a reply on Modify ResetsPasswords.php • 1 year ago

I coppied the "ResetPasswords" trait into a new folder App\Traits.

in the new trait file "DmhResetPasswords.php" I made changes to the namespace and added a "use"

``

dmhamilt left a reply on Modify ResetsPasswords.php • 1 year ago

I don't think this ever got answered with a working solution. Do you copy the trait and rename it "ResetPassword2Controlle.php" and then modify it? Do yu copy all the methods and into "ResetPasswordController.php"? The hyperlink points yout to several vendor files and says feel free to override them. but I am not sure exactly how you override (change the code there or copy the file and try to redirect everything to it, or is there some easier way to do it)?

8th May, 2017

dmhamilt left a reply on Popup • 1 year ago

jlrdw - can I pass data back from the open window?

dmhamilt left a reply on Popup • 1 year ago

thanks

I'm trying this and see what happens. I'm halfway through making a component and using the bootstrap modal css already installed.

https://vuejs.org/v2/examples/modal.html

dmhamilt started a new conversation Popup • 1 year ago

Is there an "easy" way to make a popup. I have seen several packages that require plugins and lots of code.

The javascript prompt() only allows text input. I would like to have a select field that returns a value back to a form.

19th April, 2017

dmhamilt left a reply on Can I Model A Query Instead Of A Table? • 1 year ago

Thanks andonovn, I wanted to know if it was possible and if it was supported.

Major Point model 1:1 table

dmhamilt left a reply on Vue , Ajax, And Select Components • 1 year ago

I got my code posted for several months and took it down since I didn't get any tips. I paid someone to help me and it involves creating several events, listeners, watches, etc.

Vue.js may not be the best solution if you want to update a database because you have add lots of code to different place to make it work, they keep changing how it works, and finding a "alpha to omega" reference on database interactions is very tough. I will try angular on the next project.

dmhamilt left a reply on Can I Model A Query Instead Of A Table? • 1 year ago

The Person, Men, Woman is a simplified version of my situation. My actual code is more wordy and I want to avoid repeating code in Controllers and focus on defining a robust data model.

the allMen may solve my immediate need to avoid repeating code:

''' where('sex', '=', 'male')->get() '''

Although I don't fully understand "scope". It looks like that would limit Person to males 100% of the time. I am going to keep reading that topic but i suspect it does not address by bigger question.

Can I model a Query instead of a Table?

The database table "people" contains all the data. But the model "Man" would allow relationships to be formed that are not allowed for "Woman". I could make an intermediate table "males" and make a Model "Man", but I want to know is that always necessary? Boolean in 1 table versus 2 intermediate tables with ids.

To clarify this is more about than just making a list. I want to define methods to the Man model that are not allowed for Woman and vice versus.

Table "person" field "father_id" is populated by ''' App\Man::addChild($person_id); '''

Can I do this?

'' class Man extends Model {

protected $query= 'App\Person::where('sex','=','male')';

'''

dmhamilt started a new conversation Can I Model A Query Instead Of A Table? • 1 year ago

I want to model a subset of a table to reduce code in controllers.

For example Table "people" with fields "name", "sex", "phone"

A model "Person"

''' class Person extends Model {

protected $table="people" public function men() { return $this->hasMany(Person::class)->where('sex','=','male') } ''' $list_of_men=App\People::first()->men->get();

dmhamilt left a reply on Intermediate Table Models • 1 year ago

I suspect: "using" does not specify a particular intermediate table. It can get to the target through various relationships. This will prevent you from attaching or detaching, time stamping, etc. Thus it is a great query tool, but it can not define a relationship on a model.

dmhamilt left a reply on How To Make A Bounded Custom Select Input • 1 year ago

I figured it out. thanks

dmhamilt left a reply on Vue , Ajax, And Select Components • 1 year ago

I figured it out. Thanks

21st January, 2017

dmhamilt left a reply on Vue , Ajax, And Select Components • 1 year ago

This is the snippet I am having problems with, I took out the some other stuff

<opp_category_select v-bind:value="x.opp_category_id" v-bind:disabled="!is_editable" v-on:changed="x.opp_category_id= arguments[0]"></opp_category_select >

{{option.name}} Vue.component('opp_category_select',{ template: '#opp-category-select', props:['value','disabled'],
data: function() {
        return{
            options:[],
            x_selected:[],
        };
},
created: function() {
    var self=this;
    self.fetchOptions();
    console.log('finish created ' + this.value);
},

methods: {
    fetchOptions: function(){
        var self=this;
        $.ajax({
            type: 'GET',
            dataType: 'json',
            url:'/OppCategory',
            timeout:2000,
            complete:function(){
                self.x_selected=self.value;
                console.log('completed fecth options ' + this.value);
            },
            success:function(return_data){
                self.options=return_data;
                console.log('fetchOptions Success Category ' + this.value);
                console.log(return_data);
            },
            error:function(){
                console.log("error with AJAX");
            }
        });
    },
    updateValue: function(selected_id){
        console.log('updateValue Category');
        console.log(selected_id);
        this.$emit('changed', Number(selected_id));
    },
},

});

var app= new Vue({ el: '#vue-app' });

20th January, 2017

dmhamilt started a new conversation Vue , Ajax, And Select Components • 1 year ago

I am trying to create a parent, child, grand child, etc user interface and update it using ajax. I have been successful at creating a parent list and child components that fetch and store their data. however when i need to select the value in a drop down list the wheels fall off and I get unpredictable results. Right now my issues seems that the binding and creating of the second tier is unpredictable. I tried to control this using the "success" and "complete" functions in .ajax. But nothing seems to force loading the options first and then selecting the current value in the correct procedural order. Half of my select boxes are selected to null

Does anybody have an example of a <custom-parent> <custom-select> </custom-select> </custom-parent>

18th January, 2017

dmhamilt left a reply on How To Make A Bounded Custom Select Input • 1 year ago

I think I solved my problem. Can anyone verify this is the typical way of doing this?

Vue.component('opp-category-select',{ template: '<select v-model="x_select"'+ ' v-on:change="updateValue($event.target.value)" >' + ''+ '{{option.name}}'+ ''+ '', props:['value'],

data: function() {
        return{
            options:[],
            x_select:[]

        };
},
created: function() {
    this.fetchOptions();
    this.x_select=this.value;


},

methods: {
    fetchOptions: function(){
        var self=this;
                $.getJSON('/OppCategory', function (data){
                self.options=data;
                console.log('fetchOptions');
                console.log(data);
                });
    },
    updateValue: function(selected_id){
        console.log('updateValue');
        console.log(selected_id);
        this.$emit('change',selected_id)


    }
}

});

var app= new Vue({ el: '#vue-app', data:{ category_id:1 }

});

dmhamilt started a new conversation How To Make A Bounded Custom Select Input • 1 year ago

I am new to Vue. I am trying to create a form with text boxes and drop down lists. The text boxes work great. But the select inputs don't work if I try to make them dynamic.

I have created a component that is bound to data with v-model. However I have some foreign keys I want to be selected with a custom select component. I can create a "static" select statement that updates the "select component" but that is fairly useless. I have tried to emit an event but can't get it to work and the online examples are for non-select inputs.

This is the example I trying to use. https://vuejs.org/v2/guide/components.html#Form-Input-Components-using-Custom-Events

Any help would be great.

Thanks

Edit Your Profile
Update

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