movepixels

movepixels

Member Since 2 Years Ago

Experience Points
5,380
Total
Experience

4,620 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed
2
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start-engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist Created with Sketch.

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

Level 2
5,380 XP
Oct
10
1 week ago
Activity icon

Replied to Custom Validation

Thanks,

I will give it a try and let you know how it goes.

Sorry forget to include current rules as example. Here they are as of now before trying out your suggestion:

'start_date' => 'bail|required|date|date_format:Y-m-d|after:yesterday|after_or_equal:today',
'end_date' => 'bail|required|date|date_format:Y-m-d|after_or_equal:start_date'
Activity icon

Started a new Conversation Custom Validation

I have a events table and all the validation rules set in FormRequest so all is good. Specific question will regard to start_date and end_date field validation.

When a user creates a new Event the start_date must be today or in the future (you can not start an event with a back-dated date) And end_date must be after or equal to start_date. So that all work fine as it should

Question is when a user goes to update the event that has already started?

Scenario is the event person says nobody calling because we put wrong phone number in the event details. Go to edit that event keeping same original dates but only updating other info, validation says sorry date must be today or future...

So I need to say if dates not changed do not re-validate them but if they do change then they must adhere to standard rules.

Any ideas?

Thanks all

Oct
09
1 week ago
Activity icon

Replied to Polymorphic Help

That looks like exactly what I would expect from the docs.

It was the 'item_type' => get_class($model), which had me hung up.

Excellent response I must say!

Only question is I use CHAR(36) UUID for all ID's

So simply change your table fields to CHAR(36)

$table->bigIncrements('id');
$table->unsignedBigInteger('order_id');

would be of no issue?

Thanks again for the reply. Will get working on it shortly and reply results.

Oct
05
2 weeks ago
Activity icon

Replied to Polymorphic Help

$upgrade is an actual object of an "upgrade" model.

I have my Order saved at this point, now I want to add items to it. But the items needed to be saved with the poly model and id so they can reference back to get details when needed later on. Since an invoice saying Model/Upgrade and id 5 will mean nothing to the user :)

Activity icon

Started a new Conversation Polymorphic Help

Never did this before and reading the docs is not working.

Idea is I want to have a Model OrderItem with table "order_items" that will hold all the items for an Invoice. Since the items can come from Subscription, Product, Upgrade models.

So to test out I have OrderItem.php:

public function line_item()
  {
    return $this->morphTo();
  }

Upgrade.php:

public function OrderItem()
  {
    return $this->morphMany('App\Models\Billing\Orders\OrderItem', 'line_item');
  }

But when trying to add an item to a new order like so just to test:

$newOrder->OrderItems()->save($upgrade);

I get errors. Its trying tto update the Ugrades table.

Unknown column 'order_id' in 'field list' (SQL: update `upgrades` set `updated_at` = 2019-10-05 20:25:29, `order_id` = 0 where `id` = 1)

Why is it trying to even touch Upgrade table?

Anyone once know where I am going wrong.

Activity icon

Started a new Conversation Package Development Help

Not so much an actual Package in regards to a Laravel Package, but as a set up Models / Controllers.

I was wonding what do I need in terms of Orders / Invoices / Products / Subscription.

Basically every User has 1 Subscription, but a Subscription can have many Upgrades. So I can't figure out all this Product / Order / Invoice and how they all relate to each other.

People say Order is different the Invoice yet both look exactly the same the same to me. A user can go thru the site picking what they want which creates an Order. When paid mark the Order "Paid"? Is that not the same as an Invoice? Order has many Items / Invoice hasMany Items. Is an Item a product_id? Is a subscription_id supposed to be a product and referenced by product_id? Because a Subscription has loads of other fields that simply do not apply to a "standard" product.

Casiher is not an option as this is not going to be a Braintree / Strip integration.

Just hoping someone could provide some example / reference / ideas how something like this should be structured.

Thanks!

Sep
28
3 weeks ago
Activity icon

Replied to Laravel Authorize() Not Doing Anything

I just stuck with my original setup and when I use authorize() in specific requests I needed to add in:

public function failedAuthorization() {
    parent::failedAuthorization();
}

And just throw my own Exception for this situation to throw a 403 error

I found a comment somewhere on a forum where they say what I was getting, error thrown yet controller keeps going.

"I noticed if you throw AuthorizationException($message) in a policy using Laravel's exception it jumps you out of the policy, but continues execution in the controller, "

Activity icon

Replied to Delete All Over Set Amount

Might clean it up some but quick fix using your idea.

foreach($used as $k => $v) {

  $data = [
    'active' => $k < $allowed ? 1 : 0,
    'sort' => $k + 1
  ];

  try {
    $profile->AreaProfile()->updateExistingPivot(['area_id' => $v], $data, false);
  } catch(\Exception $e) {
    DB::rollback();
    throw new $e;
  }
}
Activity icon

Replied to Delete All Over Set Amount

Excellent thoughts on soft deletes! Makes complete sense, thanks.

I will try your soft_deletes and active field.

I have to working by original idea of getting array of ids, breaking it after x number then delete those in the over array. But the idea of soft_deletes is so simple I guess thats why it never crossed my mind :)

Thanks for the insight.

Sep
27
3 weeks ago
Activity icon

Started a new Conversation Delete All Over Set Amount

Is there a quick way to delete all records over a specific number?

