deansatch

Experience

32,740

27 Best Reply Awards

  • Member Since 1 Year Ago
  • 128 Lessons Completed
  • 4 Favorites

8th May, 2018

deansatch left a reply on WithTrashed() If User Is Admin • 2 months ago

I did try that but they seem to be called before Auth so I can’t do my if statement

deansatch started a new conversation WithTrashed() If User Is Admin • 2 months ago

Is there a way to add withTrashed() to a model only if the Auth::user()->isAdmin(). So basically records are deleted to front end users but admins can still work with them when logged in?

4th May, 2018

deansatch left a reply on Task Belongs To Project And/or Milestone • 2 months ago

Never mind...just remembered I can do a morphOne

deansatch started a new conversation Task Belongs To Project And/or Milestone • 2 months ago

I want a user to be able to create a 'Task' and that task could belong to a 'Project' or it could belong to a 'Milestone'. (A milestone will always belong to a project).

What's the best table setup for this? Pivot? I want to keep options open for future too where a Task could belong to anything e.g. user, product etc...

25th March, 2018

deansatch started a new conversation "My Participation" Bug • 3 months ago

Tiny little bug:

Someone posted a question. I answered. I edited my answer. Went to "My Participation" and no sign of that thread.

Whatever the cause, it might be related to some other inconsistencies I've noticed with the "- {{time}} by {{user}} UDATED" sometimes not showing the correct name too

deansatch left a reply on How Do I Call Encrypted Value From My Database On Index() And Decrypt It There? • 3 months ago

Try changing ->get() to ->first()

deansatch left a reply on Mysql Goes Down • 3 months ago

Is that not just to stop warning in the log file? I'm more concerned with why mysql keeps shutting down and restarting

deansatch left a reply on Need To Sort Prodcut By Price ASC And DESC • 3 months ago

@snapey Just out of curiosity, what would happen if someone changed the url to ?sort=hello - would it throw an error?

deansatch left a reply on Mysql Goes Down • 3 months ago

Any ideas anyone?

22nd March, 2018

deansatch left a reply on Mysql Goes Down • 4 months ago


2018-03-20T09:50:20.352122Z 31702 [Note] Aborted connection 31702 to db: 'unconnected' user: 'root' host: 'localhost' (Got an error reading communication packets)
2018-03-20T09:50:20.352276Z 31701 [Note] Aborted connection 31701 to db: 'lingotot' user: 'root' host: 'localhost' (Got an error reading communication packets)
2018-03-20T16:53:47.637226Z 0 [Warning] Changed limits: max_open_files: 1024 (requested 5000)
2018-03-20T16:53:47.645002Z 0 [Warning] Changed limits: table_open_cache: 431 (requested 2000)
2018-03-20T16:53:48.138787Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-03-20T16:53:48.145802Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.21-0ubuntu0.16.04.1) starting as process 22518 ...
2018-03-20T16:53:48.162467Z 0 [Note] InnoDB: PUNCH HOLE support available
2018-03-20T16:53:48.162504Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2018-03-20T16:53:48.162526Z 0 [Note] InnoDB: Uses event mutexes
2018-03-20T16:53:48.162534Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2018-03-20T16:53:48.162541Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.8
2018-03-20T16:53:48.162547Z 0 [Note] InnoDB: Using Linux native AIO
2018-03-20T16:53:48.163287Z 0 [Note] InnoDB: Number of pools: 1
2018-03-20T16:53:48.164001Z 0 [Note] InnoDB: Using CPU crc32 instructions
2018-03-20T16:53:48.168087Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2018-03-20T16:53:48.168443Z 0 [ERROR] InnoDB: mmap(137428992 bytes) failed; errno 12
2018-03-20T16:53:48.168465Z 0 [ERROR] InnoDB: Cannot allocate memory for the buffer pool
2018-03-20T16:53:48.168474Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
2018-03-20T16:53:48.168486Z 0 [ERROR] Plugin 'InnoDB' init function returned error.
2018-03-20T16:53:48.168492Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2018-03-20T16:53:48.168500Z 0 [ERROR] Failed to initialize builtin plugins.
2018-03-20T16:53:48.168505Z 0 [ERROR] Aborting

2018-03-20T16:53:48.168518Z 0 [Note] Binlog end
2018-03-20T16:53:48.170083Z 0 [Note] /usr/sbin/mysqld: Shutdown complete

