FutureWeb

FutureWeb

Member Since 5 Years Ago

Experience Points
29,315
Total
Experience

685 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
284
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 6
29,315 XP
Oct
05
2 weeks ago
Activity icon

Replied to Split / Group A Collection Based On Value

Solved by using $collection->put($key,$value);

Activity icon

Started a new Conversation Split / Group A Collection Based On Value

I have a collection of options and want to separate it into chunks each chunk to be used for separate select boxes based on the value of name

$option->name = 'Size', $option->value = '10' $option->name = 'Size', $option->value = '12' $option->name = 'Size', $option->value = '14'

$option->name = 'Colour', $option->value = 'red' $option->name = 'Colour', $option->value = 'blue' $option->name = 'Colour', $option->value = 'green'

$option->name = 'Style', $option->value = 'short' $option->name = 'Style', $option->value = 'long'

How can I make the above into 3 separate select boxes one for size one for colour and one for style the option names could be anything.

Oct
04
2 weeks ago
Activity icon

Replied to Single, Variable And Bundled Products Database Relations

OK so its just dawned on me what If I wanted to add the same pair of socks, or T-shirt or Trainers to a different bundle given that scenario the above wouldn't work!

Activity icon

Started a new Conversation Single, Variable And Bundled Products Database Relations

Hi Lara Folks,

I've been tasked with porting a legacy ecommerce project to laravel it has some interesting product / size, colour, style relations.

And so wanted to know everyones thoughts on how to best tackle the following scenarios:

A product can be just that a single product with no size colour or style variations.

A product can also have variations or options some of which when selected can increase or decrease the price of the parent product i.e A Nike trainer in black, sizes 1 - 5 will use the price associated with the parent product, but the same trainer in sizes 6 - 12 will increase the price by £5 and the same trainer in red will increase the price by another £5

A product can also contain a bundle of products at a unified discounted price, so it could be a trainer as above, socks, and a t-shirt each child product in the bundle containing its own variations / options as in the above example with the possibility of increasing or decreasing the overall price depending on the variation selected for each child product to complicate things a little further users have the option of omitting some products from the bundle i.e they could select no socks which then has to lower the price of the containing bundle.

In the current system the way this is achieved clones product options repeatedly for every bundle created and causes no end of issues when it comes to updating stock.

My initial thoughts are to add a parent_id column to the products table and use this to build a bundle:

id,   parent_id,   name,               price         bundle_item_price
1,     0,                Nike Bundle,  100.00 
2,     1,                Nike trainers   50.00                 45.00
3,     1,                Nike Socks       10.00                 5.00
4,     1,                Nike T-Shirt      60.00                50.00```

Product_options:::
id,       product_id        name             value            price_adjustment
1               2                   colour            black                       0.00
2               2                   colour            red                          5.00
3               2                    size                  5                            0.00
4               2                    size                  9                            5.00```


so in the above example if the socks were removed it would deduct the bundle_item_price from the parent (Nike Bundle) making it £95.00  or if the trainer was added in red in a size 9 it would increase the price by £10 

Has anyone tackled anything like this before and do you think the above is the best way to go about it?

Thanks in advance :)
Jan
27
8 months ago
Activity icon

Replied to Allow Certain IP Addresses And Redirect The Rest In Nginx And Forge

Hi @bashy