Scenario a user has a "plan" currently allowing 25 records, when downgrading to a lower plan they are only allowed 15 records. Is there a easy way to get all records, if over 15 delete the rest?

Or just get all records toArray with only the id's, create an array of records over 15 and just pass that array of the over id's to delete?

Activity icon

Replied to Laravel Authorize() Not Doing Anything

This is the BaseRequest that my requests now extend off of, with everything but failedAuthorization removed:

<?php 

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

use Illuminate\Contracts\Validation\Validator;
use Illuminate\Http\Exceptions\HttpResponseException;


abstract class BaseRequest extends FormRequest {

  public function failedAuthorization() {

    \Log::info('failedAuthorization'); // get logged if child request authorize() returns false
      
      $response = array(
        'message' => array(
          'title' => 'Security Alert',
          'text' => 'You have attempted to perform or access something you do not have permission for.')
        );
        
      return response()->json($response, 403);

  }
}
Activity icon

Replied to Laravel Authorize() Not Doing Anything

Ok I did just that.

Now called BaseRequest.php

class UpdateBioRequest extends BaseRequest
{
  public function authorize()
  {
    \Log::info('DD BELOW');
    dd('here');
    // return false;
  }
}

Same result, Log shows: [2019-09-27 15:58:20] local.INFO: DD BELOW and nothing else

Dev tools shows same 200 OK, but no response.

If I change public function authorize() to simply return false, the log shows same as earlier with [2019-09-27 16:01:52] local.INFO: failedAuthorization as its hitting that method in BaseRequest but even though its set to return a 403 the UpdateBioRequest still continues on with the request.

Activity icon

Replied to Laravel Authorize() Not Doing Anything

Oddly enough this semi-works

class UpdateBioRequest extends Request
{


  public function authorize()
  {
    return false;
  }
}

Request.php has the callback when authorize() fails failedAuthorization

public function failedAuthorization() {

    \Log::info('failedAuthorization');

    $response = array(
        'message' => array(
            'title' => 'Security Alert',
            'text' => 'You have attempted to perform or access something you do not have permission for.')
    );

    return response()->json($response, 403);

}

Log shows [2019-09-27 11:12:54] local.INFO: failedAuthorization But the request continues to process the request as normal. No 403, no json response.

So still hoping for some ideas / suggestions.

Thanks

Activity icon

Replied to Laravel Authorize() Not Doing Anything

Using dd('here');

class UpdateBioRequest extends Request //Request extends FormRequest
{
  public function authorize()
  {
    \Log::info('DD BELOW');
    dd('here');

  }
...
}

Theses are all AJAX requests. Results in: [2019-09-27 11:05:43] local.INFO: DD BELOW

And thats it. Dev tools shows 200 OK, but no response or anything on submit.

Activity icon

Replied to Laravel Authorize() Not Doing Anything

What I have is a base app\Http\Request\request.php file which has the:

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;


abstract class Request extends FormRequest {
...
}

Then all my other generated "FormRequest" files extend off the base request.php from above.

Example:

<?php 

namespace App\Http\Requests\Profiles;

use App\Http\Requests\Request;
use App\Http\Requests\Response;

use Illuminate\Support\Facades\Auth;


class UpdateBioRequest extends Request{
....
}

But it does not like the 'extends Request' as from what I can guess is not running / catching the authorize() as intended.

I have shared functions / methods in my Request.php that I use in quite a few other FormRequest files so thats the reason for this set up.

Example:

'name' => parent::_webSafeCharacters(parent::_stripSpaces($this->name)),

But open to better ideas.

If I use extends FormRequest in the "FormRequest" file it works as expected, but not if I extend off the Request.php which extends off FormRequest.

If that make sense.

Sep
26
3 weeks ago
Activity icon

Started a new Conversation Laravel Authorize() Not Doing Anything

I have a form request and wanted to make it fail so I did this:

public function authorize()
{
    // var_dump(\Auth::user()->id); // to be sure its hitting and confirmed. Yep I see the id so its getting here
    return \Auth::user()->id == 456wer456erw; // no such so fail
}

And simple

public function authorize()
{

    return false;
}

But still the FormRequest continues on as per usual. No 403 error is thrown

Any ideas? Seems pretty straight forward for it not to work.

Sep
21
1 month ago
Activity icon

Replied to Random Undefined Index: Driver Error

Still to no resolve.

Left this part alone as I moved onto front-end stuff but now return to solve this. All is where I last left off, except changed the cache driver to file.

Right off the bat get the same error.

Now this happens on the dashboard page where there are multiple http requests to the laravel api so about 10 individual requests. Sometimes none fail, other times 1 or 2 will fail, and when they do fail that's the random part. Its never the same ones failing. request to gets users subscription info be fine this request, leave page go back and this time it fails. Thats the random part since how would I even track that down since nothing is changing. Simply navigation back and forth to and from the dashboard.

Massive stack but still no clue how to trace this back.

