tykus

Full Stack PHP Developer at Linked FInance

Experience

661,200

1010 Best Reply Awards

  • Member Since 4 Years Ago
  • 1328 Lessons Completed
  • 2 Favorites

23rd September, 2018

tykus left a reply on Auto Import Namespaces • 14 hours ago

tykus left a reply on How To Define Parent And Child Component In Vue.js • 23 hours ago

Using <Home> directly inside your <App> template will establish the parent-child relationship.

If you think you might use your Home component in multiple other components, you can globally register it:

Vue.component('Home', require('./path/to/Home'));

Otherwise, import it in your App.vue script:

import Home from './path/to/Home'
export default {
    // ...
}
``

22nd September, 2018

tykus left a reply on Find Current Model ID (has Many Relationship) • 1 day ago

You are not passing the $book instance to the view:

public function create(Book $book)
{
    return view('/reviews/create', compact($book));
}

tykus left a reply on Checkout With Credit Card Validation In Laravel • 1 day ago

I need to build my own custom server/client side credit card validation

No. No you do not.

21st September, 2018

tykus left a reply on Auth.jwt Middleware Doesn't Return Json Object When E.g No Token Is Provided • 2 days ago

In app/Exception/Handler.php you can check if the exception is an instance of UnauthorizedHttpException and return your own response:

// app/Exceptions/Handler.php

if ($exception instanceof Symfony/...../UnauthorizedHttpException) {
    return response()->json([
        'error' => $exception->getMessage()
    ], $exception->getStatusCode());
}

tykus left a reply on Submit Post Route Returning "page Can’t Be Found" • 2 days ago

Have you specified the method attribute on the form?

<form method="post" action="{{route('quotations.send-quote')}}">

tykus left a reply on Live Server Variable = Int Not Working • 2 days ago

Definitely check if the MySQL Native Driver is available locally, but not on production.

tykus left a reply on Checking Object Value • 2 days ago

$data is an empty string, yet you are using it as an object in the view!

<option value="active" <?php if($data->status != NULL && $data->status == 'active'){ echo "selected"; } ?>>active</option>

tykus left a reply on Live Server Variable = Int Not Working • 2 days ago