I too am trying to restrict access but to a certain dir and to allow a number of ips I have created an include "admin-ips" which is simply a list of ips like so: allow 123.123.123.123; this works if I restrict at root level location / { but not if I just try to restrict access to the admin folder i.e everyone gets redirected to site.com even if they are in the admin-ips include

 location ~ /admin {
         error_page 403 = @deny; // or just return a file
        include includes/admin-ips
        deny all;
        try_files $uri $uri/ /index.php?$query_string;
  }

 location @deny {
          return 301 http://site.com;
  }
Aug
24
1 year ago
Activity icon

Replied to List All Database Column Names And Types Laravel 5.6

Brilliant thanks does exactly what I need.

Activity icon

Started a new Conversation List All Database Column Names And Types Laravel 5.6

Hiya Larafolks,

Does anyone know a way to list all column types and names for a given database table, i.e:

column_name integer other_column_name varchar

May
17
1 year ago
Activity icon

Started a new Conversation Load A Class With Every View

is there anyway to load a class every time a page is rendered?

I simply want to parse the uri and then load all the bumf (meta, og tag any dependent js etc) each time a page has loaded the reason being I want to store it all in db tables to make it manageable by a web admin user.

May
11
1 year ago
Activity icon

Started a new Conversation Insert All Data From Temp Table Without Looping

Hiya LaraPeeps,

I have a number of temp tables which huge amounts of data are imported into using some custom artisan commands.

these run as jobs a couple of times a day I want to copy everything from the temp to live tables as quickly as possible with as little load as possible, one table contains up to 6.5 million records.

temp and live tables are identical.

I am after something like an insert using a sub select:

INSERT INTO live_table (SELECT * FROM tmp_table)

Any help or advice would be greatly appreciated.

Apr
19
1 year ago
Activity icon

Replied to Trigger An Artisan Command When Endpoint Is Hit Then Another When That Is Complete

Do you know what I didn't even think of that LOL what about the parsing just stick it in a job que?

Activity icon

Started a new Conversation Trigger An Artisan Command When Endpoint Is Hit Then Another When That Is Complete

Hiya LaraFolks,

I am looking to trigger an artisan command when an end point is hit and then another when that command is complete.

here's the plan..

1). I fire a command using a cron twice a day at specific time this generates some data on another server and saves the output to a file. -> This I have done.

2). The server responds once complete to an end point on my server I provide a unique single use token in my call back and check the ip of the responding server. -> This is done also

3). When this end point is hit and validation is passed I want to trigger another artisan command to download the data.

4). Then once the data has downloaded I want to trigger another command which parses it.

I have written and tested all the commands I just need to figure out how to trigger 3 and 4 any help would be very much appreciated.

Feb
03
1 year ago
Activity icon

Replied to Anyone Know How To Embed An Image In A Laravel Markdown Email?

lol sorry yes you are correct I got it working with the above with brackets I couldn't get the full url to work or embed for some reason and it seems pretty quirky with indentation in markdown. But all that said your answer is correct but for anyone else use asset($path_to_file)

Activity icon

Replied to Anyone Know How To Embed An Image In A Laravel Markdown Email?

the only way i could do it was ![alt]{{asset('image_path')}}

Activity icon

Started a new Conversation Anyone Know How To Embed An Image In A Laravel Markdown Email?

Hiya larpeeps,

Does anyone know how to embed an image in a laravel Markdown email?

Jan
21
1 year ago
Activity icon

Replied to GroupBy Works On Local Testing Server But Not On Production?

Also if I dump the query into phpmyadmin on the production server it works fine?

Activity icon

Started a new Conversation GroupBy Works On Local Testing Server But Not On Production?

Hi LaraPeeps,

I have this relationship in my User Model:

public function invoices()
{
    return $this->hasManyThrough('App\Invoice','App\Order','user_id','id','id','invoice_id')->groupBy(['invoices.id','orders.user_id']);
}

this works as does the below (on my local machine)

    public function invoices()
{
    return $this->hasManyThrough('App\Invoice','App\Order','user_id','id','id','invoice_id')->groupBy(['invoice_id','user_id']);
}

but on my production server I get this error:

SQLSTATE[42000]: Syntax error or access violation: 1055 'shopsite_db.invoices.title' isn't in GROUP BY (SQL: select `invoices`.*, `orders`.`user_id` from `invoices` inner join `orders` on `orders`.`invoice_id` = `invoices`.`id` where `orders`.`user_id` = 1 group by `invoices`.`id`, `orders`.`user_id`)
Jan
18
1 year ago
Activity icon

Replied to Best Approach To Group Orders To Each Invoice

Hi thanks for the response works a treat had to do hasManyThrough for Invoice on the user model.

Jan
17
1 year ago
Activity icon

Started a new Conversation Best Approach To Group Orders To Each Invoice

Hi Lara Folks,

I have two tables:

orders:
id, product_id, user_id, price

invoices:
id, order_id, total, payment_status

I want to list all orders per user but group them by invoice so:

user1 orders product 1,2,3 and 4 pays invoice number 1 and then orders product 5,6,7 and 8 and pays invoice 2

I would like to display this as:

Invoice 1: Product xx - £20 Product xxx - £10

Invoice 2: Product yy - £30

you get the idea the long and the short of it is I need to access the invoices through the orders table but group by invoice

is there a nice simple way using Eloquent relationships rather than writing a join

Jan
11
1 year ago
Activity icon

Replied to Redirecting Back To Intended Laravel 5.5