"message": "Undefined index: driver",
    "exception": "ErrorException",
    "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Database\DatabaseManager.php",
    "line": 115,
    "trace": [
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Database\DatabaseManager.php",
            "line": 115,
            "function": "handleError",
            "class": "Illuminate\Foundation\Bootstrap\HandleExceptions",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Database\DatabaseManager.php",
            "line": 74,
            "function": "makeConnection",
            "class": "Illuminate\Database\DatabaseManager",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.php",
            "line": 1239,
            "function": "connection",
            "class": "Illuminate\Database\DatabaseManager",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.php",
            "line": 1205,
            "function": "resolveConnection",
            "class": "Illuminate\Database\Eloquent\Model",
            "type": "::"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.php",
            "line": 1035,
            "function": "getConnection",
            "class": "Illuminate\Database\Eloquent\Model",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.php",
            "line": 952,
            "function": "newBaseQueryBuilder",
            "class": "Illuminate\Database\Eloquent\Model",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.php",
            "line": 988,
            "function": "newModelQuery",
            "class": "Illuminate\Database\Eloquent\Model",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.php",
            "line": 941,
            "function": "newQueryWithoutScopes",
            "class": "Illuminate\Database\Eloquent\Model",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.php",
            "line": 1608,
            "function": "newQuery",
            "class": "Illuminate\Database\Eloquent\Model",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.php",
            "line": 1469,
            "function": "__call",
            "class": "Illuminate\Database\Eloquent\Model",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Routing\ImplicitRouteBinding.php",
            "line": 35,
            "function": "resolveRouteBinding",
            "class": "Illuminate\Database\Eloquent\Model",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Routing\Router.php",
            "line": 785,
            "function": "resolveForRoute",
            "class": "Illuminate\Routing\ImplicitRouteBinding",
            "type": "::"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Routing\Middleware\SubstituteBindings.php",
            "line": 39,
            "function": "substituteImplicitBindings",
            "class": "Illuminate\Routing\Router",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php",
            "line": 151,
            "function": "handle",
            "class": "Illuminate\Routing\Middleware\SubstituteBindings",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php",
            "line": 53,
            "function": "Illuminate\Pipeline\{closure}",
            "class": "Illuminate\Pipeline\Pipeline",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Routing\Middleware\ThrottleRequests.php",
            "line": 58,
            "function": "Illuminate\Routing\{closure}",
            "class": "Illuminate\Routing\Pipeline",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php",
            "line": 151,
            "function": "handle",
            "class": "Illuminate\Routing\Middleware\ThrottleRequests",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php",
            "line": 53,
            "function": "Illuminate\Pipeline\{closure}",
            "class": "Illuminate\Pipeline\Pipeline",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php",
            "line": 104,
            "function": "Illuminate\Routing\{closure}",
            "class": "Illuminate\Routing\Pipeline",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Routing\Router.php",
            "line": 684,
            "function": "then",
            "class": "Illuminate\Pipeline\Pipeline",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Routing\Router.php",
            "line": 659,
            "function": "runRouteWithinStack",
            "class": "Illuminate\Routing\Router",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Routing\Router.php",
            "line": 625,
            "function": "runRoute",
            "class": "Illuminate\Routing\Router",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Routing\Router.php",
            "line": 614,
            "function": "dispatchToRoute",
            "class": "Illuminate\Routing\Router",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php",
            "line": 176,
            "function": "dispatch",
            "class": "Illuminate\Routing\Router",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php",
            "line": 30,
            "function": "Illuminate\Foundation\Http\{closure}",
            "class": "Illuminate\Foundation\Http\Kernel",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\barryvdh\laravel-cors\src\HandleCors.php",
            "line": 58,
            "function": "Illuminate\Routing\{closure}",
            "class": "Illuminate\Routing\Pipeline",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php",
            "line": 151,
            "function": "handle",
            "class": "Barryvdh\Cors\HandleCors",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php",
            "line": 53,
            "function": "Illuminate\Pipeline\{closure}",
            "class": "Illuminate\Pipeline\Pipeline",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\TransformsRequest.php",
            "line": 31,
            "function": "Illuminate\Routing\{closure}",
            "class": "Illuminate\Routing\Pipeline",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php",
            "line": 151,
            "function": "handle",
            "class": "Illuminate\Foundation\Http\Middleware\TransformsRequest",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php",
            "line": 53,
            "function": "Illuminate\Pipeline\{closure}",
            "class": "Illuminate\Pipeline\Pipeline",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\TransformsRequest.php",
            "line": 31,
            "function": "Illuminate\Routing\{closure}",
            "class": "Illuminate\Routing\Pipeline",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php",
            "line": 151,
            "function": "handle",
            "class": "Illuminate\Foundation\Http\Middleware\TransformsRequest",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php",
            "line": 53,
            "function": "Illuminate\Pipeline\{closure}",
            "class": "Illuminate\Pipeline\Pipeline",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode.php",
            "line": 62,
            "function": "Illuminate\Routing\{closure}",
            "class": "Illuminate\Routing\Pipeline",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php",
            "line": 151,
            "function": "handle",
            "class": "Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php",
            "line": 53,
            "function": "Illuminate\Pipeline\{closure}",
            "class": "Illuminate\Pipeline\Pipeline",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php",
            "line": 104,
            "function": "Illuminate\Routing\{closure}",
            "class": "Illuminate\Routing\Pipeline",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php",
            "line": 151,
            "function": "then",
            "class": "Illuminate\Pipeline\Pipeline",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php",
            "line": 116,
            "function": "sendRequestThroughRouter",
            "class": "Illuminate\Foundation\Http\Kernel",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\public\index.php",
            "line": 53,
            "function": "handle",
            "class": "Illuminate\Foundation\Http\Kernel",
            "type": "->"
        }
    ]
}

Thanks guys, really hope someone can help me solve this.

Aug
09
2 months ago
Activity icon

Replied to Cors Headers Help

Postman is using live url path to test on the remote production server.