2018-03-20T16:54:17.865993Z 0 [Warning] Changed limits: max_open_files: 1024 (requested 5000)
2018-03-20T16:54:17.866081Z 0 [Warning] Changed limits: table_open_cache: 431 (requested 2000)
2018-03-20T16:54:18.030503Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-03-20T16:54:18.032406Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.21-0ubuntu0.16.04.1) starting as process 22733 ...
2018-03-20T16:54:18.038007Z 0 [Note] InnoDB: PUNCH HOLE support available
2018-03-20T16:54:18.038049Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2018-03-20T16:54:18.038059Z 0 [Note] InnoDB: Uses event mutexes
2018-03-20T16:54:18.038065Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2018-03-20T16:54:18.038072Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.8
2018-03-20T16:54:18.038078Z 0 [Note] InnoDB: Using Linux native AIO
2018-03-20T16:54:18.038379Z 0 [Note] InnoDB: Number of pools: 1
2018-03-20T16:54:18.038522Z 0 [Note] InnoDB: Using CPU crc32 instructions
2018-03-20T16:54:18.040492Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2018-03-20T16:54:18.050071Z 0 [Note] InnoDB: Completed initialization of buffer pool
2018-03-20T16:54:18.052516Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2018-03-20T16:54:18.070163Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
2018-03-20T16:54:18.072329Z 0 [Note] InnoDB: Log scan progressed past the checkpoint lsn 39365648
2018-03-20T16:54:18.072360Z 0 [Note] InnoDB: Doing recovery: scanned up to log sequence number 39365657
2018-03-20T16:54:18.072370Z 0 [Note] InnoDB: Database was not shutdown normally!
2018-03-20T16:54:18.072389Z 0 [Note] InnoDB: Starting crash recovery.
2018-03-20T16:54:18.239588Z 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1"
2018-03-20T16:54:18.239634Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2018-03-20T16:54:18.239698Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2018-03-20T16:54:18.268402Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2018-03-20T16:54:18.269730Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
2018-03-20T16:54:18.269753Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
2018-03-20T16:54:18.270515Z 0 [Note] InnoDB: Waiting for purge to start
2018-03-20T16:54:18.320775Z 0 [Note] InnoDB: 5.7.21 started; log sequence number 39365657
2018-03-20T16:54:18.321824Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
2018-03-20T16:54:18.322183Z 0 [Note] Plugin 'FEDERATED' is disabled.
2018-03-20T16:54:18.329836Z 0 [Warning] Failed to set up SSL because of the following SSL library error: SSL context is not usable without certificate and private key
2018-03-20T16:54:18.329865Z 0 [Note] Server hostname (bind-address): '127.0.0.1'; port: 3306
2018-03-20T16:54:18.329879Z 0 [Note]   - '127.0.0.1' resolves to '127.0.0.1';
2018-03-20T16:54:18.329914Z 0 [Note] Server socket created on IP: '127.0.0.1'.
2018-03-20T16:54:18.338620Z 0 [Note] InnoDB: Buffer pool(s) load completed at 180320 16:54:18
2018-03-20T16:54:18.359917Z 0 [Note] Event Scheduler: Loaded 0 events
2018-03-20T16:54:18.360114Z 0 [Note] /usr/sbin/mysqld: ready for connections.
Version: '5.7.21-0ubuntu0.16.04.1'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  (Ubuntu)
2018-03-20T16:54:18.870806Z 2 [Note] Access denied for user 'root'@'localhost' (using password: NO)


20th March, 2018

deansatch started a new conversation Mysql Goes Down • 4 months ago

Just noticed mysql went down for a few minutes. This is the log...any ideas what the cause could be?