@GertjanRoke Yep its an out of the box auth:make

Activity icon

Replied to Redirecting Back To Intended Laravel 5.5

   $data = \Session::get('_previous');
    $url = $data['url'];
    dd($url);

seems to be what I need

Activity icon

Replied to Redirecting Back To Intended Laravel 5.5

here are the routes that redirect to the login a form is posted to /play then that stores the data in a session and redirects to checkout which checks auth if it fails it redirects to login and then after login it should redirect back to checkout

Route::get('/checkout', function(){

 if(!auth::check())
 {
     return redirect('login');

 }

  $post = Session::get('cart');
  $post = $post[0];
  $post['user_id'] = auth::user()->id;

   return view('checkout', compact('post'));
 });

 Route::post("/play", function(){
   $post = $_POST;
   if(Session::has('cart')) { Session::forget('cart'); }

    Session::push('cart', $post);

    return redirect('checkout');
   });
Activity icon

Replied to Redirecting Back To Intended Laravel 5.5

im getting this now: (after login)

Header may not contain more than a single header, new line detected
Activity icon

Replied to Redirecting Back To Intended Laravel 5.5

Still no joy :( I just get a blank screen not even a stack trace

Activity icon

Replied to Redirecting Back To Intended Laravel 5.5

Sorry i wasn't very clear when the user hits a page that requires auth I redirect them to the login form after they have successfully logged in I want to redirect them back to the page they intended to view.

Activity icon

Started a new Conversation Redirecting Back To Intended Laravel 5.5

I am trying to redirect the user to intended after login so I have taken out the $redirectTo property from the LoginController which is generated by artisan make:auth and added this method:

    protected function redirectTo(){
    
        return redirect()->intended('/home');
    }

But it only ever redirects home ? any help would be great.

Jan
10
1 year ago
Activity icon

Replied to Force Https Laravel 5.5

Yep could do just feels quick and dirty :(

Activity icon

Started a new Conversation Force Https Laravel 5.5

Since upgrading to 5.5 my force https seems to have stopped working I have changed schema to shceme this is in my app/AppServiceProvider class under the boot method it worked in previous versions any ideas?

Jan
05
1 year ago
Activity icon

Replied to Using Recursion And Getting Json Keys Which Double As Array Names

Brilliant thanks I passed in a counter variable to keep track of the depth in the end.

Jan
03
1 year ago
Activity icon

Replied to Using Recursion And Getting Json Keys Which Double As Array Names

cant do the code block either lol

Activity icon

Replied to Using Recursion And Getting Json Keys Which Double As Array Names

Ok I have written a recursive function to handle this but now my problem is I cannot keep track of the depth any ideas?

'''

public function anything($json){ $array = json_decode($json, true);

return $this->recursive_key_val_lookup($array);

} '''

'''

private function recursive_key_val_lookup($array=[]) {

   foreach($array as $key=>$val)
   {
       if(is_array($val))
       {
           echo "$key is array<br>";
           $this->recursive_key_val_lookup($val);
       } else {
           echo "$key => $val";
       }
   }
}

'''

Activity icon

Started a new Conversation Using Recursion And Getting Json Keys Which Double As Array Names

I have the below json to parse, this can go to any depth it contains an array called groups and within groups are sub groups which contain an id and a description the description doubles as an array name for a sub sub group which again contains an id and a description which in the instance below then contains and array of items id, groupingId, title, desc.

What I am trying to do is extract the id and description of the first 2 levels so group.id=2 group.description=Inclusive Services and sub_group.parent_id=2 sub_group.id=255-3 sub_group.description=Service Attributes and so on.

the problem I have found is I cannot seem to get the description of the group or sub group as it is an array.

{
  "groups": [
    {
      "id": "2",
      "Inclusive Services": [
        {
          "id": "255-3",
          "Service Attributes": [
            {
              "id": "13",
              "groupingId": "M3",
              "title": "BlackBerry Services",
              "desc": "Use the internet, email and BBM on your BlackBerry to share messages, pictures and more for free. Sync with your PC or Mac and take your favourite music, photos and videos wherever you go."
            }
          ]
        },
        {
          "id": "255-5",
          "Enhanced customer service": [
            {
              "id": "79",
              "groupingId": "M5",
              "title": "O2 Pay and Go Rewards",
              "desc": "As a new customer, when you join O2 Pay & Go and opt into O2 Rewards, you''ll earn 5% back on all top-ups every three months. So, if you top up £50, you can get £2.50 back at the end of the quarter. Even better, after you''ve been with us for six months, the % of rewards you earn will increase to 10%."
            }
          ]
        },
        {
          "id": "255-11",
          "Roaming services": [
            {
              "id": "73",
              "groupingId": "M11",
              "title": "O2 Travel",
              "suffix": "For the length of your contract",
              "desc": "O2 Travel is your perfect holiday companion.You can download TripAdvisor City Guides for reviews on things to do, the best places to eat and maps you can use offline. And if you are missing home, you can talk for up to an hour for a connection charge of just 50p and access all the data you need for just £1.99 per day."
            }
          ]
        },
        {
          "id": "255-4",
          "Entertainment freebies and discounts": [
            {
              "id": "64",
              "groupingId": "M4",
              "title": "O2 Priority",
              "suffix": "For the length of your contract",
              "desc": "Priority from O2 gives you access to exclusive offers and events including lunch for £1 every Monday. Grab some VIP treatment for you and your friends with access to gig tickets up to 48 hours before general release, exclusive entry to O2 bars and side step the queues with fast track lanes at O2 venues."
            },
            {
              "id": "65",
              "groupingId": "M4",
              "title": "O2 Tracks",
              "suffix": "For the length of your contract",
              "desc": "O2 Tracks gives you nonstop access to all the hottest music videos, top 40 playlists and backstage gossip. Try it for free with a four week free trial when you join O2 – no ads, no streaming, just great music."
            }
          ]
        },
        {
          "id": "255-23",
          "Free or discounted allowances": [
            {
              "id": "68",
              "groupingId": "M23",
              "title": "O2 TU Go",
              "desc": "TU Go is a free app that lets you use your O2 number on smartphones, tablets and laptops.It''s just like using your phone. Sign in to TU Go using a wifi connection to get your calls, texts and voicemail on up to 10 devices. The person you''re talking to doesn''t even need to have the app.Our latest version of TU Go now also lets you use the app over any mobile data (3G / 4G) connection – so you can now use TU Go for calls, texts and voicemails whenever you have mobile data available. If you want to use mobile data for TU Go calls, you can switch this on in Settings."
            },
            {
              "id": "69",
              "groupingId": "M23",
              "title": "O2 WiFi Hotspots",
              "desc": "Stay connected with O2 WiFi Hotspots available in thousands of locations nationwide including All Bar One, Debenhams, Café Rouge, Costa, House of Fraser, McDonalds and Subway."
            }
          ]
        },
        {
          "id": "255-25",
          "Free or discounted software": [
            {
              "id": "80",
              "groupingId": "M25",
              "title": "Evernote Premium for a year",
              "desc": "Experience Evernote Premium free for 1 year. With Evernote Premium you can capture your ideas, tasks, projects and more. You can share and edit your notes, access your work anywhere offline and get 1GB of free uploads each month."
            }
          ]
        }
      ]
    },
    {
      "id": "4",
      "Comes with (chargeable)": [
        {
          "id": "255-2",
          "Pay as you go Top-up": [
            {
              "id": "5",
              "groupingId": "M2",
              "title": "Pay as you go Top-up: £20",
              "suffix": "Topup",
              "cost_type": "Fixed",
              "cost": "20.00",
              "desc": "This product comes with a mandatory top-up charged at £20, meaning you will have £20 credit to use (or on your account)."
            }
          ]
        }
      ]
    }
  ]
}
Jul
26
2 years ago
Activity icon

Replied to Oembed Package For Laravel 5.1

Any for L5.4? I can't seem to find one

Nov
24
2 years ago
Activity icon

Replied to Add Integer To Eloquent Collection

Yes of course :) thanks should have been $count->aggregate; what a mistakea to makea

Activity icon

Started a new Conversation Add Integer To Eloquent Collection

Hi LaraPeeps,

I am trying to add an integer to an eloquent collection:

$deals = Deal::with('stuff')->where('this','=','that')->take(20)->get();

and then I am trying to append an integer to the collection like this

$deals->last_page = $count;

or like this

$deals->put('last_page',$count);

but I always get the following error: Object of class stdClass could not be converted to int

Any pointers would save me a good amount of hair.

Thanks in advance :)