I killed my localhost server so nothing is running to cause conflict and end up using my local set up.

I added a dummy key/value on the server login response. So when I send Postman login request I get that server => remote key value so I know I am logging into the live server.

I want to prevent with cors any API access not made from specific urls.

I thought using cors would prevent just anyone from sending requests not from any of the AllowedOrigins array to say sorry your out of luck!

Am I not understanding something? Or the setup is wrong?

I went to an online webtool api tester and sent same request and it still lets anyone make requests.

Activity icon

Started a new Conversation Cors Headers Help

I am using BarryVDH / Laravel-cors package but can not get the result I am trying to achieve.

in config/cors.php i have this snip

'allowedOrigins' => [
      'http://www.z***e.ca',
      'http://www.z***e.ch',
      'http://www.z***e.com',
    ],

Hoping to allow only those origin points to access / make request to the API

But on my machine using Postman I can still attempt a login with success.

routes/api.php snip:

Route::group(['middleware' => ['cors']], function () {
    Route::post('login', 'Auth\[email protected]')->name('auth.login');
});

app/Http/Kernel snip:

protected $middleware = [
        ...
        \Barryvdh\Cors\HandleCors::class,
];

    /**
     * The application's route middleware groups.
     *
     * @var array
     */
    protected $middlewareGroups = [
        'api' => [
            'throttle:60,1',
            'bindings',
            'cors',
        ],
    ];

protected $routeMiddleware = [
        .....
        'cors' => \Barryvdh\Cors\HandleCors::class,
    ];

But still seems anyone can access the backend API.

Anyone see where I went wrong?

Thanks,

Dave

Aug
08
2 months ago
Activity icon

Replied to Odd Route Issue

Fool!

I had

[email protected]

and it should have been

[email protected]

Human error :)

Activity icon

Started a new Conversation Odd Route Issue

I have middlware that checks the {profile} in the route to determine if user can access this request.

It works on 99% of the site / routes except this one.

... // this route group has a {profile} prefix and works with every other resource and there over 50 of them so it works 
Route::apiResource('ages', 'Dashboard\Profile\AgesController')->only(['index', 'store'])
      ->names([
        'index' => 'ages.index', // index gets the data no problem
        'store' => 'ages.store' // middleware says Call to a member function User() on string at....
    ]);

Yet if I use it like so there are no errors

Route::get('{profile}/ages' , 'Dashboard\Profile\[email protected]')->name('ages.index');
Route::post('{profile}/ages', 'Dashboard\Profile\[email protected]')->name('ages.store');

I cant see why this single post is not working if put thru apiResource way?

Looked at it 100 times and I dont see a typo...any ideas?

Activity icon

Replied to Controller Not Found Error

You got it!

I forgot all about it there.

Thanks, appreciated!

Activity icon

Started a new Conversation Controller Not Found Error

When I run php artisan route:list I get error:

Class App\Http\Controllers\Auth\RegisterController does not exist

I am not using the default Auth so I know I do not have it, but not sure where / why its looking for it.

Any ideas? Using Laravel 5.7

Thanks

Dave

Aug
07
2 months ago
Activity icon

Replied to Define Relationship Help

Also tried / trying this:

$test = Answer::whereHas('Question', function($query) use ($profile) {
        return $query->whereHas('Profile', function($query) use ($profile) {
          return $query->with('Travel')->where('profile_id', $profile->id);
        });
      })->orderBy('created_at', 'desc')->get();

    return response()->json($test);

Returns empty array

Activity icon

Replied to Define Relationship Help

I was thinking something similar to this set using hasManyThrough?

https://medium.com/@DarkGhostHunter/laravel-has-many-through-pivot-elegantly-958dd096db

Not sure if that would work.

Activity icon

Replied to Define Relationship Help

I got Undefined relationship error doing your suggestion.

I will try again to explain better.

Profile Model:

/************************************************************
  * PIVOT TABLE FOR PROFILE_TRAVEL
  * ***********************************************************
  * @access public
  * @return array
  *
  ************************************************************/ 
  public function Travel()
  {
    return $this->belongsToMany('App\Models\Answer', 'profile_travel', 'profile_id', 'answer_id')
      ->withTimestamps();
  }

So this holds all the answers they have selected from a form as it should.

For this particular situation when displaying the Users->profile->travel right now it simply shows the records they have saved from the pivot table [1=> Canada, 2 => USA]. Normally that would be fine.

But I need to also show on the page all that were not selected.

So i need a way for Travel to also get all the possible Answer records for Question where id = 5

When I did something like:

'travel' => function($query){
          $query->with(['Question' => function($query){
            $query->with(['Answer']);
          }]);
        }

each answer included the full array of possible questions, but that's repeated for every pivot table answer, and if nothing selected then zero results of possible answers.

I am trying to attach / load a unrelated model as if it was related I guess if you think of it that way.

So in the end travel response would look like / have something like this

travel = [
   answers [.... all possible answers to question 5],
   [all the answers from the pivot table if any or and empty array if none ]
]

Travel Model:

public function Question()
  {
    return $this->belongsTo('App\Models\Question');
  }

Call to undefined relationship [question] on model [App\Models\Answer]

Aug
06
2 months ago
Activity icon

Replied to Return An Empty Resource

No clue why do that. The whole point of the API Resource is to return a JSON object. This dashboard request has hundreds objects to build the dashboard so to me its somes odd to json_decod each then check if it has something?

