Our Black Friday sale is now live! All individual subscriptions are 50% OFF. This week only!

boby

boby

Member Since 1 Year Ago

Experience Points
4,710
Total
Experience

290 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
32
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start your 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-in-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 Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist 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 1
4,710 XP
Oct
26
4 weeks ago
Activity icon

Replied to Barryvdh/laravel-dompdf Table Page Break Problem

<div class="container">
	<div class="row"> 

are standard bootstrap grid classes. I don't have any styles on them, I only have bootstrap css included in my blade file:

<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">

Try to remove rowspans, and make simple table to test this, then apply it, to your solution.

It took me a while before I found working solution. You need to try some combinations as well, try bootstrap, try without, create simple table with "dummy" data, etc...

Activity icon

Replied to Barryvdh/laravel-dompdf Table Page Break Problem

Hi @joaohamerski

So I use it like this:

<body>

	<header>
		Logo and other header stuff
	</header

	<footer>
		Page number and footer stuff
	</footer

	<div style="page-break-after:auto;">

	<div class="container my-content">
		<div class="row">
			<table>
				My content here
			</table>
		</div>
	</div>
</body

In your css file add padding for the table: padding-bottom: 50px;

so it won't overlap with the footer

Hope it helps

Oct
24
1 month ago
Activity icon

Replied to Barryvdh/laravel-dompdf Large White Space Problem

Interestingly sm-6 put my divs next to each other, but I want 2nd to be on very right. I used sm-auto instead and that is ok for alligment, but still have to solve this white space.

Activity icon

Replied to Barryvdh/laravel-dompdf Large White Space Problem

@raheelkhan

that didn't help :(

@automica

I will definitely try to investigate this with bootstrap, that might be the reason.

Activity icon

Replied to Barryvdh/laravel-dompdf Large White Space Problem

@michaloravec I am not using float, check css file above.

Adding clear didn't work :(

Activity icon

Replied to Barryvdh/laravel-dompdf Large White Space Problem

Update:

when I remove this part from my blade, it is ok then:

	  			<div class="col-sm invoice-details">
	  				<p><b>AN0001/2020</b></p>
	  				<p>12.10.2020</p>
	  				<p>24.10.2020</p>
	  				<p>Customer Nr.: 0001</p>
	  			</div>
Activity icon

Replied to Barryvdh/laravel-dompdf Large White Space Problem

@automica

here is the border version:

https://www.dropbox.com/s/4wsixx1p8lujshk/offer1.png?dl=0

Css file:

* {
    font-family: "DejaVu Sans";
}
html {
    margin: 0;
}
body {
    font-size: 12px;
    margin: 30px;
    border: solid red;
}
body, h1, h2, h3, h4, h5, h6, table, th, tr, td, div {
    line-height: 1.1;

}

/* HEADER */
.header {
	height: 100px;
	border: solid red;
}

.logo {
	margin-top: 5px;
	border: solid red;
}

.invoice-user-details p{
	text-align: right;
    margin-bottom: 0.1rem; 
}

.invoice-customer-details {
    width: 300px;
    border: solid red;
}

.invoice-details{
	text-align: right;
	border: solid red;
}

hr {
	margin-top: 0rem;
}
/* END HEADER */

/* OFFER TITLE */
.offer_title,
.invoice_title  {
    font-size: 1.2rem;
    margin-bottom: 1.5rem;
    border: solid red;
}
/* END OFFER TITLE */

/* CONTENT */
.invoice-articles-table {
    padding-top: 0px;
    padding-bottom: 50px;
    border: solid red;
}

.invoice-articles-table tbody {
	font-size: 10px;
}

.invoice-amounts{
    text-align: right;
    font-size: 12px;
    font-weight: 700;
    border: solid red;
}

.invoice-amounts p{
    margin-bottom: 0.5em;
}

/* END CONTENT */

/* FOOTER */
footer {
    position: fixed; 
    bottom: 0px; 
    left: 0px; 
    right: 0px;
    height: 70px;
    margin: 30px;
}