In that case, you will need to check why you are getting a string back from the database where you were expecting an int. There is a MySQL Native Driver php-mysqlnd` which may be missing on your production server.

Or relax your equality checking to value, and not type by using a == in place of ===.

tykus left a reply on Live Server Variable = Int Not Working • 2 days ago

If approved is a tinyint column (representing a boolean), I would simply

@if($authGalleries->approved) YES @else NO @endif

Whether it comes back as a string or int from the database, you will get the correct outcome when it is evaluated as a boolean.

tykus left a reply on Live Server Variable = Int Not Working • 2 days ago

Where is the value of $var coming from; a database query? You may need to cast the attribute in your model (if this is Eloquent related).

tykus left a reply on Checking Object Value • 2 days ago

The $data that you initialize is not the same as the $data in either collection method, so why are you initializing that variable? What is it being used for in the view?

Also, your $billers and $products could by a pluck queries rather than getting all columns unnecessarily:

$billers = BillerModel::pluck('biller_name', 'biller_id');
$products = ProductModel::pluck('Productdesc', 'Productdid');

For me, you controller method could be:

public function createPromoDetail()
{
    $billers = BillerModel::pluck('biller_name', 'biller_id');
    $products = ProductModel::pluck('Productdesc', 'Productdid');

    return view('pages.promo.pdetail_create', compact('data', 'billers', 'products')) ;
}

20th September, 2018

tykus left a reply on Call Data With Ajax • 3 days ago

Your then callback is not valid... you are using object syntax directly in the function... so it could not be working in another view.

tykus left a reply on Call Data With Ajax • 3 days ago

Using Vue Resource??

this.$http.post('/auth/recover', {  email: app.email }).then(
    function () {
        app.success = true
    },
    function (resp) {
        app.error = true;
        app.errors = resp.response.data.errors;
    }
});

I don't see a CSRF token, make sure you are passing one if the route is in the web middleware group

tykus left a reply on Form Request: The Request User In Null • 3 days ago

No worries, please mark my answer above as the best reply to help others.

tykus left a reply on Form Request: The Request User In Null • 3 days ago

Is that endpoint in the auth:api middleware group? How are you authenticating users; Passport/JWT?

tykus left a reply on Form Request: The Request User In Null • 3 days ago

This is an API endpoint?

tykus left a reply on Real Time Web Application • 3 days ago

Yes, they work together. The Brodcasting Laravel docs are pretty good, but this series should also give you a good primer on the subject.

tykus left a reply on Very Slow PHPUnit Tests Using PHP7.2 Or PHP7.1. • 3 days ago

I am also experiencing this same issue at the moment.

My setup is Laravel 5.6 / PHP 7.2. I mostly have feature tests which use a MySQL database and the DatabaseTransactions trait. The tests will individually run quite quickly, but immediately there are more than ~25 examples, that ~25th test will stall for about 30 seconds and CPU usage for the process jumps to 100%.

I have tried (i) different versions and combinations of PHP and PHPUnit (ii) disabling Xdebug (iii) running within a Homestead and directly on my Mac host (iv) running on a colleagues machine (v) forced the most basic test into that position, e.g. assertTrue(true).

Every attempt has the same result; still trying to find a solution...

tykus left a reply on Separating API Controllers And Web Controllers • 4 days ago

You are essentially branching inside the same controller method depending on whether the request has the Accept header set to application/json. This can be an effective solution if the number of routes that might have this behaviour in your app is small, otherwise, it will quickly become tedious!

tykus left a reply on Real Time Web Application • 4 days ago

19th September, 2018

tykus left a reply on Creating Default Object From Empty Value: Laravel 5.6 • 4 days ago

This has resulted in null:

$user = User::find($request->id);

You need to be a little bit more defensive, especially when the id is coming from teh request.

tykus left a reply on Separating API Controllers And Web Controllers • 4 days ago

As @topvillas says, or either of (i) return a JSON response if your request wantsJson() or (ii) return the JSON as data passed to the Blade template.

tykus left a reply on Refering To Public Path • 5 days ago

Why would you ever need a fully qualified path in an <img> tag?

tykus left a reply on Save Model Association • 5 days ago

You have a mix of JSON and PHP array syntax there; are you trying to save the JSON as a string in your database? Since it is just text, there is no issue saving a JSON string; however, if you want to parse the JSON and extract the data into separate columns, then you should json_decode() first.

tykus left a reply on Refering To Public Path • 5 days ago

Add a leading forward slash so that the path is relative to public rather than your current URL:

<img src="/images/icon-check.png">

18th September, 2018

tykus left a reply on Relationship Issues • 5 days ago

You know the result of this User::find(Auth::user()->id) is this Auth::user() or auth()->user(), right?

tykus left a reply on Add Two Foreign Key To Existing Table • 5 days ago

Do you have the uri_id and job_id columns already on the siscontents table? Are there records in either of those columns that cannot be matched to the related tables (e.g. orphaned id's that cannot be matched to records on the job_urls and jobs tables respectively)?

tykus left a reply on Order Of Routes • 6 days ago

If you have the create route before the show route, then the route wildcard will see create as a parameter because you are matching the pattern blog/{id} - Laravel has no way to know that the id part should be a number unless you provide a regular expression pattern for that wildcard:

Route::get('/blog/{post}', '[email protected]')->where('id', '[0-9]+');

Now the show route will only be matched when a number is in the second URI segment, and create will not be mismatched

17th September, 2018

tykus left a reply on I Never Setup A Profile Pic On Laracast But I Have One How? • 6 days ago

Your registered email is also registered with Gravatar?

tykus left a reply on Issue With File Download For An API • 6 days ago

$get = Transaction->where('salesId', $request->get('salesId'))->firstOrFail();

tykus left a reply on Filter An Array, Using An Array • 6 days ago

If both checkboxes are selected, then I suppose we have the filter backwards:

return users.filter(user => this.gender.includes(user.gender))

tykus left a reply on Filter An Array, Using An Array • 6 days ago

Is it possible that one of the users has null as their gender?

tykus left a reply on Filter An Array, Using An Array • 6 days ago

return users.filter(user => user.gender.includes(this.gender))

tykus left a reply on Custom Error Message • 6 days ago

Ok, so you need to import the full NotFoundHttpException namespace, otherwise it will be looking for App\Exceptions\NotFoundHttpException and your exception is not of that type. Add this to the to of Handler.php

use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;

tykus left a reply on Update Inputs With Same Name Repeated • 6 days ago

Can you dd($keys) and show us?

tykus left a reply on Update Inputs With Same Name Repeated • 6 days ago

Can you show us your full controller method as it is right now?

tykus left a reply on Can Not Add Row In Table When Running Artisan Command • 6 days ago

No chance to help you if you do not share your code and/or error message(s)

tykus left a reply on Update Inputs With Same Name Repeated • 6 days ago

You should findOrFail - otherwise your query cannull which you are then attempting to assign properties/call methods on.

tykus left a reply on Update Inputs With Same Name Repeated • 6 days ago

In @Yorki 's example, change the query:

 Device::findOrFail($device['device_id'])->update($device);

tykus left a reply on Custom Error Message • 6 days ago

Did you properly import the NotFoundHttpException namespace? Maybe check the actual exception to make sure you are catching the correct exception class.

public function render($request, Exception $exception)
{
    dd($exception); // check the actual exception class
           
    if ($exception instanceof NotFoundHttpException) {
        return $this->errorResponse('The specified URL cannot be found', 403);
    }

    return $this::render($request, $exception);
}

Also, 403 is not an appropriate response code for a Not Found exception.

tykus left a reply on Update Inputs With Same Name Repeated • 6 days ago

You must've forgotten to put the device_id key in quotation marks.

tykus left a reply on Saving Array Laravel • 6 days ago

foreach ($devices[‘device_id’] as $key => $value) {
    $id = $devices[‘device_id’][$key];
    $name= $devices[‘device_name’][$key];
    $type = $devices[‘device_type’][$key];
    $modul = $devices[‘device_modul’][$key];

    // do your update
}

tykus left a reply on Update Inputs With Same Name Repeated • 6 days ago

Loop over the array:

foreach ($devices[‘device_id’] as $key => $value) {
    $id = $devices[‘device_id’][$key];
    $name= $devices[‘device_name’][$key];
    $type = $devices[‘device_type’][$key];
    $modul = $devices[‘device_modul’][$key];

    // do your update
}

tykus left a reply on Doubt In Table Relationship In Laravel? • 1 week ago

You could also use a polymorphic many to many relationship which would require only one intermediate table

tykus left a reply on Validation Under Array Validation • 1 week ago

5.1 !?! Ok... in that case

 foreach($request->get('email') as $key => $val)
  {
    $rules['email.'.$key] = 'required|max:10';
  }

tykus left a reply on Validation Under Array Validation • 1 week ago

$this->validate($request, [
    'email.*' => 'required|email'
]);

tykus left a reply on Share Value Between Function In Same Controller • 1 week ago

Assuming your query is correct:

public function searchProduct ()
{
    return Product::find(\Request::get('barcode'));
}

tykus left a reply on Share Value Between Function In Same Controller • 1 week ago

Return something from searchProduct if you intend to assign a variable wherever it is consumed

Edit Your Profile
Update

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