Either way I solved it using the Resource and Collection as needed / documented so no worries.

Thanks all the same for your insight.

Activity icon

Started a new Conversation Return An Empty Resource

I am working on implementing the Laravel API Resource to an existing site. One problem I find is that if there are no records the JSON response is null, yet the recource its-self has other coded features like link / meta data.

Controller:

AvailabilityResource::withoutWrapping();
return new AvailabilityResource($profile->availability); // single record hasOne relationship so will never be a collection of records

AvailabilityResource:

public function toArray($request)
{
  $profile = \Route::current()->parameter('profile');

  return [
    'type' => 'availability',
    'attributes' => [
      'expires_at' => $this->expires_at,
      'expires' => $this->expires
    ],
    'meta' => [
      'store' => 'availabilityStore'
    ],
    'links' => [
      'index' => [
          'url' => route('availability.index', ['profile' => $profile]),
          'method' => 'get',
        ],
      'update' => [
        'url' => route('availability.create', ['profile' => $profile]),
        'method' => 'post',
      ]
    ],
  ];
}

But this returns availability: null as a response. No other required data?

Am I missing something?

Thanks,

Dave

Aug
05
2 months ago
Activity icon

Replied to Define Relationship Help

Thanks. I will give it a try.

Hard to explain, on the dashboard there are ~20 widgets and the goal is combine/minimize every request needed to fill the dashboard with minimal calls.

Right now there are basically 1 api call for each of the widgets, so using the travel example