.foo1 {
	text-align: left;
}

.foo1 p, .foo2 p, .foo3 p{
    margin-bottom: 0.1em; 
}

.foo2 {
	text-align: center;
}

.foo3 {
	text-align: right;
}

.pagenum:before {
    content: counter(page);
}

.page-break {
    page-break-before: always;
}
/* END FOOTER */
Activity icon

Started a new Conversation Barryvdh/laravel-dompdf Large White Space Problem

So I am using barryvdh/laravel-dompdf to generate invoice pdf file. The problem is white space I have between header and the content

https://www.dropbox.com/s/23w4y7p2coz4kg8/offer.png?dl=0

So the space between Customer Number and Offer Number below it.

My blade file (striped):

	    <header id="header" class=""> <!-- header -->
	  		<div class="row header">
			    <div class="col-sm logo">
                    <img src="user_logo_1596900003.png" alt="Company Logo">
			    </div>
	    		<div class="col-sm">
	    		</div>
			    <div class="col-sm invoice-user-details">
			    	<p>Demo Company</p>
			    	<p>Some address</p>
			    	<p>Tel: 0123456789</p>
			    	<p>E-mail: [email protected]</p>
                        <p>Web: www.demo.com</p>
			    </div>
	  		</div>
	  		<hr class="header-hr">
	  		<div class="row">
	  			<div class="col-sm invoice-customer-details">
	  				<b><p>Customer company name here</p></b>
	  				<p>Customer address</p>
	  				<p>City</p>
                </div>
	  			<div class="col-sm invoice-details">
	  				<p><b>AN0001/2020</b></p>
	  				<p>12.10.2020</p>
	  				<p>24.10.2020</p>
	  				<p>Customer Nr.: 0001</p>
	  			</div>
	  		</div> 	    	
	    </header><!-- /header -->

	    <div style="page-break-after:auto;">

	    <div class="container content">
	    	<p class="offer_title">Offer AN0001/2020</p>
	    	<div class="row"> 
	  				<table class="table invoice-articles-table">
	  					<thead>
	  						<tr>
	  							<th>#</th>
	  							<th></th>
	  							<th>Article</th>
	  							<th>Quantity</th>
	  							<th>Price</th>
	  							<th>Discount}</th>
	  							<th>Total</th>  								  								
	  						</tr>
	  					</thead>
	  					<tbody>
	  						<tr>
	  								<td>
	  									1
	  								</td>
	  								<td>
	  									<img src="some_image.png" width="50px">
	  								</td>
	  								<td>
	  									Article1 
	  								</td>
	  								<td>
	  									1
	  								<td>
	  									0.00
	  								</td>  					
	  								<td>
	  									0.00
	  								</td>
	  								<td>
	  									0.00 
	  								</td>
	  							</tr>
	  					</tbody>
	  					<tfoot>
	  						<tr>
	  							<td class="invoice-amounts" colspan="7">
	  								<p>Total: 0.00 &euro; </p>
	  								<p>Tax 20%: 0.00 &euro; </p>
	  								<p>Grand Total: 0.00 &euro; </p>
	  							</td>
	  						</tr>
	  					</tfoot>
	  				</table>
	  		</div>
	  	</div>
    </body>
</html>

There is nothing special in my css file regarding this space.

Anyone have this problem?

Activity icon

Replied to Barryvdh/laravel-dompdf Table Page Break Problem

@snapey in case you still need it

Before content, in my case articles table, put this to blade file:

<div style="page-break-after:auto;">

in css file for your blade:

.page-break {
    page-break-before: always;
}

.invoice-articles-table {
    padding-bottom: 50px; //height of your footer
}

Boom! You have auto page brake no matter how many lines in the table :)

Sep
13
2 months ago
Activity icon

Replied to Allow User Login Only If Active - Laravel 7

Sh*t, I was missing @include('flash-message') in my layouts file. What a noob.

Now there is a message. Sry to everyone.

Still I will try to do this proper way.

Activity icon

Replied to Allow User Login Only If Active - Laravel 7