Aug
07
3 years ago
Activity icon

Started a new Conversation Before Send / Before Route(s) Fire

Can I do

        if(Auth::check())
        {
           if(!Auth::user()->email || is_null(Auth::user()->email))
           {
                return redirect('/dashboard')->with('error', 'You have not provided an email address');
          }
      }

reason being I have a social login and twitter logins do not provide an email address nor do some facebook logins for some reason, if you can think of a better option then redirecting the user to the dashboard and a add email form please share it as on registration I send out a welcome email via an event handler and listener and it would save me putting the same logic in the controller before firing the event if that makes sense?

thanks in advance larapeeps.

p.s sorry the codes not formatting - Yah got there in the end!!!!

Jul
21
3 years ago
Activity icon

Replied to Send Welcome Email On User Registration

seemed to be a server config issue with me server being set only allow outgoing emails to root account, and now it looks like my ip is blacklisted :( which is odd as I have never sent mail out using it before, so that's it I am using mailgun

Activity icon

Replied to Send Welcome Email On User Registration

yes I do I would have thought an exception would be thrown but I get nothing

Activity icon

Started a new Conversation Send Welcome Email On User Registration

I am trying to send a welcome email when a user registers Laravel 5.2, I have the following code in my Auth controllers user create method:

        $user = User::findOrFail($id);
        Mail::send('emails.welcome', $user, function($message) use ($user)
        {
            $message->from('[email protected]', 'xxxx.uk');
            $message->subject("Welcome to xxxxx.me.uk");
            $message->to($user->email);
        });

just before the return but it does not fire I get no errors or exceptions but I get no mail either its driving me up the wall!

Jul
20
3 years ago
Activity icon

Replied to Sending A Welcome Email

I am trying to achieve the same thing did you ever find how to do it?

Dec
07
3 years ago
Activity icon

Replied to Paypal IPN Laravel 5.1 - 405 Not Allowed??

Hahahaha what a mistakea-to-makea!! I have it as get not post!!

Activity icon

Started a new Conversation Paypal IPN Laravel 5.1 - 405 Not Allowed??

Hi LaraPeeps,

I am trying to use the paypal Ipn to log donations - I have disables csrf for the route using:

protected $except = [
    'payments/paypal'
];

in app/http/middleware/verifycsrftoken

but I still get a 405 from the paypal sandbox ipn testing tool :(

I have tried ready made curl, fsocket and even the fahim laravel package but cannot get a thing to work!! its driving me insane.

Dec
06
3 years ago
Activity icon

Replied to Hook Into Successful User Registration Laravel 5.1

i get: Cannot make static method Illuminate\Database\Eloquent\Model::boot() non static in class App\User

Activity icon

Started a new Conversation Hook Into Successful User Registration Laravel 5.1

Hi LaraPeeps,

How do I hook into a successful user registration in 5.1

Can I just do if(User::create([..])){ ..// further db insert }else{ // throw exception }

Thanks in advance

Oct
26
3 years ago
Activity icon

Replied to Controller Showing Up In Views Storage ?

LOL me being stupid sorry - copied my controller to the view by mistake on the server :)

Activity icon

Started a new Conversation Controller Showing Up In Views Storage ?

I have an odd problem I am getting a fatal exception Cannot redeclare class App..\HomeController but its in ../storage/framework/views/xxxxxx. when I open the view from the storage dir its an exact copy of my HomeController ? I am using laravel 5.1 any ideas folks?

Oct
18
4 years ago
Activity icon

Started a new Conversation Cached Ajax Pagination With Orderby And Where

is it possible to manipulate a cached paginated collection with relationships?

for instance:

         if(isset($_GET['page']) 
         {
                $page=$_GET['page'];
          }
             else{
                 $page = 0;
            }
            $product = Cache::remember('product'.$page,7200,function() use($brand){
                return Product::with('specs','prices','retailers')
                     ->where('brand','=',$brand)
                     ->orderBy('popularity','desc')
                     ->paginate(20);
   });
   
   if($page>0 || isset($_GET['order']))
   {
       // its an ajax request.. 
        if($_GET['order'] == 'price')
         {
                // order by price on prices with relationship
         }
         elseif($_GET['order'] == 'screensize')
         {
                // order by screensize on specs with relationship
        } // etc..
Oct
11
4 years ago
Activity icon

Started a new Conversation Unique Value From Column On Existing Collection

if I pull a paginated collection with many rows and columns can I pull a single column with only unique values in to a new object or array?

Thanks in advance