$profile->with(['travel, array of other relations])

I can grab all the users answers no problem, but would need to also grab all the possible answers as a whole.

But I will try your code here now.

Thanks again,

Dave

Activity icon

Replied to Define Relationship Help

I have this but it pulls all the questions and answers for every answer.

'travel' => function($query){
          $query->with(['Question' => function($query){
            $query->with(['Answer']);
          }]);
        }

If I could simply skip the question relation and get the Answer model.

Thied hasManyThrough but errors.

Activity icon

Replied to Define Relationship Help

When I display the travel select right now I have created my response manually.

$response = [
        'records' => ['travel' => $profile->travel()->pluck('attribute_answer_id')],
        'selectables' => $selectables // the available options to select from
];

But as this site is now being upgraded to use Laravel JSON API Resource for response its not liking the format.

I need a way to make a simple standard model call even thru there is no real relationship

$profile->travel()->with('get all possible options for travel' even thou there is no direct relationship)

That's the overall need. I need to include the all the possible answers (Canada, USA / Africa....) to fill the options to select from.

Hope that makes sense.

Activity icon

Started a new Conversation Define Relationship Help

Just looking for some help with this db table setup for defining a relationship.

Will try to explain since its not a common setup I think.

I have a Questions table which holds various questions so not a big deal.

Just to keep it understandable one of the questions is select favorite travel destinations. (say this question has id = 5) Answers table holds the multitude options available to each of the answers.

So there are multiple answers for question 5 they can then select from: Canada, id = 2, question_id = 5 Usa, id = 3, question_id = 5 Africa, id = 5, question_id = 5

On the front end this might get displayed as multiple checkbox, all good.

They get saved to a pivot table profile_travel saving the profile_id and answer_id.

I created a Travel Table but wondering what is the correct relationship. I need to do a Eloquent query to

$profile->with(['travel' => function($query){
          $query->with(???); // what is the relation ship to get all of the possible answers, not just the selected ones
        }])

Basically need to get all the questions / answers that user has for id = 5

Question hasMany Answer, Answer belongsTo Question is defined relationship

Ask if that does not make sense....

Thanks.

Dave

Jul
27
2 months ago
Activity icon

Started a new Conversation JWT Logout Error

I am using JWT for authentication for my Laravel back-end API. Now logout is fine when the token is valid. But if I let the site site there (forget to logout for example) go to the site a day later and click logout I get Invalid token.

logout looks like:

public function logout() {

    $this->logHistory();
        
    try {
      JWTAuth::invalidate(JWTAuth::getToken());
      return response()->json([
        'status' => 'success',
        'msg' => 'You have successfully logged out.'
      ]);
    } catch (JWTException $e) {
        JWTAuth::unsetToken();
        // something went wrong tries to validate a invalid token
        return response()->json([
          'status' => 'error',
          'msg' => 'Failed to logout, please try again.'
      ]);
    }
  }

How can I logout no matter what, valid token or not and return success.

Thanks,

Dave

Jul
22
3 months ago
Activity icon

Replied to Random Undefined Index: Driver Error

I am starting to think your both on point. Its a cache issue.

On dashboard i make http 1 request but gets 5 data sets from the db to get various records, each has a identical snip of code like the one I posted above yet in the db, only 2 or 3 are showing up. The cache is failing on those request. But only sometimes. If I dump cache db next time its correct.

Will look into redis, just not indepth with it so its all new to me on that aspect. I was using memcache on other site so figured stick with what I know.

But thanks for the assistance and time.

Much appreciated.

Activity icon

Replied to Validation Regex Assistance

Thanks!

Very helpful. I do plan to add a phone SMS verification but thats down the road. As for the urls you are 100% right. Its not my place to validate what a user enters as the social URL. If it matches a valid URL then its up to the user to know its correct. If not then they just directing users somewhere into the unknown.

I could do a background request to see that it resolves but thats more than I might be willing to do at this point :)

Activity icon

Replied to Random Undefined Index: Driver Error

I have a few lines like so:

$selectables = Cache::remember('attribute_questions_and_answers_clients', 60*24*7, function () {
      return $this->attributeQuestion->getSelectables('clients');
    });

But in the log I see it trying to set the values to the db when it should not since its good for a week but it is still sending the values to update.

Something wrong with that setup perhaps?

Activity icon

Replied to Random Undefined Index: Driver Error

env has none.

config/cache.php what should I look for?

Right now its using database but live version will be memcache

'default' => env('CACHE_DRIVER', 'database'),
..... 

'database' => [
            'driver' => 'database',
            'table' => 'cache',
            'connection' => null,
        ],
Activity icon

Replied to Random Undefined Index: Driver Error

Log shows same foreign language as the full stack.


[2019-07-22 19:29:42] local.ERROR: Undefined index: driver {"exception":"[object] (ErrorException(code: 0): Undefined index: driver at D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Database\DatabaseManager.php:115)
....
Activity icon

Replied to Random Undefined Index: Driver Error

Has this:

'default' => env('DB_CONNECTION'),
Activity icon

Replied to Validation Regex Assistance

I guess in the end it makes no difference to mysite. If someone decides to say hey this is my facebook url and its not right that's just their own fault. Just validate its a valid url and leave it at that should be good.

If they enter a phone number I don't call to see if they answer! Just make sure its a valid format.

Kind of like I order a pizza and give wrong address and wonder why it never got delivered its my own stupidity :)

Activity icon

Replied to Random Undefined Index: Driver Error

config/database.php

'mysql' => [
            'driver' => 'mysql',
            'host' => env('DB_HOST'),
            'port' => env('DB_PORT'),
            'database' => env('DB_DATABASE'),
            'username' => env('DB_USERNAME'),
            'password' => env('DB_PASSWORD'),
            'charset' => 'utf8',
            'collation' => 'utf8_unicode_ci',
            'prefix' => '',
            'strict' => true,
            'engine' => null,
        ],

env

DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=******
DB_USERNAME=******
DB_PASSWORD=******
Activity icon

Replied to Random Undefined Index: Driver Error

It will randomly fail with this error on any number of api calls. When i login, navigate to the page where this happens there a few api / http requests and it might fail at any of them at any time.

http://api.devtown/v1/cities/user1
http://api.devtown/v1/events/user1
http://api.devtown/v1/promotions/user1
.... so on 

No logic behind it. Just fails. No changes to anything. Simply go the the page, no errors. Try again this time errors. And it always a different api call that fails (example of api calls above). Its not 1 specific one.

Activity icon

Replied to Random Undefined Index: Driver Error

Its huge:

"message": "Undefined index: driver",
    "exception": "ErrorException",
    "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Database\DatabaseManager.php",
    "line": 115,
    "trace": [
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Database\DatabaseManager.php",
            "line": 115,
            "function": "handleError",
            "class": "Illuminate\Foundation\Bootstrap\HandleExceptions",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Database\DatabaseManager.php",
            "line": 74,
            "function": "makeConnection",
            "class": "Illuminate\Database\DatabaseManager",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Cache\CacheManager.php",
            "line": 210,
            "function": "connection",
            "class": "Illuminate\Database\DatabaseManager",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Cache\CacheManager.php",
            "line": 105,
            "function": "createDatabaseDriver",
            "class": "Illuminate\Cache\CacheManager",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Cache\CacheManager.php",
            "line": 80,
            "function": "resolve",
            "class": "Illuminate\Cache\CacheManager",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Cache\CacheManager.php",
            "line": 58,
            "function": "get",
            "class": "Illuminate\Cache\CacheManager",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Cache\CacheManager.php",
            "line": 69,
            "function": "store",
            "class": "Illuminate\Cache\CacheManager",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Cache\CacheServiceProvider.php",
            "line": 28,
            "function": "driver",
            "class": "Illuminate\Cache\CacheManager",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Container\Container.php",
            "line": 776,
            "function": "Illuminate\Cache\{closure}",
            "class": "Illuminate\Cache\CacheServiceProvider",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Container\Container.php",
            "line": 658,
            "function": "build",
            "class": "Illuminate\Container\Container",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Container\Container.php",
            "line": 609,
            "function": "resolve",
            "class": "Illuminate\Container\Container",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Foundation\Application.php",
            "line": 735,
            "function": "make",
            "class": "Illuminate\Container\Container",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Container\Container.php",
            "line": 912,
            "function": "make",
            "class": "Illuminate\Foundation\Application",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Container\Container.php",
            "line": 840,
            "function": "resolveClass",
            "class": "Illuminate\Container\Container",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Container\Container.php",
            "line": 807,
            "function": "resolveDependencies",
            "class": "Illuminate\Container\Container",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Container\Container.php",
            "line": 658,
            "function": "build",
            "class": "Illuminate\Container\Container",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Container\Container.php",
            "line": 609,
            "function": "resolve",
            "class": "Illuminate\Container\Container",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Foundation\Application.php",
            "line": 735,
            "function": "make",
            "class": "Illuminate\Container\Container",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Container\Container.php",
            "line": 912,
            "function": "make",
            "class": "Illuminate\Foundation\Application",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Container\Container.php",
            "line": 840,
            "function": "resolveClass",
            "class": "Illuminate\Container\Container",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Container\Container.php",
            "line": 807,
            "function": "resolveDependencies",
            "class": "Illuminate\Container\Container",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Container\Container.php",
            "line": 658,
            "function": "build",
            "class": "Illuminate\Container\Container",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Container\Container.php",
            "line": 609,
            "function": "resolve",
            "class": "Illuminate\Container\Container",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Foundation\Application.php",
            "line": 735,
            "function": "make",
            "class": "Illuminate\Container\Container",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php",
            "line": 140,
            "function": "make",
            "class": "Illuminate\Foundation\Application",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php",
            "line": 53,
            "function": "Illuminate\Pipeline\{closure}",
            "class": "Illuminate\Pipeline\Pipeline",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php",
            "line": 104,
            "function": "Illuminate\Routing\{closure}",
            "class": "Illuminate\Routing\Pipeline",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Routing\Router.php",
            "line": 684,
            "function": "then",
            "class": "Illuminate\Pipeline\Pipeline",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Routing\Router.php",
            "line": 659,
            "function": "runRouteWithinStack",
            "class": "Illuminate\Routing\Router",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Routing\Router.php",
            "line": 625,
            "function": "runRoute",
            "class": "Illuminate\Routing\Router",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Routing\Router.php",
            "line": 614,
            "function": "dispatchToRoute",
            "class": "Illuminate\Routing\Router",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php",
            "line": 176,
            "function": "dispatch",
            "class": "Illuminate\Routing\Router",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php",
            "line": 30,
            "function": "Illuminate\Foundation\Http\{closure}",
            "class": "Illuminate\Foundation\Http\Kernel",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\barryvdh\laravel-cors\src\HandleCors.php",
            "line": 58,
            "function": "Illuminate\Routing\{closure}",
            "class": "Illuminate\Routing\Pipeline",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php",
            "line": 151,
            "function": "handle",
            "class": "Barryvdh\Cors\HandleCors",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php",
            "line": 53,
            "function": "Illuminate\Pipeline\{closure}",
            "class": "Illuminate\Pipeline\Pipeline",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\TransformsRequest.php",
            "line": 31,
            "function": "Illuminate\Routing\{closure}",
            "class": "Illuminate\Routing\Pipeline",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php",
            "line": 151,
            "function": "handle",
            "class": "Illuminate\Foundation\Http\Middleware\TransformsRequest",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php",
            "line": 53,
            "function": "Illuminate\Pipeline\{closure}",
            "class": "Illuminate\Pipeline\Pipeline",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\TransformsRequest.php",
            "line": 31,
            "function": "Illuminate\Routing\{closure}",
            "class": "Illuminate\Routing\Pipeline",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php",
            "line": 151,
            "function": "handle",
            "class": "Illuminate\Foundation\Http\Middleware\TransformsRequest",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php",
            "line": 53,
            "function": "Illuminate\Pipeline\{closure}",
            "class": "Illuminate\Pipeline\Pipeline",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode.php",
            "line": 62,
            "function": "Illuminate\Routing\{closure}",
            "class": "Illuminate\Routing\Pipeline",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php",
            "line": 151,
            "function": "handle",
            "class": "Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php",
            "line": 53,
            "function": "Illuminate\Pipeline\{closure}",
            "class": "Illuminate\Pipeline\Pipeline",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php",
            "line": 104,
            "function": "Illuminate\Routing\{closure}",
            "class": "Illuminate\Routing\Pipeline",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php",
            "line": 151,
            "function": "then",
            "class": "Illuminate\Pipeline\Pipeline",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php",
            "line": 116,
            "function": "sendRequestThroughRouter",
            "class": "Illuminate\Foundation\Http\Kernel",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\public\index.php",
            "line": 53,
            "function": "handle",
            "class": "Illuminate\Foundation\Http\Kernel",
            "type": "->"
        }
    ]
}{
    "message": "Undefined index: driver",
    "exception": "ErrorException",
    "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Database\DatabaseManager.php",
    "line": 115,
    "trace": [
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Database\DatabaseManager.php",
            "line": 115,
            "function": "handleError",
            "class": "Illuminate\Foundation\Bootstrap\HandleExceptions",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Database\DatabaseManager.php",
            "line": 74,
            "function": "makeConnection",
            "class": "Illuminate\Database\DatabaseManager",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Cache\CacheManager.php",
            "line": 210,
            "function": "connection",
            "class": "Illuminate\Database\DatabaseManager",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Cache\CacheManager.php",
            "line": 105,
            "function": "createDatabaseDriver",
            "class": "Illuminate\Cache\CacheManager",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Cache\CacheManager.php",
            "line": 80,
            "function": "resolve",
            "class": "Illuminate\Cache\CacheManager",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Cache\CacheManager.php",
            "line": 58,
            "function": "get",
            "class": "Illuminate\Cache\CacheManager",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Cache\CacheManager.php",
            "line": 69,
            "function": "store",
            "class": "Illuminate\Cache\CacheManager",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Cache\CacheServiceProvider.php",
            "line": 28,
            "function": "driver",
            "class": "Illuminate\Cache\CacheManager",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Container\Container.php",
            "line": 776,
            "function": "Illuminate\Cache\{closure}",
            "class": "Illuminate\Cache\CacheServiceProvider",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Container\Container.php",
            "line": 658,
            "function": "build",
            "class": "Illuminate\Container\Container",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Container\Container.php",
            "line": 609,
            "function": "resolve",
            "class": "Illuminate\Container\Container",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Foundation\Application.php",
            "line": 735,
            "function": "make",
            "class": "Illuminate\Container\Container",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Container\Container.php",
            "line": 912,
            "function": "make",
            "class": "Illuminate\Foundation\Application",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Container\Container.php",
            "line": 840,
            "function": "resolveClass",
            "class": "Illuminate\Container\Container",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Container\Container.php",
            "line": 807,
            "function": "resolveDependencies",
            "class": "Illuminate\Container\Container",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Container\Container.php",
            "line": 658,
            "function": "build",
            "class": "Illuminate\Container\Container",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Container\Container.php",
            "line": 609,
            "function": "resolve",
            "class": "Illuminate\Container\Container",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Foundation\Application.php",
            "line": 735,
            "function": "make",
            "class": "Illuminate\Container\Container",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Container\Container.php",
            "line": 912,
            "function": "make",
            "class": "Illuminate\Foundation\Application",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Container\Container.php",
            "line": 840,
            "function": "resolveClass",
            "class": "Illuminate\Container\Container",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Container\Container.php",
            "line": 807,
            "function": "resolveDependencies",
            "class": "Illuminate\Container\Container",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Container\Container.php",
            "line": 658,
            "function": "build",
            "class": "Illuminate\Container\Container",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Container\Container.php",
            "line": 609,
            "function": "resolve",
            "class": "Illuminate\Container\Container",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Foundation\Application.php",
            "line": 735,
            "function": "make",
            "class": "Illuminate\Container\Container",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php",
            "line": 215,
            "function": "make",
            "class": "Illuminate\Foundation\Application",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php",
            "line": 189,
            "function": "terminateMiddleware",
            "class": "Illuminate\Foundation\Http\Kernel",
            "type": "->"
        },
        {
            "file": "D:\devtown\www\api\public\index.php",
            "line": 58,
            "function": "terminate",
            "class": "Illuminate\Foundation\Http\Kernel",
            "type": "->"
        }
    ]
}
Activity icon