@ismaile The message is still not being shown, but I see page reload, so redirect works.

@martinbean Same as ismaile solution, no error message.

@snapey I am planning to update to laravel 8 in near future, is there any benefit to this problem with using laravel 8, as you said that the topic should be for version < 8?

@All, I am interested to do this proper way, so solution with checking before login is maybe better, but I don't understand how this got so complicated. I thought I will be straight forward.

Activity icon

Replied to Allow User Login Only If Active - Laravel 7

@snapey updated the title.

What do you mean if I don't like the look of their account?

Activity icon

Replied to Allow User Login Only If Active - Laravel 7

Ok, after checking laravel docs, I found something, but my user still gets logged in, even if inactive.

This is my LoginController now:

    public function authenticate(Request $request)
    {
        if (Auth::attempt(['email' => $email, 'password' => $password, 'active' => 1])) {
            return redirect()->intended($this->redirectPath());
        }
    }

    protected function redirectPath()
    {
        $path = '/login';
        $role = Auth::user()->role->role_name;
        switch($role) {
            case 'admin':
                $path = '/admin';
                break;
            case 'user':
                $path = '/dashboard';
                break;
            default:
                $path = '/login';
                break;
        }
        return $path;
    }

Activity icon

Replied to Allow User Login Only If Active - Laravel 7

@ismaile Fix is ok, but if it is not the best way to do it, could you please tell me how? Also, my message isn't shown if I do it like this.

@extjac Will try your way also. Thx.

Activity icon

Started a new Conversation Allow User Login Only If Active - Laravel 7

So I have in my users table, field 'active' (true/false), and I am trying to stop user to login if it is inactive, but it still proceeds to login even if it is inactive.

LoginController.php

    protected function authenticated()
    {
        if(!Auth::user()->active) {
            return redirect('/login')->with('error', 'Your account is inactive');
        }
        
        $role = Auth::user()->role->role_name;
        switch($role) {
            case 'admin':
                return redirect('/admin');
                break;
            case 'user':
                return redirect('/dashboard');
                break;
            default:
                return redirect('/login');
                break;
        }
    }

However I can stop user with abort function, but I would rather to stay on login with error message.

Aug
18
3 months ago
Activity icon

Replied to Register Problem With Interface Implement

Why should I redirect there and not from LoginController?