2018-03-20T16:54:17.865993Z 0 [Warning] Changed limits: max_open_files: 1024 (requested 5000)
2018-03-20T16:54:17.866081Z 0 [Warning] Changed limits: table_open_cache: 431 (requested 2000)
2018-03-20T16:54:18.030503Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-03-20T16:54:18.032406Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.21-0ubuntu0.16.04.1) starting as process 22733 ...
2018-03-20T16:54:18.038007Z 0 [Note] InnoDB: PUNCH HOLE support available
2018-03-20T16:54:18.038049Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2018-03-20T16:54:18.038059Z 0 [Note] InnoDB: Uses event mutexes
2018-03-20T16:54:18.038065Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2018-03-20T16:54:18.038072Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.8
2018-03-20T16:54:18.038078Z 0 [Note] InnoDB: Using Linux native AIO
2018-03-20T16:54:18.038379Z 0 [Note] InnoDB: Number of pools: 1
2018-03-20T16:54:18.038522Z 0 [Note] InnoDB: Using CPU crc32 instructions
2018-03-20T16:54:18.040492Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2018-03-20T16:54:18.050071Z 0 [Note] InnoDB: Completed initialization of buffer pool
2018-03-20T16:54:18.052516Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2018-03-20T16:54:18.070163Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
2018-03-20T16:54:18.072329Z 0 [Note] InnoDB: Log scan progressed past the checkpoint lsn 39365648
2018-03-20T16:54:18.072360Z 0 [Note] InnoDB: Doing recovery: scanned up to log sequence number 39365657
2018-03-20T16:54:18.072370Z 0 [Note] InnoDB: Database was not shutdown normally!
2018-03-20T16:54:18.072389Z 0 [Note] InnoDB: Starting crash recovery.
2018-03-20T16:54:18.239588Z 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1"
2018-03-20T16:54:18.239634Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2018-03-20T16:54:18.239698Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2018-03-20T16:54:18.268402Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2018-03-20T16:54:18.269730Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
2018-03-20T16:54:18.269753Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
2018-03-20T16:54:18.270515Z 0 [Note] InnoDB: Waiting for purge to start
2018-03-20T16:54:18.320775Z 0 [Note] InnoDB: 5.7.21 started; log sequence number 39365657
2018-03-20T16:54:18.321824Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
2018-03-20T16:54:18.322183Z 0 [Note] Plugin 'FEDERATED' is disabled.
2018-03-20T16:54:18.329836Z 0 [Warning] Failed to set up SSL because of the following SSL library error: SSL context is not usable without certificate and private key
2018-03-20T16:54:18.329865Z 0 [Note] Server hostname (bind-address): '127.0.0.1'; port: 3306
2018-03-20T16:54:18.329879Z 0 [Note]   - '127.0.0.1' resolves to '127.0.0.1';
2018-03-20T16:54:18.329914Z 0 [Note] Server socket created on IP: '127.0.0.1'.
2018-03-20T16:54:18.338620Z 0 [Note] InnoDB: Buffer pool(s) load completed at 180320 16:54:18
2018-03-20T16:54:18.359917Z 0 [Note] Event Scheduler: Loaded 0 events
2018-03-20T16:54:18.360114Z 0 [Note] /usr/sbin/mysqld: ready for connections.
Version: '5.7.21-0ubuntu0.16.04.1'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  (Ubuntu)
2018-03-20T16:54:18.870806Z 2 [Note] Access denied for user 'root'@'localhost' (using password: NO)


19th March, 2018

deansatch left a reply on The "best" Method To Put Active Bootstrap Class On Li Element Depending On The Page • 4 months ago

How about something like...


@if (\Route::current()->getName() == 'yourRouteName') {
    <li class="active"><a href="{{route('yourRouteName')}}">Hello</a></li>
@else
    <li><a href="{{route('yourRouteName')}}">Hello</a></li>
@endif

15th March, 2018

deansatch left a reply on Empty Ajax Request & Invalid Argument Supplied For Foreach() Error • 4 months ago

Can we see the form html too?

deansatch left a reply on How To Get Max Bid Value Of Currently Logged User • 4 months ago

Snap! :)

deansatch left a reply on How To Get Max Bid Value Of Currently Logged User • 4 months ago


$highestbid = Bid::where('user_id', Auth::id())->max('bid'); // Highest bid of all users (works fine)

deansatch left a reply on Protected Registration • 4 months ago

You if you need the token in your registration processing either pass the token through to a new post route or include the token in your current blade action

form class="form-horizontal" method="POST" action="{{ route('register', ['registration_token'=>$token]) }}"

You'd have to pass the token to the view though for this:


 if (RegistrationToken::where('token', $token)) {
        return view('auth.register', compact('token'));
    }

deansatch left a reply on Property [id] Does Not Exist On This Collection Instance • 4 months ago

in your read() method dd($request) and see if that has an id. If it does make sure that ClassDetail actually has a row with course_id equal to that

deansatch left a reply on Protected Registration • 4 months ago

In your blade template you are calling your register route somewhere without passing a token