Replied to Validation Regex Assistance

Thanks for the response,

I am aware / using those site as testing the regex. I am just not sure what I should be checking for to be honest.

I am going by the regex from the link provided. But in my formRequest I am not 100% if its actually valid. Just because it passes validation of "my" regex does not mean its correct.

Since the form is basically accepting a string of characters, no http protocal since the input has a prefix of www.facebook.com/ the user just enters the rest.Come to think that might be dumb since average user will just copy and past the whole url.

Might need to re-think this.

Activity icon

Replied to Random Undefined Index: Driver Error

I have no idea how to read the stack.....lol

Not funny but no clue what any of it means.

What should I look for?

Next time I will post the stack.

Jul
21
3 months ago
Activity icon

Started a new Conversation Random Undefined Index: Driver Error

I get this error randomly for no reason?

The site is not new, its been in dev for months now. So the database is working. Records saved / edited / deleted all that so its not that its not configured like its a new site.

I login using same dummy user account and no errors. Log out and back in ~20 times and it will log me in, but the redirect to the dashboard then has multiple ajax calls will fail 4-5 out of the 20 times with this error. Not doing anything in terms of making different requests with different data. Same request every time with a simple login.

There is only 1 db connection / mySql and no issues like I said with connecting to the db in terms of it not failing. Just randomly decides to spit out the Status Code: 500 Internal Server Error