I solved initial problem, stupid me. The problem was that I removed return User::create(... so null was given.

Activity icon

Replied to Register Problem With Interface Implement

Yes I did. If you mean for

php artisan ui bootstrap --auth

I did not change much of default. I changed when user is logged in, based on role, go to admin or user part: LoginController.php

    //protected $redirectTo = RouteServiceProvider::HOME;
    protected function authenticated()
    {
        $role = Auth::user()->role->role_name;

        switch($role) {
            case 'admin':
                return redirect('/admin');
                break;
            case 'user':
                return redirect('/dashboard');
                break;
            default:
                return redirect('/login');
                break;
        }
    }

I assume that RegisterController.php is ok, as user is being created, when I click register.

Activity icon

Replied to Box 'laravel/homestead' Could Not Be Found.

Can you start virtualbox regardless of laravel?

Activity icon

Started a new Conversation Register Problem With Interface Implement

So for registration wherever I check, including laravel documantation, i must extent and implement my User model like this:

class User extends Authenticatable implements MustVerifyEmail 

but I am getting this error:

Argument 1 passed to Illuminate\Auth\SessionGuard::login() must implement interface Illuminate\Contracts\Auth\Authenticatable, null given, called in /home/vagrant/code/laravel.test/vendor/laravel/ui/auth-backend/RegistersUsers.php on line 36

So as I understand I need to implement Authenticatable as well?

User is created in DB, but before redirect this error occur.

What am I doing wrong?

Aug
17
3 months ago
Activity icon

Replied to Image Not Showing After Linking Public To Public_html (C-panel)

When you run php artisan storage:link, is there a link in public folder of your app?

Activity icon

Replied to Box 'laravel/homestead' Could Not Be Found.

Command vagrant box add laravel/homestead doesn't download virtual box application. It downloads you virtual box image (virtual machine) with laravel preinstalled and preconfigured.

You need to install virtualbox manually, download it from virtual box site.

Activity icon

Replied to Box 'laravel/homestead' Could Not Be Found.

How did you install virtualbox? What OS do you use?

You said "Yes, I did that and it downloaded virtual box but then when I try running it, it begins installing it again"

It downloaded virtual box app or you mean it downloaded virtual box image?

Activity icon

Replied to Image Not Showing After Linking Public To Public_html (C-panel)

Wait, you are trying to link non-default folders on your server? What needs to be linked with what? Your images are in public_html and you want to link that folder with laravel public folder?

Did you adapt you filesystems.php file from config folder?

        'public' => [
            'driver' => 'local',
            'root' => storage_path('app/public'),
            'url' => env('APP_URL').'/storage',
            'visibility' => 'public',
        ],
Activity icon

Replied to Model::create For Two Tables Best Way

That's true, yes.

Activity icon

Replied to Box 'laravel/homestead' Could Not Be Found.

What do you see when you list boxes? vagrant box list

Activity icon

Replied to Image Not Showing After Linking Public To Public_html (C-panel)

Not working as, command fail or it didn't set link?

Activity icon

Replied to Model::create For Two Tables Best Way

Yes, that would do the trick. But is the 2nd way I wrote "bad practice"?

Activity icon

Replied to Image Not Showing After Linking Public To Public_html (C-panel)

If you have terminal access to your live server, inside laravel app folder, run the same command as you did on local machine: php artisan storage:link

Activity icon

Replied to Box 'laravel/homestead' Could Not Be Found.

Do you have "provider: virtualbox" in your Homestead.yaml file?

Activity icon

Started a new Conversation Model::create For Two Tables Best Way

So I see there are at least two ways to this but I wonder what is the best.

So I have a form and I want to save some fields in one table and some to another. Some of them to both tables.

After validation, I can do it like this:

$attributes = validateData() // return request()->validate([--here is the validation of form fields--]);

$save1 = Model1::create($attributes['value1'], $attributes['value2'], ...);

$save2 = Model2::create($attributes['value1'], $attributes['value2'], ...);

or I can do it like this:

$save1 = Model1::create($attributes);
$save2 = Model2::create($attributes);

as laravel will ignore fields that are not needed. Now this 2nd way is much shorter, but I don't know what would be the best practice here, as I don't know how "smart" is to give it all data, and let it to choose what it needs and then throw the rest.

Aug
06
3 months ago
Activity icon

Replied to Implementing Categories/subcategories In DB Best Way

This looks promising, but I still need to think how to index my articles table, need to assign category_id & to each of them. But if I manage to do it, this could help.

Thx!

Activity icon

Started a new Conversation Implementing Categories/subcategories In DB Best Way

Hi, not exclusively related to laravel, but I am doing this in it.

So, I have DB table articles, which has a id, name, price, etc. I show it in my index using laravel index function and datatables for search. Now I want to add categories to articles, but every category can have more than one child subcategory. Example: Car Parts->Style->Body->Rims, or Car Parts->Mechanics->Engine->Something. Here "Car Parts" is my main category (not the only one), and all others are child subcategory of it's predecessor.

My idea was to have a table with categories like this:

id | name | parent_category_id

then I would assign every article to only one subcategory and with the parent_category_id I can go up all the levels to fetch whole "tree" for some article. From example above, "Rims" parent_id can be x, which is the id of "Body" and the "Body" can have parent_id xy which is the id of "Style" and finally "Style" can have parent_id xyz which is the id of "Car Parts".

Question is should I do it this way (which will be hard as I have more than 2k articles with no any data for categories), or I should store in DB every category and subcategory for each article?

If I do it "way one", is there a something in laravel eloquent that can return me all "parent_ids" for given id?

This is the idea how to narrow down list of the articles, I am planning to do. Like filters

Any other idea is more than welcome.

Sry for long post and thank you in advance!