//you must have somewhere

{{ route('register') }} 


//But it would need to be

{{ route('register', ['registration_token'=>'123']) }} 


In reality though I expect that call should be removed completely as it is invite only.

14th March, 2018

deansatch left a reply on Update Relationship Attributes • 4 months ago

Should it not be $person->addresses()->firstWhere

deansatch left a reply on Large Collection Is Empty In HTML? • 4 months ago

What if you try and output it outside of the attribute? I’m no expert with vue but just wondering if since it worked once and now doesn’t, and take(2) works that maybe it is a recent row/item contianing invalid data

deansatch left a reply on Exception Thrown With Message "DateTime::__construct(): Failed To Parse Time String • 4 months ago

Looks like this might be the problem. Maybe for now just rollback your carbon version to the previous commit until php gets sorted

https://github.com/briannesbitt/Carbon/issues/1157

deansatch left a reply on Exception Thrown With Message "DateTime::__construct(): Failed To Parse Time String • 4 months ago

Does this happen on all routes? What if you just try and return a string instead of your query?

deansatch left a reply on Validate Numbered Array • 4 months ago

Oh I see. Give this a go


public function rules() 
  {

    $rules = [ 'exists' => [ 'areas' => ['id'] ]];

    foreach($this->request->get('area_id') as $k => $v){
        $rules['area_id.'.$k] = 'required';
    }

        return $rules;
  }

deansatch left a reply on Validate Numbered Array • 4 months ago

Actually, array format aside...your code doesn’t seem to be anything to do with validation. Could you show more code in context?

deansatch left a reply on Validate Numbered Array • 4 months ago

So if it’s js that creates the array you must name it when you post it (presumably Ajax)?

deansatch left a reply on Exception Thrown With Message "DateTime::__construct(): Failed To Parse Time String • 4 months ago

It’s this - date has some negative number appended:

"DateTime::__construct(): Failed to parse time string (2018-03-14 21:13:35.-325792) at position 24 (7): Unexpected character"

Let’s see the code

deansatch left a reply on Validate Numbered Array • 4 months ago

Surely your inputs have a name? How do you end up with that array?

deansatch left a reply on Laravel Pagination Get First Page • 4 months ago

In that case you can access everything from the toArray() method:


<li><a href="{{ $paginator->toArray()['first_page_url'] }}">First</a></li>

deansatch left a reply on Laravel Pagination Get First Page • 4 months ago

Like I said, why wouldn't the first page url not just be the plain route? No calculations needed


<li><a href="{{ route('yourRoute')  }}">First</a></li>

deansatch left a reply on Laravel - Follow A Collection Of Routes In Order • 4 months ago

I would store the step number the user is up to in the database and force a redirect to that step no matter which of the routes they try to access

deansatch left a reply on Laravel Pagination Get First Page • 4 months ago

You still could have used that to generate your page numbers, next and previous..then you would just need to add your own first and last page links either side

Wouldn't the first page link just be the plain route with no query string at all?

deansatch left a reply on Best Practice For Caching? • 4 months ago

Jeff does a great video on Russian doll caching that might worth a watch. That way you can cache the queries you want and still update the cache when you make a change

deansatch left a reply on Laravel Pagination Get First Page • 4 months ago

Is there a reason you are manually building this instead of just {{ $elements->links() }}

deansatch left a reply on Preferred Date, Choose 3, System Sorts Out Who Goes When • 4 months ago

Any ideas?

13th March, 2018

deansatch left a reply on Preferred Date, Choose 3, System Sorts Out Who Goes When • 4 months ago

Yeah I'm just trying to get my head around what logic/math would work out at what point an event is definitely oversubscribed

e.g. Lets say there are 5 events A,B,C,D&E. And 1 person limit on each

U= user

U1 chooses A B C
U2 chooses A B C
U3 chooses A B D

// at this point one is full but I don't know which one as it could be A or B

U4 chooses A B D

// Now we can definitely say A-D are full

// But if U4 did A D E instead still only one unknown is full

U4 chooses A D E
U5 chooses A B D // this now becomes impossible as all 3 are full already


deansatch started a new conversation Preferred Date, Choose 3, System Sorts Out Who Goes When • 4 months ago

Basically I am wanting to build something where there are events available each with 10 places available. Users can book a place but must choose their 3 most preferred dates. Then when registration closes, the system will work out who goes on what date to ensure there are no more than 10 per event.