Don't even know where to begin since its just random.

Any ideas? Suggestions?

Thanks,

Dave

Jul
20
3 months ago
Activity icon

Started a new Conversation Validation Regex Assistance

I am trying to validate social media urls and was hoping if someone could help with the correct set up?

The form has the social media prefix already there so the user does not need to enter the www.facebook.com part for example. I just need to validate the path after the following:

www.facebook.com
www.twitter.com
www.instagram.com
www.snapchat.com

I found this link https://github.com/lorey/social-media-profiles-regexs

Would it be everyting after the platform name?

https?:\/\/(www\.)?instagram\.com\/([A-Za-z0-9_](?:(?:[A-Za-z0-9_]|(?:\.(?!\.))){0,28}(?:[A-Za-z0-9_]))?)

Would become:

/([A-Za-z0-9_](?:(?:[A-Za-z0-9_]|(?:\.(?!\.))){0,28}(?:[A-Za-z0-9_]))?)

Thanks all

Dave

Activity icon

Replied to Get Route Method

No worries. I will just hard code them as I have it. Not a big issue. I was just curious if there was a 1 line simple way to get the method. But hard coding it, once its set and tested it will never change anyways so in the end the idea is rather pointless.

Thanks again all for your time and ideas!

Dave

Activity icon

Replied to Get Route Method

Thats more the ideas I was looking for Snapey, but I am getting error.

resolveLinks does not exist

But I will play around with it.

Activity icon

Replied to Get Route Method

Sorry Snapey, you dont understand the situation. Thanks for the suggestion all the same.

The Current route has no effect / value.

I could be on the dashboard page which has no model, no relations to anything just a page. Yet on that page are 25 widgets each with its own set of links / route. Each widget has its own Resource, so on dashboard those Resources are used to create a multi dimensional response. If I use the widget as a page it still returns the same links required.

I know what links are required for each "widget" so to get a full list / filter that list vs typing method => post? Seems like overkill, if I lived across the street from work and took a helicopter would that be the most efficient way?

Your time is appreciated, but as dev_nope said just keep it as it is "I think what you have is clean enough and not sure if you need to complicate things."