Any ideas what the best route to take would be?

One big hurdle I can see is how could the system know if there are going to be too many people on one event. If for example 40 people happen to choose the same 3 there will be 10 people can't go any date.

12th March, 2018

deansatch left a reply on Disable Routing For File • 4 months ago

Glad it worked...this should actually be a better approach than using htaccess as it will work on apache and nginx. Also htaccess would have to search every file on every request just to check for the existence of your calendarserver.php

deansatch left a reply on Disable Routing For File • 4 months ago

are you sure you are on apache server and not nginx?

11th March, 2018

deansatch left a reply on Help On Printing Data. • 4 months ago

use a print stylesheet and a button with this on click: window.print();

deansatch left a reply on Why Isn't 'laravel New' Generating An Application Key Automatically? • 4 months ago

try updating composer

9th March, 2018

deansatch left a reply on Multiple Forms • 4 months ago

Not entirely sure what your form contains or what each section relies on but I would probably go for the single form split with js hide/show next section based on chosen options and handle the whole submission in one go.

deansatch left a reply on Best Way To Separate My Code • 4 months ago

Thanks Martin - I expect I should be using jobs a lot more for things like generateInvoice instead of having those as methods in my model?

So for a user placing an order would it be reasonable to do something like this:


$name = $request->input('name');
$data = $request->except('name');

$account = CreateAccount::dispatch($name, $data);
$order = CreateOrder::dispatch($product, $account);

deansatch left a reply on Best Way To Separate My Code • 4 months ago

ok, but what about the fact that only some accounts will have a user?

It is more of a CRM system where accounts can be created (by admin) for companies...this is for project management, billing, notes etc... but some accounts will be created via an order on the public facing site. Those accounts will need that visitor who placed the order to become a user associated with that account so they can log in and access their order.

Or an admin might at one point have an account that has no user but needs to create a new user and assign him to that account

deansatch left a reply on Best Way To Separate My Code • 4 months ago

I'm building something where a customer is either a 'company' or an 'individual'. A 'user' is someone that has a login and might own a company(customer) but could also own a second company, or have orders as an 'individual' too.

A user without a 'customer' related to it might only be able to login/out and update password, set privacy/mailing options etc...

So as an admin I might add a customer, they don't need a login...they are just for the admin's own project management purposes. Then I might add another customer but assign a user so they can log in and manage their online products.

deansatch started a new conversation Best Way To Separate My Code • 4 months ago

Lets say I have a front end system and a backend system. On the frontend a visitor can place an order and will be automatically registered as a 'user', they will also be a 'customer' with an 'order'. On the backend an admin would be able to add a 'customer', optionally then add a user for that customer, and at any time add an 'order'

For the backend it is quite straight forward that I can create a user or a customer and link them together at any point with a pivot table. Adding an order of course is also straight forward. But for the front end forcing all 3 to happen I'd need to call each of those functions.

What would be the best way to organise these 3 'tasks'? Are they Events? Jobs? Or just simple public methods that I should call sequentially in a transaction in my controllers?

Basically I'm thinking it would be nice to be able to (from anywhere) createUser()...or createCustomer() or - createUser() with createCustomer() instead of createUser(), createCustomer(), linkUserAndCustomer()

Apologies for not using actual code, I'm looking more for the best practice as opposed to code examples.

8th March, 2018

deansatch left a reply on Multiple Forms • 4 months ago

Its really up to you (and the form content) how the forms work i.e. a single form with js show/hide... or multiple forms storing each object in the session then processing on final submit. The transaction just makes sure that everything that is required will succeed otherwise it will rollback.

deansatch left a reply on How To Count Relationship And Add Field To Json Data ? • 4 months ago


 $json = Category::withCount('countProducts')->with('countProducts')->get();


deansatch left a reply on Multiple Forms • 4 months ago

deansatch left a reply on Text Is Superimposed In Browser • 4 months ago

Ok, I don't know why it works in your other setup...something must be different somewhere. However...to fix it on that just add width:100%!important:


.tp-parallax-wrap, .tp-loop-wrap {
   width:100% !important;
}

7th March, 2018

deansatch left a reply on Text Is Superimposed In Browser • 4 months ago

could you post a link to the page that doesn't work?

Edit Your Profile
Update

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